where can i get deep documentation of ArgoCD apis - argoproj

I need to list all applications based on some label filters.
https://argocd_domain/api/v1/applications
in order to list all apps from argoCD API, I want to put all possible filters.

The Argo CD API is documented in its Swagger document.
Copy and paste that JSON to the Swagger Editor, and you'll get a nicely-formatted page describing the API. Here's the section for listing applications:
The function to handle a list-applications request calls ConvertSelectorToLabelsMap. Reading the implementation of that parsing function, you can find the expected format of the selector parameter.
At a glance, it seems the format is a comma-delimited list of key=value pairs.
Using the Swagger Editor, I generated the this test URL:
curl -X GET "https://editor.swagger.io/api/v1/applications?selector=label1%3Dvalue1%2Clabel2%3Dvalue2" -H "accept: application/json"
Looks like you'll need to URL-encode the equals signs and commas.

You can find the Swagger docs by setting the path to /swagger-ui in your Argo CD server address. E.g. http://localhost:8080/swagger-ui.

You can find a hosted version of Argo's Swagger UI on https://cd.apps.argoproj.io/swagger-ui

Related

GCP API Gateway route returns Google Sign-In page instead of expected response

While following the documentation for setting up GCP's API Gateway, I run into an issue that when I make a call to the endpoint, like so:
curl --request POST 'https://my-dev-project-XXX.wl.gateway.dev/helloWorld?key=XXX'
it returns an HTML page to authenticate with a Google Sign-in rather than the appropriate response of: "Hello World!"
Problem with function name?
I know the Cloud Function helloWorld exists, because if I change the cURL request above to be something like:
curl --request POST 'https://my-dev-project-XXX.wl.gateway.dev/helloWorldButChangeTheName?key=XXX'
it returns:
{"message":"The current request is not defined by this API.","code":404}
Problem with API Key?
I know the API key is valid because if I change it to YYY, I get:
{"code":400,"message":"INVALID_ARGUMENT:API key not valid. Please pass a valid API key."}
Problem with Request Method?
I know the Request method of POST is correct because if I change it to GET, it returns:
{"message":"The current request is matched to the defined url template \"/helloWorld\" but its http method is not allowed","code":405}
Problems with authorization?
There are a few similar StackOverflow resolved issues with Cloud Functions generally [1] and [2]; however, this isn't the same issue. I know this because I have made the actual Cloud Function publicly accessible without requiring authorization. So if I call:
curl --request POST 'https://us-west2-my-dev-project.cloudfunctions.net/helloWorld'
I get back "Hello World!".
Problems with Service account roles?
Following the documentation for configuring a service account for the gateway, I made sure to set the two roles:
Service Account User
Cloud Functions Invoker
I'm not certain what it looks like if I don't have these set correctly (as I found the answer before reaching the conclusion that something could be wrong here), but these settings should be sufficient.
API Config File
The only "significant" difference I have different from the documented tutorial is my config file, which is:
swagger: '2.0'
info:
title: XXX
description: Sample API on API Gateway with a Google Cloud Functions backend
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
# different name than tutorial
/helloWorld:
post:
summary: Greet a user
# different id than tutorial
operationId: helloWorld
x-google-backend:
# different endpoint than tutorial
address: https://us-central1-my-prod-project.cloudfunctions.net/helloWorld
security:
- api_key: []
responses:
'200':
description: A successful response
schema:
type: string
securityDefinitions:
api_key:
type: apiKey
name: key
in: query
The Google Sign-in screen caused a lot of confusion here as the issue doesn't seem one that would produce such a result. You'd think it'd be an issue with authentication, but it's not. Instead, there are two issues with the API Config File, both regarding the address:
The region is different than the Cloud Function's. The Cloud Function is deployed on us-west2 whereas the API Config file has it set to us-central1 (what is shown in the documentation).
The project ID is different than the Cloud Function's. The Cloud Function has the ID of my-dev-project whereas the API Config file has it set to my-prod-project. This is because I have two different environments I was trying this out on and messed it up.
I imagine other subtle issues with the API Config file may cause the response to be the Google Sign-in page as well so if my two points above didn't solve your issue, look for other differences, such as the path names and operationId.
Not sure if this is the same case, but upon looking at your api config file, I can say that I had the same issue with the api gateway and the resolution was changing the x-google-backend address to what cloud function url is instead of what it is said in the documents (the document says it's
https://region-projectID.cloudfunctions.net/CloudFunctionName
but that doesn't work. You can find the url by looking at the trigger tab of your cloud function in GCP, it would be something like:
x-google-backend:
# different endpoint than tutorial
address:https://<the cloud function url>/helloWorld

Can AWS API Gateway support `application/x-www-form-urlencoded` with body and query string parameters?

Numerous services can accept query string parameters in the URL when a POST request is made with Content-Type: application/x-www-form-urlencoded and other parameters in the body, but it seems AWS API Gateway cannot while also accepting query string parameters.
When I call the AWS API Gateway with a POST Mapping Template for application/x-www-form-urlencoded and query string URL parameters (with a Lambda function), I get the following error:
{
"message":"When Content-Type:application/x-www-form-urlencoded,
URL cannot include query-string parameters (after '?'):
'/prod/webhook?inputType=wootric&outputType=glip&url=...'"
}
Here is an example cURL:
curl -XPOST 'https://{myid}.execute-api.{myregion}.amazonaws.com/prod/webhook? \
inputType=wootric&outputType=glip&url=https://hooks.glip.com/webhook/ \
11112222-3333-4444-5555-666677778888' \
-d "#docs/handlers/wootric/event-example_response-created.txt" \
-H 'Content-Type: application/x-www-form-urlencoded' -v
The specific goal is to get a Wootric webhook event posted to a Lambda function using a URL with query string parameters.
You can get the code here:
https://github.com/grokify/chathooks
The Wootric event body file is here:
https://raw.githubusercontent.com/grokify/chathooks/master/docs/handlers/wootric/event-example_response-created.txt
The GitHub issue is here:
https://github.com/grokify/chathooks/issues/15
The error message seems pretty definitive but I wanted to ask:
Is there a workaround to configure an API Gateway to support both?
Is there a standards-based reason why AWS would not support this or is this just a design decision / limitation?
If there's no solution to this, is there a good lightweight solution other than deploying a hosted server solution like Heroku. Also, do other cloud services support this with their API gateway + cloud functions, like Google?
Some examples showing support for both:
jQuery example: jQuery send GET and POST parameters simultaneously at AJAX request
C# example: Accessing query string variables sent as POST in HttpActionContext
Yes,there is a workaround and the key issue is to set the mapping template that will convert string into json . Very detailed example shown in
API Gateway any content type.
Please set the request property as "Content-Type", "application/json" for your HttpURLConnection like below
connection.setRequestProperty("Content-Type", "application/json");
I had a similar problem, with a 3rd party provider using web hooks. It turns out that my provider is transforming the url path from UPPERCASE to LOWERCASE. Example the endpoint should be apigateway.com/dev/0bscur3dpathRANDOM instead apigateway.com/dev/0bscur3dpathRANDOM. You get the point.
I'm not sure if I got the point in question correctly, but if you want to access the request body that is encoded as application/x-www-form-urlencoded(or anything, actually) in your Lambda function, you should use LAMBDA_PROXY request integration type (aka tick "Use Lambda Proxy integration" checkbox) when creating a method for your resource. Then you can access the request body in event.body field as a plain text in your lambda function and parse it manually.

Yahoo finance webservice API direct to ?bypass=true

Refer to the Yahoo finance webservice API, I unable to find http://finance.yahoo.com/webservice/v1/symbols/YHOO,AAPL/quote?format=json&view=detail
It shows 'Not a valid parameter'.
I also discover it will direct to ?bypass=true
How can I view the json data?
My understanding is that json is only supported through Yahoo Query Language (yql) API. The API endpoint is http://query.yahooapis.com/v1/public/yql and you have to submit the query in the form as (prefixed with ?) q=select * from yahoo.finance.quotes where symbol in ('symbol1,symbol2'), you must also specify the format as format=json, you may also need to specify an environment in order for the data to be return correctly based on certain schema. So far I found env=store://datatables.org/alltableswithkeys works for me. The entire url of course has to be url-encoded, you can run a curl command to test it out (replace with actual stock symbol):
curl -G http://query.yahooapis.com/v1/public/yql? --data-urlencode "q=select * from yahoo.finance.quotes where symbol in ('symbol1, symbol2') --data-urlencode "format=json" --data-urlencode "env=store://datatables.org/alltableswithkeys"
For more information, please check YQL Guide. It took me hours of reading and try-and-error to make it work!

WSO2 APIM 1.10 - config endpoint secure scheme while adding api via REST-API

I am using APIM 1.10 to add new APIs via the REST-API (see: https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APIsApi#apisPost) and it works fine but:
I want to add the security-scheme: "Basic Auth" for the api endpoint.
But I have no idea how to do this, because the endpointConfig-config is not described.
I need something like this: endpointSecured:true, endpointAuthDigest:"Basic", endpointUTUsername:"usN", endpointUTPassword:"pass"
Any ideas?
C ya,
Marty
Following steps will help you to achieve the requirement.
Edit the API and go to the implementation tab.
Click on "Show More Options".
Select "Secured" for Endpoint Security Scheme.
Provide the credentials and save.
When you create API using rest API, you can add secure endpoint details by adding following part. &endpointType=secured&epUsername="admin"& epPassword="admin"
Here is a sample command
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=SampleAPI&context=/country&version=1.0.0&visibility=public&thumbUrl=&description=Check Country by Code&tags=country&endpointType=secured&epUsername="admin"& epPassword="admin"&tiersCollection=Gold,Bronze&http_checked=http&https_checked=https&resourceCount=0&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*&default_version_checked=default_version&bizOwner=xx&bizOwnerMail=xx#ee.com&techOwner=xx&techOwnerMail=ggg#ww.com" -d'endpoint_config={"production_endpoints":{"url":"http://services.groupkt.com/country/get/iso2code/IN","config":null},"endpoint_type":"http"}';

Using the Vimeo API, how do I replace all videos in a Vimeo album?

Using curl, I'm trying to create a working Vimeo API call that replaces the videos in a Vimeo album with a different set of videos. (The docs are here.) I am successfully deleting the existing videos from the album but my new video info seems to be invisible to Vimeo. Vimeo responds with a 201 ("created") instead of the 200 I'm looking for.
Here is my curl command (with subs for actual data):
curl -H "Authorization: bearer 123abc456def" -X PUT --data "videos=%2Fvideos%2F11111%2C%2Fvideos%2F22222%2C%2Fvideos%2F33333" "https://api.vimeo.com/me/albums/7777777/videos"
I don't know what I'm doing wrong and the Vimeo API docs & playground don't give me the answers I need. My questions and observations:
Should I be url encoding the new video URIs (e.g. 11111,22222, etc)? I have also tried without url encoding and it made no difference. But then the 201 might be telling me it didn't get as far as handling my replacement URIs.
a PUT is required for this operation. I have used PUT successfully to add a video to an existing album (in LiveCode, haven't tried it with curl)
I got the same results when I tried this PUT in LiveCode. I moved the request to curl because more people are familiar with curl.
This is my first rodeo using the Vimeo API. It's a great, vast resource and I've had no problems working with it until this. I'm just stuck on this item and really need it to work!
Thanks for any help you can offer.
This is an ancient, deprecated way of handling batch editing. I'm not sure how it still exists. We will move it to the proper batch creation standard in 3.4.
I think the existing system is supposed to be a comma separated list of video id's, so
curl -H "Authorization: bearer 123abc456def" -X PUT --data "videos=11111%2C22222%2C33333" "https://api.vimeo.com/me/albums/7777777/videos"
is likely the proper request.