Skip to content

Module neuroio.spaces.v1

None

None

View Source
from httpx import Response

from neuroio.base import IAMBase, IAMBaseAsync, IAMBaseBase

class SpacesBase(IAMBaseBase):

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

        if key:

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

        else:

            return self.base_url + "/v1/spaces/"

class Impl(IAMBase, SpacesBase):

    def create(self, name: str) -> Response:

        data = {"name": name}

        with self.get_client() as client:

            return client.post(url=self.get_url(), json=data)

    def list(

        self, q: str = None, limit: int = 20, offset: int = 0

    ) -> Response:

        data = {"q": q, "limit": limit, "offset": offset}

        with self.get_client() as client:

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

    def get(self, id: int) -> Response:

        with self.get_client() as client:

            return client.get(url=self.get_url(f"{id}"))

    def update(self, id: int, name: str) -> Response:

        data = {"name": name}

        with self.get_client() as client:

            return client.patch(url=self.get_url(f"{id}"), json=data)

    def delete(self, id: int) -> Response:

        with self.get_client() as client:

            return client.delete(url=self.get_url(f"{id}"))

    def token(self, id: int, permanent: bool = False) -> Response:

        data = {"permanent": permanent}

        with self.get_client() as client:

            return client.post(url=self.get_url(f"{id}/tokens"), json=data)

class ImplAsync(IAMBaseAsync, SpacesBase):

    async def create(self, name: str) -> Response:

        data = {"name": name}

        async with self.get_client() as client:

            return await client.post(url=self.get_url(), json=data)

    async def list(

        self, q: str = None, limit: int = 20, offset: int = 0

    ) -> Response:

        data = {"q": q, "limit": limit, "offset": offset}

        async with self.get_client() as client:

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

    async def get(self, id: int) -> Response:

        async with self.get_client() as client:

            return await client.get(url=self.get_url(f"{id}"))

    async def update(self, id: int, name: str) -> Response:

        data = {"name": name}

        async with self.get_client() as client:

            return await client.patch(url=self.get_url(f"{id}"), json=data)

    async def delete(self, id: int) -> Response:

        async with self.get_client() as client:

            return await client.delete(url=self.get_url(f"{id}"))

    async def token(self, id: int, permanent: bool = False) -> Response:

        data = {"permanent": permanent}

        async with self.get_client() as client:

            return await client.post(

                url=self.get_url(f"{id}/tokens"), json=data

            )

Classes

Impl

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

    def create(self, name: str) -> Response:

        data = {"name": name}

        with self.get_client() as client:

            return client.post(url=self.get_url(), json=data)

    def list(

        self, q: str = None, limit: int = 20, offset: int = 0

    ) -> Response:

        data = {"q": q, "limit": limit, "offset": offset}

        with self.get_client() as client:

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

    def get(self, id: int) -> Response:

        with self.get_client() as client:

            return client.get(url=self.get_url(f"{id}"))

    def update(self, id: int, name: str) -> Response:

        data = {"name": name}

        with self.get_client() as client:

            return client.patch(url=self.get_url(f"{id}"), json=data)

    def delete(self, id: int) -> Response:

        with self.get_client() as client:

            return client.delete(url=self.get_url(f"{id}"))

    def token(self, id: int, permanent: bool = False) -> Response:

        data = {"permanent": permanent}

        with self.get_client() as client:

            return client.post(url=self.get_url(f"{id}/tokens"), json=data)

Ancestors (in MRO)

  • neuroio.base.IAMBase
  • abc.ABC
  • neuroio.base.Base
  • neuroio.spaces.v1.SpacesBase
  • neuroio.base.IAMBaseBase

Class variables

base_url

Methods

create

def create(
    self,
    name: str
) -> httpx.Response
View Source
    def create(self, name: str) -> Response:

        data = {"name": name}

        with self.get_client() as client:

            return client.post(url=self.get_url(), json=data)

delete

def delete(
    self,
    id: int
) -> httpx.Response
View Source
    def delete(self, id: int) -> Response:

        with self.get_client() as client:

            return client.delete(url=self.get_url(f"{id}"))

get

def get(
    self,
    id: int
) -> httpx.Response
View Source
    def get(self, id: int) -> Response:

        with self.get_client() as client:

            return client.get(url=self.get_url(f"{id}"))

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 = None
) -> str
View Source
    def get_url(self, key: str = None) -> str:

        if key:

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

        else:

            return self.base_url + "/v1/spaces/"

list

def list(
    self,
    q: str = None,
    limit: int = 20,
    offset: int = 0
) -> httpx.Response
View Source
    def list(

        self, q: str = None, limit: int = 20, offset: int = 0

    ) -> Response:

        data = {"q": q, "limit": limit, "offset": offset}

        with self.get_client() as client:

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

token

def token(
    self,
    id: int,
    permanent: bool = False
) -> httpx.Response
View Source
    def token(self, id: int, permanent: bool = False) -> Response:

        data = {"permanent": permanent}

        with self.get_client() as client:

            return client.post(url=self.get_url(f"{id}/tokens"), json=data)

update

def update(
    self,
    id: int,
    name: str
) -> httpx.Response
View Source
    def update(self, id: int, name: str) -> Response:

        data = {"name": name}

        with self.get_client() as client:

            return client.patch(url=self.get_url(f"{id}"), json=data)

ImplAsync

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

    async def create(self, name: str) -> Response:

        data = {"name": name}

        async with self.get_client() as client:

            return await client.post(url=self.get_url(), json=data)

    async def list(

        self, q: str = None, limit: int = 20, offset: int = 0

    ) -> Response:

        data = {"q": q, "limit": limit, "offset": offset}

        async with self.get_client() as client:

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

    async def get(self, id: int) -> Response:

        async with self.get_client() as client:

            return await client.get(url=self.get_url(f"{id}"))

    async def update(self, id: int, name: str) -> Response:

        data = {"name": name}

        async with self.get_client() as client:

            return await client.patch(url=self.get_url(f"{id}"), json=data)

    async def delete(self, id: int) -> Response:

        async with self.get_client() as client:

            return await client.delete(url=self.get_url(f"{id}"))

    async def token(self, id: int, permanent: bool = False) -> Response:

        data = {"permanent": permanent}

        async with self.get_client() as client:

            return await client.post(

                url=self.get_url(f"{id}/tokens"), json=data

            )

Ancestors (in MRO)

  • neuroio.base.IAMBaseAsync
  • abc.ABC
  • neuroio.base.Base
  • neuroio.spaces.v1.SpacesBase
  • neuroio.base.IAMBaseBase

Class variables

base_url

Methods

create

def create(
    self,
    name: str
) -> httpx.Response
View Source
    async def create(self, name: str) -> Response:

        data = {"name": name}

        async with self.get_client() as client:

            return await client.post(url=self.get_url(), json=data)

delete

def delete(
    self,
    id: int
) -> httpx.Response
View Source
    async def delete(self, id: int) -> Response:

        async with self.get_client() as client:

            return await client.delete(url=self.get_url(f"{id}"))

get

def get(
    self,
    id: int
) -> httpx.Response
View Source
    async def get(self, id: int) -> Response:

        async with self.get_client() as client:

            return await client.get(url=self.get_url(f"{id}"))

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 = None
) -> str
View Source
    def get_url(self, key: str = None) -> str:

        if key:

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

        else:

            return self.base_url + "/v1/spaces/"

list

def list(
    self,
    q: str = None,
    limit: int = 20,
    offset: int = 0
) -> httpx.Response
View Source
    async def list(

        self, q: str = None, limit: int = 20, offset: int = 0

    ) -> Response:

        data = {"q": q, "limit": limit, "offset": offset}

        async with self.get_client() as client:

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

token

def token(
    self,
    id: int,
    permanent: bool = False
) -> httpx.Response
View Source
    async def token(self, id: int, permanent: bool = False) -> Response:

        data = {"permanent": permanent}

        async with self.get_client() as client:

            return await client.post(

                url=self.get_url(f"{id}/tokens"), json=data

            )

update

def update(
    self,
    id: int,
    name: str
) -> httpx.Response
View Source
    async def update(self, id: int, name: str) -> Response:

        data = {"name": name}

        async with self.get_client() as client:

            return await client.patch(url=self.get_url(f"{id}"), json=data)

SpacesBase

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

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

        if key:

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

        else:

            return self.base_url + "/v1/spaces/"

Ancestors (in MRO)

  • neuroio.base.IAMBaseBase

Descendants

  • neuroio.spaces.v1.Impl
  • neuroio.spaces.v1.ImplAsync

Class variables

base_url

Methods

get_url

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

        if key:

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

        else:

            return self.base_url + "/v1/spaces/"