Deploy new version of Apps Script using Google Apps Script java API - google-apps-script

I am using the Google App Script java API to deploy the code. I am performing the following steps:
1. Update the latest code
Content content = new Content();
content.setFiles(files);
Content updatedContent = scriptService.projects().updateContent(scriptId, content).execute();
2. Create a new version
Version version = new Version();
version.setDescription("test create version");
Version createdVersion = scriptService.projects().versions().create(scriptId, version).execute();
3. Deploy the latest version
DeploymentConfig deploymentConfig = new DeploymentConfig();
deploymentConfig.setDescription("test deployment");
deploymentConfig.setVersionNumber(createdVersion.getVersionNumber());
deploymentConfig.setManifestFileName("appsscript");
Deployment deploymentCreated = scriptService.projects().deployments().create(scriptId, deploymentConfig).execute();
When I log into script.google.com I am able to view the latest version that I created. It shows the status as deployed. In the script editor, I am able to view the latest code as well. Now, when I invoke the apps script the requests are still handled by the older version. Could somebody let me know if there is something wrong with the way I am using the API?

try to set deployment version (greater then old one).
Version version = new Version();
version.setDescription("test create version");
version.setVersionNumber(3);
Version createdVersion = scriptService.projects().versions().create(scriptId, version).execute();
delete the deployment when it's no longed needed
service.projects().deployments()
.delete(scriptId, deploymentCreated.getDeploymentId()).execute();

Related

How to add a new app setting to Azure Web App using pulumi without removing the existing settings?

I'm using pulumi azure native for infrastructure as code. I need to create an Azure Web App (based on an App Service Plan) and add some app settings (and connection strings) throughout the code, e.g., Application Insights instrumentation key, Blob Storage account name, etc.
I figured out that there is a method, WebAppApplicationSettings, that can update web app settings:
from pulumi_azure_native import web
web_app = web.WebApp(
'my-web-app-test123',
...
)
web.WebAppApplicationSettings(
'myappsetting',
name=web_app.name,
resource_group='my-resource-group',
properties={'mySetting': 123456},
opts=ResourceOptions(depends_on=[web_app])
)
It turns out that WebAppApplicationSettings replaces the entire app settings with the value given in the properties parameter, which is not what I need. I need to append a new setting to the existing settings.
So, I tried this:
Fetch the existing settings from web app using list_web_app_application_settings_output
Add the new settings the existing settings
Update the app settings using WebAppApplicationSettings
from pulumi_azure_native import web
app = web.WebApp(
'my-web-app-test123',
...
)
current_apps_settings = web.list_web_app_application_settings_output(
name=web_app.name,
resource_group_name='my-resource-group',
opts=ResourceOptions(depends_on=[web_app])
).properties
my_new_setting = {'mySetting': 123456}
new_app_settings = Output.all(current=current_apps_settings).apply(
lambda args: my_new_setting.update(args['current'])
)
web.WebAppApplicationSettings(
'myappsetting',
name=app.name,
resource_group='my-resource-group',
properties=new_app_settings,
opts=ResourceOptions(depends_on=[web_app])
)
However, this doesn't work either and throws the following error during pulumi up:
Exception: invoke of azure-native:web:listWebAppApplicationSettings failed: invocation of azure-native:web:listWebAppApplicationSettings returned an error: request failed /subscriptions/--------------/reso
urceGroups/pulumi-temp2/providers/Microsoft.Web/sites/my-web-app-test123/config/appsettings/list: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Web/sites/my-web-app-test123' under resource group 'pulumi-temp2' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
error: an unhandled error occurred: Program exited with non-zero exit code: 1
Is there way that I can add a new app setting to Azure Web App using pulumi without changing/removing the existing settings?
Here's a suboptimal workaround: App Configuration and Enable Azure Function Dynamic Configuration.
And as far as I can tell it comes with some drawbacks:
cold start time may increase
additional costs
care must be taken to avoid redundant calls (costly)
additional boilerplate code needed for every function app
Maybe there's a better way, I mean I hope there is, I just haven't found it yet either.
After some searching and reaching out to pulumi-azure-native people, I found an answer:
Azure REST API doesn't currently support this feature, i.e., updating a single Web App setting apart from the others. So, there isn't such a feature in pulumi-azure-native as well.
As a workaround, I stored (kept) all the app settings I needed to be added, updated, or removed in a dictionary throughout my Python script, and then I passed them to the web.WebAppApplicationSettings class at the end of the script so that they will be applied all at once to the Web App resource. This is how I solved my problem.

Adyen create dropin fails with "Cannot read properties of null (reading 'dropin')"

Trying to do a simple initial working example of Adyen Drop-in functionality.
I'm using package "#adyen/adyen-web" version 5.2.0 in a React app. (see code attached)
My backend API is built in .Net5 calling Adyen to create a session and returning id and sessionData correctly to frontend presented in "paymentSession".
Bu when code reaches the part checkout.create('dropin').mount(adyenElementRef.current) it fails with error in browser console: "Cannot read properties of null (reading 'dropin')".
I have no idea of why, and I followed the exact documentation on https://docs.adyen.com/online-payments/web-drop-in
UPDATE:
I downgraded to version 4.1.0 and got it all to work by just changed to this code:
const checkout = new AdyenCheckout(adyenConfig)
// Create an instance of Drop-in and mount it to the container you created.
const dropinComponent = checkout.create('dropin').mount(adyenElementRef.current)
So something weird with latest version and the Promise-implementation?
I can't really reproduce your example exactly, but I see in your comment that version 4.x seems to be working.
With version 5.0, the creation of AdyenCheckout is now asynchronous. Can you make sure this is not the source of the issue?
//version 4
const checkout = await AdyenCheckout(configuration);
// version 5
const checkout = AdyenCheckout(configuration);
See the release notes.
I recommend using the latest version of the integration if you are integrating today, it has quite a few new goodies.

GMail Google Apps Script Plugin "The value returned from Apps Script has a type that cannot be used by the add-ons platform"

In the last 24 hours, a previously working GMail plugin I run has started failing.
I stripped it all the way down to only trying to get the example from the docs working:
var action = CardService.newAction().setFunctionName('composeEmailCallback');
CardService.newTextButton()
.setText('Compose Email')
.setComposeAction(action, CardService.ComposedEmailType.REPLY_AS_DRAFT);
// ...
function composeEmailCallback() {
var thread = GmailApp.getThreadById(e.threadId);
var draft = thread.createDraftReply('This is a reply');
return CardService.newComposeActionResponseBuilder()
.setGmailDraft(draft)
.build();
}
On BUILD (not on button press), the previously working GMail Addon displays the error message:
The value returned from Apps Script has a type that cannot be used by the add-ons platform. Also make sure to call build on any builder before returning it. Value: values {
proto_value {
type_url: "type.googleapis.com/caribou.api.proto.addons.templates.publicapi.ContextualAddOnMarkup.Card"
value: "...(omitted)"
}
}
Is this a new, known issue? Does anyone have some troubleshooting steps to share?
For me the error was was caused by open links not being whitelisted. For example, if you have code like this:
CardService.newOpenLink().setUrl(url)
Then the link returned by 'url' has to be whitelisted in the appscript manifest's openLinkUrlPrefixes list, like so:
"openLinkUrlPrefixes": [
"https://*.example.com"
]
This problem is caused by Google's silent upgrading of Apps Script to the V8 Runtime. To downgrade from this runtime to the old runtime (Rhino), perform this set of actions:
Run -> Disable New Apps Script runtime powered by Chrome V8
A related issue can be found here.

how can update to google map api version 3 in drupal 6

In my drupal site, I have installed the gmap module. But that is in version 2.115. Now I got a mail from google that update the google API version. I have generated the API key version 3. But no idea about implementing them to the module files.
drupal_set_html_head(' $query))) .'" type="text/javascript">');
This I changed to
drupal_set_html_head('');
Also in gmap.js
obj.map = new GMap2(elem, obj.opts); changed to obj.map = new google.maps.Map(elem, obj.opts);
But after adding this, Javascript is required to view this map. is showing.
Please help me
See this thread on d.org. There are several patches and solutions.

chrome.app.getDetails() returns null

I was trying to get the version of my extension at run-time using chrome.app.getDetails().version and noticed that chrome.app.getDetails() returns null. Surprisingly, there is no talk about this in the online community and the function isn't even documented by the Google folks. Is there a permission I am missing? I do have tabs enabled.
Very old... I know
But in case if someone is looking for this, you can have your extension version reading the manifest file with chrome.runtime API and the getManifest Method.
Ex. in your background script:
var manifest = chrome.runtime.getManifest();
var current_version = manifest.version;
console.info('Current Version: ', current_version);
The object returned is a serialization of the full manifest file, so you can get all the info in the manifest file
So.. if you want for example all and only the matches of your content_scripts... for say something...
for(var i in manifest.content_scripts) {
console.log(manifest.content_scripts[i]['matches']));
}
Note: Stable since Chrome 22
It's undocumented because they might be moving getDetails to a different part of the API -- see this bug. It's currently working on my copy of Chrome (beta channel), but I wouldn't be surprised if they've disabled it in a newer release. In the meantime you can just do an AJAX query to get the manifest.json of your extension -- you can get its URI using chrome.extension.getURL("manifest.json").
Here is what I'm using to pull the current version.
var manifest = new XMLHttpRequest();
manifest.open("get", "/manifest.json", true);
manifest.onreadystatechange = function (e) { if (manifest.readyState == 4) {console.log(JSON.parse(manifest.responseText).version)} };
manifest.send({});