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

sudo dnf install python3-pip

Cent OS / RHEL

  1. Enable the PyPA Copr Repo using these instructions .

  2. Run the following command:

    sudo dnf install python3-pip
    

openSUSE

sudo zypper install python3-pip
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

  1. Create a service account.

    For step-by-step instructions, see Create a service account.

  2. Store and read the key ID, service account ID and private key from a JSON file. It may look as follows:

    sa_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

  1. Get an IAM token.

    For step-by-step instructions and examples, see Getting an IAM token for a service account.

  2. Use the IAM token in your code:

    sdk = 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")