-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Cloud Admin module * formatting * add examples * fix comment syntax
- Loading branch information
Showing
7 changed files
with
96 additions
and
7 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
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,32 @@ | ||
# coding=utf-8 | ||
import logging | ||
|
||
from .rest_client import AtlassianRestAPI | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
ADMIN_URL = "https://api.atlassian.com" | ||
|
||
|
||
class CloudAdminOrgs(AtlassianRestAPI): | ||
def __init__(self, admin_api_key, *args, **kwargs): | ||
kwargs["token"] = admin_api_key | ||
kwargs["api_root"] = "admin" | ||
kwargs["api_version"] = "v1" | ||
super(CloudAdminOrgs, self).__init__(url=ADMIN_URL, *args, **kwargs) | ||
|
||
def get_organizations(self): | ||
url = self.resource_url("orgs") | ||
return self.get(url) | ||
|
||
|
||
class CloudAdminUsers(AtlassianRestAPI): | ||
def __init__(self, admin_api_key, *args, **kwargs): | ||
kwargs["token"] = admin_api_key | ||
kwargs["api_root"] = "users" | ||
kwargs["api_version"] = None | ||
super(CloudAdminUsers, self).__init__(ADMIN_URL, *args, **kwargs) | ||
|
||
def get_profile(self, account_id): | ||
url = self.resource_url("{}/manage/profile".format(account_id)) | ||
return self.get(url) |
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,19 @@ | ||
Cloud Admin module | ||
================== | ||
|
||
CloudAdminOrgs | ||
-------------- | ||
|
||
.. code-block:: python | ||
# Returns a list of your organizations | ||
cloud_admin_orgs.get_organizations() | ||
CloudAdminUsers | ||
--------------- | ||
|
||
.. code-block:: python | ||
# Returns information about a single Atlassian account by ID | ||
cloud_admin_users.get_profile(account_id) |
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,8 @@ | ||
# coding=utf-8 | ||
from atlassian import CloudAdminOrgs | ||
|
||
# How to get organizations | ||
|
||
cloud_admin_orgs = CloudAdminOrgs(admin_api_key="admin_api_key") | ||
|
||
cloud_admin_orgs.get_organizations() |
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,8 @@ | ||
# coding=utf-8 | ||
from atlassian import CloudAdminUsers | ||
|
||
# How to get user profile | ||
|
||
cloud_admin_users = CloudAdminUsers(admin_api_key="admin_api_key") | ||
|
||
cloud_admin_users.get_organizations(account_id="account_id") |