-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from cloudblue/first_public_release
First public release
- Loading branch information
Showing
36 changed files
with
1,678 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ dist/ | |
.vscode | ||
.devcontainer | ||
|
||
tests/reports/ | ||
coverage/ | ||
.coverage | ||
/htmlcov/ | ||
docs/_build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of the Ingram Micro Cloud Blue Connect connect-cli. | ||
# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. | ||
|
||
import click | ||
import requests | ||
|
||
|
||
def add_account(config, api_key, endpoint): | ||
headers = { | ||
'Authorization': api_key, | ||
} | ||
|
||
res = requests.get(f'{endpoint}/accounts', headers=headers) | ||
if res.status_code == 401: | ||
raise click.ClickException('Unauthorized: the provided api key is invalid.') | ||
|
||
if res.status_code == 200: | ||
account_data = res.json()[0] | ||
account_id = account_data['id'] | ||
name = account_data['name'] | ||
config.add_account( | ||
account_id, | ||
name, | ||
api_key, | ||
endpoint, | ||
) | ||
config.store() | ||
return account_id, name | ||
|
||
raise click.ClickException(f'Unexpected error: {res.status_code} - {res.text}') | ||
|
||
|
||
def activate_account(config, id): | ||
config.activate(id) | ||
config.store() | ||
return config.active | ||
|
||
|
||
def remove_account(config, id): | ||
acc = config.remove_account(id) | ||
config.store() | ||
return acc |
Oops, something went wrong.