Create Azure Artifacts universal package feed via Azure API - Example - azure-artifacts

we want/need to create feeds in an automatic way depending on a configuration file.
Looking at the official documentation neither the Azure CLI nor the Python API provides some convenience functionality to achieve my goal. There is only the REST API that is described briefly in the docs.
Is there anywhere a concrete example for a feed creation via REST API that I can reuse?
Thank you

Check Feed Management - Create Feed, to create a feed with specific name:
POST https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/feeds?api-version=5.1-preview.1
With request body:
{
"name": "MyFeedName",
"hideDeletedPackageVersions": true,
"upstreamEnabled": true
}
Then the feed with name MyFeedName will be created:
For more parameters about request body you can refer to this doc.

Related

Test/Sandbox Environment for Google My Business API

I just started with using Google My Business API and was able to perform the get operations just to verify that my Oauth setup is right. Now I want to add a location using the post method for GMB Add location API but before I push my code to production I want to test out this request. Do we have any testing/sandbox environment for Google My Business API testing ?
For anyone coming here for reference I guess if you are using third party tools(Integromat/ Zapier) to make the API Call, the best way is to validate your request by passing in query parameter: validateOnly = True
According to their doc, this is not possible. please read more here

Service one page from multiple OpenAPI spec endpoints?

We are running set of micro-services and each are exposing open-api spec to url like the following.
https://{domain}/v1/membership/v3/api-docs
https://{domain}/v1/storage/v3/api-docs
https://{domain}/v1/order/v3/api-docs
The url opens open-api json (not UI).
Does anyone know of a tool where I can combine these and be able serve all the apis via url like https://{domain}/v1/apis with UI?
I looked Google and all I saw required me to create a single json file with all apis instead of dynamically serving these.
You can use the property urls:
springdoc.swagger-ui.urls[0].name = first
springdoc.swagger-ui.urls[0].url = /firstAPI.yaml
springdoc.swagger-ui.urls[1].name = second
springdoc.swagger-ui.urls[1].url = /secondAPI.yaml
You can find this property in the documentation. There is also a nice FAQ for this question:
The properties springdoc.swagger-ui.urls.*, are suitable to configure external (/v3/api-docs url). For example if you want to agreagte all the endpoints of other services, inside one single application. Don’t forget that CORS needs to be enabled as well.

Is there a way to create a chat room in Slack using the URL?

Our team uses Slack. I would like our custom management app to automatically generate links to Slack chatrooms.
We can join rooms using the direct URL: [team].slack.com/messages/customRoom
Can we use a similar URL to create the room if non-existant? Something like: [team].slack.com/messages/customRoom/create
No, but the Slack API allows you to check if a channel exist and create a new one on demand. So you can get this functionality with a simple script, e.g. in PHP that uses the Slack API.
Here is the documentation for the Slack API method to create a new channel.

Consuming webhooks shopify-api

I'm in the process of building my first RoR webapp and I'm currently trying to set up an integration with Shopify. I want to create an order in my web application whenever one is created in Shopify. For this I want to use a Shopify webhook. Step two will be to set it up so that after processing the order I'll use the Shopify API to update some records. For now my main concern is receiving the webhooks. I've been looking at the documentation for the Shopify gem but with my limited RoR skills I can't seem to figure it out. I've been searching the web for a few hours but can't find any clear examples / explanation.
I'm confused about this gem; shopify-api (https://docs.shopify.com/api/authentication/using-api-gem-with-private-app-credentials). I've created a private app in shopify, but after that I'm lost. Where am I supposed to place this code and how is this invoked after receiving a webhook?
It seems to me that this gem is mainly used to access the Shopify API instead of consuming webhooks. Am I going at this all wrong?
For receiving the changes (especially Order Creation event) from Shopify, you don't need to use any gem or third party to integrate!
Here are the steps that I did before in my app:
1. Provide an api in your app to receive a webhook event
Here is an example:
Your route:
post '/shopify/create_order', to: 'shopify#create_order'
Your controller:
class ShopifyController < ApplicationController
def create_order
# process shopify order here: all info in `params`
end
end
2. Config to call webhook from your Shopify Settings. The configured url will be:
http://your_production_url/shopify/create_order
If you want to test from localhost, go to step 3
3. (Optional) Test from your localhost
Download this free tool: ngrok and extract it to your machine.
Run ngrok in your terminal to generate a forwarding url to your localhost by this command:
ngrok http 3000
So you will get the output from console like this:
Copy the generated url (http://fbc5cf88.ngrok.io for example) above and add to your Shopify settings in step 2
4. (Optional but critical) Set privacy in your app, to make sure only Shopify can call your api. Follow this documentation
Shopify also provides api to integrate with Shopify resources: create/update product, collection, collect, metafield,... You can directly use it. All was described at Shopify API documentation. But the easiest way to work with Shopify is shopify_api gem which provides an interface to work with Shopify (via ActiceResource)
Probably reading up on the documentation on Webhooks would help you figure out a lot of what you need to do
In essence, here are the overview of what you need to start consuming web hooks:
1. Create your web hooks
You can do it using the Shopify API (POST /admin/webhooks.json)
Or you can do it through store admin
The params that you need to take note of:
topic: the type of hook you want (for e.g orders/create)
address: the URL of the endpoint that you would be consuming the hook at (for e.g: https://myapp.domain.com/hooks/order_create)
2. Create your endpoint that will respond to hooks
You then need to setup your ROR app to expose an endpoint that will respond to a POST request.
This endpoint is the same URL that you previously specified when creating the hook
More info at https://docs.shopify.com/api/webhooks/using-webhooks#respond-to-webhook
Notes: You also need to implement a way to verify that requests that you receive through the endpoints came from Shopify, detailed here.

Is there a reference for accessing the Google APIs in a non-OOP way?

We are attempting to use the Google APIs to create folders and documents on Google Drive, and provide a link to access them. This is a relatively simple requirement. However, all of the reference materials I've found show code examples from a variety of object oriented programming languages that seem to use helper libraries. We are using ColdFusion, and need to access the API through direct HTTP calls (CFHTTP), for which I can find no good documentation for.
Is there documentation anywhere, from Google or otherwise, showing the URLs and URL variables required for each call? We would require these for both oAuth2.0 and Google Drive.
I'm just extracting this from some comments.
Google (search term: "google drive rest api") turns up an old version of the docs: "Drive REST API Reference (v1)". As per #abraham's guidance, the current version is actually this: "Drive REST API Reference (v2)".
Here # Google Drive API Explorer you can find all the available APIs. Click on any API, there you get all the variables (required and optional) with description. And there make a request they will show you the requested URL and json response.
Also have a look on this site.
Hope this helps.
I'd make a pitch for using the Java Client library anyway, primarily based on this recommendation from Google:
Although your application can complete these tasks by directly
interacting with the OAuth 2.0 system using HTTP, the mechanics of
server-to-server authentication interactions require applications to
create and cryptographically sign JSON Web Tokens (JWTs), and it's
easy to make serious errors that can have a severe impact on the
security of your application.
For this reason, we strongly encourage you to use libraries, such as
the Google APIs client libraries, that abstract the cryptography away
from your application code.
(Read more Here)
We just went through a similar process getting access to the Google Cloud Storage APIs.
If you do decide to go that route, you'll have to translate the Java code examples to make it ColdFusion friendly. Here's an example of doing a simple request to the Cloud Storage API (Getting info about one of our Buckets):
httpTransport = createObject("java", "com.google.api.client.http.javanet.NetHttpTransport").init();
jsonFactory = createObject("java","com.google.api.client.json.jackson2.JacksonFactory").init();
credentialBuilder =
createObject("java", "com.google.api.client.googleapis.auth.oauth2.GoogleCredential$Builder");
credentialBuilder.setTransport(httpTransport);
credentialBuilder.setJsonFactory(jsonFactory);
credentialBuilder.setServiceAccountId("SERVICE_ACCOUNT_EMAIL_ADDRESS");
p12File =createObject("java", "java.io.File").init(expandPath("PATH_TO_P12_FILE"));
credentialBuilder.setServiceAccountPrivateKeyFromP12File(p12File);
StorageScopes = createObject("java", "com.google.api.services.storage.StorageScopes");
// Alternative StorageScopes: DEVSTORAGE_READ_ONLY, DEVSTORAGE_READ_WRITE
credentialBuilder.setServiceAccountScopes([StorageScopes.DEVSTORAGE_FULL_CONTROL]);
credential = credentialBuilder.build();
httpRequestInitializer = createObject("java", "com.google.api.client.http.HttpRequestInitializer");
dataStoreFactory = createObject("java", "com.google.api.client.util.store.FileDataStoreFactory").init(DATA_STORE_DIR);
storage = createObject("java", "com.google.api.services.storage.Storage$Builder").init(httpTransport, jsonFactory, credential);
storage.setApplicationName(APP_NAME);
storage = storage.build();
getBucket = storage.buckets().get(BUCKET_NAME);
getBucket.setProjection("full");
bucket = getBucket.execute();

Resources