Module slack_sdk.scim.v1.response

Expand source code
import json
from typing import Dict, Any, List, Optional

from slack_sdk.scim.v1.group import Group
from slack_sdk.scim.v1.internal_utils import _to_snake_cased
from slack_sdk.scim.v1.user import User


class Errors:
    code: int
    description: str

    def __init__(self, code: int, description: str) -> None:
        self.code = code
        self.description = description

    def to_dict(self) -> dict:
        return {"code": self.code, "description": self.description}


class SCIMResponse:
    url: str
    status_code: int
    headers: Dict[str, Any]
    raw_body: Optional[str]
    body: Optional[Dict[str, Any]]
    snake_cased_body: Optional[Dict[str, Any]]

    errors: Optional[Errors]

    @property
    def snake_cased_body(self) -> Optional[Dict[str, Any]]:  # type: ignore
        if self._snake_cased_body is None:
            self._snake_cased_body = _to_snake_cased(self.body)
        return self._snake_cased_body

    @property
    def errors(self) -> Optional[Errors]:  # type: ignore
        errors = self.snake_cased_body.get("errors")
        if errors is None:
            return None
        return Errors(**errors)

    def __init__(
        self,
        *,
        url: str,
        status_code: int,
        raw_body: Optional[str],
        headers: dict,
    ):
        self.url = url
        self.status_code = status_code
        self.headers = headers
        self.raw_body = raw_body
        self.body = json.loads(raw_body) if raw_body is not None and raw_body.startswith("{") else None
        self._snake_cased_body = None  # build this when it's accessed for the first time

    def __repr__(self):
        dict_value = {}
        for key, value in vars(self).items():
            dict_value[key] = value.to_dict() if hasattr(value, "to_dict") else value

        if dict_value:  # skipcq: PYL-R1705
            return f"<slack_sdk.scim.v1.{self.__class__.__name__}: {dict_value}>"
        else:
            return self.__str__()


# ---------------------------------
# Users
# ---------------------------------


class SearchUsersResponse(SCIMResponse):
    users: List[User]

    @property
    def users(self) -> List[User]:  # type: ignore
        return [User(**r) for r in self.snake_cased_body.get("resources")]

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class ReadUserResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class UserCreateResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class UserPatchResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class UserUpdateResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class UserDeleteResponse(SCIMResponse):
    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


# ---------------------------------
# Groups
# ---------------------------------


class SearchGroupsResponse(SCIMResponse):
    groups: List[Group]

    @property
    def groups(self) -> List[Group]:  # type: ignore
        return [Group(**r) for r in self.snake_cased_body.get("resources")]

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class ReadGroupResponse(SCIMResponse):
    group: Group

    @property
    def group(self) -> Group:  # type: ignore
        return Group(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class GroupCreateResponse(SCIMResponse):
    group: Group

    @property
    def group(self) -> Group:  # type: ignore
        return Group(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class GroupPatchResponse(SCIMResponse):
    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class GroupUpdateResponse(SCIMResponse):
    group: Group

    @property
    def group(self) -> Group:  # type: ignore
        return Group(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None


class GroupDeleteResponse(SCIMResponse):
    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Classes

class Errors (code: int, description: str)
Expand source code
class Errors:
    code: int
    description: str

    def __init__(self, code: int, description: str) -> None:
        self.code = code
        self.description = description

    def to_dict(self) -> dict:
        return {"code": self.code, "description": self.description}

Class variables

var code : int
var description : str

Methods

def to_dict(self) ‑> dict
Expand source code
def to_dict(self) -> dict:
    return {"code": self.code, "description": self.description}
class GroupCreateResponse (underlying: SCIMResponse)
Expand source code
class GroupCreateResponse(SCIMResponse):
    group: Group

    @property
    def group(self) -> Group:  # type: ignore
        return Group(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var groupGroup
Expand source code
@property
def group(self) -> Group:  # type: ignore
    return Group(**self.snake_cased_body)
class GroupDeleteResponse (underlying: SCIMResponse)
Expand source code
class GroupDeleteResponse(SCIMResponse):
    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Class variables

var body : Optional[Dict[str, Any]]
var headers : Dict[str, Any]
var raw_body : Optional[str]
var status_code : int
var url : str

Instance variables

var errors : Optional[Errors]
Expand source code
@property
def errors(self) -> Optional[Errors]:  # type: ignore
    errors = self.snake_cased_body.get("errors")
    if errors is None:
        return None
    return Errors(**errors)
var snake_cased_body : Optional[Dict[str, Any]]
Expand source code
@property
def snake_cased_body(self) -> Optional[Dict[str, Any]]:  # type: ignore
    if self._snake_cased_body is None:
        self._snake_cased_body = _to_snake_cased(self.body)
    return self._snake_cased_body
class GroupPatchResponse (underlying: SCIMResponse)
Expand source code
class GroupPatchResponse(SCIMResponse):
    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Class variables

var body : Optional[Dict[str, Any]]
var headers : Dict[str, Any]
var raw_body : Optional[str]
var status_code : int
var url : str

Instance variables

var errors : Optional[Errors]
Expand source code
@property
def errors(self) -> Optional[Errors]:  # type: ignore
    errors = self.snake_cased_body.get("errors")
    if errors is None:
        return None
    return Errors(**errors)
var snake_cased_body : Optional[Dict[str, Any]]
Expand source code
@property
def snake_cased_body(self) -> Optional[Dict[str, Any]]:  # type: ignore
    if self._snake_cased_body is None:
        self._snake_cased_body = _to_snake_cased(self.body)
    return self._snake_cased_body
class GroupUpdateResponse (underlying: SCIMResponse)
Expand source code
class GroupUpdateResponse(SCIMResponse):
    group: Group

    @property
    def group(self) -> Group:  # type: ignore
        return Group(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var groupGroup
Expand source code
@property
def group(self) -> Group:  # type: ignore
    return Group(**self.snake_cased_body)
class ReadGroupResponse (underlying: SCIMResponse)
Expand source code
class ReadGroupResponse(SCIMResponse):
    group: Group

    @property
    def group(self) -> Group:  # type: ignore
        return Group(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var groupGroup
Expand source code
@property
def group(self) -> Group:  # type: ignore
    return Group(**self.snake_cased_body)
class ReadUserResponse (underlying: SCIMResponse)
Expand source code
class ReadUserResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var userUser
Expand source code
@property
def user(self) -> User:  # type: ignore
    return User(**self.snake_cased_body)
class SCIMResponse (*, url: str, status_code: int, raw_body: Optional[str], headers: dict)
Expand source code
class SCIMResponse:
    url: str
    status_code: int
    headers: Dict[str, Any]
    raw_body: Optional[str]
    body: Optional[Dict[str, Any]]
    snake_cased_body: Optional[Dict[str, Any]]

    errors: Optional[Errors]

    @property
    def snake_cased_body(self) -> Optional[Dict[str, Any]]:  # type: ignore
        if self._snake_cased_body is None:
            self._snake_cased_body = _to_snake_cased(self.body)
        return self._snake_cased_body

    @property
    def errors(self) -> Optional[Errors]:  # type: ignore
        errors = self.snake_cased_body.get("errors")
        if errors is None:
            return None
        return Errors(**errors)

    def __init__(
        self,
        *,
        url: str,
        status_code: int,
        raw_body: Optional[str],
        headers: dict,
    ):
        self.url = url
        self.status_code = status_code
        self.headers = headers
        self.raw_body = raw_body
        self.body = json.loads(raw_body) if raw_body is not None and raw_body.startswith("{") else None
        self._snake_cased_body = None  # build this when it's accessed for the first time

    def __repr__(self):
        dict_value = {}
        for key, value in vars(self).items():
            dict_value[key] = value.to_dict() if hasattr(value, "to_dict") else value

        if dict_value:  # skipcq: PYL-R1705
            return f"<slack_sdk.scim.v1.{self.__class__.__name__}: {dict_value}>"
        else:
            return self.__str__()

Subclasses

Class variables

var body : Optional[Dict[str, Any]]
var headers : Dict[str, Any]
var raw_body : Optional[str]
var status_code : int
var url : str

Instance variables

var errors : Optional[Errors]
Expand source code
@property
def errors(self) -> Optional[Errors]:  # type: ignore
    errors = self.snake_cased_body.get("errors")
    if errors is None:
        return None
    return Errors(**errors)
var snake_cased_body : Optional[Dict[str, Any]]
Expand source code
@property
def snake_cased_body(self) -> Optional[Dict[str, Any]]:  # type: ignore
    if self._snake_cased_body is None:
        self._snake_cased_body = _to_snake_cased(self.body)
    return self._snake_cased_body
class SearchGroupsResponse (underlying: SCIMResponse)
Expand source code
class SearchGroupsResponse(SCIMResponse):
    groups: List[Group]

    @property
    def groups(self) -> List[Group]:  # type: ignore
        return [Group(**r) for r in self.snake_cased_body.get("resources")]

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var groups : List[Group]
Expand source code
@property
def groups(self) -> List[Group]:  # type: ignore
    return [Group(**r) for r in self.snake_cased_body.get("resources")]
class SearchUsersResponse (underlying: SCIMResponse)
Expand source code
class SearchUsersResponse(SCIMResponse):
    users: List[User]

    @property
    def users(self) -> List[User]:  # type: ignore
        return [User(**r) for r in self.snake_cased_body.get("resources")]

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var users : List[User]
Expand source code
@property
def users(self) -> List[User]:  # type: ignore
    return [User(**r) for r in self.snake_cased_body.get("resources")]
class UserCreateResponse (underlying: SCIMResponse)
Expand source code
class UserCreateResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var userUser
Expand source code
@property
def user(self) -> User:  # type: ignore
    return User(**self.snake_cased_body)
class UserDeleteResponse (underlying: SCIMResponse)
Expand source code
class UserDeleteResponse(SCIMResponse):
    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Class variables

var body : Optional[Dict[str, Any]]
var headers : Dict[str, Any]
var raw_body : Optional[str]
var status_code : int
var url : str

Instance variables

var errors : Optional[Errors]
Expand source code
@property
def errors(self) -> Optional[Errors]:  # type: ignore
    errors = self.snake_cased_body.get("errors")
    if errors is None:
        return None
    return Errors(**errors)
var snake_cased_body : Optional[Dict[str, Any]]
Expand source code
@property
def snake_cased_body(self) -> Optional[Dict[str, Any]]:  # type: ignore
    if self._snake_cased_body is None:
        self._snake_cased_body = _to_snake_cased(self.body)
    return self._snake_cased_body
class UserPatchResponse (underlying: SCIMResponse)
Expand source code
class UserPatchResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var userUser
Expand source code
@property
def user(self) -> User:  # type: ignore
    return User(**self.snake_cased_body)
class UserUpdateResponse (underlying: SCIMResponse)
Expand source code
class UserUpdateResponse(SCIMResponse):
    user: User

    @property
    def user(self) -> User:  # type: ignore
        return User(**self.snake_cased_body)

    def __init__(self, underlying: SCIMResponse):
        self.underlying = underlying
        self.url = underlying.url
        self.status_code = underlying.status_code
        self.headers = underlying.headers
        self.raw_body = underlying.raw_body
        self.body = underlying.body
        self._snake_cased_body = None

Ancestors

Instance variables

var userUser
Expand source code
@property
def user(self) -> User:  # type: ignore
    return User(**self.snake_cased_body)