I'm still stuck on this question and I'm rephrasing it after a bit more exploration.
I cannot find code examples for using google-api-php-client with v1 API methods like projects/setIamPolicy() On this example
The PHP example appears to be broken because $service->projects is undefined. The equivalent nodejs example "just works".
I've attempted to switch to the v1-master branch, but the same code is still incompatible. I've attempted some modifications to compensate for v2 authentication methods used in the example, but hit a dead end.
What is the proper way to use v1 methods via PHP?
EDIT
It looks like this simple composer file is my solution:
{
"require": {
"google/apiclient": "^2.0",
"google/apiclient-services": "0.50"
}
}
After reproducing the documentation instructions, I came across the same error of undefined property $projects in $service.
It seems that the documentation examples for PHP Cloud Resource Manager API v1 are defining classes (like $service = new Google_Service_CloudResourceManager($client);) that are actually implemented in v2.
v1 Library contains variables $organizations and $projects.
v2 Library contains variables $folders and $operations.
In the documentation example, the script tries to access $projects, using the v2 Class, where $projects doesn’t exist, but $folders and $operations do.
By using a version of google-api-php-client-services Library, which includes the latest version n of v1, you can access $folders, $liens, $operations, $organizations, $projects but still use V2 Classes of google-api-php-client.
Related
I'm experimenting with a Windows Console Application (C++/WinRT) and so far successfully made use out of the the Storage API and a few others with no issues. Now i'd like to try and use the ApplicationDataContainer class instead of making use of Winreg.h.
I've followed the C++ code example from here and tried my own things:
https://learn.microsoft.com/en-us/uwp/api/windows.storage.applicationdatacontainer?view=winrt-19041
It seems that creating a settings object relies on a package identity which I don't want to use.
ApplicationDataContainer localSettings{ ApplicationData::Current().RoamingSettings() }; // Error
// winrt::hresult 0x80073d54 : The process has no package identity.
I understand that ApplicationData::Current() relies on using an identity. But it seems like the only way to make use of ApplicationDataContainer is to initialize in these two ways:
ApplicationDataContainer localSettings{ ApplicationData::Current().LocalSettings() };
// Or
ApplicationDataContainer localSettings{ ApplicationData::Current().RoamingSettings() };
Is there any way make use of the ApplicationDataContainer API without a package identity, or perhaps another way to initialize this class?
This is also a learning experience so it doesn't matter if the solution only gives partial use of the api. Easy access to local/roaming folders isn't necessary either. I'm happy to store the settings file in a custom location.
Background:
I have an existing code that uses functionality provided by Microsoft, to post XML data over HTTP. Specifically, IServerXMLHTTPRequest (included in MSXML3 and up) from msxml4.dll (COM). I am moving to msxml6.dll as msxml4.dll is not supported anymore (superseded by MSXML6). More information about MSXML versions.
Code:
#import "msxml6.dll"
using namespace MSXML2;
…
IServerXMLHTTPRequestPtr spIXMLHTTPRequest = NULL;
hr = spIXMLHTTPRequest.CreateInstance(__uuidof(ServerXMLHTTP40));
Problem:
When building my app with msxml4.dll as well as msxml6.dll the following is included in the msxml4.tlh and msxml6.tlh respectively:
struct __declspec(uuid("88d969c6-f192-11d4-a65f-0040963251e5"))
ServerXMLHTTP40;
// [ default ] interface IServerXMLHTTPRequest2
As I understand, looking at msxml6.tlh, I can use ServerXMLHTTP40 (and not change the code to ServerXMLHTTP60) with msxml6.dll (same for DOMDocument40, FreeThreadedDOMDocument40, XMLSchemaCache40 etc.).
Now, searching the registry in a fresh Windows 7 Ultimate installation, I cannot find the uuid above. As a result, this code fails on this machine:
hr = spIXMLHTTPRequest.CreateInstance(__uuidof(ServerXMLHTTP40));
Questions:
If msxml6 is exposing ServerXMLHTTP40, why is it that I cannot find it in the registry? Can I use ServerXMLHTTP40 when msxml6 is installed (msxml4 is not installed)?
Need additional information? Just let me know. Thank you!
.TLH file (as a product of import from .TLB, which is in turn a compiled version of .IDL file) is a description of interfaces, structures, methods etc. which ones uses to talk through COM to another object. There is no guarantee or promise that the other party implementing these interfaces is installed or otherwise available, or even exists at all.
Yes you have the signatures defined for you convenience. You might need to install runtime that implements the functionality. MSXML 4 might need a separate install regardless of where you obtained the development details from.
How can I create a Java or Javascript JSON webservice to retrieve data from a simple properties file? My intention is to uses this as a global property storage for a Jenkins instance that runs many Unit tests. The master property file also needs to be capable of being manually edited and stored in source control.
I am just wondering what method people would recommend that would be the easiest for a junior level programmer like me. I need read capability at miniumum but, and if its not too hard, write capability also. Therefore, that means it is not required to be REST.
If something like this already exists in Java or Groovy, a link to that resource would be appreciated. I am a SoapUI expert but I am unsure if a mock service could do this sort of thing.
I found something like this in Ruby but I could not get it to work as I am not a Ruby programmer at all.
There are a multitude of Java REST frameworks, but I'm most familiar with Jersey so here's a Groovy script that gives a simple read capability to a properties file.
#Grapes([
#Grab(group='org.glassfish.jersey.containers', module='jersey-container-grizzly2-http', version='2.0'),
#Grab(group='org.glassfish.jersey.core', module='jersey-server', version='2.0'),
#Grab(group='org.glassfish.jersey.media', module='jersey-media-json-jackson', version='2.0')
])
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory
import org.glassfish.jersey.jackson.JacksonFeature
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
#Path("properties")
class PropertiesResource {
#GET
#Produces("application/json")
Properties get() {
new File("test.properties").withReader { Reader reader ->
Properties p = new Properties()
p.load(reader)
return p
}
}
}
def rc = new org.glassfish.jersey.server.ResourceConfig(PropertiesResource, JacksonFeature);
GrizzlyHttpServerFactory.createHttpServer('http://localhost:8080/'.toURI(), rc).start()
System.console().readLine("Press any key to exit...")
Unfortunately, since Jersey uses the 3.1 version of the asm library, there are conflicts with Groovy's 4.0 version of asm unless you run the script using the groovy-all embeddable jar (it won't work by just calling groovy on the command-line and passing the script). I also had to supply an Apache Ivy dependency. (Hopefully the Groovy team will resolve these in the next release--the asm one in particular has caused me grief in the past.) So you can call it like this (supply the full paths to the classpath jars):
java -cp ivy-2.2.0.jar:groovy-all-2.1.6.jar groovy.lang.GroovyShell restProperties.groovy
All you have to do is create a properties file named test.properties, then copy the above script into a file named restProperties.groovy, then run via the above command line. Then you can run the following in Unix to try it out.
curl http://localhost:8080/properties
And it will return a JSON map of your properties file.
I was working with porting the sample from the link below to a Windows 8 Metro styled app
http://aws.amazon.com/code/Product-Advertising-API/2480
Looks like many features from the web model are removed (or moved) in WinRT:
HttpUtility.UrlEncode
HttpUtility.UrlDecode
HMAC / HMACSHA256
to name a few. Are there alternatives to these on WInRT? I looked online and there's very little insight.
Theres source code for URLDecode here, and looks like Uri.EscapeDataString can be used for Encode.
http://www.koders.com/csharp/fid1A50096D8FA38302680B0EEDAC5B1CE1AEA855D0.aspx?s=%22Lawrence+Pit%22
copy the source code over, change the GetChars function to this
static char [] GetChars (MemoryStream b, Encoding e)
{
return e.GetChars (b.ToArray(), 0, (int) b.Length);
}
I had to use the code snippet from here to properly hash encrypt the string
http://channel9.msdn.com/Forums/TechOff/Porting-to-WinRT/4df7586e1ef5400682eda00f0143b610
Use methods from the WebUtility class instead:
System.Net.WebUtility.UrlEncode(string);
System.Net.WebUtility.UrlDecode(string);
I would like to migrate a project (legacy code which I am not quite familiar with) from Xerces-C v2.x to v3.x.
It turns out that Xerces-C v3 dropped the DOMBuilder class. The migration archive tells me this:
...a number of DOM interfaces (DOMBuilder, DOMWriter, DOMInputSource, etc.) were replaced as part of the the final DOM Level 3 specification conformance work.
That's nice. But is there any guide on how to migrate code that relies on these classes to the new API?
Replacements for removed APIs:
Use XercesDOMParser or DOMLSParser instead of DOMBuilder (more info):
xercesDOMParser->setCreateCommentNodes(true);
Use DOMLSSerializer instead of DOMWriter:
DOMLSSerializer* writer = ((DOMImplementationLS*)impl)->createLSSerializer();
DOMConfiguration* dc = writer->getDomConfig();
dc->setParameter(XMLUni::fgDOMErrorHandler,errorHandler);
dc->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent,true);
Use DOMLSInput instead of DOMInputSource.
See also:
"Xerces-C++ API Reference 3.1.1"
"Xerces-C++ API Reference 2.8.0"