Initial commit: Email alerts application
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
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.domain import Domain
|
||||
from twilio.rest import Client
|
||||
from twilio.rest.verify.v2 import V2
|
||||
|
||||
|
||||
class VerifyBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Verify Domain
|
||||
|
||||
:returns: Domain for Verify
|
||||
"""
|
||||
super().__init__(twilio, "https://verify.twilio.com")
|
||||
self._v2: Optional[V2] = None
|
||||
|
||||
@property
|
||||
def v2(self) -> V2:
|
||||
"""
|
||||
:returns: Versions v2 of Verify
|
||||
"""
|
||||
if self._v2 is None:
|
||||
self._v2 = V2(self)
|
||||
return self._v2
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify>"
|
||||
@@ -0,0 +1,67 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.verify.VerifyBase import VerifyBase
|
||||
from twilio.rest.verify.v2.form import FormList
|
||||
from twilio.rest.verify.v2.safelist import SafelistList
|
||||
from twilio.rest.verify.v2.service import ServiceList
|
||||
from twilio.rest.verify.v2.template import TemplateList
|
||||
from twilio.rest.verify.v2.verification_attempt import VerificationAttemptList
|
||||
from twilio.rest.verify.v2.verification_attempts_summary import (
|
||||
VerificationAttemptsSummaryList,
|
||||
)
|
||||
|
||||
|
||||
class Verify(VerifyBase):
|
||||
@property
|
||||
def forms(self) -> FormList:
|
||||
warn(
|
||||
"forms is deprecated. Use v2.forms instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v2.forms
|
||||
|
||||
@property
|
||||
def safelist(self) -> SafelistList:
|
||||
warn(
|
||||
"safelist is deprecated. Use v2.safelist instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v2.safelist
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceList:
|
||||
warn(
|
||||
"services is deprecated. Use v2.services instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v2.services
|
||||
|
||||
@property
|
||||
def verification_attempts(self) -> VerificationAttemptList:
|
||||
warn(
|
||||
"verification_attempts is deprecated. Use v2.verification_attempts instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v2.verification_attempts
|
||||
|
||||
@property
|
||||
def verification_attempts_summary(self) -> VerificationAttemptsSummaryList:
|
||||
warn(
|
||||
"verification_attempts_summary is deprecated. Use v2.verification_attempts_summary instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v2.verification_attempts_summary
|
||||
|
||||
@property
|
||||
def templates(self) -> TemplateList:
|
||||
warn(
|
||||
"templates is deprecated. Use v2.templates instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v2.templates
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,86 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
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.version import Version
|
||||
from twilio.base.domain import Domain
|
||||
from twilio.rest.verify.v2.form import FormList
|
||||
from twilio.rest.verify.v2.safelist import SafelistList
|
||||
from twilio.rest.verify.v2.service import ServiceList
|
||||
from twilio.rest.verify.v2.template import TemplateList
|
||||
from twilio.rest.verify.v2.verification_attempt import VerificationAttemptList
|
||||
from twilio.rest.verify.v2.verification_attempts_summary import (
|
||||
VerificationAttemptsSummaryList,
|
||||
)
|
||||
|
||||
|
||||
class V2(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V2 version of Verify
|
||||
|
||||
:param domain: The Twilio.verify domain
|
||||
"""
|
||||
super().__init__(domain, "v2")
|
||||
self._forms: Optional[FormList] = None
|
||||
self._safelist: Optional[SafelistList] = None
|
||||
self._services: Optional[ServiceList] = None
|
||||
self._templates: Optional[TemplateList] = None
|
||||
self._verification_attempts: Optional[VerificationAttemptList] = None
|
||||
self._verification_attempts_summary: Optional[
|
||||
VerificationAttemptsSummaryList
|
||||
] = None
|
||||
|
||||
@property
|
||||
def forms(self) -> FormList:
|
||||
if self._forms is None:
|
||||
self._forms = FormList(self)
|
||||
return self._forms
|
||||
|
||||
@property
|
||||
def safelist(self) -> SafelistList:
|
||||
if self._safelist is None:
|
||||
self._safelist = SafelistList(self)
|
||||
return self._safelist
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceList:
|
||||
if self._services is None:
|
||||
self._services = ServiceList(self)
|
||||
return self._services
|
||||
|
||||
@property
|
||||
def templates(self) -> TemplateList:
|
||||
if self._templates is None:
|
||||
self._templates = TemplateList(self)
|
||||
return self._templates
|
||||
|
||||
@property
|
||||
def verification_attempts(self) -> VerificationAttemptList:
|
||||
if self._verification_attempts is None:
|
||||
self._verification_attempts = VerificationAttemptList(self)
|
||||
return self._verification_attempts
|
||||
|
||||
@property
|
||||
def verification_attempts_summary(self) -> VerificationAttemptsSummaryList:
|
||||
if self._verification_attempts_summary is None:
|
||||
self._verification_attempts_summary = VerificationAttemptsSummaryList(self)
|
||||
return self._verification_attempts_summary
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,191 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class FormInstance(InstanceResource):
|
||||
class FormTypes(object):
|
||||
FORM_PUSH = "form-push"
|
||||
|
||||
"""
|
||||
:ivar form_type:
|
||||
:ivar forms: Object that contains the available forms for this type. This available forms are given in the standard [JSON Schema](https://json-schema.org/) format
|
||||
:ivar form_meta: Additional information for the available forms for this type. E.g. The separator string used for `binding` in a Factor push.
|
||||
:ivar url: The URL to access the forms for this type.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
form_type: Optional[FormTypes] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.form_type: Optional["FormInstance.FormTypes"] = payload.get("form_type")
|
||||
self.forms: Optional[Dict[str, object]] = payload.get("forms")
|
||||
self.form_meta: Optional[Dict[str, object]] = payload.get("form_meta")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"form_type": form_type or self.form_type,
|
||||
}
|
||||
self._context: Optional[FormContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FormContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FormContext for this FormInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FormContext(
|
||||
self._version,
|
||||
form_type=self._solution["form_type"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "FormInstance":
|
||||
"""
|
||||
Fetch the FormInstance
|
||||
|
||||
|
||||
:returns: The fetched FormInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FormInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FormInstance
|
||||
|
||||
|
||||
:returns: The fetched FormInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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.Verify.V2.FormInstance {}>".format(context)
|
||||
|
||||
|
||||
class FormContext(InstanceContext):
|
||||
def __init__(self, version: Version, form_type: "FormInstance.FormTypes"):
|
||||
"""
|
||||
Initialize the FormContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param form_type: The Type of this Form. Currently only `form-push` is supported.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"form_type": form_type,
|
||||
}
|
||||
self._uri = "/Forms/{form_type}".format(**self._solution)
|
||||
|
||||
def fetch(self) -> FormInstance:
|
||||
"""
|
||||
Fetch the FormInstance
|
||||
|
||||
|
||||
:returns: The fetched FormInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FormInstance(
|
||||
self._version,
|
||||
payload,
|
||||
form_type=self._solution["form_type"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FormInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FormInstance
|
||||
|
||||
|
||||
:returns: The fetched FormInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FormInstance(
|
||||
self._version,
|
||||
payload,
|
||||
form_type=self._solution["form_type"],
|
||||
)
|
||||
|
||||
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.Verify.V2.FormContext {}>".format(context)
|
||||
|
||||
|
||||
class FormList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the FormList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self, form_type: "FormInstance.FormTypes") -> FormContext:
|
||||
"""
|
||||
Constructs a FormContext
|
||||
|
||||
:param form_type: The Type of this Form. Currently only `form-push` is supported.
|
||||
"""
|
||||
return FormContext(self._version, form_type=form_type)
|
||||
|
||||
def __call__(self, form_type: "FormInstance.FormTypes") -> FormContext:
|
||||
"""
|
||||
Constructs a FormContext
|
||||
|
||||
:param form_type: The Type of this Form. Currently only `form-push` is supported.
|
||||
"""
|
||||
return FormContext(self._version, form_type=form_type)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.FormList>"
|
||||
@@ -0,0 +1,276 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from twilio.base import values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class SafelistInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the SafeList resource.
|
||||
:ivar phone_number: The phone number in SafeList.
|
||||
:ivar url: The absolute URL of the SafeList resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
phone_number: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.phone_number: Optional[str] = payload.get("phone_number")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"phone_number": phone_number or self.phone_number,
|
||||
}
|
||||
self._context: Optional[SafelistContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "SafelistContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: SafelistContext for this SafelistInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = SafelistContext(
|
||||
self._version,
|
||||
phone_number=self._solution["phone_number"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SafelistInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SafelistInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "SafelistInstance":
|
||||
"""
|
||||
Fetch the SafelistInstance
|
||||
|
||||
|
||||
:returns: The fetched SafelistInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "SafelistInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SafelistInstance
|
||||
|
||||
|
||||
:returns: The fetched SafelistInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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.Verify.V2.SafelistInstance {}>".format(context)
|
||||
|
||||
|
||||
class SafelistContext(InstanceContext):
|
||||
def __init__(self, version: Version, phone_number: str):
|
||||
"""
|
||||
Initialize the SafelistContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"phone_number": phone_number,
|
||||
}
|
||||
self._uri = "/SafeList/Numbers/{phone_number}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the SafelistInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the SafelistInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> SafelistInstance:
|
||||
"""
|
||||
Fetch the SafelistInstance
|
||||
|
||||
|
||||
:returns: The fetched SafelistInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SafelistInstance(
|
||||
self._version,
|
||||
payload,
|
||||
phone_number=self._solution["phone_number"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> SafelistInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the SafelistInstance
|
||||
|
||||
|
||||
:returns: The fetched SafelistInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return SafelistInstance(
|
||||
self._version,
|
||||
payload,
|
||||
phone_number=self._solution["phone_number"],
|
||||
)
|
||||
|
||||
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.Verify.V2.SafelistContext {}>".format(context)
|
||||
|
||||
|
||||
class SafelistList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the SafelistList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/SafeList/Numbers"
|
||||
|
||||
def create(self, phone_number: str) -> SafelistInstance:
|
||||
"""
|
||||
Create the SafelistInstance
|
||||
|
||||
:param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
|
||||
:returns: The created SafelistInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SafelistInstance(self._version, payload)
|
||||
|
||||
async def create_async(self, phone_number: str) -> SafelistInstance:
|
||||
"""
|
||||
Asynchronously create the SafelistInstance
|
||||
|
||||
:param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
|
||||
:returns: The created SafelistInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PhoneNumber": phone_number,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return SafelistInstance(self._version, payload)
|
||||
|
||||
def get(self, phone_number: str) -> SafelistContext:
|
||||
"""
|
||||
Constructs a SafelistContext
|
||||
|
||||
:param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
"""
|
||||
return SafelistContext(self._version, phone_number=phone_number)
|
||||
|
||||
def __call__(self, phone_number: str) -> SafelistContext:
|
||||
"""
|
||||
Constructs a SafelistContext
|
||||
|
||||
:param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
"""
|
||||
return SafelistContext(self._version, phone_number=phone_number)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.SafelistList>"
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,301 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class AccessTokenInstance(InstanceResource):
|
||||
class FactorTypes(object):
|
||||
PUSH = "push"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Access Token.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar service_sid: The unique SID identifier of the Verify Service.
|
||||
:ivar entity_identity: The unique external identifier for the Entity of the Service.
|
||||
:ivar factor_type:
|
||||
:ivar factor_friendly_name: A human readable description of this factor, up to 64 characters. For a push factor, this can be the device's name.
|
||||
:ivar token: The access token generated for enrollment, this is an encrypted json web token.
|
||||
:ivar url: The URL of this resource.
|
||||
:ivar ttl: How long, in seconds, the access token is valid. Max: 5 minutes
|
||||
:ivar date_created: The date that this access token was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.entity_identity: Optional[str] = payload.get("entity_identity")
|
||||
self.factor_type: Optional["AccessTokenInstance.FactorTypes"] = payload.get(
|
||||
"factor_type"
|
||||
)
|
||||
self.factor_friendly_name: Optional[str] = payload.get("factor_friendly_name")
|
||||
self.token: Optional[str] = payload.get("token")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.ttl: Optional[int] = deserialize.integer(payload.get("ttl"))
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[AccessTokenContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "AccessTokenContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: AccessTokenContext for this AccessTokenInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = AccessTokenContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "AccessTokenInstance":
|
||||
"""
|
||||
Fetch the AccessTokenInstance
|
||||
|
||||
|
||||
:returns: The fetched AccessTokenInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "AccessTokenInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AccessTokenInstance
|
||||
|
||||
|
||||
:returns: The fetched AccessTokenInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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.Verify.V2.AccessTokenInstance {}>".format(context)
|
||||
|
||||
|
||||
class AccessTokenContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the AccessTokenContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param sid: A 34 character string that uniquely identifies this Access Token.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/AccessTokens/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> AccessTokenInstance:
|
||||
"""
|
||||
Fetch the AccessTokenInstance
|
||||
|
||||
|
||||
:returns: The fetched AccessTokenInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AccessTokenInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> AccessTokenInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the AccessTokenInstance
|
||||
|
||||
|
||||
:returns: The fetched AccessTokenInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return AccessTokenInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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.Verify.V2.AccessTokenContext {}>".format(context)
|
||||
|
||||
|
||||
class AccessTokenList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the AccessTokenList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/AccessTokens".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
identity: str,
|
||||
factor_type: "AccessTokenInstance.FactorTypes",
|
||||
factor_friendly_name: Union[str, object] = values.unset,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
) -> AccessTokenInstance:
|
||||
"""
|
||||
Create the AccessTokenInstance
|
||||
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID.
|
||||
:param factor_type:
|
||||
:param factor_friendly_name: The friendly name of the factor that is going to be created with this access token
|
||||
:param ttl: How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60.
|
||||
|
||||
:returns: The created AccessTokenInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"FactorType": factor_type,
|
||||
"FactorFriendlyName": factor_friendly_name,
|
||||
"Ttl": ttl,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AccessTokenInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
identity: str,
|
||||
factor_type: "AccessTokenInstance.FactorTypes",
|
||||
factor_friendly_name: Union[str, object] = values.unset,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
) -> AccessTokenInstance:
|
||||
"""
|
||||
Asynchronously create the AccessTokenInstance
|
||||
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID.
|
||||
:param factor_type:
|
||||
:param factor_friendly_name: The friendly name of the factor that is going to be created with this access token
|
||||
:param ttl: How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60.
|
||||
|
||||
:returns: The created AccessTokenInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"FactorType": factor_type,
|
||||
"FactorFriendlyName": factor_friendly_name,
|
||||
"Ttl": ttl,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return AccessTokenInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> AccessTokenContext:
|
||||
"""
|
||||
Constructs a AccessTokenContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Access Token.
|
||||
"""
|
||||
return AccessTokenContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> AccessTokenContext:
|
||||
"""
|
||||
Constructs a AccessTokenContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Access Token.
|
||||
"""
|
||||
return AccessTokenContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.AccessTokenList>"
|
||||
@@ -0,0 +1,584 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.verify.v2.service.entity.challenge import ChallengeList
|
||||
from twilio.rest.verify.v2.service.entity.factor import FactorList
|
||||
from twilio.rest.verify.v2.service.entity.new_factor import NewFactorList
|
||||
|
||||
|
||||
class EntityInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Entity.
|
||||
:ivar identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar service_sid: The unique SID identifier of the Service.
|
||||
:ivar date_created: The date that this Entity was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date that this Entity was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: The URL of this resource.
|
||||
:ivar links: Contains a dictionary of URL links to nested resources of this Entity.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
identity: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity or self.identity,
|
||||
}
|
||||
self._context: Optional[EntityContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "EntityContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: EntityContext for this EntityInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = EntityContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the EntityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the EntityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "EntityInstance":
|
||||
"""
|
||||
Fetch the EntityInstance
|
||||
|
||||
|
||||
:returns: The fetched EntityInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "EntityInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the EntityInstance
|
||||
|
||||
|
||||
:returns: The fetched EntityInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
@property
|
||||
def challenges(self) -> ChallengeList:
|
||||
"""
|
||||
Access the challenges
|
||||
"""
|
||||
return self._proxy.challenges
|
||||
|
||||
@property
|
||||
def factors(self) -> FactorList:
|
||||
"""
|
||||
Access the factors
|
||||
"""
|
||||
return self._proxy.factors
|
||||
|
||||
@property
|
||||
def new_factors(self) -> NewFactorList:
|
||||
"""
|
||||
Access the new_factors
|
||||
"""
|
||||
return self._proxy.new_factors
|
||||
|
||||
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.Verify.V2.EntityInstance {}>".format(context)
|
||||
|
||||
|
||||
class EntityContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, identity: str):
|
||||
"""
|
||||
Initialize the EntityContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities/{identity}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
self._challenges: Optional[ChallengeList] = None
|
||||
self._factors: Optional[FactorList] = None
|
||||
self._new_factors: Optional[NewFactorList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the EntityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the EntityInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> EntityInstance:
|
||||
"""
|
||||
Fetch the EntityInstance
|
||||
|
||||
|
||||
:returns: The fetched EntityInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return EntityInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> EntityInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the EntityInstance
|
||||
|
||||
|
||||
:returns: The fetched EntityInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return EntityInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
@property
|
||||
def challenges(self) -> ChallengeList:
|
||||
"""
|
||||
Access the challenges
|
||||
"""
|
||||
if self._challenges is None:
|
||||
self._challenges = ChallengeList(
|
||||
self._version,
|
||||
self._solution["service_sid"],
|
||||
self._solution["identity"],
|
||||
)
|
||||
return self._challenges
|
||||
|
||||
@property
|
||||
def factors(self) -> FactorList:
|
||||
"""
|
||||
Access the factors
|
||||
"""
|
||||
if self._factors is None:
|
||||
self._factors = FactorList(
|
||||
self._version,
|
||||
self._solution["service_sid"],
|
||||
self._solution["identity"],
|
||||
)
|
||||
return self._factors
|
||||
|
||||
@property
|
||||
def new_factors(self) -> NewFactorList:
|
||||
"""
|
||||
Access the new_factors
|
||||
"""
|
||||
if self._new_factors is None:
|
||||
self._new_factors = NewFactorList(
|
||||
self._version,
|
||||
self._solution["service_sid"],
|
||||
self._solution["identity"],
|
||||
)
|
||||
return self._new_factors
|
||||
|
||||
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.Verify.V2.EntityContext {}>".format(context)
|
||||
|
||||
|
||||
class EntityPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> EntityInstance:
|
||||
"""
|
||||
Build an instance of EntityInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return EntityInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.EntityPage>"
|
||||
|
||||
|
||||
class EntityList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the EntityList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities".format(**self._solution)
|
||||
|
||||
def create(self, identity: str) -> EntityInstance:
|
||||
"""
|
||||
Create the EntityInstance
|
||||
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
|
||||
:returns: The created EntityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return EntityInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(self, identity: str) -> EntityInstance:
|
||||
"""
|
||||
Asynchronously create the EntityInstance
|
||||
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
|
||||
:returns: The created EntityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return EntityInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[EntityInstance]:
|
||||
"""
|
||||
Streams EntityInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[EntityInstance]:
|
||||
"""
|
||||
Asynchronously streams EntityInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EntityInstance]:
|
||||
"""
|
||||
Lists EntityInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[EntityInstance]:
|
||||
"""
|
||||
Asynchronously lists EntityInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> EntityPage:
|
||||
"""
|
||||
Retrieve a single page of EntityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of EntityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return EntityPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> EntityPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of EntityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of EntityInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return EntityPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> EntityPage:
|
||||
"""
|
||||
Retrieve a specific page of EntityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EntityInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return EntityPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> EntityPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of EntityInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of EntityInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return EntityPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, identity: str) -> EntityContext:
|
||||
"""
|
||||
Constructs a EntityContext
|
||||
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
"""
|
||||
return EntityContext(
|
||||
self._version, service_sid=self._solution["service_sid"], identity=identity
|
||||
)
|
||||
|
||||
def __call__(self, identity: str) -> EntityContext:
|
||||
"""
|
||||
Constructs a EntityContext
|
||||
|
||||
:param identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
"""
|
||||
return EntityContext(
|
||||
self._version, service_sid=self._solution["service_sid"], identity=identity
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.EntityList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+777
@@ -0,0 +1,777 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.verify.v2.service.entity.challenge.notification import NotificationList
|
||||
|
||||
|
||||
class ChallengeInstance(InstanceResource):
|
||||
class ChallengeReasons(object):
|
||||
NONE = "none"
|
||||
NOT_NEEDED = "not_needed"
|
||||
NOT_REQUESTED = "not_requested"
|
||||
|
||||
class ChallengeStatuses(object):
|
||||
PENDING = "pending"
|
||||
EXPIRED = "expired"
|
||||
APPROVED = "approved"
|
||||
DENIED = "denied"
|
||||
|
||||
class FactorTypes(object):
|
||||
PUSH = "push"
|
||||
TOTP = "totp"
|
||||
|
||||
class ListOrders(object):
|
||||
ASC = "asc"
|
||||
DESC = "desc"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Challenge.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar service_sid: The unique SID identifier of the Service.
|
||||
:ivar entity_sid: The unique SID identifier of the Entity.
|
||||
:ivar identity: Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:ivar factor_sid: The unique SID identifier of the Factor.
|
||||
:ivar date_created: The date that this Challenge was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date that this Challenge was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_responded: The date that this Challenge was responded, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar expiration_date: The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation.
|
||||
:ivar status:
|
||||
:ivar responded_reason:
|
||||
:ivar details: Details provided to give context about the Challenge. Intended to be shown to the end user.
|
||||
:ivar hidden_details: Details provided to give context about the Challenge. Intended to be hidden from the end user. It must be a stringified JSON with only strings values eg. `{\"ip\": \"172.168.1.234\"}`
|
||||
:ivar metadata: Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.
|
||||
:ivar factor_type:
|
||||
:ivar url: The URL of this resource.
|
||||
:ivar links: Contains a dictionary of URL links to nested resources of this Challenge.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
identity: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.entity_sid: Optional[str] = payload.get("entity_sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.factor_sid: Optional[str] = payload.get("factor_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.date_responded: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_responded")
|
||||
)
|
||||
self.expiration_date: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("expiration_date")
|
||||
)
|
||||
self.status: Optional["ChallengeInstance.ChallengeStatuses"] = payload.get(
|
||||
"status"
|
||||
)
|
||||
self.responded_reason: Optional[
|
||||
"ChallengeInstance.ChallengeReasons"
|
||||
] = payload.get("responded_reason")
|
||||
self.details: Optional[Dict[str, object]] = payload.get("details")
|
||||
self.hidden_details: Optional[Dict[str, object]] = payload.get("hidden_details")
|
||||
self.metadata: Optional[Dict[str, object]] = payload.get("metadata")
|
||||
self.factor_type: Optional["ChallengeInstance.FactorTypes"] = payload.get(
|
||||
"factor_type"
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ChallengeContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ChallengeContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ChallengeContext for this ChallengeInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ChallengeContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "ChallengeInstance":
|
||||
"""
|
||||
Fetch the ChallengeInstance
|
||||
|
||||
|
||||
:returns: The fetched ChallengeInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ChallengeInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ChallengeInstance
|
||||
|
||||
|
||||
:returns: The fetched ChallengeInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
metadata: Union[object, object] = values.unset,
|
||||
) -> "ChallengeInstance":
|
||||
"""
|
||||
Update the ChallengeInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length
|
||||
:param metadata: Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length.
|
||||
|
||||
:returns: The updated ChallengeInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
auth_payload=auth_payload,
|
||||
metadata=metadata,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
metadata: Union[object, object] = values.unset,
|
||||
) -> "ChallengeInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ChallengeInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length
|
||||
:param metadata: Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length.
|
||||
|
||||
:returns: The updated ChallengeInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
auth_payload=auth_payload,
|
||||
metadata=metadata,
|
||||
)
|
||||
|
||||
@property
|
||||
def notifications(self) -> NotificationList:
|
||||
"""
|
||||
Access the notifications
|
||||
"""
|
||||
return self._proxy.notifications
|
||||
|
||||
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.Verify.V2.ChallengeInstance {}>".format(context)
|
||||
|
||||
|
||||
class ChallengeContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, identity: str, sid: str):
|
||||
"""
|
||||
Initialize the ChallengeContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:param sid: A 34 character string that uniquely identifies this Challenge.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Services/{service_sid}/Entities/{identity}/Challenges/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
self._notifications: Optional[NotificationList] = None
|
||||
|
||||
def fetch(self) -> ChallengeInstance:
|
||||
"""
|
||||
Fetch the ChallengeInstance
|
||||
|
||||
|
||||
:returns: The fetched ChallengeInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ChallengeInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ChallengeInstance
|
||||
|
||||
|
||||
:returns: The fetched ChallengeInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
metadata: Union[object, object] = values.unset,
|
||||
) -> ChallengeInstance:
|
||||
"""
|
||||
Update the ChallengeInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length
|
||||
:param metadata: Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length.
|
||||
|
||||
:returns: The updated ChallengeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AuthPayload": auth_payload,
|
||||
"Metadata": serialize.object(metadata),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
metadata: Union[object, object] = values.unset,
|
||||
) -> ChallengeInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ChallengeInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length
|
||||
:param metadata: Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length.
|
||||
|
||||
:returns: The updated ChallengeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AuthPayload": auth_payload,
|
||||
"Metadata": serialize.object(metadata),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def notifications(self) -> NotificationList:
|
||||
"""
|
||||
Access the notifications
|
||||
"""
|
||||
if self._notifications is None:
|
||||
self._notifications = NotificationList(
|
||||
self._version,
|
||||
self._solution["service_sid"],
|
||||
self._solution["identity"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._notifications
|
||||
|
||||
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.Verify.V2.ChallengeContext {}>".format(context)
|
||||
|
||||
|
||||
class ChallengePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ChallengeInstance:
|
||||
"""
|
||||
Build an instance of ChallengeInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.ChallengePage>"
|
||||
|
||||
|
||||
class ChallengeList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str, identity: str):
|
||||
"""
|
||||
Initialize the ChallengeList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities/{identity}/Challenges".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
factor_sid: str,
|
||||
expiration_date: Union[datetime, object] = values.unset,
|
||||
details_message: Union[str, object] = values.unset,
|
||||
details_fields: Union[List[object], object] = values.unset,
|
||||
hidden_details: Union[object, object] = values.unset,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
) -> ChallengeInstance:
|
||||
"""
|
||||
Create the ChallengeInstance
|
||||
|
||||
:param factor_sid: The unique SID identifier of the Factor.
|
||||
:param expiration_date: The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation.
|
||||
:param details_message: Shown to the user when the push notification arrives. Required when `factor_type` is `push`. Can be up to 256 characters in length
|
||||
:param details_fields: A list of objects that describe the Fields included in the Challenge. Each object contains the label and value of the field, the label can be up to 36 characters in length and the value can be up to 128 characters in length. Used when `factor_type` is `push`. There can be up to 20 details fields.
|
||||
:param hidden_details: Details provided to give context about the Challenge. Not shown to the end user. It must be a stringified JSON with only strings values eg. `{\\\"ip\\\": \\\"172.168.1.234\\\"}`. Can be up to 1024 characters in length
|
||||
:param auth_payload: Optional payload used to verify the Challenge upon creation. Only used with a Factor of type `totp` to carry the TOTP code that needs to be verified. For `TOTP` this value must be between 3 and 8 characters long.
|
||||
|
||||
:returns: The created ChallengeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FactorSid": factor_sid,
|
||||
"ExpirationDate": serialize.iso8601_datetime(expiration_date),
|
||||
"Details.Message": details_message,
|
||||
"Details.Fields": serialize.map(
|
||||
details_fields, lambda e: serialize.object(e)
|
||||
),
|
||||
"HiddenDetails": serialize.object(hidden_details),
|
||||
"AuthPayload": auth_payload,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
factor_sid: str,
|
||||
expiration_date: Union[datetime, object] = values.unset,
|
||||
details_message: Union[str, object] = values.unset,
|
||||
details_fields: Union[List[object], object] = values.unset,
|
||||
hidden_details: Union[object, object] = values.unset,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
) -> ChallengeInstance:
|
||||
"""
|
||||
Asynchronously create the ChallengeInstance
|
||||
|
||||
:param factor_sid: The unique SID identifier of the Factor.
|
||||
:param expiration_date: The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation.
|
||||
:param details_message: Shown to the user when the push notification arrives. Required when `factor_type` is `push`. Can be up to 256 characters in length
|
||||
:param details_fields: A list of objects that describe the Fields included in the Challenge. Each object contains the label and value of the field, the label can be up to 36 characters in length and the value can be up to 128 characters in length. Used when `factor_type` is `push`. There can be up to 20 details fields.
|
||||
:param hidden_details: Details provided to give context about the Challenge. Not shown to the end user. It must be a stringified JSON with only strings values eg. `{\\\"ip\\\": \\\"172.168.1.234\\\"}`. Can be up to 1024 characters in length
|
||||
:param auth_payload: Optional payload used to verify the Challenge upon creation. Only used with a Factor of type `totp` to carry the TOTP code that needs to be verified. For `TOTP` this value must be between 3 and 8 characters long.
|
||||
|
||||
:returns: The created ChallengeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FactorSid": factor_sid,
|
||||
"ExpirationDate": serialize.iso8601_datetime(expiration_date),
|
||||
"Details.Message": details_message,
|
||||
"Details.Fields": serialize.map(
|
||||
details_fields, lambda e: serialize.object(e)
|
||||
),
|
||||
"HiddenDetails": serialize.object(hidden_details),
|
||||
"AuthPayload": auth_payload,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ChallengeInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
factor_sid: Union[str, object] = values.unset,
|
||||
status: Union["ChallengeInstance.ChallengeStatuses", object] = values.unset,
|
||||
order: Union["ChallengeInstance.ListOrders", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ChallengeInstance]:
|
||||
"""
|
||||
Streams ChallengeInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str factor_sid: The unique SID identifier of the Factor.
|
||||
:param "ChallengeInstance.ChallengeStatuses" status: The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.
|
||||
:param "ChallengeInstance.ListOrders" order: The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
factor_sid=factor_sid,
|
||||
status=status,
|
||||
order=order,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
factor_sid: Union[str, object] = values.unset,
|
||||
status: Union["ChallengeInstance.ChallengeStatuses", object] = values.unset,
|
||||
order: Union["ChallengeInstance.ListOrders", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[ChallengeInstance]:
|
||||
"""
|
||||
Asynchronously streams ChallengeInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str factor_sid: The unique SID identifier of the Factor.
|
||||
:param "ChallengeInstance.ChallengeStatuses" status: The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.
|
||||
:param "ChallengeInstance.ListOrders" order: The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
factor_sid=factor_sid,
|
||||
status=status,
|
||||
order=order,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
factor_sid: Union[str, object] = values.unset,
|
||||
status: Union["ChallengeInstance.ChallengeStatuses", object] = values.unset,
|
||||
order: Union["ChallengeInstance.ListOrders", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ChallengeInstance]:
|
||||
"""
|
||||
Lists ChallengeInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str factor_sid: The unique SID identifier of the Factor.
|
||||
:param "ChallengeInstance.ChallengeStatuses" status: The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.
|
||||
:param "ChallengeInstance.ListOrders" order: The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
factor_sid=factor_sid,
|
||||
status=status,
|
||||
order=order,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
factor_sid: Union[str, object] = values.unset,
|
||||
status: Union["ChallengeInstance.ChallengeStatuses", object] = values.unset,
|
||||
order: Union["ChallengeInstance.ListOrders", object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[ChallengeInstance]:
|
||||
"""
|
||||
Asynchronously lists ChallengeInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str factor_sid: The unique SID identifier of the Factor.
|
||||
:param "ChallengeInstance.ChallengeStatuses" status: The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.
|
||||
:param "ChallengeInstance.ListOrders" order: The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
factor_sid=factor_sid,
|
||||
status=status,
|
||||
order=order,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
factor_sid: Union[str, object] = values.unset,
|
||||
status: Union["ChallengeInstance.ChallengeStatuses", object] = values.unset,
|
||||
order: Union["ChallengeInstance.ListOrders", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ChallengePage:
|
||||
"""
|
||||
Retrieve a single page of ChallengeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param factor_sid: The unique SID identifier of the Factor.
|
||||
:param status: The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.
|
||||
:param order: The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ChallengeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FactorSid": factor_sid,
|
||||
"Status": status,
|
||||
"Order": order,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return ChallengePage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
factor_sid: Union[str, object] = values.unset,
|
||||
status: Union["ChallengeInstance.ChallengeStatuses", object] = values.unset,
|
||||
order: Union["ChallengeInstance.ListOrders", object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> ChallengePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ChallengeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param factor_sid: The unique SID identifier of the Factor.
|
||||
:param status: The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.
|
||||
:param order: The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of ChallengeInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FactorSid": factor_sid,
|
||||
"Status": status,
|
||||
"Order": order,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return ChallengePage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> ChallengePage:
|
||||
"""
|
||||
Retrieve a specific page of ChallengeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ChallengeInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ChallengePage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ChallengePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ChallengeInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ChallengeInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ChallengePage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> ChallengeContext:
|
||||
"""
|
||||
Constructs a ChallengeContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Challenge.
|
||||
"""
|
||||
return ChallengeContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> ChallengeContext:
|
||||
"""
|
||||
Constructs a ChallengeContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Challenge.
|
||||
"""
|
||||
return ChallengeContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.ChallengeList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+166
@@ -0,0 +1,166 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class NotificationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Notification.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar service_sid: The unique SID identifier of the Service.
|
||||
:ivar entity_sid: The unique SID identifier of the Entity.
|
||||
:ivar identity: Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:ivar challenge_sid: The unique SID identifier of the Challenge.
|
||||
:ivar priority: The priority of the notification. For `push` Challenges it's always `high` which sends the notification immediately, and can wake up a sleeping device.
|
||||
:ivar ttl: How long, in seconds, the notification is valid. Max: 5 minutes
|
||||
:ivar date_created: The date that this Notification was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
identity: str,
|
||||
challenge_sid: str,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.entity_sid: Optional[str] = payload.get("entity_sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.challenge_sid: Optional[str] = payload.get("challenge_sid")
|
||||
self.priority: Optional[str] = payload.get("priority")
|
||||
self.ttl: Optional[int] = deserialize.integer(payload.get("ttl"))
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
"challenge_sid": challenge_sid,
|
||||
}
|
||||
|
||||
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.Verify.V2.NotificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class NotificationList(ListResource):
|
||||
def __init__(
|
||||
self, version: Version, service_sid: str, identity: str, challenge_sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the NotificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:param challenge_sid: The unique SID identifier of the Challenge.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
"challenge_sid": challenge_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities/{identity}/Challenges/{challenge_sid}/Notifications".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(self, ttl: Union[int, object] = values.unset) -> NotificationInstance:
|
||||
"""
|
||||
Create the NotificationInstance
|
||||
|
||||
:param ttl: How long, in seconds, the notification is valid. Can be an integer between 0 and 300. Default is 300. Delivery is attempted until the TTL elapses, even if the device is offline. 0 means that the notification delivery is attempted immediately, only once, and is not stored for future delivery.
|
||||
|
||||
:returns: The created NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Ttl": ttl,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
challenge_sid=self._solution["challenge_sid"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, ttl: Union[int, object] = values.unset
|
||||
) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronously create the NotificationInstance
|
||||
|
||||
:param ttl: How long, in seconds, the notification is valid. Can be an integer between 0 and 300. Default is 300. Delivery is attempted until the TTL elapses, even if the device is offline. 0 means that the notification delivery is attempted immediately, only once, and is not stored for future delivery.
|
||||
|
||||
:returns: The created NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Ttl": ttl,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
challenge_sid=self._solution["challenge_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.NotificationList>"
|
||||
@@ -0,0 +1,701 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class FactorInstance(InstanceResource):
|
||||
class FactorStatuses(object):
|
||||
UNVERIFIED = "unverified"
|
||||
VERIFIED = "verified"
|
||||
|
||||
class FactorTypes(object):
|
||||
PUSH = "push"
|
||||
TOTP = "totp"
|
||||
|
||||
class TotpAlgorithms(object):
|
||||
SHA1 = "sha1"
|
||||
SHA256 = "sha256"
|
||||
SHA512 = "sha512"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Factor.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar service_sid: The unique SID identifier of the Service.
|
||||
:ivar entity_sid: The unique SID identifier of the Entity.
|
||||
:ivar identity: Customer unique identity for the Entity owner of the Factor. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:ivar date_created: The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar friendly_name: A human readable description of this resource, up to 64 characters. For a push factor, this can be the device's name.
|
||||
:ivar status:
|
||||
:ivar factor_type:
|
||||
:ivar config: An object that contains configurations specific to a `factor_type`.
|
||||
:ivar metadata: Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.
|
||||
:ivar url: The URL of this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
identity: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.entity_sid: Optional[str] = payload.get("entity_sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.status: Optional["FactorInstance.FactorStatuses"] = payload.get("status")
|
||||
self.factor_type: Optional["FactorInstance.FactorTypes"] = payload.get(
|
||||
"factor_type"
|
||||
)
|
||||
self.config: Optional[Dict[str, object]] = payload.get("config")
|
||||
self.metadata: Optional[Dict[str, object]] = payload.get("metadata")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[FactorContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "FactorContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: FactorContext for this FactorInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = FactorContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FactorInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FactorInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "FactorInstance":
|
||||
"""
|
||||
Fetch the FactorInstance
|
||||
|
||||
|
||||
:returns: The fetched FactorInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "FactorInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FactorInstance
|
||||
|
||||
|
||||
:returns: The fetched FactorInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
config_notification_token: Union[str, object] = values.unset,
|
||||
config_sdk_version: Union[str, object] = values.unset,
|
||||
config_time_step: Union[int, object] = values.unset,
|
||||
config_skew: Union[int, object] = values.unset,
|
||||
config_code_length: Union[int, object] = values.unset,
|
||||
config_alg: Union["FactorInstance.TotpAlgorithms", object] = values.unset,
|
||||
config_notification_platform: Union[str, object] = values.unset,
|
||||
) -> "FactorInstance":
|
||||
"""
|
||||
Update the FactorInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code.
|
||||
:param friendly_name: The new friendly name of this Factor. It can be up to 64 characters.
|
||||
:param config_notification_token: For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long.
|
||||
:param config_sdk_version: The Verify Push SDK version used to configure the factor
|
||||
:param config_time_step: Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive
|
||||
:param config_skew: The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive
|
||||
:param config_code_length: Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive
|
||||
:param config_alg:
|
||||
:param config_notification_platform: The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`. Required when `factor_type` is `push`.
|
||||
|
||||
:returns: The updated FactorInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
auth_payload=auth_payload,
|
||||
friendly_name=friendly_name,
|
||||
config_notification_token=config_notification_token,
|
||||
config_sdk_version=config_sdk_version,
|
||||
config_time_step=config_time_step,
|
||||
config_skew=config_skew,
|
||||
config_code_length=config_code_length,
|
||||
config_alg=config_alg,
|
||||
config_notification_platform=config_notification_platform,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
config_notification_token: Union[str, object] = values.unset,
|
||||
config_sdk_version: Union[str, object] = values.unset,
|
||||
config_time_step: Union[int, object] = values.unset,
|
||||
config_skew: Union[int, object] = values.unset,
|
||||
config_code_length: Union[int, object] = values.unset,
|
||||
config_alg: Union["FactorInstance.TotpAlgorithms", object] = values.unset,
|
||||
config_notification_platform: Union[str, object] = values.unset,
|
||||
) -> "FactorInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the FactorInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code.
|
||||
:param friendly_name: The new friendly name of this Factor. It can be up to 64 characters.
|
||||
:param config_notification_token: For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long.
|
||||
:param config_sdk_version: The Verify Push SDK version used to configure the factor
|
||||
:param config_time_step: Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive
|
||||
:param config_skew: The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive
|
||||
:param config_code_length: Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive
|
||||
:param config_alg:
|
||||
:param config_notification_platform: The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`. Required when `factor_type` is `push`.
|
||||
|
||||
:returns: The updated FactorInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
auth_payload=auth_payload,
|
||||
friendly_name=friendly_name,
|
||||
config_notification_token=config_notification_token,
|
||||
config_sdk_version=config_sdk_version,
|
||||
config_time_step=config_time_step,
|
||||
config_skew=config_skew,
|
||||
config_code_length=config_code_length,
|
||||
config_alg=config_alg,
|
||||
config_notification_platform=config_notification_platform,
|
||||
)
|
||||
|
||||
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.Verify.V2.FactorInstance {}>".format(context)
|
||||
|
||||
|
||||
class FactorContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, identity: str, sid: str):
|
||||
"""
|
||||
Initialize the FactorContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: Customer unique identity for the Entity owner of the Factor. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:param sid: A 34 character string that uniquely identifies this Factor.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities/{identity}/Factors/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the FactorInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the FactorInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> FactorInstance:
|
||||
"""
|
||||
Fetch the FactorInstance
|
||||
|
||||
|
||||
:returns: The fetched FactorInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> FactorInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the FactorInstance
|
||||
|
||||
|
||||
:returns: The fetched FactorInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return FactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
config_notification_token: Union[str, object] = values.unset,
|
||||
config_sdk_version: Union[str, object] = values.unset,
|
||||
config_time_step: Union[int, object] = values.unset,
|
||||
config_skew: Union[int, object] = values.unset,
|
||||
config_code_length: Union[int, object] = values.unset,
|
||||
config_alg: Union["FactorInstance.TotpAlgorithms", object] = values.unset,
|
||||
config_notification_platform: Union[str, object] = values.unset,
|
||||
) -> FactorInstance:
|
||||
"""
|
||||
Update the FactorInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code.
|
||||
:param friendly_name: The new friendly name of this Factor. It can be up to 64 characters.
|
||||
:param config_notification_token: For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long.
|
||||
:param config_sdk_version: The Verify Push SDK version used to configure the factor
|
||||
:param config_time_step: Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive
|
||||
:param config_skew: The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive
|
||||
:param config_code_length: Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive
|
||||
:param config_alg:
|
||||
:param config_notification_platform: The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`. Required when `factor_type` is `push`.
|
||||
|
||||
:returns: The updated FactorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AuthPayload": auth_payload,
|
||||
"FriendlyName": friendly_name,
|
||||
"Config.NotificationToken": config_notification_token,
|
||||
"Config.SdkVersion": config_sdk_version,
|
||||
"Config.TimeStep": config_time_step,
|
||||
"Config.Skew": config_skew,
|
||||
"Config.CodeLength": config_code_length,
|
||||
"Config.Alg": config_alg,
|
||||
"Config.NotificationPlatform": config_notification_platform,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
auth_payload: Union[str, object] = values.unset,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
config_notification_token: Union[str, object] = values.unset,
|
||||
config_sdk_version: Union[str, object] = values.unset,
|
||||
config_time_step: Union[int, object] = values.unset,
|
||||
config_skew: Union[int, object] = values.unset,
|
||||
config_code_length: Union[int, object] = values.unset,
|
||||
config_alg: Union["FactorInstance.TotpAlgorithms", object] = values.unset,
|
||||
config_notification_platform: Union[str, object] = values.unset,
|
||||
) -> FactorInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the FactorInstance
|
||||
|
||||
:param auth_payload: The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code.
|
||||
:param friendly_name: The new friendly name of this Factor. It can be up to 64 characters.
|
||||
:param config_notification_token: For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long.
|
||||
:param config_sdk_version: The Verify Push SDK version used to configure the factor
|
||||
:param config_time_step: Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive
|
||||
:param config_skew: The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive
|
||||
:param config_code_length: Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive
|
||||
:param config_alg:
|
||||
:param config_notification_platform: The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`. Required when `factor_type` is `push`.
|
||||
|
||||
:returns: The updated FactorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"AuthPayload": auth_payload,
|
||||
"FriendlyName": friendly_name,
|
||||
"Config.NotificationToken": config_notification_token,
|
||||
"Config.SdkVersion": config_sdk_version,
|
||||
"Config.TimeStep": config_time_step,
|
||||
"Config.Skew": config_skew,
|
||||
"Config.CodeLength": config_code_length,
|
||||
"Config.Alg": config_alg,
|
||||
"Config.NotificationPlatform": config_notification_platform,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return FactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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.Verify.V2.FactorContext {}>".format(context)
|
||||
|
||||
|
||||
class FactorPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> FactorInstance:
|
||||
"""
|
||||
Build an instance of FactorInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return FactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.FactorPage>"
|
||||
|
||||
|
||||
class FactorList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str, identity: str):
|
||||
"""
|
||||
Initialize the FactorList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: Customer unique identity for the Entity owner of the Factors. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities/{identity}/Factors".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[FactorInstance]:
|
||||
"""
|
||||
Streams FactorInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[FactorInstance]:
|
||||
"""
|
||||
Asynchronously streams FactorInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[FactorInstance]:
|
||||
"""
|
||||
Lists FactorInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[FactorInstance]:
|
||||
"""
|
||||
Asynchronously lists FactorInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> FactorPage:
|
||||
"""
|
||||
Retrieve a single page of FactorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of FactorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return FactorPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> FactorPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of FactorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of FactorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return FactorPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> FactorPage:
|
||||
"""
|
||||
Retrieve a specific page of FactorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FactorInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return FactorPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> FactorPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of FactorInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of FactorInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return FactorPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> FactorContext:
|
||||
"""
|
||||
Constructs a FactorContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Factor.
|
||||
"""
|
||||
return FactorContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> FactorContext:
|
||||
"""
|
||||
Constructs a FactorContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Factor.
|
||||
"""
|
||||
return FactorContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.FactorList>"
|
||||
@@ -0,0 +1,273 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class NewFactorInstance(InstanceResource):
|
||||
class FactorStatuses(object):
|
||||
UNVERIFIED = "unverified"
|
||||
VERIFIED = "verified"
|
||||
|
||||
class FactorTypes(object):
|
||||
PUSH = "push"
|
||||
TOTP = "totp"
|
||||
|
||||
class NotificationPlatforms(object):
|
||||
APN = "apn"
|
||||
FCM = "fcm"
|
||||
NONE = "none"
|
||||
|
||||
class TotpAlgorithms(object):
|
||||
SHA1 = "sha1"
|
||||
SHA256 = "sha256"
|
||||
SHA512 = "sha512"
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Factor.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar service_sid: The unique SID identifier of the Service.
|
||||
:ivar entity_sid: The unique SID identifier of the Entity.
|
||||
:ivar identity: Customer unique identity for the Entity owner of the Factor. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
:ivar binding: Contains the `factor_type` specific secret and metadata. For push, this is `binding.public_key` and `binding.alg`. For totp, this is `binding.secret` and `binding.uri`. The `binding.uri` property is generated following the [google authenticator key URI format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format), and `Factor.friendly_name` is used for the “accountname” value and `Service.friendly_name` or `Service.totp.issuer` is used for the `issuer` value. The Binding property is ONLY returned upon Factor creation.
|
||||
:ivar date_created: The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar friendly_name: The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors. For `factor_type` `push`, this could be a device name. For `factor_type` `totp`, this value is used as the “account name” in constructing the `binding.uri` property. At the same time, we recommend avoiding providing PII.
|
||||
:ivar status:
|
||||
:ivar factor_type:
|
||||
:ivar config: An object that contains configurations specific to a `factor_type`.
|
||||
:ivar metadata: Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.
|
||||
:ivar url: The URL of this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], service_sid: str, identity: str
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.entity_sid: Optional[str] = payload.get("entity_sid")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.binding: Optional[Dict[str, object]] = payload.get("binding")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.status: Optional["NewFactorInstance.FactorStatuses"] = payload.get(
|
||||
"status"
|
||||
)
|
||||
self.factor_type: Optional["NewFactorInstance.FactorTypes"] = payload.get(
|
||||
"factor_type"
|
||||
)
|
||||
self.config: Optional[Dict[str, object]] = payload.get("config")
|
||||
self.metadata: Optional[Dict[str, object]] = payload.get("metadata")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
}
|
||||
|
||||
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.Verify.V2.NewFactorInstance {}>".format(context)
|
||||
|
||||
|
||||
class NewFactorList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str, identity: str):
|
||||
"""
|
||||
Initialize the NewFactorList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param identity: Customer unique identity for the Entity owner of the Factor. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"identity": identity,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Entities/{identity}/Factors".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
factor_type: "NewFactorInstance.FactorTypes",
|
||||
binding_alg: Union[str, object] = values.unset,
|
||||
binding_public_key: Union[str, object] = values.unset,
|
||||
config_app_id: Union[str, object] = values.unset,
|
||||
config_notification_platform: Union[
|
||||
"NewFactorInstance.NotificationPlatforms", object
|
||||
] = values.unset,
|
||||
config_notification_token: Union[str, object] = values.unset,
|
||||
config_sdk_version: Union[str, object] = values.unset,
|
||||
binding_secret: Union[str, object] = values.unset,
|
||||
config_time_step: Union[int, object] = values.unset,
|
||||
config_skew: Union[int, object] = values.unset,
|
||||
config_code_length: Union[int, object] = values.unset,
|
||||
config_alg: Union["NewFactorInstance.TotpAlgorithms", object] = values.unset,
|
||||
metadata: Union[object, object] = values.unset,
|
||||
) -> NewFactorInstance:
|
||||
"""
|
||||
Create the NewFactorInstance
|
||||
|
||||
:param friendly_name: The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors. For `factor_type` `push`, this could be a device name. For `factor_type` `totp`, this value is used as the “account name” in constructing the `binding.uri` property. At the same time, we recommend avoiding providing PII.
|
||||
:param factor_type:
|
||||
:param binding_alg: The algorithm used when `factor_type` is `push`. Algorithm supported: `ES256`
|
||||
:param binding_public_key: The Ecdsa public key in PKIX, ASN.1 DER format encoded in Base64. Required when `factor_type` is `push`
|
||||
:param config_app_id: The ID that uniquely identifies your app in the Google or Apple store, such as `com.example.myapp`. It can be up to 100 characters long. Required when `factor_type` is `push`.
|
||||
:param config_notification_platform:
|
||||
:param config_notification_token: For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Must be between 32 and 255 characters long. Required when `factor_type` is `push`.
|
||||
:param config_sdk_version: The Verify Push SDK version used to configure the factor Required when `factor_type` is `push`
|
||||
:param binding_secret: The shared secret for TOTP factors encoded in Base32. This can be provided when creating the Factor, otherwise it will be generated. Used when `factor_type` is `totp`
|
||||
:param config_time_step: Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. The default value is defined at the service level in the property `totp.time_step`. Defaults to 30 seconds if not configured. Used when `factor_type` is `totp`
|
||||
:param config_skew: The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. The default value is defined at the service level in the property `totp.skew`. If not configured defaults to 1. Used when `factor_type` is `totp`
|
||||
:param config_code_length: Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. The default value is defined at the service level in the property `totp.code_length`. If not configured defaults to 6. Used when `factor_type` is `totp`
|
||||
:param config_alg:
|
||||
:param metadata: Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length.
|
||||
|
||||
:returns: The created NewFactorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"FactorType": factor_type,
|
||||
"Binding.Alg": binding_alg,
|
||||
"Binding.PublicKey": binding_public_key,
|
||||
"Config.AppId": config_app_id,
|
||||
"Config.NotificationPlatform": config_notification_platform,
|
||||
"Config.NotificationToken": config_notification_token,
|
||||
"Config.SdkVersion": config_sdk_version,
|
||||
"Binding.Secret": binding_secret,
|
||||
"Config.TimeStep": config_time_step,
|
||||
"Config.Skew": config_skew,
|
||||
"Config.CodeLength": config_code_length,
|
||||
"Config.Alg": config_alg,
|
||||
"Metadata": serialize.object(metadata),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NewFactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
factor_type: "NewFactorInstance.FactorTypes",
|
||||
binding_alg: Union[str, object] = values.unset,
|
||||
binding_public_key: Union[str, object] = values.unset,
|
||||
config_app_id: Union[str, object] = values.unset,
|
||||
config_notification_platform: Union[
|
||||
"NewFactorInstance.NotificationPlatforms", object
|
||||
] = values.unset,
|
||||
config_notification_token: Union[str, object] = values.unset,
|
||||
config_sdk_version: Union[str, object] = values.unset,
|
||||
binding_secret: Union[str, object] = values.unset,
|
||||
config_time_step: Union[int, object] = values.unset,
|
||||
config_skew: Union[int, object] = values.unset,
|
||||
config_code_length: Union[int, object] = values.unset,
|
||||
config_alg: Union["NewFactorInstance.TotpAlgorithms", object] = values.unset,
|
||||
metadata: Union[object, object] = values.unset,
|
||||
) -> NewFactorInstance:
|
||||
"""
|
||||
Asynchronously create the NewFactorInstance
|
||||
|
||||
:param friendly_name: The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors. For `factor_type` `push`, this could be a device name. For `factor_type` `totp`, this value is used as the “account name” in constructing the `binding.uri` property. At the same time, we recommend avoiding providing PII.
|
||||
:param factor_type:
|
||||
:param binding_alg: The algorithm used when `factor_type` is `push`. Algorithm supported: `ES256`
|
||||
:param binding_public_key: The Ecdsa public key in PKIX, ASN.1 DER format encoded in Base64. Required when `factor_type` is `push`
|
||||
:param config_app_id: The ID that uniquely identifies your app in the Google or Apple store, such as `com.example.myapp`. It can be up to 100 characters long. Required when `factor_type` is `push`.
|
||||
:param config_notification_platform:
|
||||
:param config_notification_token: For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Must be between 32 and 255 characters long. Required when `factor_type` is `push`.
|
||||
:param config_sdk_version: The Verify Push SDK version used to configure the factor Required when `factor_type` is `push`
|
||||
:param binding_secret: The shared secret for TOTP factors encoded in Base32. This can be provided when creating the Factor, otherwise it will be generated. Used when `factor_type` is `totp`
|
||||
:param config_time_step: Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. The default value is defined at the service level in the property `totp.time_step`. Defaults to 30 seconds if not configured. Used when `factor_type` is `totp`
|
||||
:param config_skew: The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. The default value is defined at the service level in the property `totp.skew`. If not configured defaults to 1. Used when `factor_type` is `totp`
|
||||
:param config_code_length: Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. The default value is defined at the service level in the property `totp.code_length`. If not configured defaults to 6. Used when `factor_type` is `totp`
|
||||
:param config_alg:
|
||||
:param metadata: Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length.
|
||||
|
||||
:returns: The created NewFactorInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"FactorType": factor_type,
|
||||
"Binding.Alg": binding_alg,
|
||||
"Binding.PublicKey": binding_public_key,
|
||||
"Config.AppId": config_app_id,
|
||||
"Config.NotificationPlatform": config_notification_platform,
|
||||
"Config.NotificationToken": config_notification_token,
|
||||
"Config.SdkVersion": config_sdk_version,
|
||||
"Binding.Secret": binding_secret,
|
||||
"Config.TimeStep": config_time_step,
|
||||
"Config.Skew": config_skew,
|
||||
"Config.CodeLength": config_code_length,
|
||||
"Config.Alg": config_alg,
|
||||
"Metadata": serialize.object(metadata),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NewFactorInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
identity=self._solution["identity"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.NewFactorList>"
|
||||
+607
@@ -0,0 +1,607 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class MessagingConfigurationInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) that the resource is associated with.
|
||||
:ivar country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
|
||||
:ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar url: The URL of this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
country: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.country: Optional[str] = payload.get("country")
|
||||
self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"country": country or self.country,
|
||||
}
|
||||
self._context: Optional[MessagingConfigurationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "MessagingConfigurationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: MessagingConfigurationContext for this MessagingConfigurationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = MessagingConfigurationContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
country=self._solution["country"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "MessagingConfigurationInstance":
|
||||
"""
|
||||
Fetch the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched MessagingConfigurationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "MessagingConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched MessagingConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, messaging_service_sid: str) -> "MessagingConfigurationInstance":
|
||||
"""
|
||||
Update the MessagingConfigurationInstance
|
||||
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
|
||||
:returns: The updated MessagingConfigurationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
messaging_service_sid=messaging_service_sid,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, messaging_service_sid: str
|
||||
) -> "MessagingConfigurationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the MessagingConfigurationInstance
|
||||
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
|
||||
:returns: The updated MessagingConfigurationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
messaging_service_sid=messaging_service_sid,
|
||||
)
|
||||
|
||||
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.Verify.V2.MessagingConfigurationInstance {}>".format(context)
|
||||
|
||||
|
||||
class MessagingConfigurationContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, country: str):
|
||||
"""
|
||||
Initialize the MessagingConfigurationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) that the resource is associated with.
|
||||
:param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"country": country,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/MessagingConfigurations/{country}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Fetch the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched MessagingConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessagingConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
country=self._solution["country"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the MessagingConfigurationInstance
|
||||
|
||||
|
||||
:returns: The fetched MessagingConfigurationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return MessagingConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
country=self._solution["country"],
|
||||
)
|
||||
|
||||
def update(self, messaging_service_sid: str) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Update the MessagingConfigurationInstance
|
||||
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
|
||||
:returns: The updated MessagingConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessagingConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
country=self._solution["country"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, messaging_service_sid: str
|
||||
) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the MessagingConfigurationInstance
|
||||
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
|
||||
:returns: The updated MessagingConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessagingConfigurationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
country=self._solution["country"],
|
||||
)
|
||||
|
||||
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.Verify.V2.MessagingConfigurationContext {}>".format(context)
|
||||
|
||||
|
||||
class MessagingConfigurationPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Build an instance of MessagingConfigurationInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return MessagingConfigurationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.MessagingConfigurationPage>"
|
||||
|
||||
|
||||
class MessagingConfigurationList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the MessagingConfigurationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) that the resource is associated with.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/MessagingConfigurations".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def create(
|
||||
self, country: str, messaging_service_sid: str
|
||||
) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Create the MessagingConfigurationInstance
|
||||
|
||||
:param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
|
||||
:returns: The created MessagingConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Country": country,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessagingConfigurationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, country: str, messaging_service_sid: str
|
||||
) -> MessagingConfigurationInstance:
|
||||
"""
|
||||
Asynchronously create the MessagingConfigurationInstance
|
||||
|
||||
:param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
|
||||
|
||||
:returns: The created MessagingConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Country": country,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return MessagingConfigurationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[MessagingConfigurationInstance]:
|
||||
"""
|
||||
Streams MessagingConfigurationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[MessagingConfigurationInstance]:
|
||||
"""
|
||||
Asynchronously streams MessagingConfigurationInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessagingConfigurationInstance]:
|
||||
"""
|
||||
Lists MessagingConfigurationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[MessagingConfigurationInstance]:
|
||||
"""
|
||||
Asynchronously lists MessagingConfigurationInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagingConfigurationPage:
|
||||
"""
|
||||
Retrieve a single page of MessagingConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MessagingConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return MessagingConfigurationPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> MessagingConfigurationPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of MessagingConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of MessagingConfigurationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return MessagingConfigurationPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> MessagingConfigurationPage:
|
||||
"""
|
||||
Retrieve a specific page of MessagingConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessagingConfigurationInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return MessagingConfigurationPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> MessagingConfigurationPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of MessagingConfigurationInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of MessagingConfigurationInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return MessagingConfigurationPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, country: str) -> MessagingConfigurationContext:
|
||||
"""
|
||||
Constructs a MessagingConfigurationContext
|
||||
|
||||
:param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
|
||||
"""
|
||||
return MessagingConfigurationContext(
|
||||
self._version, service_sid=self._solution["service_sid"], country=country
|
||||
)
|
||||
|
||||
def __call__(self, country: str) -> MessagingConfigurationContext:
|
||||
"""
|
||||
Constructs a MessagingConfigurationContext
|
||||
|
||||
:param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
|
||||
"""
|
||||
return MessagingConfigurationContext(
|
||||
self._version, service_sid=self._solution["service_sid"], country=country
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.MessagingConfigurationList>"
|
||||
+634
@@ -0,0 +1,634 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
from twilio.rest.verify.v2.service.rate_limit.bucket import BucketList
|
||||
|
||||
|
||||
class RateLimitInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Rate Limit.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Rate Limit resource.
|
||||
:ivar unique_name: Provides a unique and addressable name to be assigned to this Rate Limit, assigned by the developer, to be optionally used in addition to SID. **This value should not contain PII.**
|
||||
:ivar description: Description of this Rate Limit
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar url: The URL of this resource.
|
||||
:ivar links: The URLs of related resources.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.unique_name: Optional[str] = payload.get("unique_name")
|
||||
self.description: Optional[str] = payload.get("description")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[RateLimitContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "RateLimitContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: RateLimitContext for this RateLimitInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = RateLimitContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RateLimitInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RateLimitInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "RateLimitInstance":
|
||||
"""
|
||||
Fetch the RateLimitInstance
|
||||
|
||||
|
||||
:returns: The fetched RateLimitInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "RateLimitInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RateLimitInstance
|
||||
|
||||
|
||||
:returns: The fetched RateLimitInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self, description: Union[str, object] = values.unset
|
||||
) -> "RateLimitInstance":
|
||||
"""
|
||||
Update the RateLimitInstance
|
||||
|
||||
:param description: Description of this Rate Limit
|
||||
|
||||
:returns: The updated RateLimitInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
description=description,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, description: Union[str, object] = values.unset
|
||||
) -> "RateLimitInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the RateLimitInstance
|
||||
|
||||
:param description: Description of this Rate Limit
|
||||
|
||||
:returns: The updated RateLimitInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
description=description,
|
||||
)
|
||||
|
||||
@property
|
||||
def buckets(self) -> BucketList:
|
||||
"""
|
||||
Access the buckets
|
||||
"""
|
||||
return self._proxy.buckets
|
||||
|
||||
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.Verify.V2.RateLimitInstance {}>".format(context)
|
||||
|
||||
|
||||
class RateLimitContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the RateLimitContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Rate Limit resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/RateLimits/{sid}".format(**self._solution)
|
||||
|
||||
self._buckets: Optional[BucketList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the RateLimitInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the RateLimitInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> RateLimitInstance:
|
||||
"""
|
||||
Fetch the RateLimitInstance
|
||||
|
||||
|
||||
:returns: The fetched RateLimitInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RateLimitInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> RateLimitInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the RateLimitInstance
|
||||
|
||||
|
||||
:returns: The fetched RateLimitInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return RateLimitInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self, description: Union[str, object] = values.unset
|
||||
) -> RateLimitInstance:
|
||||
"""
|
||||
Update the RateLimitInstance
|
||||
|
||||
:param description: Description of this Rate Limit
|
||||
|
||||
:returns: The updated RateLimitInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Description": description,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RateLimitInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, description: Union[str, object] = values.unset
|
||||
) -> RateLimitInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the RateLimitInstance
|
||||
|
||||
:param description: Description of this Rate Limit
|
||||
|
||||
:returns: The updated RateLimitInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Description": description,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RateLimitInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
@property
|
||||
def buckets(self) -> BucketList:
|
||||
"""
|
||||
Access the buckets
|
||||
"""
|
||||
if self._buckets is None:
|
||||
self._buckets = BucketList(
|
||||
self._version,
|
||||
self._solution["service_sid"],
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._buckets
|
||||
|
||||
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.Verify.V2.RateLimitContext {}>".format(context)
|
||||
|
||||
|
||||
class RateLimitPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> RateLimitInstance:
|
||||
"""
|
||||
Build an instance of RateLimitInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return RateLimitInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.RateLimitPage>"
|
||||
|
||||
|
||||
class RateLimitList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the RateLimitList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/RateLimits".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self, unique_name: str, description: Union[str, object] = values.unset
|
||||
) -> RateLimitInstance:
|
||||
"""
|
||||
Create the RateLimitInstance
|
||||
|
||||
:param unique_name: Provides a unique and addressable name to be assigned to this Rate Limit, assigned by the developer, to be optionally used in addition to SID. **This value should not contain PII.**
|
||||
:param description: Description of this Rate Limit
|
||||
|
||||
:returns: The created RateLimitInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"Description": description,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RateLimitInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self, unique_name: str, description: Union[str, object] = values.unset
|
||||
) -> RateLimitInstance:
|
||||
"""
|
||||
Asynchronously create the RateLimitInstance
|
||||
|
||||
:param unique_name: Provides a unique and addressable name to be assigned to this Rate Limit, assigned by the developer, to be optionally used in addition to SID. **This value should not contain PII.**
|
||||
:param description: Description of this Rate Limit
|
||||
|
||||
:returns: The created RateLimitInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"UniqueName": unique_name,
|
||||
"Description": description,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return RateLimitInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[RateLimitInstance]:
|
||||
"""
|
||||
Streams RateLimitInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[RateLimitInstance]:
|
||||
"""
|
||||
Asynchronously streams RateLimitInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RateLimitInstance]:
|
||||
"""
|
||||
Lists RateLimitInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[RateLimitInstance]:
|
||||
"""
|
||||
Asynchronously lists RateLimitInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RateLimitPage:
|
||||
"""
|
||||
Retrieve a single page of RateLimitInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RateLimitInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return RateLimitPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> RateLimitPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of RateLimitInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of RateLimitInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return RateLimitPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> RateLimitPage:
|
||||
"""
|
||||
Retrieve a specific page of RateLimitInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RateLimitInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return RateLimitPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> RateLimitPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of RateLimitInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of RateLimitInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return RateLimitPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> RateLimitContext:
|
||||
"""
|
||||
Constructs a RateLimitContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Rate Limit resource to fetch.
|
||||
"""
|
||||
return RateLimitContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> RateLimitContext:
|
||||
"""
|
||||
Constructs a RateLimitContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Rate Limit resource to fetch.
|
||||
"""
|
||||
return RateLimitContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.RateLimitList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,659 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class BucketInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies this Bucket.
|
||||
:ivar rate_limit_sid: The Twilio-provided string that uniquely identifies the Rate Limit resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Rate Limit resource.
|
||||
:ivar max: Maximum number of requests permitted in during the interval.
|
||||
:ivar interval: Number of seconds that the rate limit will be enforced over.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar url: The URL of this resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
rate_limit_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.rate_limit_sid: Optional[str] = payload.get("rate_limit_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.max: Optional[int] = deserialize.integer(payload.get("max"))
|
||||
self.interval: Optional[int] = deserialize.integer(payload.get("interval"))
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"rate_limit_sid": rate_limit_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[BucketContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "BucketContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: BucketContext for this BucketInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = BucketContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the BucketInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the BucketInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "BucketInstance":
|
||||
"""
|
||||
Fetch the BucketInstance
|
||||
|
||||
|
||||
:returns: The fetched BucketInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "BucketInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the BucketInstance
|
||||
|
||||
|
||||
:returns: The fetched BucketInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
max: Union[int, object] = values.unset,
|
||||
interval: Union[int, object] = values.unset,
|
||||
) -> "BucketInstance":
|
||||
"""
|
||||
Update the BucketInstance
|
||||
|
||||
:param max: Maximum number of requests permitted in during the interval.
|
||||
:param interval: Number of seconds that the rate limit will be enforced over.
|
||||
|
||||
:returns: The updated BucketInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
max=max,
|
||||
interval=interval,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
max: Union[int, object] = values.unset,
|
||||
interval: Union[int, object] = values.unset,
|
||||
) -> "BucketInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the BucketInstance
|
||||
|
||||
:param max: Maximum number of requests permitted in during the interval.
|
||||
:param interval: Number of seconds that the rate limit will be enforced over.
|
||||
|
||||
:returns: The updated BucketInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
max=max,
|
||||
interval=interval,
|
||||
)
|
||||
|
||||
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.Verify.V2.BucketInstance {}>".format(context)
|
||||
|
||||
|
||||
class BucketContext(InstanceContext):
|
||||
def __init__(
|
||||
self, version: Version, service_sid: str, rate_limit_sid: str, sid: str
|
||||
):
|
||||
"""
|
||||
Initialize the BucketContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:param rate_limit_sid: The Twilio-provided string that uniquely identifies the Rate Limit resource.
|
||||
:param sid: A 34 character string that uniquely identifies this Bucket.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"rate_limit_sid": rate_limit_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Services/{service_sid}/RateLimits/{rate_limit_sid}/Buckets/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the BucketInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the BucketInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> BucketInstance:
|
||||
"""
|
||||
Fetch the BucketInstance
|
||||
|
||||
|
||||
:returns: The fetched BucketInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> BucketInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the BucketInstance
|
||||
|
||||
|
||||
:returns: The fetched BucketInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
max: Union[int, object] = values.unset,
|
||||
interval: Union[int, object] = values.unset,
|
||||
) -> BucketInstance:
|
||||
"""
|
||||
Update the BucketInstance
|
||||
|
||||
:param max: Maximum number of requests permitted in during the interval.
|
||||
:param interval: Number of seconds that the rate limit will be enforced over.
|
||||
|
||||
:returns: The updated BucketInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Max": max,
|
||||
"Interval": interval,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
max: Union[int, object] = values.unset,
|
||||
interval: Union[int, object] = values.unset,
|
||||
) -> BucketInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the BucketInstance
|
||||
|
||||
:param max: Maximum number of requests permitted in during the interval.
|
||||
:param interval: Number of seconds that the rate limit will be enforced over.
|
||||
|
||||
:returns: The updated BucketInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Max": max,
|
||||
"Interval": interval,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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.Verify.V2.BucketContext {}>".format(context)
|
||||
|
||||
|
||||
class BucketPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> BucketInstance:
|
||||
"""
|
||||
Build an instance of BucketInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.BucketPage>"
|
||||
|
||||
|
||||
class BucketList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str, rate_limit_sid: str):
|
||||
"""
|
||||
Initialize the BucketList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:param rate_limit_sid: The Twilio-provided string that uniquely identifies the Rate Limit resource.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"rate_limit_sid": rate_limit_sid,
|
||||
}
|
||||
self._uri = (
|
||||
"/Services/{service_sid}/RateLimits/{rate_limit_sid}/Buckets".format(
|
||||
**self._solution
|
||||
)
|
||||
)
|
||||
|
||||
def create(self, max: int, interval: int) -> BucketInstance:
|
||||
"""
|
||||
Create the BucketInstance
|
||||
|
||||
:param max: Maximum number of requests permitted in during the interval.
|
||||
:param interval: Number of seconds that the rate limit will be enforced over.
|
||||
|
||||
:returns: The created BucketInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Max": max,
|
||||
"Interval": interval,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
)
|
||||
|
||||
async def create_async(self, max: int, interval: int) -> BucketInstance:
|
||||
"""
|
||||
Asynchronously create the BucketInstance
|
||||
|
||||
:param max: Maximum number of requests permitted in during the interval.
|
||||
:param interval: Number of seconds that the rate limit will be enforced over.
|
||||
|
||||
:returns: The created BucketInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Max": max,
|
||||
"Interval": interval,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BucketInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[BucketInstance]:
|
||||
"""
|
||||
Streams BucketInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[BucketInstance]:
|
||||
"""
|
||||
Asynchronously streams BucketInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[BucketInstance]:
|
||||
"""
|
||||
Lists BucketInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[BucketInstance]:
|
||||
"""
|
||||
Asynchronously lists BucketInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> BucketPage:
|
||||
"""
|
||||
Retrieve a single page of BucketInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of BucketInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return BucketPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> BucketPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of BucketInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of BucketInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return BucketPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> BucketPage:
|
||||
"""
|
||||
Retrieve a specific page of BucketInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of BucketInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return BucketPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> BucketPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of BucketInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of BucketInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return BucketPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> BucketContext:
|
||||
"""
|
||||
Constructs a BucketContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Bucket.
|
||||
"""
|
||||
return BucketContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> BucketContext:
|
||||
"""
|
||||
Constructs a BucketContext
|
||||
|
||||
:param sid: A 34 character string that uniquely identifies this Bucket.
|
||||
"""
|
||||
return BucketContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
rate_limit_sid=self._solution["rate_limit_sid"],
|
||||
sid=sid,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.BucketList>"
|
||||
@@ -0,0 +1,479 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class VerificationInstance(InstanceResource):
|
||||
class Channel(object):
|
||||
SMS = "sms"
|
||||
CALL = "call"
|
||||
EMAIL = "email"
|
||||
WHATSAPP = "whatsapp"
|
||||
SNA = "sna"
|
||||
|
||||
class RiskCheck(object):
|
||||
ENABLE = "enable"
|
||||
DISABLE = "disable"
|
||||
|
||||
class Status(object):
|
||||
CANCELED = "canceled"
|
||||
APPROVED = "approved"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Verification resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Verification resource.
|
||||
:ivar to: The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
:ivar channel:
|
||||
:ivar status: The status of the verification. One of: `pending`, `approved`, or `canceled`
|
||||
:ivar valid: Use \"status\" instead. Legacy property indicating whether the verification was successful.
|
||||
:ivar lookup: Information about the phone number being verified.
|
||||
:ivar amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:ivar payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:ivar send_code_attempts: An array of verification attempt objects containing the channel attempted and the channel-specific transaction SID.
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
|
||||
:ivar sna: The set of fields used for a silent network auth (`sna`) verification. Contains a single field with the URL to be invoked to verify the phone number.
|
||||
:ivar url: The absolute URL of the Verification resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.to: Optional[str] = payload.get("to")
|
||||
self.channel: Optional["VerificationInstance.Channel"] = payload.get("channel")
|
||||
self.status: Optional[str] = payload.get("status")
|
||||
self.valid: Optional[bool] = payload.get("valid")
|
||||
self.lookup: Optional[Dict[str, object]] = payload.get("lookup")
|
||||
self.amount: Optional[str] = payload.get("amount")
|
||||
self.payee: Optional[str] = payload.get("payee")
|
||||
self.send_code_attempts: Optional[List[object]] = payload.get(
|
||||
"send_code_attempts"
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.sna: Optional[Dict[str, object]] = payload.get("sna")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[VerificationContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "VerificationContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: VerificationContext for this VerificationInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = VerificationContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "VerificationInstance":
|
||||
"""
|
||||
Fetch the VerificationInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "VerificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the VerificationInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(self, status: "VerificationInstance.Status") -> "VerificationInstance":
|
||||
"""
|
||||
Update the VerificationInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated VerificationInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
status=status,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, status: "VerificationInstance.Status"
|
||||
) -> "VerificationInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the VerificationInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated VerificationInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
status=status,
|
||||
)
|
||||
|
||||
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.Verify.V2.VerificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class VerificationContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the VerificationContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the verification [Service](https://www.twilio.com/docs/verify/api/service) to update the resource from.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Verification resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Verifications/{sid}".format(
|
||||
**self._solution
|
||||
)
|
||||
|
||||
def fetch(self) -> VerificationInstance:
|
||||
"""
|
||||
Fetch the VerificationInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return VerificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> VerificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the VerificationInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return VerificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(self, status: "VerificationInstance.Status") -> VerificationInstance:
|
||||
"""
|
||||
Update the VerificationInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated VerificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return VerificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self, status: "VerificationInstance.Status"
|
||||
) -> VerificationInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the VerificationInstance
|
||||
|
||||
:param status:
|
||||
|
||||
:returns: The updated VerificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Status": status,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return VerificationInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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.Verify.V2.VerificationContext {}>".format(context)
|
||||
|
||||
|
||||
class VerificationList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the VerificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the verification [Service](https://www.twilio.com/docs/verify/api/service) to create the resource under.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Verifications".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
to: str,
|
||||
channel: str,
|
||||
custom_friendly_name: Union[str, object] = values.unset,
|
||||
custom_message: Union[str, object] = values.unset,
|
||||
send_digits: Union[str, object] = values.unset,
|
||||
locale: Union[str, object] = values.unset,
|
||||
custom_code: Union[str, object] = values.unset,
|
||||
amount: Union[str, object] = values.unset,
|
||||
payee: Union[str, object] = values.unset,
|
||||
rate_limits: Union[object, object] = values.unset,
|
||||
channel_configuration: Union[object, object] = values.unset,
|
||||
app_hash: Union[str, object] = values.unset,
|
||||
template_sid: Union[str, object] = values.unset,
|
||||
template_custom_substitutions: Union[str, object] = values.unset,
|
||||
device_ip: Union[str, object] = values.unset,
|
||||
risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset,
|
||||
) -> VerificationInstance:
|
||||
"""
|
||||
Create the VerificationInstance
|
||||
|
||||
:param to: The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
:param channel: The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna` or `auto`.
|
||||
:param custom_friendly_name: A custom user defined friendly name that overwrites the existing one in the verification message
|
||||
:param custom_message: The text of a custom message to use for the verification.
|
||||
:param send_digits: The digits to send after a phone call is answered, for example, to dial an extension. For more information, see the Programmable Voice documentation of [sendDigits](https://www.twilio.com/docs/voice/twiml/number#attributes-sendDigits).
|
||||
:param locale: Locale will automatically resolve based on phone number country code for SMS, WhatsApp, and call channel verifications. It will fallback to English or the template’s default translation if the selected translation is not available. This parameter will override the automatic locale resolution. [See supported languages and more information here](https://www.twilio.com/docs/verify/supported-languages).
|
||||
:param custom_code: A pre-generated code to use for verification. The code can be between 4 and 10 characters, inclusive.
|
||||
:param amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:param payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request.
|
||||
:param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address.
|
||||
:param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`.
|
||||
:param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only.
|
||||
:param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions.
|
||||
:param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address.
|
||||
:param risk_check:
|
||||
|
||||
:returns: The created VerificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"To": to,
|
||||
"Channel": channel,
|
||||
"CustomFriendlyName": custom_friendly_name,
|
||||
"CustomMessage": custom_message,
|
||||
"SendDigits": send_digits,
|
||||
"Locale": locale,
|
||||
"CustomCode": custom_code,
|
||||
"Amount": amount,
|
||||
"Payee": payee,
|
||||
"RateLimits": serialize.object(rate_limits),
|
||||
"ChannelConfiguration": serialize.object(channel_configuration),
|
||||
"AppHash": app_hash,
|
||||
"TemplateSid": template_sid,
|
||||
"TemplateCustomSubstitutions": template_custom_substitutions,
|
||||
"DeviceIp": device_ip,
|
||||
"RiskCheck": risk_check,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return VerificationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
to: str,
|
||||
channel: str,
|
||||
custom_friendly_name: Union[str, object] = values.unset,
|
||||
custom_message: Union[str, object] = values.unset,
|
||||
send_digits: Union[str, object] = values.unset,
|
||||
locale: Union[str, object] = values.unset,
|
||||
custom_code: Union[str, object] = values.unset,
|
||||
amount: Union[str, object] = values.unset,
|
||||
payee: Union[str, object] = values.unset,
|
||||
rate_limits: Union[object, object] = values.unset,
|
||||
channel_configuration: Union[object, object] = values.unset,
|
||||
app_hash: Union[str, object] = values.unset,
|
||||
template_sid: Union[str, object] = values.unset,
|
||||
template_custom_substitutions: Union[str, object] = values.unset,
|
||||
device_ip: Union[str, object] = values.unset,
|
||||
risk_check: Union["VerificationInstance.RiskCheck", object] = values.unset,
|
||||
) -> VerificationInstance:
|
||||
"""
|
||||
Asynchronously create the VerificationInstance
|
||||
|
||||
:param to: The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
:param channel: The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna` or `auto`.
|
||||
:param custom_friendly_name: A custom user defined friendly name that overwrites the existing one in the verification message
|
||||
:param custom_message: The text of a custom message to use for the verification.
|
||||
:param send_digits: The digits to send after a phone call is answered, for example, to dial an extension. For more information, see the Programmable Voice documentation of [sendDigits](https://www.twilio.com/docs/voice/twiml/number#attributes-sendDigits).
|
||||
:param locale: Locale will automatically resolve based on phone number country code for SMS, WhatsApp, and call channel verifications. It will fallback to English or the template’s default translation if the selected translation is not available. This parameter will override the automatic locale resolution. [See supported languages and more information here](https://www.twilio.com/docs/verify/supported-languages).
|
||||
:param custom_code: A pre-generated code to use for verification. The code can be between 4 and 10 characters, inclusive.
|
||||
:param amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:param payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:param rate_limits: The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request.
|
||||
:param channel_configuration: [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address.
|
||||
:param app_hash: Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`.
|
||||
:param template_sid: The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only.
|
||||
:param template_custom_substitutions: A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions.
|
||||
:param device_ip: Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address.
|
||||
:param risk_check:
|
||||
|
||||
:returns: The created VerificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"To": to,
|
||||
"Channel": channel,
|
||||
"CustomFriendlyName": custom_friendly_name,
|
||||
"CustomMessage": custom_message,
|
||||
"SendDigits": send_digits,
|
||||
"Locale": locale,
|
||||
"CustomCode": custom_code,
|
||||
"Amount": amount,
|
||||
"Payee": payee,
|
||||
"RateLimits": serialize.object(rate_limits),
|
||||
"ChannelConfiguration": serialize.object(channel_configuration),
|
||||
"AppHash": app_hash,
|
||||
"TemplateSid": template_sid,
|
||||
"TemplateCustomSubstitutions": template_custom_substitutions,
|
||||
"DeviceIp": device_ip,
|
||||
"RiskCheck": risk_check,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return VerificationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def get(self, sid: str) -> VerificationContext:
|
||||
"""
|
||||
Constructs a VerificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Verification resource to update.
|
||||
"""
|
||||
return VerificationContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> VerificationContext:
|
||||
"""
|
||||
Constructs a VerificationContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Verification resource to update.
|
||||
"""
|
||||
return VerificationContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.VerificationList>"
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from twilio.base import deserialize, values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class VerificationCheckInstance(InstanceResource):
|
||||
class Channel(object):
|
||||
SMS = "sms"
|
||||
CALL = "call"
|
||||
EMAIL = "email"
|
||||
WHATSAPP = "whatsapp"
|
||||
SNA = "sna"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the VerificationCheck resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the VerificationCheck resource.
|
||||
:ivar to: The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
:ivar channel:
|
||||
:ivar status: The status of the verification. Can be: `pending`, `approved`, or `canceled`.
|
||||
:ivar valid: Use \"status\" instead. Legacy property indicating whether the verification was successful.
|
||||
:ivar amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:ivar payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:ivar date_created: The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the Verification Check resource was created.
|
||||
:ivar date_updated: The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the Verification Check resource was last updated.
|
||||
:ivar sna_attempts_error_codes: List of error codes as a result of attempting a verification using the `sna` channel. The error codes are chronologically ordered, from the first attempt to the latest attempt. This will be an empty list if no errors occured or `null` if the last channel used wasn't `sna`.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.to: Optional[str] = payload.get("to")
|
||||
self.channel: Optional["VerificationCheckInstance.Channel"] = payload.get(
|
||||
"channel"
|
||||
)
|
||||
self.status: Optional[str] = payload.get("status")
|
||||
self.valid: Optional[bool] = payload.get("valid")
|
||||
self.amount: Optional[str] = payload.get("amount")
|
||||
self.payee: Optional[str] = payload.get("payee")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.sna_attempts_error_codes: Optional[List[object]] = payload.get(
|
||||
"sna_attempts_error_codes"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
|
||||
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.Verify.V2.VerificationCheckInstance {}>".format(context)
|
||||
|
||||
|
||||
class VerificationCheckList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the VerificationCheckList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the verification [Service](https://www.twilio.com/docs/verify/api/service) to create the resource under.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/VerificationCheck".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
code: Union[str, object] = values.unset,
|
||||
to: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
amount: Union[str, object] = values.unset,
|
||||
payee: Union[str, object] = values.unset,
|
||||
) -> VerificationCheckInstance:
|
||||
"""
|
||||
Create the VerificationCheckInstance
|
||||
|
||||
:param code: The 4-10 character string being verified.
|
||||
:param to: The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Either this parameter or the `verification_sid` must be specified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
:param verification_sid: A SID that uniquely identifies the Verification Check. Either this parameter or the `to` phone number/[email](https://www.twilio.com/docs/verify/email) must be specified.
|
||||
:param amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:param payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
|
||||
:returns: The created VerificationCheckInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Code": code,
|
||||
"To": to,
|
||||
"VerificationSid": verification_sid,
|
||||
"Amount": amount,
|
||||
"Payee": payee,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return VerificationCheckInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
code: Union[str, object] = values.unset,
|
||||
to: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
amount: Union[str, object] = values.unset,
|
||||
payee: Union[str, object] = values.unset,
|
||||
) -> VerificationCheckInstance:
|
||||
"""
|
||||
Asynchronously create the VerificationCheckInstance
|
||||
|
||||
:param code: The 4-10 character string being verified.
|
||||
:param to: The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Either this parameter or the `verification_sid` must be specified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
|
||||
:param verification_sid: A SID that uniquely identifies the Verification Check. Either this parameter or the `to` phone number/[email](https://www.twilio.com/docs/verify/email) must be specified.
|
||||
:param amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
:param payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
|
||||
|
||||
:returns: The created VerificationCheckInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Code": code,
|
||||
"To": to,
|
||||
"VerificationSid": verification_sid,
|
||||
"Amount": amount,
|
||||
"Payee": payee,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return VerificationCheckInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.VerificationCheckList>"
|
||||
@@ -0,0 +1,704 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class WebhookInstance(InstanceResource):
|
||||
class Methods(object):
|
||||
GET = "GET"
|
||||
POST = "POST"
|
||||
|
||||
class Status(object):
|
||||
ENABLED = "enabled"
|
||||
DISABLED = "disabled"
|
||||
|
||||
class Version(object):
|
||||
V1 = "v1"
|
||||
V2 = "v2"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Webhook resource.
|
||||
:ivar service_sid: The unique SID identifier of the Service.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:ivar event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:ivar status:
|
||||
:ivar version:
|
||||
:ivar webhook_url: The URL associated with this Webhook.
|
||||
:ivar webhook_method:
|
||||
:ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar url: The absolute URL of the Webhook resource.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
version: Version,
|
||||
payload: Dict[str, Any],
|
||||
service_sid: str,
|
||||
sid: Optional[str] = None,
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.event_types: Optional[List[str]] = payload.get("event_types")
|
||||
self.status: Optional["WebhookInstance.Status"] = payload.get("status")
|
||||
self.version: Optional["WebhookInstance.Version"] = payload.get("version")
|
||||
self.webhook_url: Optional[str] = payload.get("webhook_url")
|
||||
self.webhook_method: Optional["WebhookInstance.Methods"] = payload.get(
|
||||
"webhook_method"
|
||||
)
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[WebhookContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "WebhookContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: WebhookContext for this WebhookInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = WebhookContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "WebhookInstance":
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
event_types: Union[List[str], object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
status: Union["WebhookInstance.Status", object] = values.unset,
|
||||
version: Union["WebhookInstance.Version", object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:param event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param status:
|
||||
:param version:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
event_types=event_types,
|
||||
webhook_url=webhook_url,
|
||||
status=status,
|
||||
version=version,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
event_types: Union[List[str], object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
status: Union["WebhookInstance.Status", object] = values.unset,
|
||||
version: Union["WebhookInstance.Version", object] = values.unset,
|
||||
) -> "WebhookInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:param event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param status:
|
||||
:param version:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
event_types=event_types,
|
||||
webhook_url=webhook_url,
|
||||
status=status,
|
||||
version=version,
|
||||
)
|
||||
|
||||
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.Verify.V2.WebhookInstance {}>".format(context)
|
||||
|
||||
|
||||
class WebhookContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the WebhookContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Webhooks/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._version.delete(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the WebhookInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> WebhookInstance:
|
||||
"""
|
||||
Fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the WebhookInstance
|
||||
|
||||
|
||||
:returns: The fetched WebhookInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
event_types: Union[List[str], object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
status: Union["WebhookInstance.Status", object] = values.unset,
|
||||
version: Union["WebhookInstance.Version", object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Update the WebhookInstance
|
||||
|
||||
:param friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:param event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param status:
|
||||
:param version:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EventTypes": serialize.map(event_types, lambda e: e),
|
||||
"WebhookUrl": webhook_url,
|
||||
"Status": status,
|
||||
"Version": version,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
event_types: Union[List[str], object] = values.unset,
|
||||
webhook_url: Union[str, object] = values.unset,
|
||||
status: Union["WebhookInstance.Status", object] = values.unset,
|
||||
version: Union["WebhookInstance.Version", object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the WebhookInstance
|
||||
|
||||
:param friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:param event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param status:
|
||||
:param version:
|
||||
|
||||
:returns: The updated WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EventTypes": serialize.map(event_types, lambda e: e),
|
||||
"WebhookUrl": webhook_url,
|
||||
"Status": status,
|
||||
"Version": version,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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.Verify.V2.WebhookContext {}>".format(context)
|
||||
|
||||
|
||||
class WebhookPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance:
|
||||
"""
|
||||
Build an instance of WebhookInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return WebhookInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.WebhookPage>"
|
||||
|
||||
|
||||
class WebhookList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the WebhookList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The unique SID identifier of the Service.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Webhooks".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: str,
|
||||
event_types: List[str],
|
||||
webhook_url: str,
|
||||
status: Union["WebhookInstance.Status", object] = values.unset,
|
||||
version: Union["WebhookInstance.Version", object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Create the WebhookInstance
|
||||
|
||||
:param friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:param event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param status:
|
||||
:param version:
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EventTypes": serialize.map(event_types, lambda e: e),
|
||||
"WebhookUrl": webhook_url,
|
||||
"Status": status,
|
||||
"Version": version,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: str,
|
||||
event_types: List[str],
|
||||
webhook_url: str,
|
||||
status: Union["WebhookInstance.Status", object] = values.unset,
|
||||
version: Union["WebhookInstance.Version", object] = values.unset,
|
||||
) -> WebhookInstance:
|
||||
"""
|
||||
Asynchronously create the WebhookInstance
|
||||
|
||||
:param friendly_name: The string that you assigned to describe the webhook. **This value should not contain PII.**
|
||||
:param event_types: The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
|
||||
:param webhook_url: The URL associated with this Webhook.
|
||||
:param status:
|
||||
:param version:
|
||||
|
||||
:returns: The created WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"EventTypes": serialize.map(event_types, lambda e: e),
|
||||
"WebhookUrl": webhook_url,
|
||||
"Status": status,
|
||||
"Version": version,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return WebhookInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[WebhookInstance]:
|
||||
"""
|
||||
Streams WebhookInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously streams WebhookInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WebhookInstance]:
|
||||
"""
|
||||
Lists WebhookInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[WebhookInstance]:
|
||||
"""
|
||||
Asynchronously lists WebhookInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a single page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> WebhookPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of WebhookInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of WebhookInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return WebhookPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> WebhookContext:
|
||||
"""
|
||||
Constructs a WebhookContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update.
|
||||
"""
|
||||
return WebhookContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.WebhookList>"
|
||||
@@ -0,0 +1,291 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import values
|
||||
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class TemplateInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: A 34 character string that uniquely identifies a Verification Template.
|
||||
:ivar account_sid: The unique SID identifier of the Account.
|
||||
:ivar friendly_name: A descriptive string that you create to describe a Template. It can be up to 32 characters long.
|
||||
:ivar channels: A list of channels that support the Template. Can include: sms, voice.
|
||||
:ivar translations: An object that contains the different translations of the template. Every translation is identified by the language short name and contains its respective information as the approval status, text and created/modified date.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.channels: Optional[List[str]] = payload.get("channels")
|
||||
self.translations: Optional[Dict[str, object]] = payload.get("translations")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Verify.V2.TemplateInstance>"
|
||||
|
||||
|
||||
class TemplatePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> TemplateInstance:
|
||||
"""
|
||||
Build an instance of TemplateInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return TemplateInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.TemplatePage>"
|
||||
|
||||
|
||||
class TemplateList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the TemplateList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Templates"
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[TemplateInstance]:
|
||||
"""
|
||||
Streams TemplateInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str friendly_name: String filter used to query templates with a given friendly name.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(friendly_name=friendly_name, page_size=limits["page_size"])
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[TemplateInstance]:
|
||||
"""
|
||||
Asynchronously streams TemplateInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param str friendly_name: String filter used to query templates with a given friendly name.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
friendly_name=friendly_name, page_size=limits["page_size"]
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TemplateInstance]:
|
||||
"""
|
||||
Lists TemplateInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: String filter used to query templates with a given friendly name.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[TemplateInstance]:
|
||||
"""
|
||||
Asynchronously lists TemplateInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param str friendly_name: String filter used to query templates with a given friendly name.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
friendly_name=friendly_name,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TemplatePage:
|
||||
"""
|
||||
Retrieve a single page of TemplateInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: String filter used to query templates with a given friendly name.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TemplateInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return TemplatePage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> TemplatePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of TemplateInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: String filter used to query templates with a given friendly name.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of TemplateInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return TemplatePage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> TemplatePage:
|
||||
"""
|
||||
Retrieve a specific page of TemplateInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TemplateInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return TemplatePage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> TemplatePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of TemplateInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of TemplateInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return TemplatePage(self._version, response)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.TemplateList>"
|
||||
@@ -0,0 +1,583 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
from twilio.base.page import Page
|
||||
|
||||
|
||||
class VerificationAttemptInstance(InstanceResource):
|
||||
class Channels(object):
|
||||
SMS = "sms"
|
||||
CALL = "call"
|
||||
EMAIL = "email"
|
||||
WHATSAPP = "whatsapp"
|
||||
|
||||
class ConversionStatus(object):
|
||||
CONVERTED = "converted"
|
||||
UNCONVERTED = "unconverted"
|
||||
|
||||
"""
|
||||
:ivar sid: The SID that uniquely identifies the verification attempt resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Verification resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) used to generate the attempt.
|
||||
:ivar verification_sid: The SID of the [Verification](https://www.twilio.com/docs/verify/api/verification) that generated the attempt.
|
||||
:ivar date_created: The date that this Attempt was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar date_updated: The date that this Attempt was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
|
||||
:ivar conversion_status:
|
||||
:ivar channel:
|
||||
:ivar price: An object containing the charge for this verification attempt related to the channel costs and the currency used. The costs related to the succeeded verifications are not included. May not be immediately available. More information on pricing is available [here](https://www.twilio.com/verify/pricing).
|
||||
:ivar channel_data: An object containing the channel specific information for an attempt.
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None
|
||||
):
|
||||
super().__init__(version)
|
||||
|
||||
self.sid: Optional[str] = payload.get("sid")
|
||||
self.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.verification_sid: Optional[str] = payload.get("verification_sid")
|
||||
self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_updated")
|
||||
)
|
||||
self.conversion_status: Optional[
|
||||
"VerificationAttemptInstance.ConversionStatus"
|
||||
] = payload.get("conversion_status")
|
||||
self.channel: Optional["VerificationAttemptInstance.Channels"] = payload.get(
|
||||
"channel"
|
||||
)
|
||||
self.price: Optional[Dict[str, object]] = payload.get("price")
|
||||
self.channel_data: Optional[Dict[str, object]] = payload.get("channel_data")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[VerificationAttemptContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "VerificationAttemptContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: VerificationAttemptContext for this VerificationAttemptInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = VerificationAttemptContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(self) -> "VerificationAttemptInstance":
|
||||
"""
|
||||
Fetch the VerificationAttemptInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationAttemptInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "VerificationAttemptInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the VerificationAttemptInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationAttemptInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
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.Verify.V2.VerificationAttemptInstance {}>".format(context)
|
||||
|
||||
|
||||
class VerificationAttemptContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the VerificationAttemptContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The unique SID identifier of a Verification Attempt
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Attempts/{sid}".format(**self._solution)
|
||||
|
||||
def fetch(self) -> VerificationAttemptInstance:
|
||||
"""
|
||||
Fetch the VerificationAttemptInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationAttemptInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return VerificationAttemptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> VerificationAttemptInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the VerificationAttemptInstance
|
||||
|
||||
|
||||
:returns: The fetched VerificationAttemptInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return VerificationAttemptInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
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.Verify.V2.VerificationAttemptContext {}>".format(context)
|
||||
|
||||
|
||||
class VerificationAttemptPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> VerificationAttemptInstance:
|
||||
"""
|
||||
Build an instance of VerificationAttemptInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return VerificationAttemptInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.VerificationAttemptPage>"
|
||||
|
||||
|
||||
class VerificationAttemptList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the VerificationAttemptList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Attempts"
|
||||
|
||||
def stream(
|
||||
self,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
channel_data_to: Union[str, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union["VerificationAttemptInstance.Channels", object] = values.unset,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
status: Union[
|
||||
"VerificationAttemptInstance.ConversionStatus", object
|
||||
] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[VerificationAttemptInstance]:
|
||||
"""
|
||||
Streams VerificationAttemptInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param str channel_data_to: Destination of a verification. It is phone number in E.164 format.
|
||||
:param str country: Filter used to query Verification Attempts sent to the specified destination country.
|
||||
:param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL`
|
||||
:param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned.
|
||||
:param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned.
|
||||
:param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = self.page(
|
||||
date_created_after=date_created_after,
|
||||
date_created_before=date_created_before,
|
||||
channel_data_to=channel_data_to,
|
||||
country=country,
|
||||
channel=channel,
|
||||
verify_service_sid=verify_service_sid,
|
||||
verification_sid=verification_sid,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
channel_data_to: Union[str, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union["VerificationAttemptInstance.Channels", object] = values.unset,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
status: Union[
|
||||
"VerificationAttemptInstance.ConversionStatus", object
|
||||
] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[VerificationAttemptInstance]:
|
||||
"""
|
||||
Asynchronously streams VerificationAttemptInstance records from the API as a generator stream.
|
||||
This operation lazily loads records as efficiently as possible until the limit
|
||||
is reached.
|
||||
The results are returned as a generator, so this operation is memory efficient.
|
||||
|
||||
:param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param str channel_data_to: Destination of a verification. It is phone number in E.164 format.
|
||||
:param str country: Filter used to query Verification Attempts sent to the specified destination country.
|
||||
:param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL`
|
||||
:param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned.
|
||||
:param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned.
|
||||
:param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed.
|
||||
:param limit: Upper limit for the number of records to return. stream()
|
||||
guarantees to never return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, stream() will attempt to read the
|
||||
limit with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: Generator that will yield up to limit results
|
||||
"""
|
||||
limits = self._version.read_limits(limit, page_size)
|
||||
page = await self.page_async(
|
||||
date_created_after=date_created_after,
|
||||
date_created_before=date_created_before,
|
||||
channel_data_to=channel_data_to,
|
||||
country=country,
|
||||
channel=channel,
|
||||
verify_service_sid=verify_service_sid,
|
||||
verification_sid=verification_sid,
|
||||
status=status,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
channel_data_to: Union[str, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union["VerificationAttemptInstance.Channels", object] = values.unset,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
status: Union[
|
||||
"VerificationAttemptInstance.ConversionStatus", object
|
||||
] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[VerificationAttemptInstance]:
|
||||
"""
|
||||
Lists VerificationAttemptInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param str channel_data_to: Destination of a verification. It is phone number in E.164 format.
|
||||
:param str country: Filter used to query Verification Attempts sent to the specified destination country.
|
||||
:param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL`
|
||||
:param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned.
|
||||
:param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned.
|
||||
:param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return list(
|
||||
self.stream(
|
||||
date_created_after=date_created_after,
|
||||
date_created_before=date_created_before,
|
||||
channel_data_to=channel_data_to,
|
||||
country=country,
|
||||
channel=channel,
|
||||
verify_service_sid=verify_service_sid,
|
||||
verification_sid=verification_sid,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
channel_data_to: Union[str, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union["VerificationAttemptInstance.Channels", object] = values.unset,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
status: Union[
|
||||
"VerificationAttemptInstance.ConversionStatus", object
|
||||
] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[VerificationAttemptInstance]:
|
||||
"""
|
||||
Asynchronously lists VerificationAttemptInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param str channel_data_to: Destination of a verification. It is phone number in E.164 format.
|
||||
:param str country: Filter used to query Verification Attempts sent to the specified destination country.
|
||||
:param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL`
|
||||
:param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned.
|
||||
:param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned.
|
||||
:param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed.
|
||||
:param limit: Upper limit for the number of records to return. list() guarantees
|
||||
never to return more than limit. Default is no limit
|
||||
:param page_size: Number of records to fetch per request, when not set will use
|
||||
the default value of 50 records. If no page_size is defined
|
||||
but a limit is defined, list() will attempt to read the limit
|
||||
with the most efficient page size, i.e. min(limit, 1000)
|
||||
|
||||
:returns: list that will contain up to limit results
|
||||
"""
|
||||
return [
|
||||
record
|
||||
async for record in await self.stream_async(
|
||||
date_created_after=date_created_after,
|
||||
date_created_before=date_created_before,
|
||||
channel_data_to=channel_data_to,
|
||||
country=country,
|
||||
channel=channel,
|
||||
verify_service_sid=verify_service_sid,
|
||||
verification_sid=verification_sid,
|
||||
status=status,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
channel_data_to: Union[str, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union["VerificationAttemptInstance.Channels", object] = values.unset,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
status: Union[
|
||||
"VerificationAttemptInstance.ConversionStatus", object
|
||||
] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> VerificationAttemptPage:
|
||||
"""
|
||||
Retrieve a single page of VerificationAttemptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param channel_data_to: Destination of a verification. It is phone number in E.164 format.
|
||||
:param country: Filter used to query Verification Attempts sent to the specified destination country.
|
||||
:param channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL`
|
||||
:param verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned.
|
||||
:param verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned.
|
||||
:param status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of VerificationAttemptInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
|
||||
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
|
||||
"ChannelData.To": channel_data_to,
|
||||
"Country": country,
|
||||
"Channel": channel,
|
||||
"VerifyServiceSid": verify_service_sid,
|
||||
"VerificationSid": verification_sid,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return VerificationAttemptPage(self._version, response)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
channel_data_to: Union[str, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union["VerificationAttemptInstance.Channels", object] = values.unset,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
verification_sid: Union[str, object] = values.unset,
|
||||
status: Union[
|
||||
"VerificationAttemptInstance.ConversionStatus", object
|
||||
] = values.unset,
|
||||
page_token: Union[str, object] = values.unset,
|
||||
page_number: Union[int, object] = values.unset,
|
||||
page_size: Union[int, object] = values.unset,
|
||||
) -> VerificationAttemptPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of VerificationAttemptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param channel_data_to: Destination of a verification. It is phone number in E.164 format.
|
||||
:param country: Filter used to query Verification Attempts sent to the specified destination country.
|
||||
:param channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL`
|
||||
:param verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned.
|
||||
:param verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned.
|
||||
:param status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed.
|
||||
:param page_token: PageToken provided by the API
|
||||
:param page_number: Page Number, this value is simply for client state
|
||||
:param page_size: Number of records to return, defaults to 50
|
||||
|
||||
:returns: Page of VerificationAttemptInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
|
||||
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
|
||||
"ChannelData.To": channel_data_to,
|
||||
"Country": country,
|
||||
"Channel": channel,
|
||||
"VerifyServiceSid": verify_service_sid,
|
||||
"VerificationSid": verification_sid,
|
||||
"Status": status,
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return VerificationAttemptPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> VerificationAttemptPage:
|
||||
"""
|
||||
Retrieve a specific page of VerificationAttemptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of VerificationAttemptInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return VerificationAttemptPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> VerificationAttemptPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of VerificationAttemptInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of VerificationAttemptInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return VerificationAttemptPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> VerificationAttemptContext:
|
||||
"""
|
||||
Constructs a VerificationAttemptContext
|
||||
|
||||
:param sid: The unique SID identifier of a Verification Attempt
|
||||
"""
|
||||
return VerificationAttemptContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> VerificationAttemptContext:
|
||||
"""
|
||||
Constructs a VerificationAttemptContext
|
||||
|
||||
:param sid: The unique SID identifier of a Verification Attempt
|
||||
"""
|
||||
return VerificationAttemptContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.VerificationAttemptList>"
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Verify
|
||||
This is the public Twilio REST API.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator.
|
||||
https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from twilio.base import deserialize, serialize, values
|
||||
from twilio.base.instance_context import InstanceContext
|
||||
from twilio.base.instance_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class VerificationAttemptsSummaryInstance(InstanceResource):
|
||||
class Channels(object):
|
||||
SMS = "sms"
|
||||
CALL = "call"
|
||||
EMAIL = "email"
|
||||
WHATSAPP = "whatsapp"
|
||||
|
||||
"""
|
||||
:ivar total_attempts: Total of attempts made according to the provided filters
|
||||
:ivar total_converted: Total of attempts made that were confirmed by the end user, according to the provided filters.
|
||||
:ivar total_unconverted: Total of attempts made that were not confirmed by the end user, according to the provided filters.
|
||||
:ivar conversion_rate_percentage: Percentage of the confirmed messages over the total, defined by (total_converted/total_attempts)*100.
|
||||
:ivar url:
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any]):
|
||||
super().__init__(version)
|
||||
|
||||
self.total_attempts: Optional[int] = deserialize.integer(
|
||||
payload.get("total_attempts")
|
||||
)
|
||||
self.total_converted: Optional[int] = deserialize.integer(
|
||||
payload.get("total_converted")
|
||||
)
|
||||
self.total_unconverted: Optional[int] = deserialize.integer(
|
||||
payload.get("total_unconverted")
|
||||
)
|
||||
self.conversion_rate_percentage: Optional[float] = deserialize.decimal(
|
||||
payload.get("conversion_rate_percentage")
|
||||
)
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
|
||||
self._context: Optional[VerificationAttemptsSummaryContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "VerificationAttemptsSummaryContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: VerificationAttemptsSummaryContext for this VerificationAttemptsSummaryInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = VerificationAttemptsSummaryContext(
|
||||
self._version,
|
||||
)
|
||||
return self._context
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union[
|
||||
"VerificationAttemptsSummaryInstance.Channels", object
|
||||
] = values.unset,
|
||||
destination_prefix: Union[str, object] = values.unset,
|
||||
) -> "VerificationAttemptsSummaryInstance":
|
||||
"""
|
||||
Fetch the VerificationAttemptsSummaryInstance
|
||||
|
||||
:param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation.
|
||||
:param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation.
|
||||
:param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS`, `CALL` and `WHATSAPP`
|
||||
:param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format.
|
||||
|
||||
:returns: The fetched VerificationAttemptsSummaryInstance
|
||||
"""
|
||||
return self._proxy.fetch(
|
||||
verify_service_sid=verify_service_sid,
|
||||
date_created_after=date_created_after,
|
||||
date_created_before=date_created_before,
|
||||
country=country,
|
||||
channel=channel,
|
||||
destination_prefix=destination_prefix,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union[
|
||||
"VerificationAttemptsSummaryInstance.Channels", object
|
||||
] = values.unset,
|
||||
destination_prefix: Union[str, object] = values.unset,
|
||||
) -> "VerificationAttemptsSummaryInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the VerificationAttemptsSummaryInstance
|
||||
|
||||
:param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation.
|
||||
:param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation.
|
||||
:param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS`, `CALL` and `WHATSAPP`
|
||||
:param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format.
|
||||
|
||||
:returns: The fetched VerificationAttemptsSummaryInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async(
|
||||
verify_service_sid=verify_service_sid,
|
||||
date_created_after=date_created_after,
|
||||
date_created_before=date_created_before,
|
||||
country=country,
|
||||
channel=channel,
|
||||
destination_prefix=destination_prefix,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Verify.V2.VerificationAttemptsSummaryInstance>"
|
||||
|
||||
|
||||
class VerificationAttemptsSummaryContext(InstanceContext):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the VerificationAttemptsSummaryContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Attempts/Summary"
|
||||
|
||||
def fetch(
|
||||
self,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union[
|
||||
"VerificationAttemptsSummaryInstance.Channels", object
|
||||
] = values.unset,
|
||||
destination_prefix: Union[str, object] = values.unset,
|
||||
) -> VerificationAttemptsSummaryInstance:
|
||||
"""
|
||||
Fetch the VerificationAttemptsSummaryInstance
|
||||
|
||||
:param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation.
|
||||
:param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation.
|
||||
:param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS`, `CALL` and `WHATSAPP`
|
||||
:param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format.
|
||||
|
||||
:returns: The fetched VerificationAttemptsSummaryInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"VerifyServiceSid": verify_service_sid,
|
||||
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
|
||||
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
|
||||
"Country": country,
|
||||
"Channel": channel,
|
||||
"DestinationPrefix": destination_prefix,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.fetch(method="GET", uri=self._uri, params=data)
|
||||
|
||||
return VerificationAttemptsSummaryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
async def fetch_async(
|
||||
self,
|
||||
verify_service_sid: Union[str, object] = values.unset,
|
||||
date_created_after: Union[datetime, object] = values.unset,
|
||||
date_created_before: Union[datetime, object] = values.unset,
|
||||
country: Union[str, object] = values.unset,
|
||||
channel: Union[
|
||||
"VerificationAttemptsSummaryInstance.Channels", object
|
||||
] = values.unset,
|
||||
destination_prefix: Union[str, object] = values.unset,
|
||||
) -> VerificationAttemptsSummaryInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the VerificationAttemptsSummaryInstance
|
||||
|
||||
:param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation.
|
||||
:param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z.
|
||||
:param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation.
|
||||
:param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS`, `CALL` and `WHATSAPP`
|
||||
:param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format.
|
||||
|
||||
:returns: The fetched VerificationAttemptsSummaryInstance
|
||||
"""
|
||||
|
||||
data = values.of(
|
||||
{
|
||||
"VerifyServiceSid": verify_service_sid,
|
||||
"DateCreatedAfter": serialize.iso8601_datetime(date_created_after),
|
||||
"DateCreatedBefore": serialize.iso8601_datetime(date_created_before),
|
||||
"Country": country,
|
||||
"Channel": channel,
|
||||
"DestinationPrefix": destination_prefix,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
|
||||
return VerificationAttemptsSummaryInstance(
|
||||
self._version,
|
||||
payload,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
|
||||
return "<Twilio.Verify.V2.VerificationAttemptsSummaryContext>"
|
||||
|
||||
|
||||
class VerificationAttemptsSummaryList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the VerificationAttemptsSummaryList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
def get(self) -> VerificationAttemptsSummaryContext:
|
||||
"""
|
||||
Constructs a VerificationAttemptsSummaryContext
|
||||
|
||||
"""
|
||||
return VerificationAttemptsSummaryContext(self._version)
|
||||
|
||||
def __call__(self) -> VerificationAttemptsSummaryContext:
|
||||
"""
|
||||
Constructs a VerificationAttemptsSummaryContext
|
||||
|
||||
"""
|
||||
return VerificationAttemptsSummaryContext(self._version)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Verify.V2.VerificationAttemptsSummaryList>"
|
||||
Reference in New Issue
Block a user