Install DoubleCloud API SDK
Before you start
Install Python 3 pip
Make sure you have python3-pip
installed on your system. If not, run the following:
sudo apt install -y python3-pip
Distribution type |
Command |
Fedora |
|
Cent OS / RHEL |
|
openSUSE |
|
python3 -m pip install --upgrade pip
python3 -m ensurepip
Install the SDK package
To install DoubleCloud API Python SDK, run the following command:
pip install doublecloud
To install DoubleCloud API Go SDK, run the following command:
go install github.com/doublecloud/go-sdk@latest
Authenticate your API requests
You can use 2 authentication methods: service account API keys and IAM tokens.
Service account keys
-
Create a service account.
For step-by-step instructions, see Create a service account.
-
Store and read the key ID, service account ID and private key from a JSON file. It may look as follows:
PythonGosa_key = { "id": "<your key ID>", "service_account_id": "<your service account ID>", "private_key": "<your private key value>" } sdk = doublecloud.SDK(service_account_key=sa_key)
IAM tokens
-
Get an IAM token.
For step-by-step instructions and examples, see Getting an IAM token for a service account.
-
Use the IAM token in your code:
PythonGosdk = doublecloud.SDK(iam_token="<your IAM token value>")
key, err := iamkey.ReadFromJSONFile(*flags.saPath) ret.saPath = flag.String("saPath", "authorized_key.json", "Path to the service account key JSON file.\nThis file can be created using UI:\n"+ "Members -> Service Accounts -> Create and then create authorized keys")