File: __init__.py

package info (click to toggle)
python-twilio 9.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,756 kB
  • sloc: python: 8,281; makefile: 65
file content (128 lines) | stat: -rw-r--r-- 3,916 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
r"""
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Organization Public API
    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
"""

from typing import Optional
from twilio.base.instance_context import InstanceContext

from twilio.base.list_resource import ListResource
from twilio.base.version import Version

from twilio.rest.preview_iam.versionless.organization.account import AccountList
from twilio.rest.preview_iam.versionless.organization.role_assignment import (
    RoleAssignmentList,
)
from twilio.rest.preview_iam.versionless.organization.user import UserList


class OrganizationContext(InstanceContext):

    def __init__(self, version: Version, organization_sid: str):
        """
        Initialize the OrganizationContext

        :param version: Version that contains the resource
        :param organization_sid:
        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "organization_sid": organization_sid,
        }
        self._uri = "/{organization_sid}".format(**self._solution)

        self._accounts: Optional[AccountList] = None
        self._role_assignments: Optional[RoleAssignmentList] = None
        self._users: Optional[UserList] = None

    @property
    def accounts(self) -> AccountList:
        """
        Access the accounts
        """
        if self._accounts is None:
            self._accounts = AccountList(
                self._version,
                self._solution["organization_sid"],
            )
        return self._accounts

    @property
    def role_assignments(self) -> RoleAssignmentList:
        """
        Access the role_assignments
        """
        if self._role_assignments is None:
            self._role_assignments = RoleAssignmentList(
                self._version,
                self._solution["organization_sid"],
            )
        return self._role_assignments

    @property
    def users(self) -> UserList:
        """
        Access the users
        """
        if self._users is None:
            self._users = UserList(
                self._version,
                self._solution["organization_sid"],
            )
        return self._users

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.PreviewIam.Versionless.OrganizationContext {}>".format(context)


class OrganizationList(ListResource):

    def __init__(self, version: Version):
        """
        Initialize the OrganizationList

        :param version: Version that contains the resource

        """
        super().__init__(version)

    def get(self, organization_sid: str) -> OrganizationContext:
        """
        Constructs a OrganizationContext

        :param organization_sid:
        """
        return OrganizationContext(self._version, organization_sid=organization_sid)

    def __call__(self, organization_sid: str) -> OrganizationContext:
        """
        Constructs a OrganizationContext

        :param organization_sid:
        """
        return OrganizationContext(self._version, organization_sid=organization_sid)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        return "<Twilio.PreviewIam.Versionless.OrganizationList>"