Module isilon.api.accounts
View Source
import attr
from isilon.api.base import BaseAPI
@attr.s(frozen=True)
class Accounts(BaseAPI):
async def show(self, account_name, headers: dict = {}, **kwargs):
"""Show account details and list containers."""
response = await self.base_request(
self.http.get,
f"{self.url}/{self.API_VERSION}/{account_name}?format=json",
headers=headers,
**kwargs,
)
response = await response.json()
return response
async def update(self, account_name, headers: dict = {}, **kwargs):
"""Create, update, or delete account metadata."""
response = await self.base_request(
self.http.post,
f"{self.url}/{self.API_VERSION}/{account_name}",
headers=headers,
**kwargs,
)
return response
async def metadata(self, account_name, headers: dict = {}, **kwargs):
"""Show account metadata."""
response = await self.base_request(
self.http.head,
f"{self.url}/{self.API_VERSION}/{account_name}",
headers=headers,
**kwargs,
)
return response.headers
Classes
Accounts
class Accounts(
http: isilon.http.Http,
url,
credentials: isilon.creds.Credentials
)
View Source
class Accounts(BaseAPI):
async def show(self, account_name, headers: dict = {}, **kwargs):
"""Show account details and list containers."""
response = await self.base_request(
self.http.get,
f"{self.url}/{self.API_VERSION}/{account_name}?format=json",
headers=headers,
**kwargs,
)
response = await response.json()
return response
async def update(self, account_name, headers: dict = {}, **kwargs):
"""Create, update, or delete account metadata."""
response = await self.base_request(
self.http.post,
f"{self.url}/{self.API_VERSION}/{account_name}",
headers=headers,
**kwargs,
)
return response
async def metadata(self, account_name, headers: dict = {}, **kwargs):
"""Show account metadata."""
response = await self.base_request(
self.http.head,
f"{self.url}/{self.API_VERSION}/{account_name}",
headers=headers,
**kwargs,
)
return response.headers
Ancestors (in MRO)
- isilon.api.base.BaseAPI
Class variables
API_VERSION
Methods
base_request
def base_request(
self,
fn,
url,
headers: dict = {},
*args,
**kwargs
)
View Source
async def base_request(self, fn, url, headers: dict = {}, *args, **kwargs):
headers = await self.get_token(headers)
response = await fn(url, headers=headers, *args, **kwargs)
return response
get_token
def get_token(
self,
headers: dict
) -> dict
View Source
async def get_token(self, headers: dict) -> dict:
token = await self.credentials.x_auth_token(self.url)
headers.update(token)
return headers
metadata
def metadata(
self,
account_name,
headers: dict = {},
**kwargs
)
Show account metadata.
View Source
async def metadata(self, account_name, headers: dict = {}, **kwargs):
"""Show account metadata."""
response = await self.base_request(
self.http.head,
f"{self.url}/{self.API_VERSION}/{account_name}",
headers=headers,
**kwargs,
)
return response.headers
show
def show(
self,
account_name,
headers: dict = {},
**kwargs
)
Show account details and list containers.
View Source
async def show(self, account_name, headers: dict = {}, **kwargs):
"""Show account details and list containers."""
response = await self.base_request(
self.http.get,
f"{self.url}/{self.API_VERSION}/{account_name}?format=json",
headers=headers,
**kwargs,
)
response = await response.json()
return response
update
def update(
self,
account_name,
headers: dict = {},
**kwargs
)
Create, update, or delete account metadata.
View Source
async def update(self, account_name, headers: dict = {}, **kwargs):
"""Create, update, or delete account metadata."""
response = await self.base_request(
self.http.post,
f"{self.url}/{self.API_VERSION}/{account_name}",
headers=headers,
**kwargs,
)
return response