Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch completely to $DIGITALOCEAN_TOKEN #140

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ next page.
```python
resp = self.client.ssh_keys.list(per_page=50, page=page)
pages = resp.links.pages
if 'next' in pages.keys():
parsed_url = urlparse(pages['next'])
page = parse_qs(parsed_url.query)['page'][0]
else:
paginated = False
if 'next' in pages.keys():
parsed_url = urlparse(pages['next'])
page = parse_qs(parsed_url.query)['page'][0]
else:
paginated = False
```

# **Contributing**
Expand Down Expand Up @@ -137,7 +137,7 @@ resources on the respective DigitalOcean account.
To run integration tests, run:

```shell
DO_TOKEN=$DIGITALOCEAN_TOKEN make test-integration
DIGITALOCEAN_TOKEN=... make test-integration
```

#### Test Customizations
Expand Down
4 changes: 2 additions & 2 deletions examples/customize_client_settings/add_http_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)

token = os.environ.get("DO_TOKEN")
token = os.environ.get("DIGITALOCEAN_TOKEN")
if token == "":
raise Exception("No DigitalOcean API token in DO_TOKEN env var")
raise Exception("No DigitalOcean API token in DIGITALOCEAN_TOKEN env var")
# Initialize the client with the `logger` kwarg set to the application's logger.
client = Client(
token,
Expand Down
4 changes: 2 additions & 2 deletions examples/customize_client_settings/custom_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# Set the DO_ENDPOINT environment variable to a valid endpoint
ENDPOINT = environ.get("DO_ENDPOINT") or "https://my.proxy"

token = environ.get("DO_TOKEN")
token = environ.get("DIGITALOCEAN_TOKEN")
if token == "":
raise Exception("No DigitalOcean API token in DO_TOKEN env var")
raise Exception("No DigitalOcean API token in DIGITALOCEAN_TOKEN env var")

# Initialize the client with the `endpoint` kwarg set to the custom endpoint.
client = Client(token, endpoint=ENDPOINT)
Expand Down
8 changes: 5 additions & 3 deletions examples/customize_client_settings/custom_request_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
TIMEOUT_APP = 120
TIMEOUT_KUBERNETES_CREATE = 1200

token = environ.get("DO_TOKEN")
token = environ.get("DIGITALOCEAN_TOKEN")
if token == "":
raise Exception("No DigitalOcean API token in DO_TOKEN env var")
raise Exception("No DigitalOcean API token in DIGITALOCEAN_TOKEN env var")

# Overwrite the default timeout set by the client with your own
client = Client(token, timeout=TIMEOUT_APP)
Expand All @@ -35,7 +35,9 @@

# Setting the `timeout` kwarg value for a specific operation method call will overwrite
# the timeout for that request.
cluster_create_resp = client.kubernetes.create_cluster(new_cluster_req, timeout=TIMEOUT_KUBERNETES_CREATE)
cluster_create_resp = client.kubernetes.create_cluster(
new_cluster_req, timeout=TIMEOUT_KUBERNETES_CREATE
)
# Note: This method was chosen for the sake of the example. The `create_cluster`
# kubernetes operation isn't a log running process (unlike the background action that
# tracks the clusters provisioning state).
Expand Down
4 changes: 2 additions & 2 deletions examples/customize_client_settings/custom_user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# Define a custom value for your application's user-agent
USER_AGENT = "droplets-example"

token = environ.get("DO_TOKEN")
token = environ.get("DIGITALOCEAN_TOKEN")
if token == "":
raise Exception("No DigitalOcean API token in DO_TOKEN env var")
raise Exception("No DigitalOcean API token in DIGITALOCEAN_TOKEN env var")

if environ.get("DO_OVERWRITE_AGENT"):
# When the `user_agent_overwrite` client setting is True, the `user_agent` value
Expand Down
6 changes: 3 additions & 3 deletions examples/poc_droplets_volumes_sshkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class DigitalOceanError(Exception):

class DropletCreator:
def __init__(self, *args, **kwargs):
token = os.environ.get("DO_TOKEN")
token = os.environ.get("DIGITALOCEAN_TOKEN")
if token == "":
raise Exception("No DigitalOcean API token in DO_TOKEN env var")
self.client = Client(token=os.environ.get("DO_TOKEN"))
raise Exception("No DigitalOcean API token in DIGITALOCEAN_TOKEN env var")
self.client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

def throw(self, message):
raise DigitalOceanError(message) from None
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
def integration_client() -> Client:
"""Instantiates a pydo Client for use with integration tests.

The client requires the environment variable DO_TOKEN with a valid API
The client requires the environment variable DIGITALOCEAN_TOKEN with a valid API
token.

*IMPORTANT*: Use of this client will create real resources on the
account.
"""

token = environ.get("DO_TOKEN", None)
token = environ.get("DIGITALOCEAN_TOKEN", None)

if token is None:
pytest.fail("Expected environment variable DO_TOKEN")
pytest.fail("Expected environment variable DIGITALOCEAN_TOKEN")

client = Client(token)
return client
Expand All @@ -36,17 +36,17 @@ def integration_client() -> Client:
def async_integration_client() -> aioClient:
"""Instantiates a pydo Client for use with integration tests.

The client requires the environment variable DO_TOKEN with a valid API
The client requires the environment variable DIGITALOCEAN_TOKEN with a valid API
token.

*IMPORTANT*: Use of this client will create real resources on the
account.
"""

token = environ.get("DO_TOKEN", None)
token = environ.get("DIGITALOCEAN_TOKEN", None)

if token is None:
pytest.fail("Expected environment variable DO_TOKEN")
pytest.fail("Expected environment variable DIGITALOCEAN_TOKEN")

client = aioClient(token)
return client
Expand Down