pydo.tags.create()

Description

To create a tag you can send a POST request to /v2/tags with a name attribute.

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "tag": {
    "name": "extra-awesome",
    "resources": {
      "count": 0,
      "droplets": {
        "count": 0
      },
      "images": {
        "count": 0
      },
      "volumes": {
        "count": 0
      },
      "volume_snapshots": {
        "count": 0
      },
      "databases": {
        "count": 0
      }
    }
  }
}

resp = client.tags.create(body=req)

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

The response will be a JSON object with a key called tag. The value of this will be a tag object containing the standard tag attributes

Click to expand an example response.
{
  "tag": {
    "name": "extra-awesome",
    "resources": {
      "count": 0,
      "droplets": {
        "count": 0
      },
      "images": {
        "count": 0
      },
      "volumes": {
        "count": 0
      },
      "volume_snapshots": {
        "count": 0
      },
      "databases": {
        "count": 0
      }
    }
  }
}

Bad Request

Click to expand an example response for InvalidCharacters.
{
  "value": {
    "error": "Error validating resource tag: \\\"tag-name \\\\\\\"\u0437\u0434\u043e\u0440\u043e\u0432\u043e\\\\\\\" contains invalid characters\\\"",
    "messages": null,
    "root_causes": [
      "rpc error: code = InvalidArgument desc = Error validating resource tag: \\\"tag-name \\\\\\\"\u0437\u0434\u043e\u0440\u043e\u0432\u043e\\\\\\\" contains invalid characters\\\""
    ]
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}