# Cloudcraft API Client for Python
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache2.0-yellow.svg)](LICENSE.md)
[![versions](https://img.shields.io/pypi/pyversions/cloudcraftco)](https://www.python.org/downloads/release/python-3100/)
[![Build Status](https://github.com/DataDog/cloudcraft-python/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/DataDog/cloudcraft-python/actions?query=branch%3Amain)
![Cloudcraft diagram](https://static.cloudcraft.co/sdk/cloudcraft-sdk-example-1.svg)
Visualize your cloud architecture with Cloudcraft by Datadog, [the best way to create smart AWS and Azure diagrams](https://www.cloudcraft.co/).
Cloudcraft supports both manual and programmatic diagramming, as well as automatic reverse engineering of existing cloud environments into
beautiful system architecture diagrams.
This `cloudcraftco` Python library provides an easy-to-use native Python SDK for interacting with [the Cloudcraft API](https://developers.cloudcraft.co/).
Use case examples:
- Snapshot and visually compare your live AWS or Azure environment before and after a deployment, in your app or as part of your automated CI pipeline
- Download an inventory of all your cloud resources from a linked account as JSON
- Write a converter from a third party data format to Cloudcraft diagrams
- Backup, export & import your Cloudcraft data
- Programmatically create Cloudcraft diagrams
This SDK requires a [Cloudcraft API key](https://developers.cloudcraft.co/#authentication) to use. [A free trial of Cloudcraft Pro](https://www.cloudcraft.co/pricing) with API access is available.
## Requirements
- Python 3.10
- Requests 2.28
## Installation
```
python3.10 -m pip install cloudcraftco
```
## Usage
The API is accessed through the `Cloudcraft` class. An API key available through the Cloudcraft user interface is required when instantiating `Cloudcraft`. It can be passed to the class as an argument or through the `CLOUDCRAFT_API_KEY` environment variable:
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
profile = cloudcraft.read_user_profile()
```
### Configuration
#### Initialize with config object
The package can be initialized with several options:
```python
from cloudcraftco.cloudcraft import Cloudcraft
cloudcraft = Cloudcraft({"api_key": "api-key-value", "timeout": 30000})
```
`api_key` must be provided via config object or environment variable.
| Option | Default | Description |
| ------------------- | --------------------- | ----------------------------------------------- |
| `api_key` | | API Key associated with Cloudcraft account |
| `maxNetworkRetries` | 10 | The amount of times a request should be retried |
| `timeout` | 80000 | Maximum time each request can take in ms |
| `host` | `'api.cloudcraft.co'` | Host that requests are made to |
| `port` | 443 | Port that requests are made to |
| `protocol` | `'https'` | `'https'` or `'http'` |
Options may also be specified by environment variable...
| Option | Environment Variable |
| ------------------- | ----------------------------------- |
| `api_key` | `CLOUDCRAFT_API_KEY` |
| `maxNetworkRetries` | `CLOUDCRAFT_MAX_NETWORK_RETRIES` |
| `timeout` | `CLOUDCRAFT_TIMEOUT` |
| `host` | `CLOUDCRAFT_HOST` |
| `port` | `CLOUDCRAFT_PORT` |
| `protocol` | `CLOUDCRAFT_PROTOCOL` |
### Blueprints
#### List blueprints
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
blueprints = cloudcraft.list_blueprints()
```
#### Retrieve blueprint
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
blueprint_id = "BLUEPRINT-ID" # valid blueprint uuid
blueprint = cloudcraft.read_blueprint(blueprint_id)
```
#### Create blueprint
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
data = {"data": {"grid": "standard", "name": "New blueprint"}}
blueprint = cloudcraft.create_blueprint(data)
```
#### Update blueprint
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
blueprint_id = "BLUEPRINT-ID" # valid blueprint uuid
data = {"data": {"grid": "standard", "name": "Updated blueprint"}}
cloudcraft.update_blueprint(blueprint_id, data)
```
#### Delete blueprint
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
blueprint_id = "BLUEPRINT-ID" # valid blueprint uuid
cloudcraft.delete_blueprint(blueprint_id)
```
#### Export blueprint as image
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
script_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
bp_id = "BLUEPRINT-ID" # valid blueprint uuid
bp_format = "svg"
bp_file = script_dir + bp_id + "." + bp_format
export = cloudcraft.export_blueprint(bp_id, bp_format)
with open(bp_file, "wb") as binary_file:
binary_file.write(export)
```
### AWS Accounts
#### Add AWS account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
# role must exist and match your api_key/account
role = "arn:aws:iam::{}:role/cloudcraft".format(aws_account_id)
data = {"name": "New AWS Account", "roleArn": role}
result = cloudcraft.create_aws_account(data)
```
#### List AWS accounts
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
accounts = cloudcraft.list_aws_accounts()
```
#### Update AWS account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
account_id = "AWS-ACCOUNT" # valid account uuid for api-key
role = "AWS-ROLE" # valid role for AWS Account
data = {"name": "Updated Playground AWS Account", "roleArn": role}
result = cloudcraft.update_aws_account(account_id, data)
```
#### Delete AWS account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
account_id = "AWS-ACCOUNT" # valid account uuid for api-key
cloudcraft.delete_aws_account(account_id)
```
#### Get my AWS IAM Role parameters
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
iam_parameters = cloudcraft.read_aws_role_parameters()
```
#### Snapshot AWS account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
script_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
ss_account = "AWS-ACCOUNT" # valid account uuid for api-key
ss_region = "us-west-2"
ss_format = "png"
ss_file = script_dir + ss_region + "." + ss_format
snapshot = cloudcraft.snapshot_aws_account(ss_account, ss_region, ss_format)
with open(ss_file, "wb") as binary_file:
binary_file.write(snapshot)
```
### Azure Accounts
#### Add Azure account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
# id and secret values must be valid
data = {
"name": "Azure Account",
"subscriptionId": "subscriptionId",
"directoryId": "directoryId",
"applicationId": "applicationId",
"clientSecret": "clientSecret"
}
result = cloudcraft.create_azure_account(data)
```
#### List Azure accounts
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
accounts = cloudcraft.list_azure_accounts()
```
#### Update Azure account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
account_id = "AZURE-ACCOUNT" # valid account uuid for api-key
data = {
"name": "Updated Azure Account",
"subscriptionId": "subscriptionId",
"directoryId": "directoryId",
"applicationId": "applicationId",
}
result = cloudcraft.update_azure_account(account_id, data)
```
#### Delete Azure account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
account_id = "AZURE-ACCOUNT" # valid account uuid for api-key
cloudcraft.delete_azure_account(account_id)
```
#### Snapshot Azure account
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
script_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
ss_account = "AZURE-ACCOUNT" # valid account uuid for api-key
ss_location = "canadaeast"
ss_format = "png"
ss_file = script_dir + ss_location + "." + ss_format
snapshot = cloudcraft.snapshot_azure_account(ss_account, ss_location, ss_format)
with open(ss_file, "wb") as binary_file:
binary_file.write(snapshot)
```
### Budgets
#### Export budget for a blueprint
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
script_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
bp_id = "BLUEPRINT-ID" # valid blueprint uuid
bp_format = "csv"
bp_file = script_dir + bp_id + "." + bp_format
export = cloudcraft.export_blueprint_budget(bp_id, bp_format)
with open(bp_file, "wb") as binary_file:
binary_file.write(export)
```
### Users
#### Get Cloudcraft account info
```python
from cloudcraftco.cloudcraft import Cloudcraft
# assumes CLOUDCRAFT_API_KEY exported
cloudcraft = Cloudcraft()
profile = cloudcraft.read_user_profile()
```
## More information
See the [Cloudcraft Developer API docs](https://developers.cloudcraft.co/).
## Development
### Host Environment
`cloudcraft-python` was developed using...
- Python 3.7.15
- Poetry 1.1.14
- Tox 3.25.1
Host environment was macOS 12, but the other environments should work.
Earlier versions may work, but Python 3.10 is minimum supported version.
### Running Playground (Examples)
Development examples showing how Cloudcraft API works running source code.
Testing accounts requires care, since creating an account requires valid role.
```
% cd {repo-directory}
% poetry env use python3.10
% poetry shell
% poetry install
% export CLOUDCRAFT_API_KEY={{ api-key }}
% python3 dev_playgrounds/blueprints.py
% python3 dev_playgrounds/budgets.py
% python3 dev_playgrounds/exports.py
% python3 dev_playgrounds/snapshots_aws.py
% python3 dev_playgrounds/snapshots_azure.py
% python3 dev_playgrounds/users.py
% export CLOUDCRAFT_TEST_ROLE={{ your-role-arn }}
% python3 dev_playgrounds/accounts_aws.py
% export CLOUDCRAFT_TEST_SUBSCRIPTION={{ your-subscription-id }}
% export CLOUDCRAFT_TEST_DIRECTORY={{ your-directory-id }}
% export CLOUDCRAFT_TEST_APPLICATION={{ your-application-id }}
% export CLOUDCRAFT_TEST_SECRET={{ your-client-secret }}
% python3 dev_playgrounds/accounts_azure.py
```
### Running Tests
```
% poetry run pytest tests/unit
% poetry run pytest tests/functional
% tox
```
### Formatting Code
```
% poetry run isort . --profile black
% poetry run black .
```
### Checking Test Coverage
```
% poetry run coverage run --source=cloudcraftco --branch -m pytest .
% poetry run coverage html
```
Raw data
{
"_id": null,
"home_page": "https://www.cloudcraft.co/",
"name": "cloudcraftco",
"maintainer": "Sean Broderick",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "sean.broderick@datadoghq.com",
"keywords": "datadog,cloudcraft,aws,azure,diagrams,sdk",
"author": "Datadog, Inc.",
"author_email": "dev@datadoghq.com",
"download_url": "https://files.pythonhosted.org/packages/95/50/5052a9f86fb39892294887a87c8778784a6a1991b0ffed479434d9d953c0/cloudcraftco-1.1.0.tar.gz",
"platform": null,
"description": "# Cloudcraft API Client for Python\n\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache2.0-yellow.svg)](LICENSE.md)\n[![versions](https://img.shields.io/pypi/pyversions/cloudcraftco)](https://www.python.org/downloads/release/python-3100/)\n[![Build Status](https://github.com/DataDog/cloudcraft-python/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/DataDog/cloudcraft-python/actions?query=branch%3Amain)\n\n![Cloudcraft diagram](https://static.cloudcraft.co/sdk/cloudcraft-sdk-example-1.svg)\n\nVisualize your cloud architecture with Cloudcraft by Datadog, [the best way to create smart AWS and Azure diagrams](https://www.cloudcraft.co/).\n\nCloudcraft supports both manual and programmatic diagramming, as well as automatic reverse engineering of existing cloud environments into\nbeautiful system architecture diagrams.\n\nThis `cloudcraftco` Python library provides an easy-to-use native Python SDK for interacting with [the Cloudcraft API](https://developers.cloudcraft.co/).\n\nUse case examples:\n- Snapshot and visually compare your live AWS or Azure environment before and after a deployment, in your app or as part of your automated CI pipeline\n- Download an inventory of all your cloud resources from a linked account as JSON\n- Write a converter from a third party data format to Cloudcraft diagrams\n- Backup, export & import your Cloudcraft data\n- Programmatically create Cloudcraft diagrams\n\nThis SDK requires a [Cloudcraft API key](https://developers.cloudcraft.co/#authentication) to use. [A free trial of Cloudcraft Pro](https://www.cloudcraft.co/pricing) with API access is available.\n\n## Requirements\n\n - Python 3.10\n - Requests 2.28\n\n## Installation\n\n```\npython3.10 -m pip install cloudcraftco\n```\n\n## Usage\n\nThe API is accessed through the `Cloudcraft` class. An API key available through the Cloudcraft user interface is required when instantiating `Cloudcraft`. It can be passed to the class as an argument or through the `CLOUDCRAFT_API_KEY` environment variable:\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\nprofile = cloudcraft.read_user_profile()\n```\n\n### Configuration\n\n#### Initialize with config object\n\nThe package can be initialized with several options:\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\ncloudcraft = Cloudcraft({\"api_key\": \"api-key-value\", \"timeout\": 30000})\n```\n\n`api_key` must be provided via config object or environment variable.\n\n| Option | Default | Description |\n| ------------------- | --------------------- | ----------------------------------------------- |\n| `api_key` | | API Key associated with Cloudcraft account |\n| `maxNetworkRetries` | 10 | The amount of times a request should be retried |\n| `timeout` | 80000 | Maximum time each request can take in ms |\n| `host` | `'api.cloudcraft.co'` | Host that requests are made to |\n| `port` | 443 | Port that requests are made to |\n| `protocol` | `'https'` | `'https'` or `'http'` |\n\n\nOptions may also be specified by environment variable...\n\n| Option | Environment Variable |\n| ------------------- | ----------------------------------- |\n| `api_key` | `CLOUDCRAFT_API_KEY` |\n| `maxNetworkRetries` | `CLOUDCRAFT_MAX_NETWORK_RETRIES` |\n| `timeout` | `CLOUDCRAFT_TIMEOUT` |\n| `host` | `CLOUDCRAFT_HOST` |\n| `port` | `CLOUDCRAFT_PORT` |\n| `protocol` | `CLOUDCRAFT_PROTOCOL` |\n\n### Blueprints\n\n#### List blueprints\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\nblueprints = cloudcraft.list_blueprints()\n```\n\n#### Retrieve blueprint\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\nblueprint_id = \"BLUEPRINT-ID\" # valid blueprint uuid\nblueprint = cloudcraft.read_blueprint(blueprint_id)\n```\n\n#### Create blueprint\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\ndata = {\"data\": {\"grid\": \"standard\", \"name\": \"New blueprint\"}}\nblueprint = cloudcraft.create_blueprint(data)\n```\n\n#### Update blueprint\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\nblueprint_id = \"BLUEPRINT-ID\" # valid blueprint uuid\ndata = {\"data\": {\"grid\": \"standard\", \"name\": \"Updated blueprint\"}}\ncloudcraft.update_blueprint(blueprint_id, data)\n```\n\n#### Delete blueprint\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\nblueprint_id = \"BLUEPRINT-ID\" # valid blueprint uuid\ncloudcraft.delete_blueprint(blueprint_id)\n```\n\n#### Export blueprint as image\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\nscript_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep\n\nbp_id = \"BLUEPRINT-ID\" # valid blueprint uuid\nbp_format = \"svg\"\nbp_file = script_dir + bp_id + \".\" + bp_format\nexport = cloudcraft.export_blueprint(bp_id, bp_format)\n\nwith open(bp_file, \"wb\") as binary_file:\n binary_file.write(export)\n```\n\n### AWS Accounts\n\n#### Add AWS account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\n# role must exist and match your api_key/account\nrole = \"arn:aws:iam::{}:role/cloudcraft\".format(aws_account_id)\ndata = {\"name\": \"New AWS Account\", \"roleArn\": role}\nresult = cloudcraft.create_aws_account(data)\n```\n\n#### List AWS accounts\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\naccounts = cloudcraft.list_aws_accounts()\n```\n\n#### Update AWS account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\naccount_id = \"AWS-ACCOUNT\" # valid account uuid for api-key\nrole = \"AWS-ROLE\" # valid role for AWS Account\ndata = {\"name\": \"Updated Playground AWS Account\", \"roleArn\": role}\nresult = cloudcraft.update_aws_account(account_id, data)\n```\n\n#### Delete AWS account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\naccount_id = \"AWS-ACCOUNT\" # valid account uuid for api-key\ncloudcraft.delete_aws_account(account_id)\n```\n\n#### Get my AWS IAM Role parameters\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\niam_parameters = cloudcraft.read_aws_role_parameters()\n```\n\n#### Snapshot AWS account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\nscript_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep\n\nss_account = \"AWS-ACCOUNT\" # valid account uuid for api-key\nss_region = \"us-west-2\"\nss_format = \"png\"\nss_file = script_dir + ss_region + \".\" + ss_format\nsnapshot = cloudcraft.snapshot_aws_account(ss_account, ss_region, ss_format)\n\nwith open(ss_file, \"wb\") as binary_file:\n binary_file.write(snapshot)\n```\n\n### Azure Accounts\n\n#### Add Azure account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\n# id and secret values must be valid\ndata = {\n \"name\": \"Azure Account\",\n \"subscriptionId\": \"subscriptionId\",\n \"directoryId\": \"directoryId\",\n \"applicationId\": \"applicationId\",\n \"clientSecret\": \"clientSecret\"\n}\nresult = cloudcraft.create_azure_account(data)\n```\n\n#### List Azure accounts\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\naccounts = cloudcraft.list_azure_accounts()\n```\n\n#### Update Azure account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\naccount_id = \"AZURE-ACCOUNT\" # valid account uuid for api-key\ndata = {\n \"name\": \"Updated Azure Account\",\n \"subscriptionId\": \"subscriptionId\",\n \"directoryId\": \"directoryId\",\n \"applicationId\": \"applicationId\",\n}\nresult = cloudcraft.update_azure_account(account_id, data)\n```\n\n#### Delete Azure account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\naccount_id = \"AZURE-ACCOUNT\" # valid account uuid for api-key\ncloudcraft.delete_azure_account(account_id)\n```\n\n#### Snapshot Azure account\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\nscript_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep\n\nss_account = \"AZURE-ACCOUNT\" # valid account uuid for api-key\nss_location = \"canadaeast\"\nss_format = \"png\"\nss_file = script_dir + ss_location + \".\" + ss_format\nsnapshot = cloudcraft.snapshot_azure_account(ss_account, ss_location, ss_format)\n\nwith open(ss_file, \"wb\") as binary_file:\n binary_file.write(snapshot)\n```\n\n### Budgets\n\n#### Export budget for a blueprint\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\nscript_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep\n\nbp_id = \"BLUEPRINT-ID\" # valid blueprint uuid\nbp_format = \"csv\"\nbp_file = script_dir + bp_id + \".\" + bp_format\nexport = cloudcraft.export_blueprint_budget(bp_id, bp_format)\n\nwith open(bp_file, \"wb\") as binary_file:\n binary_file.write(export)\n```\n\n### Users\n\n#### Get Cloudcraft account info\n\n```python\nfrom cloudcraftco.cloudcraft import Cloudcraft\n\n# assumes CLOUDCRAFT_API_KEY exported\ncloudcraft = Cloudcraft()\n\nprofile = cloudcraft.read_user_profile()\n```\n\n\n## More information\n\nSee the [Cloudcraft Developer API docs](https://developers.cloudcraft.co/).\n\n\n## Development\n\n### Host Environment\n\n`cloudcraft-python` was developed using...\n\n - Python 3.7.15\n - Poetry 1.1.14\n - Tox 3.25.1\n\nHost environment was macOS 12, but the other environments should work.\n\nEarlier versions may work, but Python 3.10 is minimum supported version.\n\n### Running Playground (Examples)\n\nDevelopment examples showing how Cloudcraft API works running source code.\n\nTesting accounts requires care, since creating an account requires valid role.\n\n```\n% cd {repo-directory}\n% poetry env use python3.10\n% poetry shell\n% poetry install\n% export CLOUDCRAFT_API_KEY={{ api-key }}\n% python3 dev_playgrounds/blueprints.py\n% python3 dev_playgrounds/budgets.py\n% python3 dev_playgrounds/exports.py\n% python3 dev_playgrounds/snapshots_aws.py\n% python3 dev_playgrounds/snapshots_azure.py\n% python3 dev_playgrounds/users.py\n% export CLOUDCRAFT_TEST_ROLE={{ your-role-arn }}\n% python3 dev_playgrounds/accounts_aws.py\n% export CLOUDCRAFT_TEST_SUBSCRIPTION={{ your-subscription-id }}\n% export CLOUDCRAFT_TEST_DIRECTORY={{ your-directory-id }}\n% export CLOUDCRAFT_TEST_APPLICATION={{ your-application-id }}\n% export CLOUDCRAFT_TEST_SECRET={{ your-client-secret }}\n% python3 dev_playgrounds/accounts_azure.py\n```\n\n### Running Tests\n\n```\n% poetry run pytest tests/unit\n% poetry run pytest tests/functional\n% tox\n```\n\n### Formatting Code\n\n```\n% poetry run isort . --profile black\n% poetry run black .\n```\n\n### Checking Test Coverage\n\n```\n% poetry run coverage run --source=cloudcraftco --branch -m pytest .\n% poetry run coverage html\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python SDK for rendering AWS and Azure diagrams using the Cloudcraft API.",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://www.cloudcraft.co/",
"Repository": "https://github.com/DataDog/cloudcraft-python"
},
"split_keywords": [
"datadog",
"cloudcraft",
"aws",
"azure",
"diagrams",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d5b03e363b77fee3ac4794b70f4ed43a7351464e6556e92c74fdc90ec2580d3d",
"md5": "7ee5f3fbefc23f904da71f4abd318f1b",
"sha256": "a8d1f42b6e07952154d215da729719e9670d23470be5fb4aa274ec14394021b2"
},
"downloads": -1,
"filename": "cloudcraftco-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7ee5f3fbefc23f904da71f4abd318f1b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 12738,
"upload_time": "2024-03-18T19:52:23",
"upload_time_iso_8601": "2024-03-18T19:52:23.768854Z",
"url": "https://files.pythonhosted.org/packages/d5/b0/3e363b77fee3ac4794b70f4ed43a7351464e6556e92c74fdc90ec2580d3d/cloudcraftco-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "95505052a9f86fb39892294887a87c8778784a6a1991b0ffed479434d9d953c0",
"md5": "f07c008c4499aaede10cf7b0c7d935a2",
"sha256": "b6a556bc1ae7b53de9fa7457c145881dcb32704cfd8a0de983807af7912a8a26"
},
"downloads": -1,
"filename": "cloudcraftco-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f07c008c4499aaede10cf7b0c7d935a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 13558,
"upload_time": "2024-03-18T19:52:25",
"upload_time_iso_8601": "2024-03-18T19:52:25.225636Z",
"url": "https://files.pythonhosted.org/packages/95/50/5052a9f86fb39892294887a87c8778784a6a1991b0ffed479434d9d953c0/cloudcraftco-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-18 19:52:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DataDog",
"github_project": "cloudcraft-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "cloudcraftco"
}