Module isilon.api.containers
View Source
import attr
from isilon.api.base import BaseAPI
@attr.s(frozen=True)
class Containers(BaseAPI):
    async def objects(self, container_name: str, headers: dict = {}, **kwargs):
        """Show container details and list objects."""
        response = await self.base_request(
            self.http.get,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}?format=json",
            headers=headers,
            **kwargs,
        )
        response = await response.json()
        return response
    async def create(self, container_name, headers: dict = {}, **kwargs) -> int:
        """Create container."""
        response = await self.base_request(
            self.http.put,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return int(response.status)
    async def update_metadata(self, container_name, headers: dict = {}, **kwargs):
        """Create, update, or delete container metadata."""
        response = await self.base_request(
            self.http.put,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.status
    async def show_metadata(self, container_name, headers: dict = {}, **kwargs):
        """Show container metadata."""
        response = await self.base_request(
            self.http.head,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.headers
    async def delete(self, container_name, headers: dict = {}, **kwargs):
        """Delete container."""
        response = await self.base_request(
            self.http.delete,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.status
Classes
Containers
class Containers(
    http: isilon.http.Http,
    url,
    credentials: isilon.creds.Credentials
)
View Source
class Containers(BaseAPI):
    async def objects(self, container_name: str, headers: dict = {}, **kwargs):
        """Show container details and list objects."""
        response = await self.base_request(
            self.http.get,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}?format=json",
            headers=headers,
            **kwargs,
        )
        response = await response.json()
        return response
    async def create(self, container_name, headers: dict = {}, **kwargs) -> int:
        """Create container."""
        response = await self.base_request(
            self.http.put,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return int(response.status)
    async def update_metadata(self, container_name, headers: dict = {}, **kwargs):
        """Create, update, or delete container metadata."""
        response = await self.base_request(
            self.http.put,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.status
    async def show_metadata(self, container_name, headers: dict = {}, **kwargs):
        """Show container metadata."""
        response = await self.base_request(
            self.http.head,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.headers
    async def delete(self, container_name, headers: dict = {}, **kwargs):
        """Delete container."""
        response = await self.base_request(
            self.http.delete,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.status
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
create
def create(
    self,
    container_name,
    headers: dict = {},
    **kwargs
) -> int
Create container.
View Source
    async def create(self, container_name, headers: dict = {}, **kwargs) -> int:
        """Create container."""
        response = await self.base_request(
            self.http.put,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return int(response.status)
delete
def delete(
    self,
    container_name,
    headers: dict = {},
    **kwargs
)
Delete container.
View Source
    async def delete(self, container_name, headers: dict = {}, **kwargs):
        """Delete container."""
        response = await self.base_request(
            self.http.delete,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.status
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
objects
def objects(
    self,
    container_name: str,
    headers: dict = {},
    **kwargs
)
Show container details and list objects.
View Source
    async def objects(self, container_name: str, headers: dict = {}, **kwargs):
        """Show container details and list objects."""
        response = await self.base_request(
            self.http.get,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}?format=json",
            headers=headers,
            **kwargs,
        )
        response = await response.json()
        return response
show_metadata
def show_metadata(
    self,
    container_name,
    headers: dict = {},
    **kwargs
)
Show container metadata.
View Source
    async def show_metadata(self, container_name, headers: dict = {}, **kwargs):
        """Show container metadata."""
        response = await self.base_request(
            self.http.head,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.headers
update_metadata
def update_metadata(
    self,
    container_name,
    headers: dict = {},
    **kwargs
)
Create, update, or delete container metadata.
View Source
    async def update_metadata(self, container_name, headers: dict = {}, **kwargs):
        """Create, update, or delete container metadata."""
        response = await self.base_request(
            self.http.put,
            f"{self.url}/{self.API_VERSION}/AUTH_{self.credentials.account}/{container_name}",
            headers=headers,
            **kwargs,
        )
        return response.status