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.notify.v1 import V1
|
||||
|
||||
|
||||
class NotifyBase(Domain):
|
||||
def __init__(self, twilio: Client):
|
||||
"""
|
||||
Initialize the Notify Domain
|
||||
|
||||
:returns: Domain for Notify
|
||||
"""
|
||||
super().__init__(twilio, "https://notify.twilio.com")
|
||||
self._v1: Optional[V1] = None
|
||||
|
||||
@property
|
||||
def v1(self) -> V1:
|
||||
"""
|
||||
:returns: Versions v1 of Notify
|
||||
"""
|
||||
if self._v1 is None:
|
||||
self._v1 = V1(self)
|
||||
return self._v1
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify>"
|
||||
@@ -0,0 +1,25 @@
|
||||
from warnings import warn
|
||||
|
||||
from twilio.rest.notify.NotifyBase import NotifyBase
|
||||
from twilio.rest.notify.v1.credential import CredentialList
|
||||
from twilio.rest.notify.v1.service import ServiceList
|
||||
|
||||
|
||||
class Notify(NotifyBase):
|
||||
@property
|
||||
def credentials(self) -> CredentialList:
|
||||
warn(
|
||||
"credentials is deprecated. Use v1.credentials instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.credentials
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceList:
|
||||
warn(
|
||||
"services is deprecated. Use v1.services instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.v1.services
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Notify
|
||||
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.notify.v1.credential import CredentialList
|
||||
from twilio.rest.notify.v1.service import ServiceList
|
||||
|
||||
|
||||
class V1(Version):
|
||||
def __init__(self, domain: Domain):
|
||||
"""
|
||||
Initialize the V1 version of Notify
|
||||
|
||||
:param domain: The Twilio.notify domain
|
||||
"""
|
||||
super().__init__(domain, "v1")
|
||||
self._credentials: Optional[CredentialList] = None
|
||||
self._services: Optional[ServiceList] = None
|
||||
|
||||
@property
|
||||
def credentials(self) -> CredentialList:
|
||||
if self._credentials is None:
|
||||
self._credentials = CredentialList(self)
|
||||
return self._credentials
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceList:
|
||||
if self._services is None:
|
||||
self._services = ServiceList(self)
|
||||
return self._services
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,676 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Notify
|
||||
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 CredentialInstance(InstanceResource):
|
||||
class PushService(object):
|
||||
GCM = "gcm"
|
||||
APN = "apn"
|
||||
FCM = "fcm"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Credential resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Credential resource.
|
||||
:ivar friendly_name: The string that you assigned to describe the resource.
|
||||
:ivar type:
|
||||
:ivar sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
: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 absolute URL of the Credential resource.
|
||||
"""
|
||||
|
||||
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.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
self.type: Optional["CredentialInstance.PushService"] = payload.get("type")
|
||||
self.sandbox: Optional[str] = payload.get("sandbox")
|
||||
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 = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[CredentialContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "CredentialContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: CredentialContext for this CredentialInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = CredentialContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "CredentialInstance":
|
||||
"""
|
||||
Fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "CredentialInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> "CredentialInstance":
|
||||
"""
|
||||
Update the CredentialInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
|
||||
:param private_key: [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----`
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
:param secret: [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
certificate=certificate,
|
||||
private_key=private_key,
|
||||
sandbox=sandbox,
|
||||
api_key=api_key,
|
||||
secret=secret,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> "CredentialInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the CredentialInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
|
||||
:param private_key: [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----`
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
:param secret: [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
certificate=certificate,
|
||||
private_key=private_key,
|
||||
sandbox=sandbox,
|
||||
api_key=api_key,
|
||||
secret=secret,
|
||||
)
|
||||
|
||||
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.Notify.V1.CredentialInstance {}>".format(context)
|
||||
|
||||
|
||||
class CredentialContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the CredentialContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Credential resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Credentials/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the CredentialInstance
|
||||
|
||||
|
||||
: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 CredentialInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> CredentialInstance:
|
||||
"""
|
||||
Fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return CredentialInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> CredentialInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the CredentialInstance
|
||||
|
||||
|
||||
:returns: The fetched CredentialInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return CredentialInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Update the CredentialInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
|
||||
:param private_key: [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----`
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
:param secret: [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the CredentialInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
|
||||
:param private_key: [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----`
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
:param secret: [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
|
||||
:returns: The updated CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(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.Notify.V1.CredentialContext {}>".format(context)
|
||||
|
||||
|
||||
class CredentialPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance:
|
||||
"""
|
||||
Build an instance of CredentialInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return CredentialInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.CredentialPage>"
|
||||
|
||||
|
||||
class CredentialList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the CredentialList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Credentials"
|
||||
|
||||
def create(
|
||||
self,
|
||||
type: "CredentialInstance.PushService",
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Create the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
|
||||
:param private_key: [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----`
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
:param secret: [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
|
||||
:returns: The created CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
type: "CredentialInstance.PushService",
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
certificate: Union[str, object] = values.unset,
|
||||
private_key: Union[str, object] = values.unset,
|
||||
sandbox: Union[bool, object] = values.unset,
|
||||
api_key: Union[str, object] = values.unset,
|
||||
secret: Union[str, object] = values.unset,
|
||||
) -> CredentialInstance:
|
||||
"""
|
||||
Asynchronously create the CredentialInstance
|
||||
|
||||
:param type:
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param certificate: [APN only] The URL-encoded representation of the certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
|
||||
:param private_key: [APN only] The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. `-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\\\n.-----END RSA PRIVATE KEY-----`
|
||||
:param sandbox: [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
||||
:param api_key: [GCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
:param secret: [FCM only] The `Server key` of your project from Firebase console under Settings / Cloud messaging.
|
||||
|
||||
:returns: The created CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Type": type,
|
||||
"FriendlyName": friendly_name,
|
||||
"Certificate": certificate,
|
||||
"PrivateKey": private_key,
|
||||
"Sandbox": sandbox,
|
||||
"ApiKey": api_key,
|
||||
"Secret": secret,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return CredentialInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[CredentialInstance]:
|
||||
"""
|
||||
Streams CredentialInstance 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[CredentialInstance]:
|
||||
"""
|
||||
Asynchronously streams CredentialInstance 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[CredentialInstance]:
|
||||
"""
|
||||
Lists CredentialInstance 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[CredentialInstance]:
|
||||
"""
|
||||
Asynchronously lists CredentialInstance 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,
|
||||
) -> CredentialPage:
|
||||
"""
|
||||
Retrieve a single page of CredentialInstance 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 CredentialInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
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,
|
||||
) -> CredentialPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of CredentialInstance 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 CredentialInstance
|
||||
"""
|
||||
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 CredentialPage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> CredentialPage:
|
||||
"""
|
||||
Retrieve a specific page of CredentialInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of CredentialInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> CredentialPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of CredentialInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of CredentialInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return CredentialPage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> CredentialContext:
|
||||
"""
|
||||
Constructs a CredentialContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Credential resource to update.
|
||||
"""
|
||||
return CredentialContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> CredentialContext:
|
||||
"""
|
||||
Constructs a CredentialContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Credential resource to update.
|
||||
"""
|
||||
return CredentialContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.CredentialList>"
|
||||
@@ -0,0 +1,907 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Notify
|
||||
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.notify.v1.service.binding import BindingList
|
||||
from twilio.rest.notify.v1.service.notification import NotificationList
|
||||
|
||||
|
||||
class ServiceInstance(InstanceResource):
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Service resource.
|
||||
: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 resource.
|
||||
: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 apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:ivar gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:ivar fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. In order to send SMS notifications this parameter has to be set.
|
||||
:ivar facebook_messenger_page_id: Deprecated.
|
||||
:ivar default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:ivar default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:ivar default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:ivar log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:ivar url: The absolute URL of the Service resource.
|
||||
:ivar links: The URLs of the Binding, Notification, Segment, and User resources related to the service.
|
||||
:ivar alexa_skill_id: Deprecated.
|
||||
:ivar default_alexa_notification_protocol_version: Deprecated.
|
||||
:ivar delivery_callback_url: URL to send delivery status callback.
|
||||
:ivar delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
"""
|
||||
|
||||
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.friendly_name: Optional[str] = payload.get("friendly_name")
|
||||
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.apn_credential_sid: Optional[str] = payload.get("apn_credential_sid")
|
||||
self.gcm_credential_sid: Optional[str] = payload.get("gcm_credential_sid")
|
||||
self.fcm_credential_sid: Optional[str] = payload.get("fcm_credential_sid")
|
||||
self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid")
|
||||
self.facebook_messenger_page_id: Optional[str] = payload.get(
|
||||
"facebook_messenger_page_id"
|
||||
)
|
||||
self.default_apn_notification_protocol_version: Optional[str] = payload.get(
|
||||
"default_apn_notification_protocol_version"
|
||||
)
|
||||
self.default_gcm_notification_protocol_version: Optional[str] = payload.get(
|
||||
"default_gcm_notification_protocol_version"
|
||||
)
|
||||
self.default_fcm_notification_protocol_version: Optional[str] = payload.get(
|
||||
"default_fcm_notification_protocol_version"
|
||||
)
|
||||
self.log_enabled: Optional[bool] = payload.get("log_enabled")
|
||||
self.url: Optional[str] = payload.get("url")
|
||||
self.links: Optional[Dict[str, object]] = payload.get("links")
|
||||
self.alexa_skill_id: Optional[str] = payload.get("alexa_skill_id")
|
||||
self.default_alexa_notification_protocol_version: Optional[str] = payload.get(
|
||||
"default_alexa_notification_protocol_version"
|
||||
)
|
||||
self.delivery_callback_url: Optional[str] = payload.get("delivery_callback_url")
|
||||
self.delivery_callback_enabled: Optional[bool] = payload.get(
|
||||
"delivery_callback_enabled"
|
||||
)
|
||||
|
||||
self._solution = {
|
||||
"sid": sid or self.sid,
|
||||
}
|
||||
self._context: Optional[ServiceContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "ServiceContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: ServiceContext for this ServiceInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = ServiceContext(
|
||||
self._version,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "ServiceInstance":
|
||||
"""
|
||||
Fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "ServiceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
return await self._proxy.fetch_async()
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
apn_credential_sid: Union[str, object] = values.unset,
|
||||
gcm_credential_sid: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
facebook_messenger_page_id: Union[str, object] = values.unset,
|
||||
default_apn_notification_protocol_version: Union[str, object] = values.unset,
|
||||
default_gcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
fcm_credential_sid: Union[str, object] = values.unset,
|
||||
default_fcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
alexa_skill_id: Union[str, object] = values.unset,
|
||||
default_alexa_notification_protocol_version: Union[str, object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
delivery_callback_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ServiceInstance":
|
||||
"""
|
||||
Update the ServiceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
|
||||
:param facebook_messenger_page_id: Deprecated.
|
||||
:param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:param default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:param alexa_skill_id: Deprecated.
|
||||
:param default_alexa_notification_protocol_version: Deprecated.
|
||||
:param delivery_callback_url: URL to send delivery status callback.
|
||||
:param delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
|
||||
:returns: The updated ServiceInstance
|
||||
"""
|
||||
return self._proxy.update(
|
||||
friendly_name=friendly_name,
|
||||
apn_credential_sid=apn_credential_sid,
|
||||
gcm_credential_sid=gcm_credential_sid,
|
||||
messaging_service_sid=messaging_service_sid,
|
||||
facebook_messenger_page_id=facebook_messenger_page_id,
|
||||
default_apn_notification_protocol_version=default_apn_notification_protocol_version,
|
||||
default_gcm_notification_protocol_version=default_gcm_notification_protocol_version,
|
||||
fcm_credential_sid=fcm_credential_sid,
|
||||
default_fcm_notification_protocol_version=default_fcm_notification_protocol_version,
|
||||
log_enabled=log_enabled,
|
||||
alexa_skill_id=alexa_skill_id,
|
||||
default_alexa_notification_protocol_version=default_alexa_notification_protocol_version,
|
||||
delivery_callback_url=delivery_callback_url,
|
||||
delivery_callback_enabled=delivery_callback_enabled,
|
||||
)
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
apn_credential_sid: Union[str, object] = values.unset,
|
||||
gcm_credential_sid: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
facebook_messenger_page_id: Union[str, object] = values.unset,
|
||||
default_apn_notification_protocol_version: Union[str, object] = values.unset,
|
||||
default_gcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
fcm_credential_sid: Union[str, object] = values.unset,
|
||||
default_fcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
alexa_skill_id: Union[str, object] = values.unset,
|
||||
default_alexa_notification_protocol_version: Union[str, object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
delivery_callback_enabled: Union[bool, object] = values.unset,
|
||||
) -> "ServiceInstance":
|
||||
"""
|
||||
Asynchronous coroutine to update the ServiceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
|
||||
:param facebook_messenger_page_id: Deprecated.
|
||||
:param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:param default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:param alexa_skill_id: Deprecated.
|
||||
:param default_alexa_notification_protocol_version: Deprecated.
|
||||
:param delivery_callback_url: URL to send delivery status callback.
|
||||
:param delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
|
||||
:returns: The updated ServiceInstance
|
||||
"""
|
||||
return await self._proxy.update_async(
|
||||
friendly_name=friendly_name,
|
||||
apn_credential_sid=apn_credential_sid,
|
||||
gcm_credential_sid=gcm_credential_sid,
|
||||
messaging_service_sid=messaging_service_sid,
|
||||
facebook_messenger_page_id=facebook_messenger_page_id,
|
||||
default_apn_notification_protocol_version=default_apn_notification_protocol_version,
|
||||
default_gcm_notification_protocol_version=default_gcm_notification_protocol_version,
|
||||
fcm_credential_sid=fcm_credential_sid,
|
||||
default_fcm_notification_protocol_version=default_fcm_notification_protocol_version,
|
||||
log_enabled=log_enabled,
|
||||
alexa_skill_id=alexa_skill_id,
|
||||
default_alexa_notification_protocol_version=default_alexa_notification_protocol_version,
|
||||
delivery_callback_url=delivery_callback_url,
|
||||
delivery_callback_enabled=delivery_callback_enabled,
|
||||
)
|
||||
|
||||
@property
|
||||
def bindings(self) -> BindingList:
|
||||
"""
|
||||
Access the bindings
|
||||
"""
|
||||
return self._proxy.bindings
|
||||
|
||||
@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.Notify.V1.ServiceInstance {}>".format(context)
|
||||
|
||||
|
||||
class ServiceContext(InstanceContext):
|
||||
def __init__(self, version: Version, sid: str):
|
||||
"""
|
||||
Initialize the ServiceContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Service resource to update.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{sid}".format(**self._solution)
|
||||
|
||||
self._bindings: Optional[BindingList] = None
|
||||
self._notifications: Optional[NotificationList] = None
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the ServiceInstance
|
||||
|
||||
|
||||
: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 ServiceInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> ServiceInstance:
|
||||
"""
|
||||
Fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ServiceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> ServiceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the ServiceInstance
|
||||
|
||||
|
||||
:returns: The fetched ServiceInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return ServiceInstance(
|
||||
self._version,
|
||||
payload,
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
def update(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
apn_credential_sid: Union[str, object] = values.unset,
|
||||
gcm_credential_sid: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
facebook_messenger_page_id: Union[str, object] = values.unset,
|
||||
default_apn_notification_protocol_version: Union[str, object] = values.unset,
|
||||
default_gcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
fcm_credential_sid: Union[str, object] = values.unset,
|
||||
default_fcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
alexa_skill_id: Union[str, object] = values.unset,
|
||||
default_alexa_notification_protocol_version: Union[str, object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
delivery_callback_enabled: Union[bool, object] = values.unset,
|
||||
) -> ServiceInstance:
|
||||
"""
|
||||
Update the ServiceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
|
||||
:param facebook_messenger_page_id: Deprecated.
|
||||
:param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:param default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:param alexa_skill_id: Deprecated.
|
||||
:param default_alexa_notification_protocol_version: Deprecated.
|
||||
:param delivery_callback_url: URL to send delivery status callback.
|
||||
:param delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
|
||||
:returns: The updated ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ApnCredentialSid": apn_credential_sid,
|
||||
"GcmCredentialSid": gcm_credential_sid,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"FacebookMessengerPageId": facebook_messenger_page_id,
|
||||
"DefaultApnNotificationProtocolVersion": default_apn_notification_protocol_version,
|
||||
"DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version,
|
||||
"FcmCredentialSid": fcm_credential_sid,
|
||||
"DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version,
|
||||
"LogEnabled": log_enabled,
|
||||
"AlexaSkillId": alexa_skill_id,
|
||||
"DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version,
|
||||
"DeliveryCallbackUrl": delivery_callback_url,
|
||||
"DeliveryCallbackEnabled": delivery_callback_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.update(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ServiceInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
async def update_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
apn_credential_sid: Union[str, object] = values.unset,
|
||||
gcm_credential_sid: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
facebook_messenger_page_id: Union[str, object] = values.unset,
|
||||
default_apn_notification_protocol_version: Union[str, object] = values.unset,
|
||||
default_gcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
fcm_credential_sid: Union[str, object] = values.unset,
|
||||
default_fcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
alexa_skill_id: Union[str, object] = values.unset,
|
||||
default_alexa_notification_protocol_version: Union[str, object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
delivery_callback_enabled: Union[bool, object] = values.unset,
|
||||
) -> ServiceInstance:
|
||||
"""
|
||||
Asynchronous coroutine to update the ServiceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
|
||||
:param facebook_messenger_page_id: Deprecated.
|
||||
:param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:param default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:param alexa_skill_id: Deprecated.
|
||||
:param default_alexa_notification_protocol_version: Deprecated.
|
||||
:param delivery_callback_url: URL to send delivery status callback.
|
||||
:param delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
|
||||
:returns: The updated ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ApnCredentialSid": apn_credential_sid,
|
||||
"GcmCredentialSid": gcm_credential_sid,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"FacebookMessengerPageId": facebook_messenger_page_id,
|
||||
"DefaultApnNotificationProtocolVersion": default_apn_notification_protocol_version,
|
||||
"DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version,
|
||||
"FcmCredentialSid": fcm_credential_sid,
|
||||
"DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version,
|
||||
"LogEnabled": log_enabled,
|
||||
"AlexaSkillId": alexa_skill_id,
|
||||
"DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version,
|
||||
"DeliveryCallbackUrl": delivery_callback_url,
|
||||
"DeliveryCallbackEnabled": delivery_callback_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.update_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ServiceInstance(self._version, payload, sid=self._solution["sid"])
|
||||
|
||||
@property
|
||||
def bindings(self) -> BindingList:
|
||||
"""
|
||||
Access the bindings
|
||||
"""
|
||||
if self._bindings is None:
|
||||
self._bindings = BindingList(
|
||||
self._version,
|
||||
self._solution["sid"],
|
||||
)
|
||||
return self._bindings
|
||||
|
||||
@property
|
||||
def notifications(self) -> NotificationList:
|
||||
"""
|
||||
Access the notifications
|
||||
"""
|
||||
if self._notifications is None:
|
||||
self._notifications = NotificationList(
|
||||
self._version,
|
||||
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.Notify.V1.ServiceContext {}>".format(context)
|
||||
|
||||
|
||||
class ServicePage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance:
|
||||
"""
|
||||
Build an instance of ServiceInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return ServiceInstance(self._version, payload)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.ServicePage>"
|
||||
|
||||
|
||||
class ServiceList(ListResource):
|
||||
def __init__(self, version: Version):
|
||||
"""
|
||||
Initialize the ServiceList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
self._uri = "/Services"
|
||||
|
||||
def create(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
apn_credential_sid: Union[str, object] = values.unset,
|
||||
gcm_credential_sid: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
facebook_messenger_page_id: Union[str, object] = values.unset,
|
||||
default_apn_notification_protocol_version: Union[str, object] = values.unset,
|
||||
default_gcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
fcm_credential_sid: Union[str, object] = values.unset,
|
||||
default_fcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
alexa_skill_id: Union[str, object] = values.unset,
|
||||
default_alexa_notification_protocol_version: Union[str, object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
delivery_callback_enabled: Union[bool, object] = values.unset,
|
||||
) -> ServiceInstance:
|
||||
"""
|
||||
Create the ServiceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
|
||||
:param facebook_messenger_page_id: Deprecated.
|
||||
:param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:param default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:param alexa_skill_id: Deprecated.
|
||||
:param default_alexa_notification_protocol_version: Deprecated.
|
||||
:param delivery_callback_url: URL to send delivery status callback.
|
||||
:param delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
|
||||
:returns: The created ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ApnCredentialSid": apn_credential_sid,
|
||||
"GcmCredentialSid": gcm_credential_sid,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"FacebookMessengerPageId": facebook_messenger_page_id,
|
||||
"DefaultApnNotificationProtocolVersion": default_apn_notification_protocol_version,
|
||||
"DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version,
|
||||
"FcmCredentialSid": fcm_credential_sid,
|
||||
"DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version,
|
||||
"LogEnabled": log_enabled,
|
||||
"AlexaSkillId": alexa_skill_id,
|
||||
"DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version,
|
||||
"DeliveryCallbackUrl": delivery_callback_url,
|
||||
"DeliveryCallbackEnabled": delivery_callback_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ServiceInstance(self._version, payload)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
apn_credential_sid: Union[str, object] = values.unset,
|
||||
gcm_credential_sid: Union[str, object] = values.unset,
|
||||
messaging_service_sid: Union[str, object] = values.unset,
|
||||
facebook_messenger_page_id: Union[str, object] = values.unset,
|
||||
default_apn_notification_protocol_version: Union[str, object] = values.unset,
|
||||
default_gcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
fcm_credential_sid: Union[str, object] = values.unset,
|
||||
default_fcm_notification_protocol_version: Union[str, object] = values.unset,
|
||||
log_enabled: Union[bool, object] = values.unset,
|
||||
alexa_skill_id: Union[str, object] = values.unset,
|
||||
default_alexa_notification_protocol_version: Union[str, object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
delivery_callback_enabled: Union[bool, object] = values.unset,
|
||||
) -> ServiceInstance:
|
||||
"""
|
||||
Asynchronously create the ServiceInstance
|
||||
|
||||
:param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long.
|
||||
:param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.
|
||||
:param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.
|
||||
:param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
|
||||
:param facebook_messenger_page_id: Deprecated.
|
||||
:param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.
|
||||
:param default_fcm_notification_protocol_version: The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource.
|
||||
:param log_enabled: Whether to log notifications. Can be: `true` or `false` and the default is `true`.
|
||||
:param alexa_skill_id: Deprecated.
|
||||
:param default_alexa_notification_protocol_version: Deprecated.
|
||||
:param delivery_callback_url: URL to send delivery status callback.
|
||||
:param delivery_callback_enabled: Callback configuration that enables delivery callbacks, default false
|
||||
|
||||
:returns: The created ServiceInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"FriendlyName": friendly_name,
|
||||
"ApnCredentialSid": apn_credential_sid,
|
||||
"GcmCredentialSid": gcm_credential_sid,
|
||||
"MessagingServiceSid": messaging_service_sid,
|
||||
"FacebookMessengerPageId": facebook_messenger_page_id,
|
||||
"DefaultApnNotificationProtocolVersion": default_apn_notification_protocol_version,
|
||||
"DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version,
|
||||
"FcmCredentialSid": fcm_credential_sid,
|
||||
"DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version,
|
||||
"LogEnabled": log_enabled,
|
||||
"AlexaSkillId": alexa_skill_id,
|
||||
"DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version,
|
||||
"DeliveryCallbackUrl": delivery_callback_url,
|
||||
"DeliveryCallbackEnabled": delivery_callback_enabled,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return ServiceInstance(self._version, payload)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
friendly_name: Union[str, object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[ServiceInstance]:
|
||||
"""
|
||||
Streams ServiceInstance 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: The string that identifies the Service resources to read.
|
||||
: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[ServiceInstance]:
|
||||
"""
|
||||
Asynchronously streams ServiceInstance 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: The string that identifies the Service resources to read.
|
||||
: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[ServiceInstance]:
|
||||
"""
|
||||
Lists ServiceInstance 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: The string that identifies the Service resources to read.
|
||||
: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[ServiceInstance]:
|
||||
"""
|
||||
Asynchronously lists ServiceInstance 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: The string that identifies the Service resources to read.
|
||||
: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,
|
||||
) -> ServicePage:
|
||||
"""
|
||||
Retrieve a single page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The string that identifies the Service resources to read.
|
||||
: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 ServiceInstance
|
||||
"""
|
||||
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 ServicePage(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,
|
||||
) -> ServicePage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param friendly_name: The string that identifies the Service resources to read.
|
||||
: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 ServiceInstance
|
||||
"""
|
||||
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 ServicePage(self._version, response)
|
||||
|
||||
def get_page(self, target_url: str) -> ServicePage:
|
||||
"""
|
||||
Retrieve a specific page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ServiceInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return ServicePage(self._version, response)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> ServicePage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of ServiceInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of ServiceInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return ServicePage(self._version, response)
|
||||
|
||||
def get(self, sid: str) -> ServiceContext:
|
||||
"""
|
||||
Constructs a ServiceContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Service resource to update.
|
||||
"""
|
||||
return ServiceContext(self._version, sid=sid)
|
||||
|
||||
def __call__(self, sid: str) -> ServiceContext:
|
||||
"""
|
||||
Constructs a ServiceContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Service resource to update.
|
||||
"""
|
||||
return ServiceContext(self._version, sid=sid)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.ServiceList>"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,654 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Notify
|
||||
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 date, 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 BindingInstance(InstanceResource):
|
||||
class BindingType(object):
|
||||
APN = "apn"
|
||||
GCM = "gcm"
|
||||
SMS = "sms"
|
||||
FCM = "fcm"
|
||||
FACEBOOK_MESSENGER = "facebook-messenger"
|
||||
ALEXA = "alexa"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Binding resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Binding resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/notify/api/service-resource) the resource is associated with.
|
||||
:ivar credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applicable only to `apn`, `fcm`, and `gcm` type Bindings.
|
||||
: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 notification_protocol_version: The protocol version to use to send the notification. This defaults to the value of `default_xxxx_notification_protocol_version` in the [Service](https://www.twilio.com/docs/notify/api/service-resource) for the protocol. The current version is `\"3\"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed.
|
||||
:ivar endpoint: Deprecated.
|
||||
:ivar identity: The `identity` value that uniquely identifies the resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Up to 20 Bindings can be created for the same Identity in a given Service.
|
||||
:ivar binding_type: The transport technology to use for the Binding. Can be: `apn`, `fcm`, `gcm`, `sms`, or `facebook-messenger`.
|
||||
:ivar address: The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format.
|
||||
:ivar tags: The list of tags associated with this Binding. Tags can be used to select the Bindings to use when sending a notification. Maximum 20 tags are allowed.
|
||||
:ivar url: The absolute URL of the Binding 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.account_sid: Optional[str] = payload.get("account_sid")
|
||||
self.service_sid: Optional[str] = payload.get("service_sid")
|
||||
self.credential_sid: Optional[str] = payload.get("credential_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.notification_protocol_version: Optional[str] = payload.get(
|
||||
"notification_protocol_version"
|
||||
)
|
||||
self.endpoint: Optional[str] = payload.get("endpoint")
|
||||
self.identity: Optional[str] = payload.get("identity")
|
||||
self.binding_type: Optional[str] = payload.get("binding_type")
|
||||
self.address: Optional[str] = payload.get("address")
|
||||
self.tags: Optional[List[str]] = payload.get("tags")
|
||||
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[BindingContext] = None
|
||||
|
||||
@property
|
||||
def _proxy(self) -> "BindingContext":
|
||||
"""
|
||||
Generate an instance context for the instance, the context is capable of
|
||||
performing various actions. All instance actions are proxied to the context
|
||||
|
||||
:returns: BindingContext for this BindingInstance
|
||||
"""
|
||||
if self._context is None:
|
||||
self._context = BindingContext(
|
||||
self._version,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
return self._context
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return self._proxy.delete()
|
||||
|
||||
async def delete_async(self) -> bool:
|
||||
"""
|
||||
Asynchronous coroutine that deletes the BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._proxy.delete_async()
|
||||
|
||||
def fetch(self) -> "BindingInstance":
|
||||
"""
|
||||
Fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
return self._proxy.fetch()
|
||||
|
||||
async def fetch_async(self) -> "BindingInstance":
|
||||
"""
|
||||
Asynchronous coroutine to fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
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.Notify.V1.BindingInstance {}>".format(context)
|
||||
|
||||
|
||||
class BindingContext(InstanceContext):
|
||||
def __init__(self, version: Version, service_sid: str, sid: str):
|
||||
"""
|
||||
Initialize the BindingContext
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/notify/api/service-resource) to fetch the resource from.
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Binding resource to fetch.
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
"sid": sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Bindings/{sid}".format(**self._solution)
|
||||
|
||||
def delete(self) -> bool:
|
||||
"""
|
||||
Deletes the BindingInstance
|
||||
|
||||
|
||||
: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 BindingInstance
|
||||
|
||||
|
||||
:returns: True if delete succeeds, False otherwise
|
||||
"""
|
||||
return await self._version.delete_async(
|
||||
method="DELETE",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
def fetch(self) -> BindingInstance:
|
||||
"""
|
||||
Fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
|
||||
payload = self._version.fetch(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return BindingInstance(
|
||||
self._version,
|
||||
payload,
|
||||
service_sid=self._solution["service_sid"],
|
||||
sid=self._solution["sid"],
|
||||
)
|
||||
|
||||
async def fetch_async(self) -> BindingInstance:
|
||||
"""
|
||||
Asynchronous coroutine to fetch the BindingInstance
|
||||
|
||||
|
||||
:returns: The fetched BindingInstance
|
||||
"""
|
||||
|
||||
payload = await self._version.fetch_async(
|
||||
method="GET",
|
||||
uri=self._uri,
|
||||
)
|
||||
|
||||
return BindingInstance(
|
||||
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.Notify.V1.BindingContext {}>".format(context)
|
||||
|
||||
|
||||
class BindingPage(Page):
|
||||
def get_instance(self, payload: Dict[str, Any]) -> BindingInstance:
|
||||
"""
|
||||
Build an instance of BindingInstance
|
||||
|
||||
:param payload: Payload response from the API
|
||||
"""
|
||||
return BindingInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.BindingPage>"
|
||||
|
||||
|
||||
class BindingList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the BindingList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/notify/api/service-resource) to read the resource from.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Bindings".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
identity: str,
|
||||
binding_type: "BindingInstance.BindingType",
|
||||
address: str,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
notification_protocol_version: Union[str, object] = values.unset,
|
||||
credential_sid: Union[str, object] = values.unset,
|
||||
endpoint: Union[str, object] = values.unset,
|
||||
) -> BindingInstance:
|
||||
"""
|
||||
Create the BindingInstance
|
||||
|
||||
:param identity: The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Up to 20 Bindings can be created for the same Identity in a given Service.
|
||||
:param binding_type:
|
||||
:param address: The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format.
|
||||
:param tag: A tag that can be used to select the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 20 tags.
|
||||
:param notification_protocol_version: The protocol version to use to send the notification. This defaults to the value of `default_xxxx_notification_protocol_version` for the protocol in the [Service](https://www.twilio.com/docs/notify/api/service-resource). The current version is `\\\"3\\\"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed.
|
||||
:param credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applies to only `apn`, `fcm`, and `gcm` type Bindings.
|
||||
:param endpoint: Deprecated.
|
||||
|
||||
:returns: The created BindingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"BindingType": binding_type,
|
||||
"Address": address,
|
||||
"Tag": serialize.map(tag, lambda e: e),
|
||||
"NotificationProtocolVersion": notification_protocol_version,
|
||||
"CredentialSid": credential_sid,
|
||||
"Endpoint": endpoint,
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BindingInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
identity: str,
|
||||
binding_type: "BindingInstance.BindingType",
|
||||
address: str,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
notification_protocol_version: Union[str, object] = values.unset,
|
||||
credential_sid: Union[str, object] = values.unset,
|
||||
endpoint: Union[str, object] = values.unset,
|
||||
) -> BindingInstance:
|
||||
"""
|
||||
Asynchronously create the BindingInstance
|
||||
|
||||
:param identity: The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Up to 20 Bindings can be created for the same Identity in a given Service.
|
||||
:param binding_type:
|
||||
:param address: The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format.
|
||||
:param tag: A tag that can be used to select the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 20 tags.
|
||||
:param notification_protocol_version: The protocol version to use to send the notification. This defaults to the value of `default_xxxx_notification_protocol_version` for the protocol in the [Service](https://www.twilio.com/docs/notify/api/service-resource). The current version is `\\\"3\\\"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed.
|
||||
:param credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applies to only `apn`, `fcm`, and `gcm` type Bindings.
|
||||
:param endpoint: Deprecated.
|
||||
|
||||
:returns: The created BindingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Identity": identity,
|
||||
"BindingType": binding_type,
|
||||
"Address": address,
|
||||
"Tag": serialize.map(tag, lambda e: e),
|
||||
"NotificationProtocolVersion": notification_protocol_version,
|
||||
"CredentialSid": credential_sid,
|
||||
"Endpoint": endpoint,
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return BindingInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def stream(
|
||||
self,
|
||||
start_date: Union[date, object] = values.unset,
|
||||
end_date: Union[date, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> Iterator[BindingInstance]:
|
||||
"""
|
||||
Streams BindingInstance 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 date start_date: Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param date end_date: Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param List[str] identity: The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read.
|
||||
:param List[str] tag: Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
identity=identity,
|
||||
tag=tag,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream(page, limits["limit"])
|
||||
|
||||
async def stream_async(
|
||||
self,
|
||||
start_date: Union[date, object] = values.unset,
|
||||
end_date: Union[date, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> AsyncIterator[BindingInstance]:
|
||||
"""
|
||||
Asynchronously streams BindingInstance 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 date start_date: Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param date end_date: Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param List[str] identity: The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read.
|
||||
:param List[str] tag: Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
identity=identity,
|
||||
tag=tag,
|
||||
page_size=limits["page_size"],
|
||||
)
|
||||
|
||||
return self._version.stream_async(page, limits["limit"])
|
||||
|
||||
def list(
|
||||
self,
|
||||
start_date: Union[date, object] = values.unset,
|
||||
end_date: Union[date, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[BindingInstance]:
|
||||
"""
|
||||
Lists BindingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date start_date: Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param date end_date: Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param List[str] identity: The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read.
|
||||
:param List[str] tag: Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
identity=identity,
|
||||
tag=tag,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
)
|
||||
|
||||
async def list_async(
|
||||
self,
|
||||
start_date: Union[date, object] = values.unset,
|
||||
end_date: Union[date, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
limit: Optional[int] = None,
|
||||
page_size: Optional[int] = None,
|
||||
) -> List[BindingInstance]:
|
||||
"""
|
||||
Asynchronously lists BindingInstance records from the API as a list.
|
||||
Unlike stream(), this operation is eager and will load `limit` records into
|
||||
memory before returning.
|
||||
|
||||
:param date start_date: Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param date end_date: Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param List[str] identity: The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read.
|
||||
:param List[str] tag: Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
|
||||
: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(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
identity=identity,
|
||||
tag=tag,
|
||||
limit=limit,
|
||||
page_size=page_size,
|
||||
)
|
||||
]
|
||||
|
||||
def page(
|
||||
self,
|
||||
start_date: Union[date, object] = values.unset,
|
||||
end_date: Union[date, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[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,
|
||||
) -> BindingPage:
|
||||
"""
|
||||
Retrieve a single page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param start_date: Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param end_date: Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param identity: The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read.
|
||||
:param tag: Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
|
||||
: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 BindingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": serialize.iso8601_date(start_date),
|
||||
"EndDate": serialize.iso8601_date(end_date),
|
||||
"Identity": serialize.map(identity, lambda e: e),
|
||||
"Tag": serialize.map(tag, lambda e: e),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = self._version.page(method="GET", uri=self._uri, params=data)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
async def page_async(
|
||||
self,
|
||||
start_date: Union[date, object] = values.unset,
|
||||
end_date: Union[date, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[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,
|
||||
) -> BindingPage:
|
||||
"""
|
||||
Asynchronously retrieve a single page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param start_date: Only include usage that has occurred on or after this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param end_date: Only include usage that occurred on or before this date. Specify the date in GMT and format as `YYYY-MM-DD`.
|
||||
:param identity: The [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value of the resources to read.
|
||||
:param tag: Only list Bindings that have all of the specified Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
|
||||
: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 BindingInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"StartDate": serialize.iso8601_date(start_date),
|
||||
"EndDate": serialize.iso8601_date(end_date),
|
||||
"Identity": serialize.map(identity, lambda e: e),
|
||||
"Tag": serialize.map(tag, lambda e: e),
|
||||
"PageToken": page_token,
|
||||
"Page": page_number,
|
||||
"PageSize": page_size,
|
||||
}
|
||||
)
|
||||
|
||||
response = await self._version.page_async(
|
||||
method="GET", uri=self._uri, params=data
|
||||
)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
def get_page(self, target_url: str) -> BindingPage:
|
||||
"""
|
||||
Retrieve a specific page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of BindingInstance
|
||||
"""
|
||||
response = self._version.domain.twilio.request("GET", target_url)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
async def get_page_async(self, target_url: str) -> BindingPage:
|
||||
"""
|
||||
Asynchronously retrieve a specific page of BindingInstance records from the API.
|
||||
Request is executed immediately
|
||||
|
||||
:param target_url: API-generated URL for the requested results page
|
||||
|
||||
:returns: Page of BindingInstance
|
||||
"""
|
||||
response = await self._version.domain.twilio.request_async("GET", target_url)
|
||||
return BindingPage(self._version, response, self._solution)
|
||||
|
||||
def get(self, sid: str) -> BindingContext:
|
||||
"""
|
||||
Constructs a BindingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Binding resource to fetch.
|
||||
"""
|
||||
return BindingContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __call__(self, sid: str) -> BindingContext:
|
||||
"""
|
||||
Constructs a BindingContext
|
||||
|
||||
:param sid: The Twilio-provided string that uniquely identifies the Binding resource to fetch.
|
||||
"""
|
||||
return BindingContext(
|
||||
self._version, service_sid=self._solution["service_sid"], sid=sid
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.BindingList>"
|
||||
@@ -0,0 +1,276 @@
|
||||
r"""
|
||||
This code was generated by
|
||||
___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
||||
| | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
||||
| |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
||||
|
||||
Twilio - Notify
|
||||
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_resource import InstanceResource
|
||||
from twilio.base.list_resource import ListResource
|
||||
from twilio.base.version import Version
|
||||
|
||||
|
||||
class NotificationInstance(InstanceResource):
|
||||
class Priority(object):
|
||||
HIGH = "high"
|
||||
LOW = "low"
|
||||
|
||||
"""
|
||||
:ivar sid: The unique string that we created to identify the Notification resource.
|
||||
:ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Notification resource.
|
||||
:ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/notify/api/service-resource) the resource is associated with.
|
||||
: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 identities: The list of `identity` values of the Users to notify. We will attempt to deliver notifications only to Bindings with an identity in this list.
|
||||
:ivar tags: The tags that select the Bindings to notify. Notifications will be attempted only to Bindings that have all of the tags listed in this property.
|
||||
:ivar segments: The list of Segments to notify. The [Segment](https://www.twilio.com/docs/notify/api/segment-resource) resource is deprecated. Use the `tags` property, instead.
|
||||
:ivar priority:
|
||||
:ivar ttl: How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property.
|
||||
:ivar title: The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices.
|
||||
:ivar body: The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.
|
||||
:ivar sound: The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property.
|
||||
:ivar action: The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels.
|
||||
:ivar data: The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels.
|
||||
:ivar apn: The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.
|
||||
:ivar gcm: The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.
|
||||
:ivar fcm: The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel.
|
||||
:ivar sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/api/message-resource) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array.
|
||||
:ivar facebook_messenger: Deprecated.
|
||||
:ivar alexa: Deprecated.
|
||||
"""
|
||||
|
||||
def __init__(self, version: Version, payload: Dict[str, Any], service_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.date_created: Optional[datetime] = deserialize.iso8601_datetime(
|
||||
payload.get("date_created")
|
||||
)
|
||||
self.identities: Optional[List[str]] = payload.get("identities")
|
||||
self.tags: Optional[List[str]] = payload.get("tags")
|
||||
self.segments: Optional[List[str]] = payload.get("segments")
|
||||
self.priority: Optional["NotificationInstance.Priority"] = payload.get(
|
||||
"priority"
|
||||
)
|
||||
self.ttl: Optional[int] = deserialize.integer(payload.get("ttl"))
|
||||
self.title: Optional[str] = payload.get("title")
|
||||
self.body: Optional[str] = payload.get("body")
|
||||
self.sound: Optional[str] = payload.get("sound")
|
||||
self.action: Optional[str] = payload.get("action")
|
||||
self.data: Optional[Dict[str, object]] = payload.get("data")
|
||||
self.apn: Optional[Dict[str, object]] = payload.get("apn")
|
||||
self.gcm: Optional[Dict[str, object]] = payload.get("gcm")
|
||||
self.fcm: Optional[Dict[str, object]] = payload.get("fcm")
|
||||
self.sms: Optional[Dict[str, object]] = payload.get("sms")
|
||||
self.facebook_messenger: Optional[Dict[str, object]] = payload.get(
|
||||
"facebook_messenger"
|
||||
)
|
||||
self.alexa: Optional[Dict[str, object]] = payload.get("alexa")
|
||||
|
||||
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.Notify.V1.NotificationInstance {}>".format(context)
|
||||
|
||||
|
||||
class NotificationList(ListResource):
|
||||
def __init__(self, version: Version, service_sid: str):
|
||||
"""
|
||||
Initialize the NotificationList
|
||||
|
||||
:param version: Version that contains the resource
|
||||
:param service_sid: The SID of the [Service](https://www.twilio.com/docs/notify/api/service-resource) to create the resource under.
|
||||
|
||||
"""
|
||||
super().__init__(version)
|
||||
|
||||
# Path Solution
|
||||
self._solution = {
|
||||
"service_sid": service_sid,
|
||||
}
|
||||
self._uri = "/Services/{service_sid}/Notifications".format(**self._solution)
|
||||
|
||||
def create(
|
||||
self,
|
||||
body: Union[str, object] = values.unset,
|
||||
priority: Union["NotificationInstance.Priority", object] = values.unset,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
title: Union[str, object] = values.unset,
|
||||
sound: Union[str, object] = values.unset,
|
||||
action: Union[str, object] = values.unset,
|
||||
data: Union[object, object] = values.unset,
|
||||
apn: Union[object, object] = values.unset,
|
||||
gcm: Union[object, object] = values.unset,
|
||||
sms: Union[object, object] = values.unset,
|
||||
facebook_messenger: Union[object, object] = values.unset,
|
||||
fcm: Union[object, object] = values.unset,
|
||||
segment: Union[List[str], object] = values.unset,
|
||||
alexa: Union[object, object] = values.unset,
|
||||
to_binding: Union[List[str], object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
) -> NotificationInstance:
|
||||
"""
|
||||
Create the NotificationInstance
|
||||
|
||||
:param body: The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.
|
||||
:param priority:
|
||||
:param ttl: How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property.
|
||||
:param title: The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices.
|
||||
:param sound: The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property.
|
||||
:param action: The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels.
|
||||
:param data: The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels.
|
||||
:param apn: The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.
|
||||
:param gcm: The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. See the [GCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref).
|
||||
:param sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/send-messages) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array.
|
||||
:param facebook_messenger: Deprecated.
|
||||
:param fcm: The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel.
|
||||
:param segment: The Segment resource is deprecated. Use the `tag` parameter, instead.
|
||||
:param alexa: Deprecated.
|
||||
:param to_binding: The destination address specified as a JSON string. Multiple `to_binding` parameters can be included but the total size of the request entity should not exceed 1MB. This is typically sufficient for 10,000 phone numbers.
|
||||
:param delivery_callback_url: URL to send webhooks.
|
||||
:param identity: The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Delivery will be attempted only to Bindings with an Identity in this list. No more than 20 items are allowed in this list.
|
||||
:param tag: A tag that selects the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 5 tags. The implicit tag `all` is available to notify all Bindings in a Service instance. Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger` are available to notify all Bindings in a specific channel.
|
||||
|
||||
:returns: The created NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Body": body,
|
||||
"Priority": priority,
|
||||
"Ttl": ttl,
|
||||
"Title": title,
|
||||
"Sound": sound,
|
||||
"Action": action,
|
||||
"Data": serialize.object(data),
|
||||
"Apn": serialize.object(apn),
|
||||
"Gcm": serialize.object(gcm),
|
||||
"Sms": serialize.object(sms),
|
||||
"FacebookMessenger": serialize.object(facebook_messenger),
|
||||
"Fcm": serialize.object(fcm),
|
||||
"Segment": serialize.map(segment, lambda e: e),
|
||||
"Alexa": serialize.object(alexa),
|
||||
"ToBinding": serialize.map(to_binding, lambda e: e),
|
||||
"DeliveryCallbackUrl": delivery_callback_url,
|
||||
"Identity": serialize.map(identity, lambda e: e),
|
||||
"Tag": serialize.map(tag, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = self._version.create(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
async def create_async(
|
||||
self,
|
||||
body: Union[str, object] = values.unset,
|
||||
priority: Union["NotificationInstance.Priority", object] = values.unset,
|
||||
ttl: Union[int, object] = values.unset,
|
||||
title: Union[str, object] = values.unset,
|
||||
sound: Union[str, object] = values.unset,
|
||||
action: Union[str, object] = values.unset,
|
||||
data: Union[object, object] = values.unset,
|
||||
apn: Union[object, object] = values.unset,
|
||||
gcm: Union[object, object] = values.unset,
|
||||
sms: Union[object, object] = values.unset,
|
||||
facebook_messenger: Union[object, object] = values.unset,
|
||||
fcm: Union[object, object] = values.unset,
|
||||
segment: Union[List[str], object] = values.unset,
|
||||
alexa: Union[object, object] = values.unset,
|
||||
to_binding: Union[List[str], object] = values.unset,
|
||||
delivery_callback_url: Union[str, object] = values.unset,
|
||||
identity: Union[List[str], object] = values.unset,
|
||||
tag: Union[List[str], object] = values.unset,
|
||||
) -> NotificationInstance:
|
||||
"""
|
||||
Asynchronously create the NotificationInstance
|
||||
|
||||
:param body: The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.
|
||||
:param priority:
|
||||
:param ttl: How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property.
|
||||
:param title: The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices.
|
||||
:param sound: The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`. For APNS, this translates to `aps.sound`. SMS does not support this property.
|
||||
:param action: The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels.
|
||||
:param data: The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels.
|
||||
:param apn: The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed.
|
||||
:param gcm: The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. See the [GCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref).
|
||||
:param sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/send-messages) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array.
|
||||
:param facebook_messenger: Deprecated.
|
||||
:param fcm: The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel.
|
||||
:param segment: The Segment resource is deprecated. Use the `tag` parameter, instead.
|
||||
:param alexa: Deprecated.
|
||||
:param to_binding: The destination address specified as a JSON string. Multiple `to_binding` parameters can be included but the total size of the request entity should not exceed 1MB. This is typically sufficient for 10,000 phone numbers.
|
||||
:param delivery_callback_url: URL to send webhooks.
|
||||
:param identity: The `identity` value that uniquely identifies the new resource's [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/notify/api/service-resource). Delivery will be attempted only to Bindings with an Identity in this list. No more than 20 items are allowed in this list.
|
||||
:param tag: A tag that selects the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 5 tags. The implicit tag `all` is available to notify all Bindings in a Service instance. Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger` are available to notify all Bindings in a specific channel.
|
||||
|
||||
:returns: The created NotificationInstance
|
||||
"""
|
||||
data = values.of(
|
||||
{
|
||||
"Body": body,
|
||||
"Priority": priority,
|
||||
"Ttl": ttl,
|
||||
"Title": title,
|
||||
"Sound": sound,
|
||||
"Action": action,
|
||||
"Data": serialize.object(data),
|
||||
"Apn": serialize.object(apn),
|
||||
"Gcm": serialize.object(gcm),
|
||||
"Sms": serialize.object(sms),
|
||||
"FacebookMessenger": serialize.object(facebook_messenger),
|
||||
"Fcm": serialize.object(fcm),
|
||||
"Segment": serialize.map(segment, lambda e: e),
|
||||
"Alexa": serialize.object(alexa),
|
||||
"ToBinding": serialize.map(to_binding, lambda e: e),
|
||||
"DeliveryCallbackUrl": delivery_callback_url,
|
||||
"Identity": serialize.map(identity, lambda e: e),
|
||||
"Tag": serialize.map(tag, lambda e: e),
|
||||
}
|
||||
)
|
||||
|
||||
payload = await self._version.create_async(
|
||||
method="POST",
|
||||
uri=self._uri,
|
||||
data=data,
|
||||
)
|
||||
|
||||
return NotificationInstance(
|
||||
self._version, payload, service_sid=self._solution["service_sid"]
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
Provide a friendly representation
|
||||
|
||||
:returns: Machine friendly representation
|
||||
"""
|
||||
return "<Twilio.Notify.V1.NotificationList>"
|
||||
Reference in New Issue
Block a user