Skip to content

Module neuroio.billing.v1

None

None

View Source
from typing import List, Union, cast

from httpx import Response

from neuroio.base import IAMBase, IAMBaseAsync, IAMBaseBase

from neuroio.constants import sentinel

from neuroio.utils import request_query_processing, validate_month_str

class BillingBase(IAMBaseBase):

    def get_url(self, key: str) -> str:

        return self.base_url + f"/v1/billing/{key}/"

class Impl(IAMBase, BillingBase):

    def usage(

        self,

        limit: int = 20,

        offset: int = 0,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        with self.get_client() as client:

            return client.get(url=self.get_url("usage"), params=data)

    def usage_total(

        self,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        with self.get_client() as client:

            return client.get(url=self.get_url("usage/total"), params=data)

class ImplAsync(IAMBaseAsync, BillingBase):

    async def usage(

        self,

        limit: int = 20,

        offset: int = 0,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        async with self.get_client() as client:

            return await client.get(url=self.get_url("usage"), params=data)

    async def usage_total(

        self,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        async with self.get_client() as client:

            return await client.get(

                url=self.get_url("usage/total"), params=data

            )

Variables

sentinel

Classes

BillingBase

class BillingBase(
    /,
    *args,
    **kwargs
)
View Source
class BillingBase(IAMBaseBase):

    def get_url(self, key: str) -> str:

        return self.base_url + f"/v1/billing/{key}/"

Ancestors (in MRO)

  • neuroio.base.IAMBaseBase

Descendants

  • neuroio.billing.v1.Impl
  • neuroio.billing.v1.ImplAsync

Class variables

base_url

Methods

get_url

def get_url(
    self,
    key: str
) -> str
View Source
    def get_url(self, key: str) -> str:

        return self.base_url + f"/v1/billing/{key}/"

Impl

class Impl(
    settings: dict
)
View Source
class Impl(IAMBase, BillingBase):

    def usage(

        self,

        limit: int = 20,

        offset: int = 0,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        with self.get_client() as client:

            return client.get(url=self.get_url("usage"), params=data)

    def usage_total(

        self,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        with self.get_client() as client:

            return client.get(url=self.get_url("usage/total"), params=data)

Ancestors (in MRO)

  • neuroio.base.IAMBase
  • abc.ABC
  • neuroio.base.Base
  • neuroio.billing.v1.BillingBase
  • neuroio.base.IAMBaseBase

Class variables

base_url

Methods

get_client

def get_client(
    self
) -> httpx.Client
View Source
    def get_client(self) -> Client:

        return Client(**self.settings)

get_url

def get_url(
    self,
    key: str
) -> str
View Source
    def get_url(self, key: str) -> str:

        return self.base_url + f"/v1/billing/{key}/"

usage

def usage(
    self,
    limit: int = 20,
    offset: int = 0,
    spaces_ids: Union[List[int], object] = <object object at 0x10c207fb0>,
    event_types: Union[List[int], object] = <object object at 0x10c207fb0>,
    month_from: Union[str, object] = <object object at 0x10c207fb0>,
    month_to: Union[str, object] = <object object at 0x10c207fb0>
) -> httpx.Response
View Source
    def usage(

        self,

        limit: int = 20,

        offset: int = 0,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        with self.get_client() as client:

            return client.get(url=self.get_url("usage"), params=data)

usage_total

def usage_total(
    self,
    spaces_ids: Union[List[int], object] = <object object at 0x10c207fb0>,
    event_types: Union[List[int], object] = <object object at 0x10c207fb0>,
    month_from: Union[str, object] = <object object at 0x10c207fb0>,
    month_to: Union[str, object] = <object object at 0x10c207fb0>
) -> httpx.Response
View Source
    def usage_total(

        self,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        with self.get_client() as client:

            return client.get(url=self.get_url("usage/total"), params=data)

ImplAsync

class ImplAsync(
    settings: dict
)
View Source
class ImplAsync(IAMBaseAsync, BillingBase):

    async def usage(

        self,

        limit: int = 20,

        offset: int = 0,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        async with self.get_client() as client:

            return await client.get(url=self.get_url("usage"), params=data)

    async def usage_total(

        self,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        async with self.get_client() as client:

            return await client.get(

                url=self.get_url("usage/total"), params=data

            )

Ancestors (in MRO)

  • neuroio.base.IAMBaseAsync
  • abc.ABC
  • neuroio.base.Base
  • neuroio.billing.v1.BillingBase
  • neuroio.base.IAMBaseBase

Class variables

base_url

Methods

get_client

def get_client(
    self
) -> httpx.AsyncClient
View Source
    def get_client(self) -> AsyncClient:

        return AsyncClient(**self.settings)

get_url

def get_url(
    self,
    key: str
) -> str
View Source
    def get_url(self, key: str) -> str:

        return self.base_url + f"/v1/billing/{key}/"

usage

def usage(
    self,
    limit: int = 20,
    offset: int = 0,
    spaces_ids: Union[List[int], object] = <object object at 0x10c207fb0>,
    event_types: Union[List[int], object] = <object object at 0x10c207fb0>,
    month_from: Union[str, object] = <object object at 0x10c207fb0>,
    month_to: Union[str, object] = <object object at 0x10c207fb0>
) -> httpx.Response
View Source
    async def usage(

        self,

        limit: int = 20,

        offset: int = 0,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        async with self.get_client() as client:

            return await client.get(url=self.get_url("usage"), params=data)

usage_total

def usage_total(
    self,
    spaces_ids: Union[List[int], object] = <object object at 0x10c207fb0>,
    event_types: Union[List[int], object] = <object object at 0x10c207fb0>,
    month_from: Union[str, object] = <object object at 0x10c207fb0>,
    month_to: Union[str, object] = <object object at 0x10c207fb0>
) -> httpx.Response
View Source
    async def usage_total(

        self,

        spaces_ids: Union[List[int], object] = sentinel,

        event_types: Union[List[int], object] = sentinel,

        month_from: Union[str, object] = sentinel,

        month_to: Union[str, object] = sentinel,

    ) -> Response:

        if month_to != sentinel:

            validate_month_str(cast(str, month_to))

        if month_from != sentinel:

            validate_month_str(cast(str, month_from))

        data = request_query_processing(locals(), ["self"])

        async with self.get_client() as client:

            return await client.get(

                url=self.get_url("usage/total"), params=data

            )