How to rename an AWS API Gateway API instance? - aws-api-gateway

In AWS API Gateway, is it possible to rename an API instance somehow?
I don't see the option on the UI, but maybe it's possible by using some API call.

Yes it's available in the API or CLI.
In the API you use a PATCH request on the 'name' field. http://docs.aws.amazon.com/apigateway/api-reference/resource/rest-api/
In the CLI, see docs http://docs.aws.amazon.com/cli/latest/reference/apigateway/update-rest-api.html
The PATCH op is 'replace' and the path would be '/name'
Edit: Thanks #Canotto90 for the example
aws apigateway update-rest-api --rest-api-id IDOfTheAPIThatNeedsTobeUpdated --patch-operations op=replace,path=/name,value=NewName

Here is how you can get the list of APIs and their IDs:
aws apigateway get-rest-apis
Use the Id to update name of API as mentioned by Canotto90 above:
aws apigateway update-rest-api --rest-api-id IDOfTheAPIThatNeedsTobeUpdated --patch-operations op=replace,path=/name,value=NewName

It turns out, there is now a way to rename the API!
Under the Amazon API Gateway service, select APIs. You will see the list of your APIs.
Now, click the little cog wheel in the top right corner of the API that you wish to rename...
Simply change the name, hit save, and you're good!

From https://console.aws.amazon.com/apigateway -> Select API by Name -> Settings -> General Settings -> Name

I know this is an old question, but people may still need an answer as I just did.
Amazon's AWS UI isn't always clear. There is no "Rename" function to change the name of an existing API. However, it can be done by cloning your existing API.
To rename your API, click the "Create API" button and select "Clone from existing API". This will allow you to give it a new name.

The latest version of the console allows you to edit the name via the API settings: see where in console here

Related

How to configure google identity platform with CLI sdk?

I am trying to change google identity platform configuration with cli using gcloud CLI SDK for linux.
to be specific I want to call these API getConfig and UpdateConfig
Is there a way to do this using gcloud cli? there seems to be a group called Identity as per the docs, but this does not seem to be doing what I want
I struggled using Google's Identity Toolkit/Platform and how these correspond with Firebase-Auth too.
The term is overloaded by Google and Cloud Identity, Identity Platform and Firebase Auth have overlapping sets of functionality.
Name
URL
Cloud Identity API
cloudidentity.googleapis.com
Identity Toolkit API
identitytoolkit.googleapis.com
NOTE Identity Toolkit is inaccessible through Google APIs Explorer
I wanted to be able to programmatically update Firebase Auth's authorized domains.
By observing the calls made by Firebase Console, I needed to use getConfig and updateConfig too.
These aren't surfaced through gcloud.
Essentially:
GET the response from getConfig
I used jq to transform it into my desired state
PATCH config1 using an updateMask
1 The endpoint for the updateConfig method is actually (just) config
This worked for me and hopefully helps you better understand how you can use these methods directly.
I blogged about it more comprehensively here

Is there an IBM Cloud API call to retreive the account name?

The account settings page (Manage > Account > Account Settings) lists an account ID and an account name under the "Account" heading. The account ID is easy enough to retrieve using the API, but I've not found a way to get the account name. Is this possible to get using the API?
I've been looking at the IBM Cloud API Docs and at the Softlayer API docs but haven't been able to find something which returns the account name.
The ibmcloud CLI returns the info, but I'd rather not have to use the CLI since this will be used from within a Python app.
You can always use IBMCLOUD_TRACE=true on the CLI to find out what the ibmcloud command is doing. What you see as "account name" is the ID resolved by going to the user management API.

How to set secrets in Github Actions?

The official boilerplate code injects the npm token as follows
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
How do I access and set this variable? I cant find it in the GUI.
Go to your project in Github
Select the Settings tab
Click the Secrets section in the left hand menu
Add a new secret and provide a name (e.g. npm_token) and a value.
In addition to the GUI, you now (January 2020) have a GitHub Actions API(!, still beta though), as announced here.
And it does include a GitHub Actions Secrets API:
Create or update an repository secret:
Creates or updates an organization secret with an encrypted value. Encrypt your secret using LibSodium.
You must authenticate using an access token with the admin:repo scope to use this endpoint.
GitHub Apps must have the secrets organization permission to use this endpoint.
PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}
Get a repository secret
Gets a single secret without revealing its encrypted value.
Anyone with write access to the repository can use this endpoint.
GitHub Apps must have the secrets permission to use this endpoint.
GET /repos/:owner/:repo/actions/secrets/:name
So the GUI is no longer the sole option: you can script and get/set an Actions secret through this new API.
This page is hard to find, but it exists in the official docs here: Creating and using secrets (encrypted variables).
Copied from the docs below for convenience:
Secret names cannot include any spaces. To ensure that GitHub redacts
your secret in logs, avoid using structured data as the values of
secrets, like JSON or encoded Git blobs.
On GitHub, navigate to the main page of the repository.
Under your repository name, click Settings.
In the left sidebar, click Secrets.
Type a name for your secret in the "Name" input box.
Type the value for your secret.
Click Add secret.
The link above has a bit more info around using secrets as well.
I've created a simple CLI that can help you achieve that - https://github.com/unfor19/githubsecrets
This CLI is based on the official API. You can install it with pip or use Docker, read the README.md for more information

Can I manage my Bluemix account using an API instead of CF tool?

Can I manage my Bluemix account using an API instead of CF tool? I don't like the output from using the tool and I don't always have access to it.
Yes, you can set the environment variable CF_TRACE=true to see the API calls made by the cf cli. Also, see the API docs here https://apidocs.cloudfoundry.org/

Restoring API Gateway Resource from previous Deploy

/r1
|- POST <-- accidentally deleted, want to restore
|- GET <-- new method, will remove the POST from the previous deploy
One of the methods in one of our resources has been deleted. The resource is of course still in the most recent deploy, and we want to restore it so we can add, say, a GET method to the same resource.
If we just add the new GET and deploy, the POST will be removed. Is there no way to save and restore an API?
2017- You can now export a stage as Swagger + API Gateway Extensions (Stages > [your stage] > Export > Swagger + API Gateway Extensions)and import it through Actions > Import API
You can easily restore your AWS API Gateway from a previous deployment. Go to API Gateway and select your API. Then select Stages. Pick a stage that has the last version of your deployment that you want to restore. Select it and click the Export tab, and export the JSON + Swagger file. Then select the Resources tab and under actions click Import. Once you import your swagger file, your API Gateway resources will be restored to the version that was deployed to that aforementioned Stage. I hope this helps.
Unfortunately this is not possible. You may want to manage your API moving forward using a Swagger or RAML definition and using the API import tool. Doing so will allow you to treat your API definition like source code, with tracking and ability to revert changes.
We can restore the previous state of the API gateway by changing deployment. If any resource is deleted then we can't restore that resource under API gateway Resources. but we can restore the previous deployment state and Also, we can export the restored deployment state using the Export option in Stages. You can see in the image that we can restore by choosing deployment and click on Change Deployment.
You can also try to use the CLI tool to retrieve configuration details for your deployed API (Get-Deployment CLI).
aws apigateway get-deployment --rest-api-id "value" --deployment-id "value"
The output contains a field "apiSummary" which will show you some details about the api configuration.
Best,
Jurgen