|
| 1 | +r""" |
| 2 | + This code was generated by |
| 3 | + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | +
|
| 7 | + Twilio - Api |
| 8 | + This is the public Twilio REST API. |
| 9 | +
|
| 10 | + NOTE: This class is auto generated by OpenAPI Generator. |
| 11 | + https://openapi-generator.tech |
| 12 | + Do not edit the class manually. |
| 13 | +""" |
| 14 | + |
| 15 | +from typing import Any, Dict, Optional |
| 16 | +from twilio.base.instance_context import InstanceContext |
| 17 | +from twilio.base.instance_resource import InstanceResource |
| 18 | +from twilio.base.list_resource import ListResource |
| 19 | +from twilio.base.version import Version |
| 20 | + |
| 21 | + |
| 22 | +class DataInstance(InstanceResource): |
| 23 | + """ |
| 24 | + :ivar redirect_to: The URL to redirect to to get the data returned by the AddOn that was previously stored. |
| 25 | + """ |
| 26 | + |
| 27 | + def __init__( |
| 28 | + self, |
| 29 | + version: Version, |
| 30 | + payload: Dict[str, Any], |
| 31 | + account_sid: str, |
| 32 | + reference_sid: str, |
| 33 | + add_on_result_sid: str, |
| 34 | + payload_sid: str, |
| 35 | + ): |
| 36 | + super().__init__(version) |
| 37 | + |
| 38 | + self.redirect_to: Optional[str] = payload.get("redirect_to") |
| 39 | + |
| 40 | + self._solution = { |
| 41 | + "account_sid": account_sid, |
| 42 | + "reference_sid": reference_sid, |
| 43 | + "add_on_result_sid": add_on_result_sid, |
| 44 | + "payload_sid": payload_sid, |
| 45 | + } |
| 46 | + self._context: Optional[DataContext] = None |
| 47 | + |
| 48 | + @property |
| 49 | + def _proxy(self) -> "DataContext": |
| 50 | + """ |
| 51 | + Generate an instance context for the instance, the context is capable of |
| 52 | + performing various actions. All instance actions are proxied to the context |
| 53 | +
|
| 54 | + :returns: DataContext for this DataInstance |
| 55 | + """ |
| 56 | + if self._context is None: |
| 57 | + self._context = DataContext( |
| 58 | + self._version, |
| 59 | + account_sid=self._solution["account_sid"], |
| 60 | + reference_sid=self._solution["reference_sid"], |
| 61 | + add_on_result_sid=self._solution["add_on_result_sid"], |
| 62 | + payload_sid=self._solution["payload_sid"], |
| 63 | + ) |
| 64 | + return self._context |
| 65 | + |
| 66 | + def fetch(self) -> "DataInstance": |
| 67 | + """ |
| 68 | + Fetch the DataInstance |
| 69 | +
|
| 70 | +
|
| 71 | + :returns: The fetched DataInstance |
| 72 | + """ |
| 73 | + return self._proxy.fetch() |
| 74 | + |
| 75 | + async def fetch_async(self) -> "DataInstance": |
| 76 | + """ |
| 77 | + Asynchronous coroutine to fetch the DataInstance |
| 78 | +
|
| 79 | +
|
| 80 | + :returns: The fetched DataInstance |
| 81 | + """ |
| 82 | + return await self._proxy.fetch_async() |
| 83 | + |
| 84 | + def __repr__(self) -> str: |
| 85 | + """ |
| 86 | + Provide a friendly representation |
| 87 | +
|
| 88 | + :returns: Machine friendly representation |
| 89 | + """ |
| 90 | + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) |
| 91 | + return "<Twilio.Api.V2010.DataInstance {}>".format(context) |
| 92 | + |
| 93 | + |
| 94 | +class DataContext(InstanceContext): |
| 95 | + |
| 96 | + def __init__( |
| 97 | + self, |
| 98 | + version: Version, |
| 99 | + account_sid: str, |
| 100 | + reference_sid: str, |
| 101 | + add_on_result_sid: str, |
| 102 | + payload_sid: str, |
| 103 | + ): |
| 104 | + """ |
| 105 | + Initialize the DataContext |
| 106 | +
|
| 107 | + :param version: Version that contains the resource |
| 108 | + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult Payload resource to fetch. |
| 109 | + :param reference_sid: The SID of the recording to which the AddOnResult resource that contains the payload to fetch belongs. |
| 110 | + :param add_on_result_sid: The SID of the AddOnResult to which the payload to fetch belongs. |
| 111 | + :param payload_sid: The Twilio-provided string that uniquely identifies the Recording AddOnResult Payload resource to fetch. |
| 112 | + """ |
| 113 | + super().__init__(version) |
| 114 | + |
| 115 | + # Path Solution |
| 116 | + self._solution = { |
| 117 | + "account_sid": account_sid, |
| 118 | + "reference_sid": reference_sid, |
| 119 | + "add_on_result_sid": add_on_result_sid, |
| 120 | + "payload_sid": payload_sid, |
| 121 | + } |
| 122 | + self._uri = "/Accounts/{account_sid}/Recordings/{reference_sid}/AddOnResults/{add_on_result_sid}/Payloads/{payload_sid}/Data.json".format( |
| 123 | + **self._solution |
| 124 | + ) |
| 125 | + |
| 126 | + def fetch(self) -> DataInstance: |
| 127 | + """ |
| 128 | + Fetch the DataInstance |
| 129 | +
|
| 130 | +
|
| 131 | + :returns: The fetched DataInstance |
| 132 | + """ |
| 133 | + |
| 134 | + payload = self._version.fetch( |
| 135 | + method="GET", |
| 136 | + uri=self._uri, |
| 137 | + ) |
| 138 | + |
| 139 | + return DataInstance( |
| 140 | + self._version, |
| 141 | + payload, |
| 142 | + account_sid=self._solution["account_sid"], |
| 143 | + reference_sid=self._solution["reference_sid"], |
| 144 | + add_on_result_sid=self._solution["add_on_result_sid"], |
| 145 | + payload_sid=self._solution["payload_sid"], |
| 146 | + ) |
| 147 | + |
| 148 | + async def fetch_async(self) -> DataInstance: |
| 149 | + """ |
| 150 | + Asynchronous coroutine to fetch the DataInstance |
| 151 | +
|
| 152 | +
|
| 153 | + :returns: The fetched DataInstance |
| 154 | + """ |
| 155 | + |
| 156 | + payload = await self._version.fetch_async( |
| 157 | + method="GET", |
| 158 | + uri=self._uri, |
| 159 | + ) |
| 160 | + |
| 161 | + return DataInstance( |
| 162 | + self._version, |
| 163 | + payload, |
| 164 | + account_sid=self._solution["account_sid"], |
| 165 | + reference_sid=self._solution["reference_sid"], |
| 166 | + add_on_result_sid=self._solution["add_on_result_sid"], |
| 167 | + payload_sid=self._solution["payload_sid"], |
| 168 | + ) |
| 169 | + |
| 170 | + def __repr__(self) -> str: |
| 171 | + """ |
| 172 | + Provide a friendly representation |
| 173 | +
|
| 174 | + :returns: Machine friendly representation |
| 175 | + """ |
| 176 | + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) |
| 177 | + return "<Twilio.Api.V2010.DataContext {}>".format(context) |
| 178 | + |
| 179 | + |
| 180 | +class DataList(ListResource): |
| 181 | + |
| 182 | + def __init__( |
| 183 | + self, |
| 184 | + version: Version, |
| 185 | + account_sid: str, |
| 186 | + reference_sid: str, |
| 187 | + add_on_result_sid: str, |
| 188 | + payload_sid: str, |
| 189 | + ): |
| 190 | + """ |
| 191 | + Initialize the DataList |
| 192 | +
|
| 193 | + :param version: Version that contains the resource |
| 194 | + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Recording AddOnResult Payload resource to fetch. |
| 195 | + :param reference_sid: The SID of the recording to which the AddOnResult resource that contains the payload to fetch belongs. |
| 196 | + :param add_on_result_sid: The SID of the AddOnResult to which the payload to fetch belongs. |
| 197 | + :param payload_sid: The Twilio-provided string that uniquely identifies the Recording AddOnResult Payload resource to fetch. |
| 198 | +
|
| 199 | + """ |
| 200 | + super().__init__(version) |
| 201 | + |
| 202 | + # Path Solution |
| 203 | + self._solution = { |
| 204 | + "account_sid": account_sid, |
| 205 | + "reference_sid": reference_sid, |
| 206 | + "add_on_result_sid": add_on_result_sid, |
| 207 | + "payload_sid": payload_sid, |
| 208 | + } |
| 209 | + |
| 210 | + def get(self) -> DataContext: |
| 211 | + """ |
| 212 | + Constructs a DataContext |
| 213 | +
|
| 214 | + """ |
| 215 | + return DataContext( |
| 216 | + self._version, |
| 217 | + account_sid=self._solution["account_sid"], |
| 218 | + reference_sid=self._solution["reference_sid"], |
| 219 | + add_on_result_sid=self._solution["add_on_result_sid"], |
| 220 | + payload_sid=self._solution["payload_sid"], |
| 221 | + ) |
| 222 | + |
| 223 | + def __call__(self) -> DataContext: |
| 224 | + """ |
| 225 | + Constructs a DataContext |
| 226 | +
|
| 227 | + """ |
| 228 | + return DataContext( |
| 229 | + self._version, |
| 230 | + account_sid=self._solution["account_sid"], |
| 231 | + reference_sid=self._solution["reference_sid"], |
| 232 | + add_on_result_sid=self._solution["add_on_result_sid"], |
| 233 | + payload_sid=self._solution["payload_sid"], |
| 234 | + ) |
| 235 | + |
| 236 | + def __repr__(self) -> str: |
| 237 | + """ |
| 238 | + Provide a friendly representation |
| 239 | +
|
| 240 | + :returns: Machine friendly representation |
| 241 | + """ |
| 242 | + return "<Twilio.Api.V2010.DataList>" |
0 commit comments