Continue error trying to change Google cloud trigger with REST APIs - google-apis-explorer

I'm trying to change a trigger using REST API, specifically https://cloud.google.com/build/docs/api/reference/rest/v1/projects.triggers/patch. Note that I'm able to use curl and list all the triggers. Also I tried to download the trigger in JSON using https://cloud.google.com/build/docs/api/reference/rest/v1/projects.triggers/get (which works perfectly) but when I tried to upload the same file the error is always:
{
"error": {
"code": 400,
"message": "exactly 1 build config required, got: 0",
"status": "INVALID_ARGUMENT"
}
}
if I try to upload an invalid Json correctly it gives error parsing JSON, so surely it's trying to parse using JSON format.
So I tried the same experiment using "Try it!" button on Google page which opens Google APIs explorer. Same results. The interface gave me a warning that some fields are only output so I tried also to remove these fields but I got the same error.
The file I'm trying to upload is (changed some strings to remove company name)
{
"description": "Push to any branch",
"github": {
"push": {
"branch": ".*"
},
"owner": "company",
"name": "repo-utils"
},
"tags": [
"github-default-push-trigger"
],
"name": "default-push-trigger-127"
}

I think I found the issue. Google API seems to require either build or filename to be passed to specify a way to build. On the other hand the web interface allows to insert an Autodetect option for the build which will try to look for either cloudbuild.yaml or Dockerfile in the root directory. If you specify Autodetect on the web interface the Json configuration won't have either build or filename so when you try to import back that configuration it will fail.
I tried to pass filename as empty string, the web interface shows a cloudbuild.yaml (which is present) but the execution of the trigger fails.
So it seems there's no way to insert a Autodetect mode trigger using the API.

Related

ADF, CopyData & Rest API

I actually try to make a simple pipeline to read JSON Data on a API REST and store it in a database.
I try first with a CopyData acticity.
I set up the linked service, the dataset, etc etc...
I need to call an API with POST Method and a Body's payload.
Everything is set, I launch the pipeline and... the api respond like i don't providethe Body's payload.
Double check it, check it via the generated json :
and in the generated pipeline JSON
...
"source": {
"type": "RestSource",
"httpRequestTimeout": "00:01:40",
"requestInterval": "00.00:00:00.010",
"requestMethod": "POST",
"requestBody": "{ \"startDate\":\"2022-09-01T00:00\", \"endDate\":\"2022-09-01T23:59\"}"
},
...
Because requestBody wait a string type, the double quote are escaped...
Never wanted to work. Nothing to do. API never seems to find the body.
I find the "Web" activity and I decide to give it a quick try.
Same api call,same linked service, same dataset same url, same method, same body payload...
Just a big copy&paste.
And it's work...
So, why Web activity works and not CopyData?
I reopen the generated pipeline's JSON and :
Web Activity:
"body": {
"startDate": "2022-09-01T00:00",
"endDate": "2022-09-01T23:59"
},
Copy Activity:
"requestBody": "{ \"startDate\":\"2022-09-01T00:00\", \"endDate\":\"2022-09-01T23:59\"}"
Seems that Web activity don't request the body type to be a String.
Maybe it's the problem,
Maybe Copy rewrite body "badly" and it's fail.
So,
Do I miss something?
or
Is it a bug?
And how do you do it? (consume API data in adf pipeline)
Cheers,
Mike.
You can use #json('{"startDate":"2022-09-01T00:00","endDate":"2022-09-01T23:59"}') in copy activity body
After using the above dynamic content, my copy activity receives the requestBody as an object. Look at the following image:
https://learn.microsoft.com/en-us/answers/questions/1000566/adf-copydata-amp-rest-api.html?childToView=1001129#answer-1001129
Just miss the additional header : content-type : application/json
...
:)

Use Postman to Login a Cognito user with API alone

I'm migrating from Firebase where this was rather simple to do.
I'm building a custom api because the environment I need to build in will not let me use any official sdk's or anything, so this solely has to be done via rest type actions.
I essentially want to just post the username/password to aws cognito, and recieve an auth token that I can then append to the headers of future requests (to other api calls)
After hunting for quite a bit, almost all help has postman connecting to Amazon's login UI etc, and I cannot do that. It must completely handle the login process "behind the scenes" and not prompt the user with Amazon's own UI.
So, assuming this is possible:
What headers do I need (content-type etc)
How do I format the body json (or is it using something else?)
I assume I'd send it as "raw" body.
This is as far as I got so far and I'm scratching my head:
Url: https://[DOMAIN].auth.us-east-1.amazoncognito.com/oauth2/token
Body Json:
{
"ClientId": "1234etc",
"Password": "Password1_",
"UserAttributes": [
{
"Name": "email",
"Value": "test#test.com"
}
],
"Username": "test#test.com"
}
No idea if this is even the right format for the JSON I just scalped it from other posts.

Download a Document with Autodesk API

I'm trying to download documents from BIM 360 Docs. If I want to download a file with the type "type": "items:autodesk.bim360:File" I just need to get the bucketID and objectID (/projects/<projectID>/items/<itemID>) and call buckets/<bucketID>/objects/<ObjectID>. (I used this tutorial)
But how do I download a file with the type "type": "items:autodesk.bim360:Document"?
First, I get the version of the document /projects/<projectID>/items/<itemID>/versions. After that I call projects/<ProjectID>/versions/<versionID>/downloadFormats but it returns an empty JSON. The call projects/<ProjectID>/versions/<versionID>/downloads returns a 400 Bad Input. Whats the right way to get the bucket & objectID from a "document"? The way from the tutorial doesn't work because there is no "storage" tag in the JSON (example).
For BIM 360 Project Folder items, follow the tutorial here to download document.
Basically you will need to obtain the URN of the document from the relationships.storage.data.id field via GET projects/:project_id/folders/:folder_id/contents.
For item type items:autodesk.bim360:Document, call GET projects/:project_id/versions/:version_id/relationships/refs to obtain the storage locations:
"storage": {
"meta": {
"link": {
"href": "/oss/v2/buckets/wipbucket/objects/urn:adsk.objects:os.object:wip.dm.prod%2F9f8bdc3f-e29c-4ada-ab7b-bb8dfa821163.pdf"
}
}
See doc here.

Unable to import swagger JSON or YAML into Postman

Problem
Unable to convert swagger 2.0 into a format which is being affected by Postman import functionality
Generated via /swagger.json|yaml
Swagger endpoint exposed via dropwizard jetty using swagger
swagger-core: 1.5.17
swagger-jaxrs: 1.5.17
swagger-jersey2-jaxrs: 1.5.17
swagger-models: 1.5.17
Attempts
Tried manually importing the JSON or YAML versions via the import screen
import file
import from link
paste raw text
Tried converting to different formats using: api-spec-converter and swagger2-postman-generator
Result
Error on import: Must contain an info object
Question
Has anyone managed to get around this issue allowing the import
In Swagger 2.0 the info field is mandatory. Just add the following to your YAML root:
info:
title: 'EmptyTitle'
description: 'EmptyDescription'
version: 0.1.0
Or like this if you have it in JSON format (in the root too):
"info": {
"title": "EmptyTitle",
"description": "EmptyDescription",
"version": "0.1.0"
}
Hope it helped !
Have you tried converting to Postman v2?
The swagger2-postman-generator you tried converts Swagger v2 to Postman v1. This one converts Swagger v2 to Postman v2: https://www.npmjs.com/package/swagger2-postman2-converter as used in this tutorial.
My setup: Spring boot generated swagger-ui, which gives me the raw open-api documentation.
In my case
"info": {
"title": "EmptyTitle"
}
was already available in the json which spring-boot open api generated for me, but was missing the other two fields which #BBerastegui mentions in his answer:
"description": "EmptyDescription",
"version": "0.1.0"
I added them, and the esult looks like
so that the rsult looks like this, which works:
"info": {
"title": "EmptyTitle",
"description": "EmptyDescription",
"version": "0.1.0"
}

Accessing Google AppEngine Cloud Endpoints using ActionScript 3?

Is anyone aware of method of accessing Google AppEngine Cloud Enpoints using ActionScript 3 without having to go through the JavaScript layer? I have been going on the docs and Google to find any tutorials or examples but did not find anything useful.
We don't have AS3 client libraries and currently there are none planned that I know of, so you'll have to rely on HTTP to make your REST calls.
TLDR; Use the APIs Explorer
If you visit
https://your-app-id.appspot.com/_ah/api/explorer
(replacing your-app-id with your actual application ID), then you'll be redirected to your own custom version of the Google APIs Explorer.
In it you can click on individual APIs and see the list of all available methods. Within a the page for each method, you can try out forming requests and the Explorer will suggest the correct values to use.
After you click "Execute", the full HTTP request (headers and all) and response will be printed on your page, which will show you which commands to use.
Description of how to use the Discovery Document
The Discovery Document for your API will contain all the information you need to construct a request.
To find the root for calling your API, check out the baseUrl key. It should be something like:
https://your-app-id.appspot.com/_ah/api/tictactoe/v1/
To figure out how to call a specific method, there are descriptions of every method, nested down as resources in the Discovery Document. For example, for the Tic Tac Toe Python sample, the board_get_move method has a name of board.getmove in the #endpoints.api decorator. This means the method getmove is owned by the resource board.
If you look in the resources.board.methods key in the Discovery Document you can see the getmove method:
"getmove": {
"id": "tictactoe.board.getmove",
"path": "board",
"httpMethod": "POST",
"description": "Exposes...",
"request": {
"$ref": "TictactoeApiMessagesBoardMessage"
},
"response": {
"$ref": "TictactoeApiMessagesBoardMessage"
}
}
Combining the path with our baseUrl we know requests will need to be sent to
https://your-app-id.appspot.com/_ah/api/tictactoe/v1/board
and from httpMethod we know requests will use the HTTP method POST.
Finally, to specify the request, we see a reference to a schema:
"$ref": "TictactoeApiMessagesBoardMessage"
Looking in the schemas.TictactoeApiMessagesBoardMessage key in the Discovery Document we see:
"TictactoeApiMessagesBoardMessage": {
"id": "TictactoeApiMessagesBoardMessage",
"type": "object",
"description": "ProtoRPC message definition to represent a board.",
"properties": {
"state": {
"type": "string"
}
}
}
so we know the payload must contain a single field called state and that field must be a string.