diff --git a/twilio/rest/api/v2010/account/conference/__init__.py b/twilio/rest/api/v2010/account/conference/__init__.py index 9edc8ce21..03cc250b7 100644 --- a/twilio/rest/api/v2010/account/conference/__init__.py +++ b/twilio/rest/api/v2010/account/conference/__init__.py @@ -642,7 +642,7 @@ def stream( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -693,7 +693,7 @@ async def stream_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -742,7 +742,7 @@ def stream_with_http_info( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -792,7 +792,7 @@ async def stream_with_http_info_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -843,7 +843,7 @@ def list( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -894,7 +894,7 @@ async def list_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -945,7 +945,7 @@ def list_with_http_info( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -994,7 +994,7 @@ async def list_with_http_info_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -1044,7 +1044,7 @@ def page( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -1101,7 +1101,7 @@ async def page_async( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -1158,7 +1158,7 @@ def page_with_http_info( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 @@ -1216,7 +1216,7 @@ async def page_with_http_info_async( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :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 diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index c0673c70a..13eeb8521 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -217,8 +217,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -244,8 +244,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -692,63 +692,63 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = ( ContentList.TwilioText(payload.get("twilio/text")) - if payload.get("twilio/text") is not None - else None + if isinstance(payload.get("twilio/text"), dict) + else payload.get("twilio/text") ) self.twilio_media: Optional[ContentList.TwilioMedia] = ( ContentList.TwilioMedia(payload.get("twilio/media")) - if payload.get("twilio/media") is not None - else None + if isinstance(payload.get("twilio/media"), dict) + else payload.get("twilio/media") ) self.twilio_location: Optional[ContentList.TwilioLocation] = ( ContentList.TwilioLocation(payload.get("twilio/location")) - if payload.get("twilio/location") is not None - else None + if isinstance(payload.get("twilio/location"), dict) + else payload.get("twilio/location") ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( ContentList.TwilioListPicker(payload.get("twilio/list-picker")) - if payload.get("twilio/list-picker") is not None - else None + if isinstance(payload.get("twilio/list-picker"), dict) + else payload.get("twilio/list-picker") ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) - if payload.get("twilio/call-to-action") is not None - else None + if isinstance(payload.get("twilio/call-to-action"), dict) + else payload.get("twilio/call-to-action") ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) - if payload.get("twilio/quick-reply") is not None - else None + if isinstance(payload.get("twilio/quick-reply"), dict) + else payload.get("twilio/quick-reply") ) self.twilio_card: Optional[ContentList.TwilioCard] = ( ContentList.TwilioCard(payload.get("twilio/card")) - if payload.get("twilio/card") is not None - else None + if isinstance(payload.get("twilio/card"), dict) + else payload.get("twilio/card") ) self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( ContentList.TwilioCatalog(payload.get("twilio/catalog")) - if payload.get("twilio/catalog") is not None - else None + if isinstance(payload.get("twilio/catalog"), dict) + else payload.get("twilio/catalog") ) self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( ContentList.TwilioCarousel(payload.get("twilio/carousel")) - if payload.get("twilio/carousel") is not None - else None + if isinstance(payload.get("twilio/carousel"), dict) + else payload.get("twilio/carousel") ) self.twilio_flows: Optional[ContentList.TwilioFlows] = ( ContentList.TwilioFlows(payload.get("twilio/flows")) - if payload.get("twilio/flows") is not None - else None + if isinstance(payload.get("twilio/flows"), dict) + else payload.get("twilio/flows") ) self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( ContentList.TwilioSchedule(payload.get("twilio/schedule")) - if payload.get("twilio/schedule") is not None - else None + if isinstance(payload.get("twilio/schedule"), dict) + else payload.get("twilio/schedule") ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( ContentList.WhatsappCard(payload.get("whatsapp/card")) - if payload.get("whatsapp/card") is not None - else None + if isinstance(payload.get("whatsapp/card"), dict) + else payload.get("whatsapp/card") ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication @@ -756,13 +756,13 @@ def __init__(self, payload: Dict[str, Any]): ContentList.WhatsappAuthentication( payload.get("whatsapp/authentication") ) - if payload.get("whatsapp/authentication") is not None - else None + if isinstance(payload.get("whatsapp/authentication"), dict) + else payload.get("whatsapp/authentication") ) self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( ContentList.WhatsappFlows(payload.get("whatsapp/flows")) - if payload.get("whatsapp/flows") is not None - else None + if isinstance(payload.get("whatsapp/flows"), dict) + else payload.get("whatsapp/flows") ) def to_dict(self): @@ -1376,8 +1376,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -1403,8 +1403,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -1851,63 +1851,63 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = ( ContentList.TwilioText(payload.get("twilio/text")) - if payload.get("twilio/text") is not None - else None + if isinstance(payload.get("twilio/text"), dict) + else payload.get("twilio/text") ) self.twilio_media: Optional[ContentList.TwilioMedia] = ( ContentList.TwilioMedia(payload.get("twilio/media")) - if payload.get("twilio/media") is not None - else None + if isinstance(payload.get("twilio/media"), dict) + else payload.get("twilio/media") ) self.twilio_location: Optional[ContentList.TwilioLocation] = ( ContentList.TwilioLocation(payload.get("twilio/location")) - if payload.get("twilio/location") is not None - else None + if isinstance(payload.get("twilio/location"), dict) + else payload.get("twilio/location") ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( ContentList.TwilioListPicker(payload.get("twilio/list-picker")) - if payload.get("twilio/list-picker") is not None - else None + if isinstance(payload.get("twilio/list-picker"), dict) + else payload.get("twilio/list-picker") ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) - if payload.get("twilio/call-to-action") is not None - else None + if isinstance(payload.get("twilio/call-to-action"), dict) + else payload.get("twilio/call-to-action") ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) - if payload.get("twilio/quick-reply") is not None - else None + if isinstance(payload.get("twilio/quick-reply"), dict) + else payload.get("twilio/quick-reply") ) self.twilio_card: Optional[ContentList.TwilioCard] = ( ContentList.TwilioCard(payload.get("twilio/card")) - if payload.get("twilio/card") is not None - else None + if isinstance(payload.get("twilio/card"), dict) + else payload.get("twilio/card") ) self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( ContentList.TwilioCatalog(payload.get("twilio/catalog")) - if payload.get("twilio/catalog") is not None - else None + if isinstance(payload.get("twilio/catalog"), dict) + else payload.get("twilio/catalog") ) self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( ContentList.TwilioCarousel(payload.get("twilio/carousel")) - if payload.get("twilio/carousel") is not None - else None + if isinstance(payload.get("twilio/carousel"), dict) + else payload.get("twilio/carousel") ) self.twilio_flows: Optional[ContentList.TwilioFlows] = ( ContentList.TwilioFlows(payload.get("twilio/flows")) - if payload.get("twilio/flows") is not None - else None + if isinstance(payload.get("twilio/flows"), dict) + else payload.get("twilio/flows") ) self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( ContentList.TwilioSchedule(payload.get("twilio/schedule")) - if payload.get("twilio/schedule") is not None - else None + if isinstance(payload.get("twilio/schedule"), dict) + else payload.get("twilio/schedule") ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( ContentList.WhatsappCard(payload.get("whatsapp/card")) - if payload.get("whatsapp/card") is not None - else None + if isinstance(payload.get("whatsapp/card"), dict) + else payload.get("whatsapp/card") ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication @@ -1915,13 +1915,13 @@ def __init__(self, payload: Dict[str, Any]): ContentList.WhatsappAuthentication( payload.get("whatsapp/authentication") ) - if payload.get("whatsapp/authentication") is not None - else None + if isinstance(payload.get("whatsapp/authentication"), dict) + else payload.get("whatsapp/authentication") ) self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( ContentList.WhatsappFlows(payload.get("whatsapp/flows")) - if payload.get("whatsapp/flows") is not None - else None + if isinstance(payload.get("whatsapp/flows"), dict) + else payload.get("whatsapp/flows") ) def to_dict(self): @@ -2627,8 +2627,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -2654,8 +2654,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -3102,63 +3102,63 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = ( ContentList.TwilioText(payload.get("twilio/text")) - if payload.get("twilio/text") is not None - else None + if isinstance(payload.get("twilio/text"), dict) + else payload.get("twilio/text") ) self.twilio_media: Optional[ContentList.TwilioMedia] = ( ContentList.TwilioMedia(payload.get("twilio/media")) - if payload.get("twilio/media") is not None - else None + if isinstance(payload.get("twilio/media"), dict) + else payload.get("twilio/media") ) self.twilio_location: Optional[ContentList.TwilioLocation] = ( ContentList.TwilioLocation(payload.get("twilio/location")) - if payload.get("twilio/location") is not None - else None + if isinstance(payload.get("twilio/location"), dict) + else payload.get("twilio/location") ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( ContentList.TwilioListPicker(payload.get("twilio/list-picker")) - if payload.get("twilio/list-picker") is not None - else None + if isinstance(payload.get("twilio/list-picker"), dict) + else payload.get("twilio/list-picker") ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) - if payload.get("twilio/call-to-action") is not None - else None + if isinstance(payload.get("twilio/call-to-action"), dict) + else payload.get("twilio/call-to-action") ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) - if payload.get("twilio/quick-reply") is not None - else None + if isinstance(payload.get("twilio/quick-reply"), dict) + else payload.get("twilio/quick-reply") ) self.twilio_card: Optional[ContentList.TwilioCard] = ( ContentList.TwilioCard(payload.get("twilio/card")) - if payload.get("twilio/card") is not None - else None + if isinstance(payload.get("twilio/card"), dict) + else payload.get("twilio/card") ) self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( ContentList.TwilioCatalog(payload.get("twilio/catalog")) - if payload.get("twilio/catalog") is not None - else None + if isinstance(payload.get("twilio/catalog"), dict) + else payload.get("twilio/catalog") ) self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( ContentList.TwilioCarousel(payload.get("twilio/carousel")) - if payload.get("twilio/carousel") is not None - else None + if isinstance(payload.get("twilio/carousel"), dict) + else payload.get("twilio/carousel") ) self.twilio_flows: Optional[ContentList.TwilioFlows] = ( ContentList.TwilioFlows(payload.get("twilio/flows")) - if payload.get("twilio/flows") is not None - else None + if isinstance(payload.get("twilio/flows"), dict) + else payload.get("twilio/flows") ) self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( ContentList.TwilioSchedule(payload.get("twilio/schedule")) - if payload.get("twilio/schedule") is not None - else None + if isinstance(payload.get("twilio/schedule"), dict) + else payload.get("twilio/schedule") ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( ContentList.WhatsappCard(payload.get("whatsapp/card")) - if payload.get("whatsapp/card") is not None - else None + if isinstance(payload.get("whatsapp/card"), dict) + else payload.get("whatsapp/card") ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication @@ -3166,13 +3166,13 @@ def __init__(self, payload: Dict[str, Any]): ContentList.WhatsappAuthentication( payload.get("whatsapp/authentication") ) - if payload.get("whatsapp/authentication") is not None - else None + if isinstance(payload.get("whatsapp/authentication"), dict) + else payload.get("whatsapp/authentication") ) self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( ContentList.WhatsappFlows(payload.get("whatsapp/flows")) - if payload.get("whatsapp/flows") is not None - else None + if isinstance(payload.get("whatsapp/flows"), dict) + else payload.get("whatsapp/flows") ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/action.py b/twilio/rest/conversations/v2/action.py index b09e961c2..edc1b95d9 100644 --- a/twilio/rest/conversations/v2/action.py +++ b/twilio/rest/conversations/v2/action.py @@ -41,13 +41,14 @@ class ConversationsV2Channel(object): """ :ivar id: Unique identifier for this Action. - :ivar type: The type of action. Accepted values: SEND_MESSAGE. + :ivar type: The type of action: action-send-message or action-start-flow. :ivar status: :ivar conversation_id: The conversation this action belongs to. - :ivar related: Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED) + :ivar related: Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED) For START_FLOW: - executionSid: The Studio Flow execution SID (present when COMPLETED) :ivar created_at: Timestamp when the action was created. :ivar updated_at: Timestamp when the action was last updated. :ivar completed_at: Timestamp when the action reached a terminal status. + :ivar failure_reason: Human-readable failure reason. Null unless status is FAILED. """ def __init__( @@ -75,6 +76,7 @@ def __init__( self.completed_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("completedAt") ) + self.failure_reason: Optional[str] = payload.get("failureReason") # Only set _solution if path params are provided (not None) if conversation_id is not None or action_id is not None: @@ -331,8 +333,8 @@ def __init__(self, payload: Dict[str, Any]): self._from: Optional[ActionList.ConversationsV2SendMessageParticipant] = ( ActionList.ConversationsV2SendMessageParticipant(payload.get("from")) - if payload.get("from") is not None - else None + if isinstance(payload.get("from"), dict) + else payload.get("from") ) self.to: Optional[ List[ActionList.ConversationsV2SendMessageParticipant] @@ -350,8 +352,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.content: Optional[ActionList.ConversationsV2SendMessageContent] = ( ActionList.ConversationsV2SendMessageContent(payload.get("content")) - if payload.get("content") is not None - else None + if isinstance(payload.get("content"), dict) + else payload.get("content") ) self.channel_settings: Optional[Dict[str, Dict[str, object]]] = payload.get( "channelSettings" @@ -376,8 +378,8 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional[str] = payload.get("type") self.payload: Optional[ActionList.ConversationsV2SendMessagePayload] = ( ActionList.ConversationsV2SendMessagePayload(payload.get("payload")) - if payload.get("payload") is not None - else None + if isinstance(payload.get("payload"), dict) + else payload.get("payload") ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/communication.py b/twilio/rest/conversations/v2/communication.py index 299490962..770ef7e76 100644 --- a/twilio/rest/conversations/v2/communication.py +++ b/twilio/rest/conversations/v2/communication.py @@ -389,6 +389,7 @@ class CreateCommunicationInConversationRequest(object): :ivar author: :ivar content: :ivar channel_id: + :ivar resource_id: External resource identifier for this Communication (e.g. MessageSid for SMS/RCS/WhatsApp, TranscriptionSid + MessageIndex for Voice). If a Communication with the same resourceId already exists in the Conversation, it is updated instead of a new one being created. :ivar recipients: :ivar occurred_at: Timestamp when this Communication occurred. If omitted, the server uses the current time. """ @@ -401,8 +402,8 @@ def __init__(self, payload: Dict[str, Any]): CommunicationList.CreateCommunicationInConversationRequestAuthor( payload.get("author") ) - if payload.get("author") is not None - else None + if isinstance(payload.get("author"), dict) + else payload.get("author") ) self.content: Optional[ CommunicationList.CreateCommunicationInConversationRequestContent @@ -410,10 +411,11 @@ def __init__(self, payload: Dict[str, Any]): CommunicationList.CreateCommunicationInConversationRequestContent( payload.get("content") ) - if payload.get("content") is not None - else None + if isinstance(payload.get("content"), dict) + else payload.get("content") ) self.channel_id: Optional[str] = payload.get("channelId") + self.resource_id: Optional[str] = payload.get("resourceId") self.recipients: Optional[ List[ CommunicationList.CreateCommunicationInConversationRequestRecipients @@ -439,6 +441,7 @@ def to_dict(self): "author": self.author.to_dict() if self.author is not None else None, "content": self.content.to_dict() if self.content is not None else None, "channelId": self.channel_id, + "resourceId": self.resource_id, "recipients": ( [recipients.to_dict() for recipients in self.recipients] if self.recipients is not None @@ -484,8 +487,8 @@ def __init__(self, payload: Dict[str, Any]): CommunicationList.ContentTranscriptionTranscription( payload.get("transcription") ) - if payload.get("transcription") is not None - else None + if isinstance(payload.get("transcription"), dict) + else payload.get("transcription") ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/configuration.py b/twilio/rest/conversations/v2/configuration.py index 84a67a9b4..8b17f29c8 100644 --- a/twilio/rest/conversations/v2/configuration.py +++ b/twilio/rest/conversations/v2/configuration.py @@ -35,8 +35,6 @@ class ConversationsV2ConversationGroupingType(object): ) """ - :ivar status_url: URL to poll for operation status. - :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId :ivar id: Configuration ID. :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. :ivar description: Human-readable description for the Configuration. Allows spaces and special characters, typically limited to a paragraph of text. This serves as a descriptive field rather than just a name. @@ -45,11 +43,15 @@ class ConversationsV2ConversationGroupingType(object): :ivar channel_settings: Channel-specific configuration settings by channel type. Keys should be valid channel types (`VOICE`, `SMS`, `RCS`, `WHATSAPP`, `CHAT`). :ivar status_callbacks: List of default webhook configurations applied to Conversations under this Configuration. :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. + :ivar trait_extraction_strategy_ids: A list of Trait Extraction Strategy IDs. + :ivar observation_extraction_strategy_ids: A list of Observation Extraction Strategy IDs. :ivar memory_extraction_enabled: Whether memory extraction is enabled for conversations under this configuration. Defaults to false. :ivar conversations_v1_bridge: :ivar created_at: Timestamp when this Configuration was created. :ivar updated_at: Timestamp when this Configuration was last updated. :ivar version: Version number used for optimistic locking. + :ivar status_url: URL to poll for operation status. + :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId """ def __init__( @@ -57,8 +59,6 @@ def __init__( ): super().__init__(version) - self.status_url: Optional[str] = payload.get("statusUrl") - self.related: Optional[Dict[str, str]] = payload.get("related") self.id: Optional[str] = payload.get("id") self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") @@ -75,6 +75,12 @@ def __init__( self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) + self.trait_extraction_strategy_ids: Optional[List[str]] = payload.get( + "traitExtractionStrategyIds" + ) + self.observation_extraction_strategy_ids: Optional[List[str]] = payload.get( + "observationExtractionStrategyIds" + ) self.memory_extraction_enabled: Optional[bool] = payload.get( "memoryExtractionEnabled" ) @@ -88,6 +94,8 @@ def __init__( payload.get("updatedAt") ) self.version: Optional[int] = payload.get("version") + self.status_url: Optional[str] = payload.get("statusUrl") + self.related: Optional[Dict[str, str]] = payload.get("related") # Only set _solution if path params are provided (not None) if id is not None: @@ -901,8 +909,8 @@ def __init__(self, payload: Dict[str, Any]): self.status_timeouts: Optional[ConversationsV2StatusTimeouts] = ( ConversationsV2StatusTimeouts(payload.get("statusTimeouts")) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[List[ConversationsV2CaptureRule]] = ( [ @@ -1043,8 +1051,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( payload.get("conversationsV1Bridge") ) - if payload.get("conversationsV1Bridge") is not None - else None + if isinstance(payload.get("conversationsV1Bridge"), dict) + else payload.get("conversationsV1Bridge") ) def to_dict(self): @@ -1089,8 +1097,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.CreateConfigurationRequestChannelSettingsValueStatusTimeouts( payload.get("statusTimeouts") ) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[ List[ @@ -1260,8 +1268,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.PatchConfigurationRequestConversationsV1Bridge( payload.get("conversationsV1Bridge") ) - if payload.get("conversationsV1Bridge") is not None - else None + if isinstance(payload.get("conversationsV1Bridge"), dict) + else payload.get("conversationsV1Bridge") ) def to_dict(self): @@ -1306,8 +1314,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( payload.get("statusTimeouts") ) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[ List[ @@ -1424,8 +1432,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( payload.get("conversationsV1Bridge") ) - if payload.get("conversationsV1Bridge") is not None - else None + if isinstance(payload.get("conversationsV1Bridge"), dict) + else payload.get("conversationsV1Bridge") ) def to_dict(self): @@ -1470,8 +1478,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( payload.get("statusTimeouts") ) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[ List[ diff --git a/twilio/rest/conversations/v2/conversation.py b/twilio/rest/conversations/v2/conversation.py index 9b80ae4af..2d3358292 100644 --- a/twilio/rest/conversations/v2/conversation.py +++ b/twilio/rest/conversations/v2/conversation.py @@ -824,8 +824,8 @@ def __init__(self, payload: Dict[str, Any]): self.channel: Optional[ConversationsV2Channel] = ( ConversationsV2Channel(payload.get("channel")) - if payload.get("channel") is not None - else None + if isinstance(payload.get("channel"), dict) + else payload.get("channel") ) self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") @@ -887,8 +887,8 @@ def __init__(self, payload: Dict[str, Any]): ConversationList.CreateConversationWithConfigRequestConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.participants: Optional[ List[ConversationList.CreateConversationWithConfigRequestParticipants] @@ -928,6 +928,8 @@ def to_dict(self): class CreateConversationWithConfigRequestConfiguration(object): """ :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. + :ivar trait_extraction_strategy_ids: A list of Trait Extraction Strategy IDs. + :ivar observation_extraction_strategy_ids: A list of Observation Extraction Strategy IDs. :ivar workflows: The Workflows to associate with this Conversation. Overrides the Configuration's own. """ @@ -936,6 +938,12 @@ def __init__(self, payload: Dict[str, Any]): self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) + self.trait_extraction_strategy_ids: Optional[List[str]] = payload.get( + "traitExtractionStrategyIds" + ) + self.observation_extraction_strategy_ids: Optional[List[str]] = payload.get( + "observationExtractionStrategyIds" + ) self.workflows: Optional[List[ConversationList.ConversationWorkflow]] = ( [ ( @@ -952,6 +960,8 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { "intelligenceConfigurationIds": self.intelligence_configuration_ids, + "traitExtractionStrategyIds": self.trait_extraction_strategy_ids, + "observationExtractionStrategyIds": self.observation_extraction_strategy_ids, "workflows": ( [workflows.to_dict() for workflows in self.workflows] if self.workflows is not None @@ -1041,8 +1051,8 @@ def __init__(self, payload: Dict[str, Any]): ConversationList.PatchConversationByIdRequestConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.metadata: Optional[Dict[str, Optional[str]]] = payload.get("metadata") diff --git a/twilio/rest/iam/v1/o_auth_app.py b/twilio/rest/iam/v1/o_auth_app.py index 67c96df8a..506d1f422 100644 --- a/twilio/rest/iam/v1/o_auth_app.py +++ b/twilio/rest/iam/v1/o_auth_app.py @@ -52,8 +52,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendoroauthappPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -89,8 +89,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -335,8 +335,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendoroauthappPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -372,8 +372,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -657,8 +657,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendoroauthappPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -694,8 +694,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") diff --git a/twilio/rest/insights/v1/call/call_summary.py b/twilio/rest/insights/v1/call/call_summary.py index 4d1e0d94d..628cb7153 100644 --- a/twilio/rest/insights/v1/call/call_summary.py +++ b/twilio/rest/insights/v1/call/call_summary.py @@ -78,7 +78,7 @@ class ProcessingState(object): :ivar client_edge: `object` Contains metrics and properties for the Twilio media gateway of a Client call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sdk_edge: `object` Contains metrics and properties for the SDK sensor library for Client calls. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sip_edge: `object` Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. - :ivar tags: Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality. + :ivar tags: [Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags) that Voice Insights analysis applies to calls. They indicate a condition that may influence the subjective experience of call audio quality. :ivar url: The URL of this resource. :ivar attributes: `object` Attributes capturing call-flow-specific details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#attributes-object) for the object properties. :ivar properties: `object` Contains edge-agnostic call-level details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#properties-object) for the object properties. diff --git a/twilio/rest/insights/v1/call_summaries.py b/twilio/rest/insights/v1/call_summaries.py index 1f66d767e..accf7159c 100644 --- a/twilio/rest/insights/v1/call_summaries.py +++ b/twilio/rest/insights/v1/call_summaries.py @@ -89,7 +89,7 @@ class CallSummaryCrelaySessionState(object): :ivar client_edge: `object` Contains metrics and properties for the Twilio media gateway of a Client call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sdk_edge: `object` Contains metrics and properties for the SDK sensor library for Client calls. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sip_edge: `object` Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. - :ivar tags: Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality. + :ivar tags: [Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags) that Voice Insights analysis applies to calls. They indicate a condition that may influence the subjective experience of call audio quality. :ivar url: The URL of this resource. :ivar attributes: `object` Attributes capturing call-flow-specific details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#attributes-object) for the object properties. :ivar properties: `object` Contains edge-agnostic call-level details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#properties-object) for the object properties. diff --git a/twilio/rest/insights/v2/inbound_report.py b/twilio/rest/insights/v2/inbound_report.py index 18f45a0dd..64ad4d4f3 100644 --- a/twilio/rest/insights/v2/inbound_report.py +++ b/twilio/rest/insights/v2/inbound_report.py @@ -39,8 +39,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ @@ -171,8 +171,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ diff --git a/twilio/rest/insights/v2/outbound_report.py b/twilio/rest/insights/v2/outbound_report.py index c79d3b6f7..d944b639f 100644 --- a/twilio/rest/insights/v2/outbound_report.py +++ b/twilio/rest/insights/v2/outbound_report.py @@ -38,8 +38,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ @@ -136,8 +136,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ diff --git a/twilio/rest/insights/v2/report.py b/twilio/rest/insights/v2/report.py index 1ade17bec..7ed49c093 100644 --- a/twilio/rest/insights/v2/report.py +++ b/twilio/rest/insights/v2/report.py @@ -130,8 +130,8 @@ def __init__(self, payload: Dict[str, Any]): AccountReportKYTOutboundCarrierCalling( payload.get("outbound_carrier_calling") ) - if payload.get("outbound_carrier_calling") is not None - else None + if isinstance(payload.get("outbound_carrier_calling"), dict) + else payload.get("outbound_carrier_calling") ) def to_dict(self): @@ -183,18 +183,18 @@ def __init__(self, payload: Dict[str, Any]): ) self.branded_calling: Optional[BrandedCalling] = ( BrandedCalling(payload.get("branded_calling")) - if payload.get("branded_calling") is not None - else None + if isinstance(payload.get("branded_calling"), dict) + else payload.get("branded_calling") ) self.voice_integrity: Optional[VoiceIntegrity] = ( VoiceIntegrity(payload.get("voice_integrity")) - if payload.get("voice_integrity") is not None - else None + if isinstance(payload.get("voice_integrity"), dict) + else payload.get("voice_integrity") ) self.stir_shaken: Optional[StirShaken] = ( StirShaken(payload.get("stir_shaken")) - if payload.get("stir_shaken") is not None - else None + if isinstance(payload.get("stir_shaken"), dict) + else payload.get("stir_shaken") ) def to_dict(self): @@ -237,13 +237,13 @@ def __init__(self, payload: Dict[str, Any]): self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( AccountReportNetworkIssuesSdk(payload.get("sdk")) - if payload.get("sdk") is not None - else None + if isinstance(payload.get("sdk"), dict) + else payload.get("sdk") ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) - if payload.get("twilio_gateway") is not None - else None + if isinstance(payload.get("twilio_gateway"), dict) + else payload.get("twilio_gateway") ) def to_dict(self): @@ -425,8 +425,8 @@ def __init__(self, payload: Dict[str, Any]): ReportList.InsightsV2CreateAccountReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[ReportList.ReportFilter]] = ( [ @@ -494,18 +494,18 @@ def __init__(self, payload: Dict[str, Any]): self.call_count: Optional[StirShakenCallCount] = ( StirShakenCallCount(payload.get("call_count")) - if payload.get("call_count") is not None - else None + if isinstance(payload.get("call_count"), dict) + else payload.get("call_count") ) self.percentage: Optional[StirShakenPercentage] = ( StirShakenPercentage(payload.get("percentage")) - if payload.get("percentage") is not None - else None + if isinstance(payload.get("percentage"), dict) + else payload.get("percentage") ) self.answer_rate: Optional[StirShakenAnswerRate] = ( StirShakenAnswerRate(payload.get("answer_rate")) - if payload.get("answer_rate") is not None - else None + if isinstance(payload.get("answer_rate"), dict) + else payload.get("answer_rate") ) def to_dict(self): @@ -850,8 +850,8 @@ def __init__(self, payload: Dict[str, Any]): AccountReportKYTOutboundCarrierCalling( payload.get("outbound_carrier_calling") ) - if payload.get("outbound_carrier_calling") is not None - else None + if isinstance(payload.get("outbound_carrier_calling"), dict) + else payload.get("outbound_carrier_calling") ) def to_dict(self): @@ -903,18 +903,18 @@ def __init__(self, payload: Dict[str, Any]): ) self.branded_calling: Optional[BrandedCalling] = ( BrandedCalling(payload.get("branded_calling")) - if payload.get("branded_calling") is not None - else None + if isinstance(payload.get("branded_calling"), dict) + else payload.get("branded_calling") ) self.voice_integrity: Optional[VoiceIntegrity] = ( VoiceIntegrity(payload.get("voice_integrity")) - if payload.get("voice_integrity") is not None - else None + if isinstance(payload.get("voice_integrity"), dict) + else payload.get("voice_integrity") ) self.stir_shaken: Optional[StirShaken] = ( StirShaken(payload.get("stir_shaken")) - if payload.get("stir_shaken") is not None - else None + if isinstance(payload.get("stir_shaken"), dict) + else payload.get("stir_shaken") ) def to_dict(self): @@ -957,13 +957,13 @@ def __init__(self, payload: Dict[str, Any]): self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( AccountReportNetworkIssuesSdk(payload.get("sdk")) - if payload.get("sdk") is not None - else None + if isinstance(payload.get("sdk"), dict) + else payload.get("sdk") ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) - if payload.get("twilio_gateway") is not None - else None + if isinstance(payload.get("twilio_gateway"), dict) + else payload.get("twilio_gateway") ) def to_dict(self): @@ -1145,8 +1145,8 @@ def __init__(self, payload: Dict[str, Any]): ReportList.InsightsV2CreateAccountReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[ReportList.ReportFilter]] = ( [ @@ -1214,18 +1214,18 @@ def __init__(self, payload: Dict[str, Any]): self.call_count: Optional[StirShakenCallCount] = ( StirShakenCallCount(payload.get("call_count")) - if payload.get("call_count") is not None - else None + if isinstance(payload.get("call_count"), dict) + else payload.get("call_count") ) self.percentage: Optional[StirShakenPercentage] = ( StirShakenPercentage(payload.get("percentage")) - if payload.get("percentage") is not None - else None + if isinstance(payload.get("percentage"), dict) + else payload.get("percentage") ) self.answer_rate: Optional[StirShakenAnswerRate] = ( StirShakenAnswerRate(payload.get("answer_rate")) - if payload.get("answer_rate") is not None - else None + if isinstance(payload.get("answer_rate"), dict) + else payload.get("answer_rate") ) def to_dict(self): @@ -1590,8 +1590,8 @@ def __init__(self, payload: Dict[str, Any]): AccountReportKYTOutboundCarrierCalling( payload.get("outbound_carrier_calling") ) - if payload.get("outbound_carrier_calling") is not None - else None + if isinstance(payload.get("outbound_carrier_calling"), dict) + else payload.get("outbound_carrier_calling") ) def to_dict(self): @@ -1643,18 +1643,18 @@ def __init__(self, payload: Dict[str, Any]): ) self.branded_calling: Optional[BrandedCalling] = ( BrandedCalling(payload.get("branded_calling")) - if payload.get("branded_calling") is not None - else None + if isinstance(payload.get("branded_calling"), dict) + else payload.get("branded_calling") ) self.voice_integrity: Optional[VoiceIntegrity] = ( VoiceIntegrity(payload.get("voice_integrity")) - if payload.get("voice_integrity") is not None - else None + if isinstance(payload.get("voice_integrity"), dict) + else payload.get("voice_integrity") ) self.stir_shaken: Optional[StirShaken] = ( StirShaken(payload.get("stir_shaken")) - if payload.get("stir_shaken") is not None - else None + if isinstance(payload.get("stir_shaken"), dict) + else payload.get("stir_shaken") ) def to_dict(self): @@ -1697,13 +1697,13 @@ def __init__(self, payload: Dict[str, Any]): self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( AccountReportNetworkIssuesSdk(payload.get("sdk")) - if payload.get("sdk") is not None - else None + if isinstance(payload.get("sdk"), dict) + else payload.get("sdk") ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) - if payload.get("twilio_gateway") is not None - else None + if isinstance(payload.get("twilio_gateway"), dict) + else payload.get("twilio_gateway") ) def to_dict(self): @@ -1885,8 +1885,8 @@ def __init__(self, payload: Dict[str, Any]): ReportList.InsightsV2CreateAccountReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[ReportList.ReportFilter]] = ( [ @@ -1954,18 +1954,18 @@ def __init__(self, payload: Dict[str, Any]): self.call_count: Optional[StirShakenCallCount] = ( StirShakenCallCount(payload.get("call_count")) - if payload.get("call_count") is not None - else None + if isinstance(payload.get("call_count"), dict) + else payload.get("call_count") ) self.percentage: Optional[StirShakenPercentage] = ( StirShakenPercentage(payload.get("percentage")) - if payload.get("percentage") is not None - else None + if isinstance(payload.get("percentage"), dict) + else payload.get("percentage") ) self.answer_rate: Optional[StirShakenAnswerRate] = ( StirShakenAnswerRate(payload.get("answer_rate")) - if payload.get("answer_rate") is not None - else None + if isinstance(payload.get("answer_rate"), dict) + else payload.get("answer_rate") ) def to_dict(self): diff --git a/twilio/rest/insights/v3/custom_field_mapping.py b/twilio/rest/insights/v3/custom_field_mapping.py index 5dc658057..698c562de 100644 --- a/twilio/rest/insights/v3/custom_field_mapping.py +++ b/twilio/rest/insights/v3/custom_field_mapping.py @@ -96,8 +96,8 @@ def __init__(self, payload: Dict[str, Any]): CustomFieldMappingList.IntelligenceOperatorEntityMetadata( payload.get("entityMetadata") ) - if payload.get("entityMetadata") is not None - else None + if isinstance(payload.get("entityMetadata"), dict) + else payload.get("entityMetadata") ) def to_dict(self): @@ -133,8 +133,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.entity_metadata: Optional[IntelligenceOperatorEntityMetadata] = ( IntelligenceOperatorEntityMetadata(payload.get("entityMetadata")) - if payload.get("entityMetadata") is not None - else None + if isinstance(payload.get("entityMetadata"), dict) + else payload.get("entityMetadata") ) self.created_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("createdAt") diff --git a/twilio/rest/insights/v3/query.py b/twilio/rest/insights/v3/query.py index 35b079ccc..44e740de5 100644 --- a/twilio/rest/insights/v3/query.py +++ b/twilio/rest/insights/v3/query.py @@ -62,8 +62,8 @@ def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") self.query: Optional[QueryList.QueryDefinition] = ( QueryList.QueryDefinition(payload.get("query")) - if payload.get("query") is not None - else None + if isinstance(payload.get("query"), dict) + else payload.get("query") ) def to_dict(self): diff --git a/twilio/rest/insights/v3/query_job.py b/twilio/rest/insights/v3/query_job.py index 66c25e084..6827e4afe 100644 --- a/twilio/rest/insights/v3/query_job.py +++ b/twilio/rest/insights/v3/query_job.py @@ -293,8 +293,8 @@ def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") self.query: Optional[QueryList.QueryDefinition] = ( QueryList.QueryDefinition(payload.get("query")) - if payload.get("query") is not None - else None + if isinstance(payload.get("query"), dict) + else payload.get("query") ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/configuration.py b/twilio/rest/intelligence/v3/configuration.py index 882848272..449c7e88f 100644 --- a/twilio/rest/intelligence/v3/configuration.py +++ b/twilio/rest/intelligence/v3/configuration.py @@ -575,13 +575,13 @@ def __init__(self, payload: Dict[str, Any]): self.memory: Optional[ConfigurationList.ContextMemory] = ( ConfigurationList.ContextMemory(payload.get("memory")) - if payload.get("memory") is not None - else None + if isinstance(payload.get("memory"), dict) + else payload.get("memory") ) self.knowledge: Optional[ConfigurationList.ContextKnowledge] = ( ConfigurationList.ContextKnowledge(payload.get("knowledge")) - if payload.get("knowledge") is not None - else None + if isinstance(payload.get("knowledge"), dict) + else payload.get("knowledge") ) def to_dict(self): @@ -711,8 +711,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.context: Optional[ConfigurationList.Context] = ( ConfigurationList.Context(payload.get("context")) - if payload.get("context") is not None - else None + if isinstance(payload.get("context"), dict) + else payload.get("context") ) def to_dict(self): @@ -773,8 +773,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.context: Optional[ConfigurationList.Context] = ( ConfigurationList.Context(payload.get("context")) - if payload.get("context") is not None - else None + if isinstance(payload.get("context"), dict) + else payload.get("context") ) def to_dict(self): @@ -809,8 +809,8 @@ def __init__(self, payload: Dict[str, Any]): self.on: Optional[str] = payload.get("on") self.parameters: Optional[ConfigurationList.TriggerParameters] = ( ConfigurationList.TriggerParameters(payload.get("parameters")) - if payload.get("parameters") is not None - else None + if isinstance(payload.get("parameters"), dict) + else payload.get("parameters") ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/operator.py b/twilio/rest/intelligence/v3/operator.py index 64fc9f1cf..fb1b40f91 100644 --- a/twilio/rest/intelligence/v3/operator.py +++ b/twilio/rest/intelligence/v3/operator.py @@ -645,8 +645,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.context: Optional[OperatorList.OperatorContext] = ( OperatorList.OperatorContext(payload.get("context")) - if payload.get("context") is not None - else None + if isinstance(payload.get("context"), dict) + else payload.get("context") ) self.parameters: Optional[Dict[str, OperatorList.OperatorParameter]] = ( { @@ -693,13 +693,13 @@ def __init__(self, payload: Dict[str, Any]): self.memory: Optional[OperatorList.OperatorContextMemory] = ( OperatorList.OperatorContextMemory(payload.get("memory")) - if payload.get("memory") is not None - else None + if isinstance(payload.get("memory"), dict) + else payload.get("memory") ) self.knowledge: Optional[OperatorList.OperatorContextKnowledge] = ( OperatorList.OperatorContextKnowledge(payload.get("knowledge")) - if payload.get("knowledge") is not None - else None + if isinstance(payload.get("knowledge"), dict) + else payload.get("knowledge") ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/rule_execution.py b/twilio/rest/intelligence/v3/rule_execution.py index 550491f86..833f9a459 100644 --- a/twilio/rest/intelligence/v3/rule_execution.py +++ b/twilio/rest/intelligence/v3/rule_execution.py @@ -70,8 +70,8 @@ def __init__(self, payload: Dict[str, Any]): self.conversation_id: Optional[str] = payload.get("conversationId") self.rule: Optional[RuleExecutionList.RuleOverride] = ( RuleExecutionList.RuleOverride(payload.get("rule")) - if payload.get("rule") is not None - else None + if isinstance(payload.get("rule"), dict) + else payload.get("rule") ) def to_dict(self): diff --git a/twilio/rest/knowledge/v1/knowledge/__init__.py b/twilio/rest/knowledge/v1/knowledge/__init__.py index 568850ebc..96aff9e5a 100644 --- a/twilio/rest/knowledge/v1/knowledge/__init__.py +++ b/twilio/rest/knowledge/v1/knowledge/__init__.py @@ -50,8 +50,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -117,8 +117,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -380,8 +380,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -447,8 +447,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -840,8 +840,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -907,8 +907,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") diff --git a/twilio/rest/knowledge/v2/knowledge.py b/twilio/rest/knowledge/v2/knowledge.py index 1f5fedbe6..f4a934ddb 100644 --- a/twilio/rest/knowledge/v2/knowledge.py +++ b/twilio/rest/knowledge/v2/knowledge.py @@ -632,8 +632,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.source: Optional[KnowledgeList.KnowledgeSourceTypes] = ( KnowledgeList.KnowledgeSourceTypes(payload.get("source")) - if payload.get("source") is not None - else None + if isinstance(payload.get("source"), dict) + else payload.get("source") ) def to_dict(self): diff --git a/twilio/rest/lookups/v2/query.py b/twilio/rest/lookups/v2/query.py index c421107cc..d58702b7b 100644 --- a/twilio/rest/lookups/v2/query.py +++ b/twilio/rest/lookups/v2/query.py @@ -108,18 +108,18 @@ def __init__(self, payload: Dict[str, Any]): self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( QueryList.IdentityMatchParameters(payload.get("identity_match")) - if payload.get("identity_match") is not None - else None + if isinstance(payload.get("identity_match"), dict) + else payload.get("identity_match") ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) - if payload.get("reassigned_number") is not None - else None + if isinstance(payload.get("reassigned_number"), dict) + else payload.get("reassigned_number") ) self.sms_pumping_risk: Optional[QueryList.RiskParameters] = ( QueryList.RiskParameters(payload.get("sms_pumping_risk")) - if payload.get("sms_pumping_risk") is not None - else None + if isinstance(payload.get("sms_pumping_risk"), dict) + else payload.get("sms_pumping_risk") ) def to_dict(self): @@ -307,18 +307,18 @@ def __init__(self, payload: Dict[str, Any]): self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( QueryList.IdentityMatchParameters(payload.get("identity_match")) - if payload.get("identity_match") is not None - else None + if isinstance(payload.get("identity_match"), dict) + else payload.get("identity_match") ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) - if payload.get("reassigned_number") is not None - else None + if isinstance(payload.get("reassigned_number"), dict) + else payload.get("reassigned_number") ) self.sms_pumping_risk: Optional[QueryList.RiskParameters] = ( QueryList.RiskParameters(payload.get("sms_pumping_risk")) - if payload.get("sms_pumping_risk") is not None - else None + if isinstance(payload.get("sms_pumping_risk"), dict) + else payload.get("sms_pumping_risk") ) def to_dict(self): diff --git a/twilio/rest/memory/v1/conversation_summary.py b/twilio/rest/memory/v1/conversation_summary.py index a53ba66c0..16933d864 100644 --- a/twilio/rest/memory/v1/conversation_summary.py +++ b/twilio/rest/memory/v1/conversation_summary.py @@ -27,14 +27,14 @@ class ConversationSummaryInstance(InstanceResource): """ - :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar message: + :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar content: The main content of the summary. :ivar occurred_at: The timestamp when the summary was originally created. :ivar conversation_id: A unique identifier for the conversation using Twilio Type ID (TTID) format. :ivar id: A unique identifier for the summary using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the summary was created. :ivar updated_at: The timestamp when the summary was last updated. - :ivar message: """ def __init__( @@ -47,6 +47,7 @@ def __init__( ): super().__init__(version) + self.message: Optional[str] = payload.get("message") self.source: Optional[str] = payload.get("source") self.content: Optional[str] = payload.get("content") self.occurred_at: Optional[datetime] = deserialize.iso8601_datetime( @@ -60,7 +61,6 @@ def __init__( self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("updatedAt") ) - self.message: Optional[str] = payload.get("message") # Only set _solution if path params are provided (not None) if store_id is not None or profile_id is not None or summary_id is not None: @@ -580,7 +580,7 @@ def to_dict(self): class SummaryCore(object): """ - :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar content: The main content of the summary. :ivar occurred_at: The timestamp when the summary was originally created. :ivar conversation_id: A unique identifier for the conversation using Twilio Type ID (TTID) format. @@ -603,7 +603,7 @@ def to_dict(self): class SummaryCorePatch(object): """ - :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar content: The main content of the summary. :ivar occurred_at: The timestamp when the summary was originally created. If not provided, defaults to the time the summary was received. :ivar conversation_id: A unique identifier for the conversation using Twilio Type ID (TTID) format. diff --git a/twilio/rest/memory/v1/data_mapping.py b/twilio/rest/memory/v1/data_mapping.py index 151a63c6a..70ea91252 100644 --- a/twilio/rest/memory/v1/data_mapping.py +++ b/twilio/rest/memory/v1/data_mapping.py @@ -603,13 +603,13 @@ def __init__(self, payload: Dict[str, Any]): self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( DataMappingList.DataMappingToTraits(payload.get("mappingTo")) - if payload.get("mappingTo") is not None - else None + if isinstance(payload.get("mappingTo"), dict) + else payload.get("mappingTo") ) self.mapping_from: Optional[DataMappingList.DataMappingFromTypes] = ( DataMappingList.DataMappingFromTypes(payload.get("mappingFrom")) - if payload.get("mappingFrom") is not None - else None + if isinstance(payload.get("mappingFrom"), dict) + else payload.get("mappingFrom") ) def to_dict(self): @@ -642,8 +642,8 @@ def __init__(self, payload: Dict[str, Any]): self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( DataMappingList.DataMappingToTraits(payload.get("mappingTo")) - if payload.get("mappingTo") is not None - else None + if isinstance(payload.get("mappingTo"), dict) + else payload.get("mappingTo") ) def to_dict(self): diff --git a/twilio/rest/memory/v1/observation.py b/twilio/rest/memory/v1/observation.py index c24f89897..c4e1473f5 100644 --- a/twilio/rest/memory/v1/observation.py +++ b/twilio/rest/memory/v1/observation.py @@ -30,7 +30,7 @@ class ObservationInstance(InstanceResource): :ivar message: :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. :ivar id: A unique identifier for the observation using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the observation was created. @@ -578,7 +578,7 @@ class ObservationBase(object): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. """ @@ -601,7 +601,7 @@ class ObservationCreateRequest(object): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. """ @@ -830,7 +830,7 @@ def stream( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -878,7 +878,7 @@ async def stream_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -924,7 +924,7 @@ def stream_with_http_info( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -971,7 +971,7 @@ async def stream_with_http_info_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1019,7 +1019,7 @@ def list( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1067,7 +1067,7 @@ async def list_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1115,7 +1115,7 @@ def list_with_http_info( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1161,7 +1161,7 @@ async def list_with_http_info_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1207,7 +1207,7 @@ def page( :param page_size: The maximum number of items to return per page, maximum of 1000. :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1261,7 +1261,7 @@ async def page_async( :param page_size: The maximum number of items to return per page, maximum of 1000. :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1315,7 +1315,7 @@ def page_with_http_info( :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1376,7 +1376,7 @@ async def page_with_http_info_async( :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. diff --git a/twilio/rest/memory/v1/recall.py b/twilio/rest/memory/v1/recall.py index d04f56a39..ee536d074 100644 --- a/twilio/rest/memory/v1/recall.py +++ b/twilio/rest/memory/v1/recall.py @@ -100,8 +100,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.type: Optional[ParticipantType] = ( ParticipantType(payload.get("type")) - if payload.get("type") is not None - else None + if isinstance(payload.get("type"), dict) + else payload.get("type") ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") @@ -174,8 +174,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.type: Optional[ParticipantType] = ( ParticipantType(payload.get("type")) - if payload.get("type") is not None - else None + if isinstance(payload.get("type"), dict) + else payload.get("type") ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") diff --git a/twilio/rest/memory/v1/revision.py b/twilio/rest/memory/v1/revision.py index 34684c408..5f9a41745 100644 --- a/twilio/rest/memory/v1/revision.py +++ b/twilio/rest/memory/v1/revision.py @@ -29,7 +29,7 @@ class RevisionInstance(InstanceResource): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. :ivar id: A unique identifier for the observation using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the observation was created. diff --git a/twilio/rest/memory/v1/trait_group.py b/twilio/rest/memory/v1/trait_group.py index 30dbd279d..32f65284a 100644 --- a/twilio/rest/memory/v1/trait_group.py +++ b/twilio/rest/memory/v1/trait_group.py @@ -785,8 +785,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.validation_rule: Optional[TraitGroupList.ValidationRule] = ( TraitGroupList.ValidationRule(payload.get("validationRule")) - if payload.get("validationRule") is not None - else None + if isinstance(payload.get("validationRule"), dict) + else payload.get("validationRule") ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -850,8 +850,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.validation_rule: Optional[ValidationRule] = ( ValidationRule(payload.get("validationRule")) - if payload.get("validationRule") is not None - else None + if isinstance(payload.get("validationRule"), dict) + else payload.get("validationRule") ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -916,8 +916,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.validation_rule: Optional[TraitGroupList.ValidationRule] = ( TraitGroupList.ValidationRule(payload.get("validationRule")) - if payload.get("validationRule") is not None - else None + if isinstance(payload.get("validationRule"), dict) + else payload.get("validationRule") ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") diff --git a/twilio/rest/messaging/v2/channels_sender.py b/twilio/rest/messaging/v2/channels_sender.py index 23462b7d0..6bf5c0bf7 100644 --- a/twilio/rest/messaging/v2/channels_sender.py +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -12,8 +12,9 @@ Do not edit the class manually. """ +from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import values +from twilio.base import deserialize, values from twilio.base.api_response import ApiResponse from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource @@ -54,7 +55,7 @@ def to_dict(self): class MessagingV2ChannelsSenderProfile(object): """ - :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). + :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). On update, a WhatsApp sender's name is not changed synchronously: it is submitted to Meta for review, and `profile.name` continues to report the current active name until Meta approves the new one and the sender is automatically re-registered. Track progress with `pending_display_name_status` on Fetch Sender, and see `display_name_status` on the update response for the immediate outcome. Re-submitting the same name is how you retry applying a name Meta has already approved, for example after correcting the sender's two-step verification PIN. Meta permits a limited number of display name changes per 30-day period. :ivar about: The profile about text for the sender. :ivar address: The address of the sender. :ivar description: The description of the sender. @@ -179,8 +180,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -188,8 +189,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -197,8 +198,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -231,8 +232,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -240,8 +241,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -249,8 +250,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -307,8 +308,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.status: Optional[MessagingV2RcsCarrierStatus] = ( MessagingV2RcsCarrierStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) def to_dict(self): @@ -331,8 +332,8 @@ def __init__(self, payload: Dict[str, Any]): self.registration_sid: Optional[str] = payload.get("registration_sid") self.status: Optional[MessagingV2RcsCountryStatus] = ( MessagingV2RcsCountryStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( [ @@ -388,10 +389,14 @@ class MessagingV2RcsCountryStatus(object): :ivar configuration: :ivar webhook: :ivar profile: + :ivar pending_display_name: WhatsApp only. The display name the most recent change applies to — awaiting Meta review, approved by Meta and awaiting re-registration, or, once `pending_display_name_status` is `COMPLETED`, the name now in effect (identical to `name`). Absent when no display name change has been made, and once a completed change stops being reported. + :ivar pending_display_name_status: WhatsApp only. The status of the most recent display name change. `PENDING_REVIEW`, `APPROVED` and `DECLINED` are reported by Meta. `PIN_MISMATCH` and `REGISTRATION_FAILED` mean Meta approved the name but it could not be applied; `EXPIRED` means Meta's 14-day window to apply an approved name elapsed. In all three cases, re-submit the same `profile.name` to retry. `COMPLETED` means the name was approved and applied — `name` now returns it. A `COMPLETED` change is reported for 14 days after it completes and is absent afterwards, so treat its presence as \"recently completed\" rather than a permanent flag; use `pending_display_name_status_date` to tell how recent. Absent when no display name change has been made. + :ivar pending_display_name_status_date: WhatsApp only. The date and time in UTC when `pending_display_name_status` last changed, specified in ISO 8601 format. Absent whenever `pending_display_name_status` is absent, so the three `pending_display_name*` fields are always present or absent together. :ivar properties: :ivar offline_reasons: The reasons why the sender is offline. :ivar compliance: :ivar url: The URL of the resource. + :ivar display_name_status: WhatsApp only. The outcome of the display name operation in this request. Present only when the request included `profile.name`. `updating` — accepted; either submitted to Meta for review, or, when Meta had already approved this exact name, routed straight to re-registration. `no_change` — the name already matches the sender's active display name; nothing was submitted to Meta. `pending_review` — the same name is already under review at Meta; the existing request continues unchanged. `error` — the display name could not be processed, while other profile fields in the same request were still applied. Returned with a 202 and carries no error code or message. This covers every failure mode, including the case where Meta accepted the name but tracking could not be started — poll `pending_display_name_status` to establish the real state rather than assuming the name was rejected. When `profile.name` is the only field in the request, the failure is returned as an error response with a specific code instead of this status. """ def __init__( @@ -406,10 +411,20 @@ def __init__( self.configuration: Optional[str] = payload.get("configuration") self.webhook: Optional[str] = payload.get("webhook") self.profile: Optional[str] = payload.get("profile") + self.pending_display_name: Optional[str] = payload.get("pending_display_name") + self.pending_display_name_status: Optional[str] = payload.get( + "pending_display_name_status" + ) + self.pending_display_name_status_date: Optional[datetime] = ( + deserialize.iso8601_datetime( + payload.get("pending_display_name_status_date") + ) + ) self.properties: Optional[str] = payload.get("properties") self.offline_reasons: Optional[List[str]] = payload.get("offline_reasons") self.compliance: Optional[str] = payload.get("compliance") self.url: Optional[str] = payload.get("url") + self.display_name_status: Optional[str] = payload.get("display_name_status") self._solution = { "sid": sid or self.sid, @@ -614,7 +629,7 @@ def to_dict(self): class MessagingV2ChannelsSenderProfile(object): """ - :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). + :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). On update, a WhatsApp sender's name is not changed synchronously: it is submitted to Meta for review, and `profile.name` continues to report the current active name until Meta approves the new one and the sender is automatically re-registered. Track progress with `pending_display_name_status` on Fetch Sender, and see `display_name_status` on the update response for the immediate outcome. Re-submitting the same name is how you retry applying a name Meta has already approved, for example after correcting the sender's two-step verification PIN. Meta permits a limited number of display name changes per 30-day period. :ivar about: The profile about text for the sender. :ivar address: The address of the sender. :ivar description: The description of the sender. @@ -739,8 +754,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -748,8 +763,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -757,8 +772,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -791,8 +806,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -800,8 +815,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -809,8 +824,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -867,8 +882,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.status: Optional[MessagingV2RcsCarrierStatus] = ( MessagingV2RcsCarrierStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) def to_dict(self): @@ -891,8 +906,8 @@ def __init__(self, payload: Dict[str, Any]): self.registration_sid: Optional[str] = payload.get("registration_sid") self.status: Optional[MessagingV2RcsCountryStatus] = ( MessagingV2RcsCountryStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( [ @@ -1276,7 +1291,7 @@ def to_dict(self): class MessagingV2ChannelsSenderProfile(object): """ - :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). + :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). On update, a WhatsApp sender's name is not changed synchronously: it is submitted to Meta for review, and `profile.name` continues to report the current active name until Meta approves the new one and the sender is automatically re-registered. Track progress with `pending_display_name_status` on Fetch Sender, and see `display_name_status` on the update response for the immediate outcome. Re-submitting the same name is how you retry applying a name Meta has already approved, for example after correcting the sender's two-step verification PIN. Meta permits a limited number of display name changes per 30-day period. :ivar about: The profile about text for the sender. :ivar address: The address of the sender. :ivar description: The description of the sender. @@ -1401,8 +1416,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -1410,8 +1425,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -1419,8 +1434,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -1453,8 +1468,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -1462,8 +1477,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -1471,8 +1486,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -1529,8 +1544,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.status: Optional[MessagingV2RcsCarrierStatus] = ( MessagingV2RcsCarrierStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) def to_dict(self): @@ -1553,8 +1568,8 @@ def __init__(self, payload: Dict[str, Any]): self.registration_sid: Optional[str] = payload.get("registration_sid") self.status: Optional[MessagingV2RcsCountryStatus] = ( MessagingV2RcsCountryStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( [ diff --git a/twilio/rest/monitor/v2/__init__.py b/twilio/rest/monitor/v2/__init__.py new file mode 100644 index 000000000..d2d420c1d --- /dev/null +++ b/twilio/rest/monitor/v2/__init__.py @@ -0,0 +1,51 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Alarms + Manages Twilio Alarms + + 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.monitor.v2.alarm import AlarmList +from twilio.rest.monitor.v2.status import StatusList + + +class V2(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V2 version of Monitor + + :param domain: The Twilio.monitor domain + """ + super().__init__(domain, "v2") + self._alarms: Optional[AlarmList] = None + self._status: Optional[StatusList] = None + + @property + def alarms(self) -> AlarmList: + if self._alarms is None: + self._alarms = AlarmList(self) + return self._alarms + + @property + def status(self) -> StatusList: + if self._status is None: + self._status = StatusList(self) + return self._status + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/monitor/v2/alarm.py b/twilio/rest/monitor/v2/alarm.py new file mode 100644 index 000000000..085c022bf --- /dev/null +++ b/twilio/rest/monitor/v2/alarm.py @@ -0,0 +1,1250 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Alarms + Manages Twilio Alarms + + 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.api_response import ApiResponse +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 AlarmInstance(InstanceResource): + + class MonitorV2AlarmCreateObject(object): + """ + :ivar friendly_name: Friendly name for alarm + :ivar query_type: + :ivar query: Value to query for + :ivar trigger_value: Threshold to send customer alarm notification + :ivar time_window: + :ivar email: Email notifications to send + :ivar webhook: Webhook notification to send + :ivar console_indicator: Whether to send console notifications + :ivar description: Description for the alarm. + :ivar enabled: Is alarm enbled? Default is true. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.query_type: Optional["AlarmInstance.QueryType"] = payload.get( + "queryType" + ) + self.query: Optional[str] = payload.get("query") + self.trigger_value: Optional[int] = payload.get("triggerValue") + self.time_window: Optional["AlarmInstance.TimeWindow"] = payload.get( + "timeWindow" + ) + self.email: Optional[List[str]] = payload.get("email") + self.webhook: Optional[str] = payload.get("webhook") + self.console_indicator: Optional[bool] = payload.get("consoleIndicator") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + + def to_dict(self): + return { + "friendlyName": self.friendly_name, + "queryType": self.query_type, + "query": self.query, + "triggerValue": self.trigger_value, + "timeWindow": self.time_window, + "email": self.email, + "webhook": self.webhook, + "consoleIndicator": self.console_indicator, + "description": self.description, + "enabled": self.enabled, + } + + class QueryType(object): + ERROR_CODE = "ERROR_CODE" + LOG_LEVEL = "LOG_LEVEL" + ALL = "ALL" + + class TimeWindow(object): + FIVE_MINS = "FIVE_MINS" + FIFTEEN_MINS = "FIFTEEN_MINS" + ONE_HOUR = "ONE_HOUR" + TWELVE_HOURS = "TWELVE_HOURS" + ONE_DAY = "ONE_DAY" + + """ + :ivar sid: + :ivar message: Error message + :ivar code: Twilio error code + :ivar user_error: Indicates if it was a user error + :ivar http_status_code: Http error code returned + :ivar params: + :ivar more_info: More information link + :ivar status: HTTP status code + :ivar friendly_name: Friendly name for alarm + :ivar query_type: + :ivar query: Value to query for + :ivar trigger_value: Threshold to send customer alarm notification + :ivar time_window: + :ivar email: Email notifications to send + :ivar webhook: Webhook notification to send + :ivar console_indicator: Whether to send console notifications + :ivar description: Description for the alarm. + :ivar enabled: Is alarm enbled? Default is true. + :ivar product: Product the alarm is related to. + :ivar alert_config_sid: Sid for the alarm + :ivar date_updated: The date and time in UTC when the alarm was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format + :ivar date_created: The date and time in UTC when the alarm was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = deserialize.integer(payload.get("code")) + self.user_error: Optional[bool] = payload.get("user_error") + self.http_status_code: Optional[int] = deserialize.integer( + payload.get("http_status_code") + ) + self.params: Optional[Dict[str, str]] = payload.get("params") + self.more_info: Optional[str] = payload.get("more_info") + self.status: Optional[int] = deserialize.integer(payload.get("status")) + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.query_type: Optional["AlarmInstance.QueryType"] = payload.get("queryType") + self.query: Optional[str] = payload.get("query") + self.trigger_value: Optional[int] = deserialize.integer( + payload.get("triggerValue") + ) + self.time_window: Optional["AlarmInstance.TimeWindow"] = payload.get( + "timeWindow" + ) + self.email: Optional[List[str]] = payload.get("email") + self.webhook: Optional[str] = payload.get("webhook") + self.console_indicator: Optional[bool] = payload.get("consoleIndicator") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.product: Optional[str] = payload.get("product") + self.alert_config_sid: Optional[str] = payload.get("alertConfigSid") + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateUpdated") + ) + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateCreated") + ) + + self._solution = { + "sid": sid or self.sid, + } + + self._context: Optional[AlarmContext] = None + + @property + def _proxy(self) -> "AlarmContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AlarmContext for this AlarmInstance + """ + if self._context is None: + self._context = AlarmContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the AlarmInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AlarmInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AlarmInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AlarmInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def fetch(self) -> "AlarmInstance": + """ + Fetch the AlarmInstance + + + :returns: The fetched AlarmInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AlarmInstance": + """ + Asynchronous coroutine to fetch the AlarmInstance + + + :returns: The fetched AlarmInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the AlarmInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.fetch_with_http_info() + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the AlarmInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> "AlarmInstance": + """ + Update the AlarmInstance + + :param monitor_v2_alarm_create_object: + + :returns: The updated AlarmInstance + """ + return self._proxy.update( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object, + ) + + async def update_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> "AlarmInstance": + """ + Asynchronous coroutine to update the AlarmInstance + + :param monitor_v2_alarm_create_object: + + :returns: The updated AlarmInstance + """ + return await self._proxy.update_async( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object, + ) + + def update_with_http_info( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> ApiResponse: + """ + Update the AlarmInstance with HTTP info + + :param monitor_v2_alarm_create_object: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object, + ) + + async def update_with_http_info_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> ApiResponse: + """ + Asynchronous coroutine to update the AlarmInstance with HTTP info + + :param monitor_v2_alarm_create_object: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object, + ) + + 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 "".format(context) + + +class AlarmContext(InstanceContext): + + class MonitorV2AlarmCreateObject(object): + """ + :ivar friendly_name: Friendly name for alarm + :ivar query_type: + :ivar query: Value to query for + :ivar trigger_value: Threshold to send customer alarm notification + :ivar time_window: + :ivar email: Email notifications to send + :ivar webhook: Webhook notification to send + :ivar console_indicator: Whether to send console notifications + :ivar description: Description for the alarm. + :ivar enabled: Is alarm enbled? Default is true. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.query_type: Optional["AlarmInstance.QueryType"] = payload.get( + "queryType" + ) + self.query: Optional[str] = payload.get("query") + self.trigger_value: Optional[int] = payload.get("triggerValue") + self.time_window: Optional["AlarmInstance.TimeWindow"] = payload.get( + "timeWindow" + ) + self.email: Optional[List[str]] = payload.get("email") + self.webhook: Optional[str] = payload.get("webhook") + self.console_indicator: Optional[bool] = payload.get("consoleIndicator") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + + def to_dict(self): + return { + "friendlyName": self.friendly_name, + "queryType": self.query_type, + "query": self.query, + "triggerValue": self.trigger_value, + "timeWindow": self.time_window, + "email": self.email, + "webhook": self.webhook, + "consoleIndicator": self.console_indicator, + "description": self.description, + "enabled": self.enabled, + } + + def __init__(self, version: Version, sid: str): + """ + Initialize the AlarmContext + + :param version: Version that contains the resource + :param sid: Sid + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Alarms/{sid}".format(**self._solution) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the AlarmInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AlarmInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AlarmInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AlarmInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + def _fetch(self) -> tuple: + """ + Internal helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> AlarmInstance: + """ + Fetch the AlarmInstance + + + :returns: The fetched AlarmInstance + """ + payload, _, _ = self._fetch() + return AlarmInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the AlarmInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = AlarmInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _fetch_async(self) -> tuple: + """ + Internal async helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.fetch_with_response_info_async( + method="GET", uri=self._uri, headers=headers + ) + + async def fetch_async(self) -> AlarmInstance: + """ + Asynchronous coroutine to fetch the AlarmInstance + + + :returns: The fetched AlarmInstance + """ + payload, _, _ = await self._fetch_async() + return AlarmInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the AlarmInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = AlarmInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = monitor_v2_alarm_create_object.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> AlarmInstance: + """ + Update the AlarmInstance + + :param monitor_v2_alarm_create_object: + + :returns: The updated AlarmInstance + """ + payload, _, _ = self._update( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + return AlarmInstance(self._version, payload, sid=self._solution["sid"]) + + def update_with_http_info( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> ApiResponse: + """ + Update the AlarmInstance and return response metadata + + :param monitor_v2_alarm_create_object: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + instance = AlarmInstance(self._version, payload, sid=self._solution["sid"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = monitor_v2_alarm_create_object.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> AlarmInstance: + """ + Asynchronous coroutine to update the AlarmInstance + + :param monitor_v2_alarm_create_object: + + :returns: The updated AlarmInstance + """ + payload, _, _ = await self._update_async( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + return AlarmInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_with_http_info_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> ApiResponse: + """ + Asynchronous coroutine to update the AlarmInstance and return response metadata + + :param monitor_v2_alarm_create_object: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + instance = AlarmInstance(self._version, payload, sid=self._solution["sid"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + 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 "".format(context) + + +class AlarmPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AlarmInstance: + """ + Build an instance of AlarmInstance + + :param payload: Payload response from the API + """ + + return AlarmInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AlarmList(ListResource): + + class MonitorV2AlarmCreateObject(object): + """ + :ivar friendly_name: Friendly name for alarm + :ivar query_type: + :ivar query: Value to query for + :ivar trigger_value: Threshold to send customer alarm notification + :ivar time_window: + :ivar email: Email notifications to send + :ivar webhook: Webhook notification to send + :ivar console_indicator: Whether to send console notifications + :ivar description: Description for the alarm. + :ivar enabled: Is alarm enbled? Default is true. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.query_type: Optional["AlarmInstance.QueryType"] = payload.get( + "queryType" + ) + self.query: Optional[str] = payload.get("query") + self.trigger_value: Optional[int] = payload.get("triggerValue") + self.time_window: Optional["AlarmInstance.TimeWindow"] = payload.get( + "timeWindow" + ) + self.email: Optional[List[str]] = payload.get("email") + self.webhook: Optional[str] = payload.get("webhook") + self.console_indicator: Optional[bool] = payload.get("consoleIndicator") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + + def to_dict(self): + return { + "friendlyName": self.friendly_name, + "queryType": self.query_type, + "query": self.query, + "triggerValue": self.trigger_value, + "timeWindow": self.time_window, + "email": self.email, + "webhook": self.webhook, + "consoleIndicator": self.console_indicator, + "description": self.description, + "enabled": self.enabled, + } + + def __init__(self, version: Version): + """ + Initialize the AlarmList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Alarms" + + def _create( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = monitor_v2_alarm_create_object.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> AlarmInstance: + """ + Create the AlarmInstance + + :param monitor_v2_alarm_create_object: + + :returns: The created AlarmInstance + """ + payload, _, _ = self._create( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + return AlarmInstance(self._version, payload) + + def create_with_http_info( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> ApiResponse: + """ + Create the AlarmInstance and return response metadata + + :param monitor_v2_alarm_create_object: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + instance = AlarmInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = monitor_v2_alarm_create_object.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def create_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> AlarmInstance: + """ + Asynchronously create the AlarmInstance + + :param monitor_v2_alarm_create_object: + + :returns: The created AlarmInstance + """ + payload, _, _ = await self._create_async( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + return AlarmInstance(self._version, payload) + + async def create_with_http_info_async( + self, monitor_v2_alarm_create_object: MonitorV2AlarmCreateObject + ) -> ApiResponse: + """ + Asynchronously create the AlarmInstance and return response metadata + + :param monitor_v2_alarm_create_object: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + monitor_v2_alarm_create_object=monitor_v2_alarm_create_object + ) + instance = AlarmInstance(self._version, payload) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def stream( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AlarmInstance]: + """ + Streams AlarmInstance 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 sort_order: + :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(sort_order=sort_order, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[AlarmInstance]: + """ + Asynchronously streams AlarmInstance 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 sort_order: + :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( + sort_order=sort_order, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams AlarmInstance and returns headers from first page + + + :param str sort_order: + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info( + sort_order=sort_order, page_size=limits["page_size"] + ) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams AlarmInstance and returns headers from first page + + + :param str sort_order: + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + sort_order=sort_order, page_size=limits["page_size"] + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AlarmInstance]: + """ + Lists AlarmInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str sort_order: + :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( + sort_order=sort_order, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AlarmInstance]: + """ + Asynchronously lists AlarmInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str sort_order: + :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( + sort_order=sort_order, + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists AlarmInstance and returns headers from first page + + + :param str sort_order: + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + sort_order=sort_order, + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + sort_order: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists AlarmInstance and returns headers from first page + + + :param str sort_order: + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + sort_order=sort_order, + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + sort_order: 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, + ) -> AlarmPage: + """ + Retrieve a single page of AlarmInstance records from the API. + Request is executed immediately + + :param sort_order: + :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 AlarmInstance + """ + data = values.of( + { + "SortOrder": sort_order, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AlarmPage(self._version, response) + + async def page_async( + self, + sort_order: 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, + ) -> AlarmPage: + """ + Asynchronously retrieve a single page of AlarmInstance records from the API. + Request is executed immediately + + :param sort_order: + :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 AlarmInstance + """ + data = values.of( + { + "SortOrder": sort_order, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AlarmPage(self._version, response) + + def page_with_http_info( + self, + sort_order: 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, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :param sort_order: + :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: ApiResponse with AlarmPage, status code, and headers + """ + data = values.of( + { + "SortOrder": sort_order, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = AlarmPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + sort_order: 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, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :param sort_order: + :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: ApiResponse with AlarmPage, status code, and headers + """ + data = values.of( + { + "SortOrder": sort_order, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = AlarmPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> AlarmPage: + """ + Retrieve a specific page of AlarmInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AlarmInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AlarmPage(self._version, response) + + async def get_page_async(self, target_url: str) -> AlarmPage: + """ + Asynchronously retrieve a specific page of AlarmInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AlarmInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AlarmPage(self._version, response) + + def get(self, sid: str) -> AlarmContext: + """ + Constructs a AlarmContext + + :param sid: Sid + """ + return AlarmContext(self._version, sid=sid) + + def __call__(self, sid: str) -> AlarmContext: + """ + Constructs a AlarmContext + + :param sid: Sid + """ + return AlarmContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/monitor/v2/status.py b/twilio/rest/monitor/v2/status.py new file mode 100644 index 000000000..7b1b4aff6 --- /dev/null +++ b/twilio/rest/monitor/v2/status.py @@ -0,0 +1,215 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Alarms + Manages Twilio Alarms + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional +from twilio.base import deserialize, values +from twilio.base.api_response import ApiResponse + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class StatusInstance(InstanceResource): + + class MonitorV2AlarmStatus(object): + """ + :ivar enabled: status of alarm + """ + + def __init__(self, payload: Dict[str, Any]): + + self.enabled: Optional[bool] = payload.get("enabled") + + def to_dict(self): + return { + "enabled": self.enabled, + } + + """ + :ivar message: Error message + :ivar code: Twilio error code + :ivar user_error: Indicates if it was a user error + :ivar http_status_code: Http error code returned + :ivar params: + :ivar more_info: More information link + :ivar status: HTTP status code + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.message: Optional[str] = payload.get("message") + self.code: Optional[int] = deserialize.integer(payload.get("code")) + self.user_error: Optional[bool] = payload.get("user_error") + self.http_status_code: Optional[int] = deserialize.integer( + payload.get("http_status_code") + ) + self.params: Optional[Dict[str, str]] = payload.get("params") + self.more_info: Optional[str] = payload.get("more_info") + self.status: Optional[int] = deserialize.integer(payload.get("status")) + + self._solution = { + "sid": sid or self.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 "".format(context) + + +class StatusList(ListResource): + + class MonitorV2AlarmStatus(object): + """ + :ivar enabled: status of alarm + """ + + def __init__(self, payload: Dict[str, Any]): + + self.enabled: Optional[bool] = payload.get("enabled") + + def to_dict(self): + return { + "enabled": self.enabled, + } + + def __init__(self, version: Version, sid: str): + """ + Initialize the StatusList + + :param version: Version that contains the resource + :param sid: Sid + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Alarms/{sid}/status".format(**self._solution) + + def _update(self, monitor_v2_alarm_status: MonitorV2AlarmStatus) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = monitor_v2_alarm_status.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update(self, monitor_v2_alarm_status: MonitorV2AlarmStatus) -> StatusInstance: + """ + Update the StatusInstance + + :param monitor_v2_alarm_status: + + :returns: The updated StatusInstance + """ + payload, _, _ = self._update(monitor_v2_alarm_status=monitor_v2_alarm_status) + return StatusInstance(self._version, payload, sid=self._solution["sid"]) + + def update_with_http_info( + self, monitor_v2_alarm_status: MonitorV2AlarmStatus + ) -> ApiResponse: + """ + Update the StatusInstance and return response metadata + + :param monitor_v2_alarm_status: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + monitor_v2_alarm_status=monitor_v2_alarm_status + ) + instance = StatusInstance(self._version, payload, sid=self._solution["sid"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, monitor_v2_alarm_status: MonitorV2AlarmStatus + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = monitor_v2_alarm_status.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, monitor_v2_alarm_status: MonitorV2AlarmStatus + ) -> StatusInstance: + """ + Asynchronously update the StatusInstance + + :param monitor_v2_alarm_status: + + :returns: The updated StatusInstance + """ + payload, _, _ = await self._update_async( + monitor_v2_alarm_status=monitor_v2_alarm_status + ) + return StatusInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_with_http_info_async( + self, monitor_v2_alarm_status: MonitorV2AlarmStatus + ) -> ApiResponse: + """ + Asynchronously update the StatusInstance and return response metadata + + :param monitor_v2_alarm_status: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + monitor_v2_alarm_status=monitor_v2_alarm_status + ) + instance = StatusInstance(self._version, payload, sid=self._solution["sid"]) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index 59dd3d522..2ca3e1151 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -37,7 +37,6 @@ from twilio.rest.numbers.v1.sms_verification import SmsVerificationList from twilio.rest.numbers.v1.sms_verification_check import SmsVerificationCheckList from twilio.rest.numbers.v1.voice_verification import VoiceVerificationList -from twilio.rest.numbers.v1.voice_verification_check import VoiceVerificationCheckList from twilio.rest.numbers.v1.webhook import WebhookList @@ -71,7 +70,6 @@ def __init__(self, domain: Domain): self._sms_verifications: Optional[SmsVerificationList] = None self._sms_verification_checks: Optional[SmsVerificationCheckList] = None self._voice_verifications: Optional[VoiceVerificationList] = None - self._voice_verification_checks: Optional[VoiceVerificationCheckList] = None self._webhook: Optional[WebhookList] = None @property @@ -170,12 +168,6 @@ def voice_verifications(self) -> VoiceVerificationList: self._voice_verifications = VoiceVerificationList(self) return self._voice_verifications - @property - def voice_verification_checks(self) -> VoiceVerificationCheckList: - if self._voice_verification_checks is None: - self._voice_verification_checks = VoiceVerificationCheckList(self) - return self._voice_verification_checks - @property def webhook(self) -> WebhookList: if self._webhook is None: diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py index 9824148a0..3d16cfc94 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -79,8 +79,8 @@ def __init__(self, payload: Dict[str, Any]): self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( PortingPortInList.NumbersV1PortingAddress(payload.get("address")) - if payload.get("address") is not None - else None + if isinstance(payload.get("address"), dict) + else payload.get("address") ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -151,8 +151,8 @@ def __init__(self, payload: Dict[str, Any]): PortingPortInList.NumbersV1PortingLosingCarrierInformation( payload.get("losing_carrier_information") ) - if payload.get("losing_carrier_information") is not None - else None + if isinstance(payload.get("losing_carrier_information"), dict) + else payload.get("losing_carrier_information") ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" @@ -444,8 +444,8 @@ def __init__(self, payload: Dict[str, Any]): self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( PortingPortInList.NumbersV1PortingAddress(payload.get("address")) - if payload.get("address") is not None - else None + if isinstance(payload.get("address"), dict) + else payload.get("address") ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -516,8 +516,8 @@ def __init__(self, payload: Dict[str, Any]): PortingPortInList.NumbersV1PortingLosingCarrierInformation( payload.get("losing_carrier_information") ) - if payload.get("losing_carrier_information") is not None - else None + if isinstance(payload.get("losing_carrier_information"), dict) + else payload.get("losing_carrier_information") ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" @@ -819,8 +819,8 @@ def __init__(self, payload: Dict[str, Any]): self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( PortingPortInList.NumbersV1PortingAddress(payload.get("address")) - if payload.get("address") is not None - else None + if isinstance(payload.get("address"), dict) + else payload.get("address") ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -891,8 +891,8 @@ def __init__(self, payload: Dict[str, Any]): PortingPortInList.NumbersV1PortingLosingCarrierInformation( payload.get("losing_carrier_information") ) - if payload.get("losing_carrier_information") is not None - else None + if isinstance(payload.get("losing_carrier_information"), dict) + else payload.get("losing_carrier_information") ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" diff --git a/twilio/rest/numbers/v1/sms_verification.py b/twilio/rest/numbers/v1/sms_verification.py index 71d0d2215..d673b039c 100644 --- a/twilio/rest/numbers/v1/sms_verification.py +++ b/twilio/rest/numbers/v1/sms_verification.py @@ -22,6 +22,27 @@ class SmsVerificationInstance(InstanceResource): + + class NumbersV1SmsVerificationRequest(object): + """ + :ivar to: The phone number to verify in E.164 format. + :ivar locale: The locale for the verification SMS message. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.locale: Optional[str] = payload.get("locale") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "locale": self.locale, + "friendly_name": self.friendly_name, + } + """ :ivar to: The phone number being verified in E.164 format. :ivar verification_sid: The unique SID of this verification resource. @@ -47,6 +68,26 @@ def __repr__(self) -> str: class SmsVerificationList(ListResource): + class NumbersV1SmsVerificationRequest(object): + """ + :ivar to: The phone number to verify in E.164 format. + :ivar locale: The locale for the verification SMS message. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.locale: Optional[str] = payload.get("locale") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "locale": self.locale, + "friendly_name": self.friendly_name, + } + def __init__(self, version: Version): """ Initialize the SmsVerificationList @@ -58,77 +99,107 @@ def __init__(self, version: Version): self._uri = "/CallerIds/SmsVerifications" - def _create(self) -> tuple: + def _create( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> tuple: """ Internal helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> SmsVerificationInstance: + def create( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> SmsVerificationInstance: """ Create the SmsVerificationInstance + :param numbers_v1_sms_verification_request: :returns: The created SmsVerificationInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) return SmsVerificationInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> ApiResponse: """ Create the SmsVerificationInstance and return response metadata + :param numbers_v1_sms_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) instance = SmsVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> tuple: """ Internal async helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - async def create_async(self) -> SmsVerificationInstance: + async def create_async( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> SmsVerificationInstance: """ Asynchronously create the SmsVerificationInstance + :param numbers_v1_sms_verification_request: :returns: The created SmsVerificationInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) return SmsVerificationInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> ApiResponse: """ Asynchronously create the SmsVerificationInstance and return response metadata + :param numbers_v1_sms_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) instance = SmsVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/numbers/v1/sms_verification_check.py b/twilio/rest/numbers/v1/sms_verification_check.py index f57035319..1bba87b5f 100644 --- a/twilio/rest/numbers/v1/sms_verification_check.py +++ b/twilio/rest/numbers/v1/sms_verification_check.py @@ -22,6 +22,27 @@ class SmsVerificationCheckInstance(InstanceResource): + + class NumbersV1SmsVerificationCheckRequest(object): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_code: The 6 character verification code to check. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.verification_code: Optional[str] = payload.get("verification_code") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "verification_code": self.verification_code, + "friendly_name": self.friendly_name, + } + """ :ivar to: The phone number that was verified in E.164 format. :ivar verification_sid: The unique SID of this verification resource. @@ -49,6 +70,26 @@ def __repr__(self) -> str: class SmsVerificationCheckList(ListResource): + class NumbersV1SmsVerificationCheckRequest(object): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_code: The 6 character verification code to check. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.verification_code: Optional[str] = payload.get("verification_code") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "verification_code": self.verification_code, + "friendly_name": self.friendly_name, + } + def __init__(self, version: Version): """ Initialize the SmsVerificationCheckList @@ -60,77 +101,113 @@ def __init__(self, version: Version): self._uri = "/CallerIds/SmsVerificationChecks" - def _create(self) -> tuple: + def _create( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> tuple: """ Internal helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_check_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> SmsVerificationCheckInstance: + def create( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> SmsVerificationCheckInstance: """ Create the SmsVerificationCheckInstance + :param numbers_v1_sms_verification_check_request: :returns: The created SmsVerificationCheckInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) return SmsVerificationCheckInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> ApiResponse: """ Create the SmsVerificationCheckInstance and return response metadata + :param numbers_v1_sms_verification_check_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) instance = SmsVerificationCheckInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> tuple: """ Internal async helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_check_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - async def create_async(self) -> SmsVerificationCheckInstance: + async def create_async( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> SmsVerificationCheckInstance: """ Asynchronously create the SmsVerificationCheckInstance + :param numbers_v1_sms_verification_check_request: :returns: The created SmsVerificationCheckInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) return SmsVerificationCheckInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> ApiResponse: """ Asynchronously create the SmsVerificationCheckInstance and return response metadata + :param numbers_v1_sms_verification_check_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) instance = SmsVerificationCheckInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/numbers/v1/voice_verification.py b/twilio/rest/numbers/v1/voice_verification.py index 5e41647d7..e4c3b2fcb 100644 --- a/twilio/rest/numbers/v1/voice_verification.py +++ b/twilio/rest/numbers/v1/voice_verification.py @@ -22,6 +22,46 @@ class VoiceVerificationInstance(InstanceResource): + + class NumbersV1VoiceVerificationRequest(object): + """ + :ivar phone_number: The phone number to verify in E.164 format. + :ivar friendly_name: A human-readable name for the caller ID. + :ivar custom_code: A custom verification code to use instead of a generated one. + :ivar call_delay: Number of seconds to delay the verification call (0-60). + :ivar status_callback: URL to receive status callback events. + :ivar status_callback_method: HTTP method for status callback requests. + :ivar extension: Phone extension to dial after connecting. + :ivar custom_success_message: Custom message to play after successful verification. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.phone_number: Optional[str] = payload.get("phone_number") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.custom_code: Optional[str] = payload.get("custom_code") + self.call_delay: Optional[str] = payload.get("call_delay") + self.status_callback: Optional[str] = payload.get("status_callback") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + self.extension: Optional[str] = payload.get("extension") + self.custom_success_message: Optional[str] = payload.get( + "custom_success_message" + ) + + def to_dict(self): + return { + "phone_number": self.phone_number, + "friendly_name": self.friendly_name, + "custom_code": self.custom_code, + "call_delay": self.call_delay, + "status_callback": self.status_callback, + "status_callback_method": self.status_callback_method, + "extension": self.extension, + "custom_success_message": self.custom_success_message, + } + """ :ivar account_sid: The Account SID that owns this verification. :ivar phone_number: The phone number being verified in E.164 format. @@ -51,6 +91,45 @@ def __repr__(self) -> str: class VoiceVerificationList(ListResource): + class NumbersV1VoiceVerificationRequest(object): + """ + :ivar phone_number: The phone number to verify in E.164 format. + :ivar friendly_name: A human-readable name for the caller ID. + :ivar custom_code: A custom verification code to use instead of a generated one. + :ivar call_delay: Number of seconds to delay the verification call (0-60). + :ivar status_callback: URL to receive status callback events. + :ivar status_callback_method: HTTP method for status callback requests. + :ivar extension: Phone extension to dial after connecting. + :ivar custom_success_message: Custom message to play after successful verification. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.phone_number: Optional[str] = payload.get("phone_number") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.custom_code: Optional[str] = payload.get("custom_code") + self.call_delay: Optional[str] = payload.get("call_delay") + self.status_callback: Optional[str] = payload.get("status_callback") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + self.extension: Optional[str] = payload.get("extension") + self.custom_success_message: Optional[str] = payload.get( + "custom_success_message" + ) + + def to_dict(self): + return { + "phone_number": self.phone_number, + "friendly_name": self.friendly_name, + "custom_code": self.custom_code, + "call_delay": self.call_delay, + "status_callback": self.status_callback, + "status_callback_method": self.status_callback_method, + "extension": self.extension, + "custom_success_message": self.custom_success_message, + } + def __init__(self, version: Version): """ Initialize the VoiceVerificationList @@ -62,77 +141,107 @@ def __init__(self, version: Version): self._uri = "/CallerIds/VoiceVerifications" - def _create(self) -> tuple: + def _create( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> tuple: """ Internal helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_voice_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> VoiceVerificationInstance: + def create( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> VoiceVerificationInstance: """ Create the VoiceVerificationInstance + :param numbers_v1_voice_verification_request: :returns: The created VoiceVerificationInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) return VoiceVerificationInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> ApiResponse: """ Create the VoiceVerificationInstance and return response metadata + :param numbers_v1_voice_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) instance = VoiceVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> tuple: """ Internal async helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_voice_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - async def create_async(self) -> VoiceVerificationInstance: + async def create_async( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> VoiceVerificationInstance: """ Asynchronously create the VoiceVerificationInstance + :param numbers_v1_voice_verification_request: :returns: The created VoiceVerificationInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) return VoiceVerificationInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> ApiResponse: """ Asynchronously create the VoiceVerificationInstance and return response metadata + :param numbers_v1_voice_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) instance = VoiceVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/numbers/v2/application.py b/twilio/rest/numbers/v2/application.py index 3b9115d33..de1b10e4e 100644 --- a/twilio/rest/numbers/v2/application.py +++ b/twilio/rest/numbers/v2/application.py @@ -43,8 +43,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( payload.get("business_information") ) - if payload.get("business_information") is not None - else None + if isinstance(payload.get("business_information"), dict) + else payload.get("business_information") ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup @@ -52,8 +52,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestSetup( payload.get("setup") ) - if payload.get("setup") is not None - else None + if isinstance(payload.get("setup"), dict) + else payload.get("setup") ) def to_dict(self): @@ -246,8 +246,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( payload.get("business_information") ) - if payload.get("business_information") is not None - else None + if isinstance(payload.get("business_information"), dict) + else payload.get("business_information") ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup @@ -255,8 +255,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestSetup( payload.get("setup") ) - if payload.get("setup") is not None - else None + if isinstance(payload.get("setup"), dict) + else payload.get("setup") ) def to_dict(self): @@ -456,8 +456,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( payload.get("business_information") ) - if payload.get("business_information") is not None - else None + if isinstance(payload.get("business_information"), dict) + else payload.get("business_information") ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup @@ -465,8 +465,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestSetup( payload.get("setup") ) - if payload.get("setup") is not None - else None + if isinstance(payload.get("setup"), dict) + else payload.get("setup") ) def to_dict(self): diff --git a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py index 27ff55c37..cd868149d 100644 --- a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py +++ b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py @@ -89,6 +89,42 @@ def _proxy(self) -> "AuthorizationDocumentContext": ) return self._context + def delete(self) -> bool: + """ + Deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AuthorizationDocumentInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + def fetch(self) -> "AuthorizationDocumentInstance": """ Fetch the AuthorizationDocumentInstance @@ -297,6 +333,74 @@ def __init__(self, version: Version, sid: str): DependentHostedNumberOrderList ] = None + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AuthorizationDocumentInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + def _fetch(self) -> tuple: """ Internal helper for fetch operation diff --git a/twilio/rest/preview_iam/__init__.py b/twilio/rest/preview_iam/__init__.py index 9a5bf85b2..224327779 100644 --- a/twilio/rest/preview_iam/__init__.py +++ b/twilio/rest/preview_iam/__init__.py @@ -1,26 +1,51 @@ -from twilio.rest.preview_iam.PreviewIamBase import PreviewIamBase +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ -from twilio.rest.preview_iam.v1.authorize import ( - AuthorizeList, -) -from twilio.rest.preview_iam.v1.token import ( - TokenList, -) -from twilio.rest.preview_iam.versionless.organization import ( - OrganizationList, -) -from twilio.rest.preview_iam.versionless import Versionless + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" -class PreviewIam(PreviewIamBase): - @property - def organization(self) -> OrganizationList: - return Versionless(self).organization +from typing import Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.preview_iam.v1.authorize import AuthorizeList +from twilio.rest.preview_iam.v1.token import TokenList + + +class V1(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V1 version of PreviewIam + + :param domain: The Twilio.preview_iam domain + """ + super().__init__(domain, "v1") + self._authorize: Optional[AuthorizeList] = None + self._token: Optional[TokenList] = None @property def authorize(self) -> AuthorizeList: - return self.v1.authorize + if self._authorize is None: + self._authorize = AuthorizeList(self) + return self._authorize @property def token(self) -> TokenList: - return self.v1.token + if self._token is None: + self._token = TokenList(self) + return self._token + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/__init__.py b/twilio/rest/preview_iam/organizations/__init__.py new file mode 100644 index 000000000..dd51b9748 --- /dev/null +++ b/twilio/rest/preview_iam/organizations/__init__.py @@ -0,0 +1,59 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +from twilio.rest.preview_iam.organizations.account import AccountList +from twilio.rest.preview_iam.organizations.role_assignment import RoleAssignmentList +from twilio.rest.preview_iam.organizations.user import UserList + + +class Organizations(Version): + + def __init__(self, domain: Domain): + """ + Initialize the Organizations version of PreviewIam + + :param domain: The Twilio.preview_iam domain + """ + super().__init__(domain, "Organizations") + self._accounts: Optional[AccountList] = None + self._role_assignments: Optional[RoleAssignmentList] = None + self._users: Optional[UserList] = None + + @property + def accounts(self) -> AccountList: + if self._accounts is None: + self._accounts = AccountList(self) + return self._accounts + + @property + def role_assignments(self) -> RoleAssignmentList: + if self._role_assignments is None: + self._role_assignments = RoleAssignmentList(self) + return self._role_assignments + + @property + def users(self) -> UserList: + if self._users is None: + self._users = UserList(self) + return self._users + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/account.py b/twilio/rest/preview_iam/organizations/account.py new file mode 100644 index 000000000..095fddab9 --- /dev/null +++ b/twilio/rest/preview_iam/organizations/account.py @@ -0,0 +1,679 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.api_response import ApiResponse +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 AccountInstance(InstanceResource): + """ + :ivar account_sid: Twilio account sid + :ivar friendly_name: Account friendly name + :ivar status: Account status + :ivar owner_sid: Twilio account sid + :ivar date_created: The date and time when the account was created in the system + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + organization_sid: Optional[str] = None, + account_sid: Optional[str] = None, + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional[str] = payload.get("status") + self.owner_sid: Optional[str] = payload.get("owner_sid") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + + self._solution = { + "organization_sid": organization_sid or self.organization_sid, + "account_sid": account_sid or self.account_sid, + } + + self._context: Optional[AccountContext] = None + + @property + def _proxy(self) -> "AccountContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AccountContext for this AccountInstance + """ + if self._context is None: + self._context = AccountContext( + self._version, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + return self._context + + def fetch(self) -> "AccountInstance": + """ + Fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AccountInstance": + """ + Asynchronous coroutine to fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the AccountInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.fetch_with_http_info() + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the AccountInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_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 "".format(context) + + +class AccountContext(InstanceContext): + + def __init__(self, version: Version, organization_sid: str, account_sid: str): + """ + Initialize the AccountContext + + :param version: Version that contains the resource + :param organization_sid: + :param account_sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "account_sid": account_sid, + } + self._uri = "/{organization_sid}/Accounts/{account_sid}".format( + **self._solution + ) + + def _fetch(self) -> tuple: + """ + Internal helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> AccountInstance: + """ + Fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + payload, _, _ = self._fetch() + return AccountInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the AccountInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = AccountInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _fetch_async(self) -> tuple: + """ + Internal async helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.fetch_with_response_info_async( + method="GET", uri=self._uri, headers=headers + ) + + async def fetch_async(self) -> AccountInstance: + """ + Asynchronous coroutine to fetch the AccountInstance + + + :returns: The fetched AccountInstance + """ + payload, _, _ = await self._fetch_async() + return AccountInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the AccountInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = AccountInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + account_sid=self._solution["account_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + 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 "".format(context) + + +class AccountPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AccountInstance: + """ + Build an instance of AccountInstance + + :param payload: Payload response from the API + """ + + return AccountInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AccountList(ListResource): + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the AccountList + + :param version: Version that contains the resource + :param organization_sid: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + } + self._uri = "/{organization_sid}/Accounts".format(**self._solution) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AccountInstance]: + """ + Streams AccountInstance 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[AccountInstance]: + """ + Asynchronously streams AccountInstance 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 stream_with_http_info( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams AccountInstance and returns headers from first page + + + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info(page_size=limits["page_size"]) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams AccountInstance and returns headers from first page + + + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + page_size=limits["page_size"] + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AccountInstance]: + """ + Lists AccountInstance 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[AccountInstance]: + """ + Asynchronously lists AccountInstance 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 list_with_http_info( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists AccountInstance and returns headers from first page + + + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists AccountInstance and returns headers from first page + + + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AccountPage: + """ + Retrieve a single page of AccountInstance 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 AccountInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AccountPage(self._version, response, solution=self._solution) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AccountPage: + """ + Asynchronously retrieve a single page of AccountInstance 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 AccountInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AccountPage(self._version, response, solution=self._solution) + + def page_with_http_info( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :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: ApiResponse with AccountPage, status code, and headers + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = AccountPage(self._version, response, solution=self._solution) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :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: ApiResponse with AccountPage, status code, and headers + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = AccountPage(self._version, response, solution=self._solution) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> AccountPage: + """ + Retrieve a specific page of AccountInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AccountInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AccountPage(self._version, response, solution=self._solution) + + async def get_page_async(self, target_url: str) -> AccountPage: + """ + Asynchronously retrieve a specific page of AccountInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AccountInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AccountPage(self._version, response, solution=self._solution) + + def get(self, organization_sid: str, account_sid: str) -> AccountContext: + """ + Constructs a AccountContext + + :param organization_sid: + :param account_sid: + """ + return AccountContext( + self._version, organization_sid=organization_sid, account_sid=account_sid + ) + + def __call__(self, organization_sid: str, account_sid: str) -> AccountContext: + """ + Constructs a AccountContext + + :param organization_sid: + :param account_sid: + """ + return AccountContext( + self._version, organization_sid=organization_sid, account_sid=account_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/role_assignment.py b/twilio/rest/preview_iam/organizations/role_assignment.py new file mode 100644 index 000000000..79935875d --- /dev/null +++ b/twilio/rest/preview_iam/organizations/role_assignment.py @@ -0,0 +1,1025 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import values +from twilio.base.api_response import ApiResponse +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 RoleAssignmentInstance(InstanceResource): + + class PublicApiCreateRoleAssignmentRequest(object): + """ + :ivar role_sid: Twilio Role Sid representing assigned role + :ivar scope: Twilio Sid representing scope of this assignment + :ivar identity: Twilio Sid representing identity of this assignment + :ivar resource_type: The resource type for resource-level role assignments + :ivar resource_id: The resource id for resource-level role assignments + """ + + def __init__(self, payload: Dict[str, Any]): + + self.role_sid: Optional[str] = payload.get("role_sid") + self.scope: Optional[str] = payload.get("scope") + self.identity: Optional[str] = payload.get("identity") + self.resource_type: Optional[str] = payload.get("resource_type") + self.resource_id: Optional[str] = payload.get("resource_id") + + def to_dict(self): + return { + "role_sid": self.role_sid, + "scope": self.scope, + "identity": self.identity, + "resource_type": self.resource_type, + "resource_id": self.resource_id, + } + + """ + :ivar sid: Twilio Role Assignment Sid representing this role assignment + :ivar role_sid: Twilio Role Sid representing assigned role + :ivar scope: Twilio Sid representing identity of this assignment + :ivar identity: Twilio Sid representing scope of this assignment + :ivar resource_type: The resource type for resource-level role assignments + :ivar resource_id: The resource id for resource-level role assignments + :ivar code: Twilio-specific error code + :ivar message: Error message + :ivar more_info: Link to Error Code References + :ivar status: HTTP response status code + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + organization_sid: Optional[str] = None, + role_assignment_sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.role_sid: Optional[str] = payload.get("role_sid") + self.scope: Optional[str] = payload.get("scope") + self.identity: Optional[str] = payload.get("identity") + self.resource_type: Optional[str] = payload.get("resource_type") + self.resource_id: Optional[str] = payload.get("resource_id") + self.code: Optional[int] = payload.get("code") + self.message: Optional[str] = payload.get("message") + self.more_info: Optional[str] = payload.get("moreInfo") + self.status: Optional[int] = payload.get("status") + + self._solution = { + "organization_sid": organization_sid or self.organization_sid, + "role_assignment_sid": role_assignment_sid or self.role_assignment_sid, + } + + self._context: Optional[RoleAssignmentContext] = None + + @property + def _proxy(self) -> "RoleAssignmentContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: RoleAssignmentContext for this RoleAssignmentInstance + """ + if self._context is None: + self._context = RoleAssignmentContext( + self._version, + organization_sid=self._solution["organization_sid"], + role_assignment_sid=self._solution["role_assignment_sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the RoleAssignmentInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_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 "".format( + context + ) + + +class RoleAssignmentContext(InstanceContext): + + class PublicApiCreateRoleAssignmentRequest(object): + """ + :ivar role_sid: Twilio Role Sid representing assigned role + :ivar scope: Twilio Sid representing scope of this assignment + :ivar identity: Twilio Sid representing identity of this assignment + :ivar resource_type: The resource type for resource-level role assignments + :ivar resource_id: The resource id for resource-level role assignments + """ + + def __init__(self, payload: Dict[str, Any]): + + self.role_sid: Optional[str] = payload.get("role_sid") + self.scope: Optional[str] = payload.get("scope") + self.identity: Optional[str] = payload.get("identity") + self.resource_type: Optional[str] = payload.get("resource_type") + self.resource_id: Optional[str] = payload.get("resource_id") + + def to_dict(self): + return { + "role_sid": self.role_sid, + "scope": self.scope, + "identity": self.identity, + "resource_type": self.resource_type, + "resource_id": self.resource_id, + } + + def __init__( + self, version: Version, organization_sid: str, role_assignment_sid: str + ): + """ + Initialize the RoleAssignmentContext + + :param version: Version that contains the resource + :param organization_sid: + :param role_assignment_sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "role_assignment_sid": role_assignment_sid, + } + self._uri = "/{organization_sid}/RoleAssignments/{role_assignment_sid}".format( + **self._solution + ) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the RoleAssignmentInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + 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 "".format( + context + ) + + +class RoleAssignmentPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> RoleAssignmentInstance: + """ + Build an instance of RoleAssignmentInstance + + :param payload: Payload response from the API + """ + + return RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class RoleAssignmentList(ListResource): + + class PublicApiCreateRoleAssignmentRequest(object): + """ + :ivar role_sid: Twilio Role Sid representing assigned role + :ivar scope: Twilio Sid representing scope of this assignment + :ivar identity: Twilio Sid representing identity of this assignment + :ivar resource_type: The resource type for resource-level role assignments + :ivar resource_id: The resource id for resource-level role assignments + """ + + def __init__(self, payload: Dict[str, Any]): + + self.role_sid: Optional[str] = payload.get("role_sid") + self.scope: Optional[str] = payload.get("scope") + self.identity: Optional[str] = payload.get("identity") + self.resource_type: Optional[str] = payload.get("resource_type") + self.resource_id: Optional[str] = payload.get("resource_id") + + def to_dict(self): + return { + "role_sid": self.role_sid, + "scope": self.scope, + "identity": self.identity, + "resource_type": self.resource_type, + "resource_id": self.resource_id, + } + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the RoleAssignmentList + + :param version: Version that contains the resource + :param organization_sid: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + } + self._uri = "/{organization_sid}/RoleAssignments".format(**self._solution) + + def _create( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = public_api_create_role_assignment_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> RoleAssignmentInstance: + """ + Create the RoleAssignmentInstance + + :param public_api_create_role_assignment_request: + + :returns: The created RoleAssignmentInstance + """ + payload, _, _ = self._create( + public_api_create_role_assignment_request=public_api_create_role_assignment_request + ) + return RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def create_with_http_info( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> ApiResponse: + """ + Create the RoleAssignmentInstance and return response metadata + + :param public_api_create_role_assignment_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create( + public_api_create_role_assignment_request=public_api_create_role_assignment_request + ) + instance = RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = public_api_create_role_assignment_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def create_async( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> RoleAssignmentInstance: + """ + Asynchronously create the RoleAssignmentInstance + + :param public_api_create_role_assignment_request: + + :returns: The created RoleAssignmentInstance + """ + payload, _, _ = await self._create_async( + public_api_create_role_assignment_request=public_api_create_role_assignment_request + ) + return RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + async def create_with_http_info_async( + self, + public_api_create_role_assignment_request: PublicApiCreateRoleAssignmentRequest, + ) -> ApiResponse: + """ + Asynchronously create the RoleAssignmentInstance and return response metadata + + :param public_api_create_role_assignment_request: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async( + public_api_create_role_assignment_request=public_api_create_role_assignment_request + ) + instance = RoleAssignmentInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def stream( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[RoleAssignmentInstance]: + """ + Streams RoleAssignmentInstance 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 identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[RoleAssignmentInstance]: + """ + Asynchronously streams RoleAssignmentInstance 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 identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams RoleAssignmentInstance and returns headers from first page + + + :param str identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + page_size=limits["page_size"], + ) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams RoleAssignmentInstance and returns headers from first page + + + :param str identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + page_size=limits["page_size"], + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[RoleAssignmentInstance]: + """ + Lists RoleAssignmentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[RoleAssignmentInstance]: + """ + Asynchronously lists RoleAssignmentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists RoleAssignmentInstance and returns headers from first page + + + :param str identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists RoleAssignmentInstance and returns headers from first page + + + :param str identity: + :param str scope: + :param str resource_type: Filter by resource type for resource-level role assignments + :param str resource_id: Filter by resource id for resource-level role assignments + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + identity=identity, + scope=scope, + resource_type=resource_type, + resource_id=resource_id, + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: 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, + ) -> RoleAssignmentPage: + """ + Retrieve a single page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param identity: + :param scope: + :param resource_type: Filter by resource type for resource-level role assignments + :param resource_id: Filter by resource id for resource-level role assignments + :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 RoleAssignmentInstance + """ + data = values.of( + { + "Identity": identity, + "Scope": scope, + "ResourceType": resource_type, + "ResourceId": resource_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return RoleAssignmentPage(self._version, response, solution=self._solution) + + async def page_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: 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, + ) -> RoleAssignmentPage: + """ + Asynchronously retrieve a single page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param identity: + :param scope: + :param resource_type: Filter by resource type for resource-level role assignments + :param resource_id: Filter by resource id for resource-level role assignments + :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 RoleAssignmentInstance + """ + data = values.of( + { + "Identity": identity, + "Scope": scope, + "ResourceType": resource_type, + "ResourceId": resource_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return RoleAssignmentPage(self._version, response, solution=self._solution) + + def page_with_http_info( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: 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, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :param identity: + :param scope: + :param resource_type: Filter by resource type for resource-level role assignments + :param resource_id: Filter by resource id for resource-level role assignments + :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: ApiResponse with RoleAssignmentPage, status code, and headers + """ + data = values.of( + { + "Identity": identity, + "Scope": scope, + "ResourceType": resource_type, + "ResourceId": resource_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = RoleAssignmentPage(self._version, response, solution=self._solution) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + identity: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + resource_type: Union[str, object] = values.unset, + resource_id: 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, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :param identity: + :param scope: + :param resource_type: Filter by resource type for resource-level role assignments + :param resource_id: Filter by resource id for resource-level role assignments + :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: ApiResponse with RoleAssignmentPage, status code, and headers + """ + data = values.of( + { + "Identity": identity, + "Scope": scope, + "ResourceType": resource_type, + "ResourceId": resource_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = RoleAssignmentPage(self._version, response, solution=self._solution) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> RoleAssignmentPage: + """ + Retrieve a specific page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of RoleAssignmentInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return RoleAssignmentPage(self._version, response, solution=self._solution) + + async def get_page_async(self, target_url: str) -> RoleAssignmentPage: + """ + Asynchronously retrieve a specific page of RoleAssignmentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of RoleAssignmentInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return RoleAssignmentPage(self._version, response, solution=self._solution) + + def get( + self, organization_sid: str, role_assignment_sid: str + ) -> RoleAssignmentContext: + """ + Constructs a RoleAssignmentContext + + :param organization_sid: + :param role_assignment_sid: + """ + return RoleAssignmentContext( + self._version, + organization_sid=organization_sid, + role_assignment_sid=role_assignment_sid, + ) + + def __call__( + self, organization_sid: str, role_assignment_sid: str + ) -> RoleAssignmentContext: + """ + Constructs a RoleAssignmentContext + + :param organization_sid: + :param role_assignment_sid: + """ + return RoleAssignmentContext( + self._version, + organization_sid=organization_sid, + role_assignment_sid=role_assignment_sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/organizations/user.py b/twilio/rest/preview_iam/organizations/user.py new file mode 100644 index 000000000..a2601196c --- /dev/null +++ b/twilio/rest/preview_iam/organizations/user.py @@ -0,0 +1,1898 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Organization Public API + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import values +from twilio.base.api_response import ApiResponse +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 UserInstance(InstanceResource): + + class ScimEmailAddress(object): + """ + :ivar primary: Indicates if this email address is the primary one + :ivar value: The actual email address value + :ivar type: The type of email address (e.g., work, home, etc.) + """ + + def __init__(self, payload: Dict[str, Any]): + + self.primary: Optional[bool] = payload.get("primary") + self.value: Optional[str] = payload.get("value") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "primary": self.primary, + "value": self.value, + "type": self.type, + } + + class ScimMeta(object): + """ + :ivar resource_type: Indicates the type of the resource + :ivar created: The date and time when the resource was created in the system + :ivar last_modified: The date and time when the resource was last modified + :ivar version: A version identifier for the resource. This can be used to manage resource versioning and concurrency control. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.resource_type: Optional[str] = payload.get("resourceType") + self.created: Optional[datetime] = payload.get("created") + self.last_modified: Optional[datetime] = payload.get("lastModified") + self.version: Optional[str] = payload.get("version") + + def to_dict(self): + return { + "resourceType": self.resource_type, + "created": self.created, + "lastModified": self.last_modified, + "version": self.version, + } + + class ScimName(object): + """ + :ivar given_name: The user's first or given name + :ivar family_name: The user's last or family name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.given_name: Optional[str] = payload.get("givenName") + self.family_name: Optional[str] = payload.get("familyName") + + def to_dict(self): + return { + "givenName": self.given_name, + "familyName": self.family_name, + } + + class ScimPatchOperation(object): + """ + :ivar op: The operation to perform + :ivar path: + :ivar value: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.op: Optional[str] = payload.get("op") + self.path: Optional[str] = payload.get("path") + self.value: Optional[Dict[str, object]] = payload.get("value") + + def to_dict(self): + return { + "op": self.op, + "path": self.path, + "value": self.value, + } + + class ScimPatchRequest(object): + """ + :ivar schemas: + :ivar operations: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.schemas: Optional[List[str]] = payload.get("schemas") + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None + ) + + def to_dict(self): + return { + "schemas": self.schemas, + "Operations": ( + [operations.to_dict() for operations in self.operations] + if self.operations is not None + else None + ), + } + + class ScimUser(object): + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("externalId") + self.user_name: Optional[str] = payload.get("userName") + self.display_name: Optional[str] = payload.get("displayName") + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if isinstance(payload.get("name"), dict) + else payload.get("name") + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None + ) + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if isinstance(payload.get("meta"), dict) + else payload.get("meta") + ) + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scimType") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("moreInfo") + + def to_dict(self): + return { + "id": self.id, + "externalId": self.external_id, + "userName": self.user_name, + "displayName": self.display_name, + "name": self.name.to_dict() if self.name is not None else None, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "active": self.active, + "locale": self.locale, + "timezone": self.timezone, + "schemas": self.schemas, + "meta": self.meta.to_dict() if self.meta is not None else None, + "detail": self.detail, + "scimType": self.scim_type, + "status": self.status, + "code": self.code, + "moreInfo": self.more_info, + } + + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + organization_sid: Optional[str] = None, + user_sid: Optional[str] = None, + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("externalId") + self.user_name: Optional[str] = payload.get("userName") + self.display_name: Optional[str] = payload.get("displayName") + self.name: Optional[UserList.ScimName] = payload.get("name") + self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get("emails") + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scimType") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("moreInfo") + + self._solution = { + "organization_sid": organization_sid or self.organization_sid, + "user_sid": user_sid or self.user_sid, + } + + self._context: Optional[UserContext] = None + + @property + def _proxy(self) -> "UserContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: UserContext for this UserInstance + """ + if self._context is None: + self._context = UserContext( + self._version, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the UserInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the UserInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + + def fetch(self) -> "UserInstance": + """ + Fetch the UserInstance + + + :returns: The fetched UserInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "UserInstance": + """ + Asynchronous coroutine to fetch the UserInstance + + + :returns: The fetched UserInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the UserInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.fetch_with_http_info() + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the UserInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def patch( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> "UserInstance": + """ + Patch the UserInstance + + :param scim_patch_request: + :param if_match: + + :returns: The patched UserInstance + """ + return self._proxy.patch( + scim_patch_request=scim_patch_request, + if_match=if_match, + ) + + async def patch_async( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> "UserInstance": + """ + Asynchronous coroutine to patch the UserInstance + + :param scim_patch_request: + :param if_match: + + :returns: The patched UserInstance + """ + return await self._proxy.patch_async( + scim_patch_request=scim_patch_request, + if_match=if_match, + ) + + def update( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> "UserInstance": + """ + Update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + return self._proxy.update( + scim_user=scim_user, + if_match=if_match, + ) + + async def update_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> "UserInstance": + """ + Asynchronous coroutine to update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + return await self._proxy.update_async( + scim_user=scim_user, + if_match=if_match, + ) + + def update_with_http_info( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> ApiResponse: + """ + Update the UserInstance with HTTP info + + :param scim_user: + :param if_match: + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + scim_user=scim_user, + if_match=if_match, + ) + + async def update_with_http_info_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> ApiResponse: + """ + Asynchronous coroutine to update the UserInstance with HTTP info + + :param scim_user: + :param if_match: + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + scim_user=scim_user, + if_match=if_match, + ) + + 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 "".format(context) + + +class UserContext(InstanceContext): + + class ScimEmailAddress(object): + """ + :ivar primary: Indicates if this email address is the primary one + :ivar value: The actual email address value + :ivar type: The type of email address (e.g., work, home, etc.) + """ + + def __init__(self, payload: Dict[str, Any]): + + self.primary: Optional[bool] = payload.get("primary") + self.value: Optional[str] = payload.get("value") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "primary": self.primary, + "value": self.value, + "type": self.type, + } + + class ScimMeta(object): + """ + :ivar resource_type: Indicates the type of the resource + :ivar created: The date and time when the resource was created in the system + :ivar last_modified: The date and time when the resource was last modified + :ivar version: A version identifier for the resource. This can be used to manage resource versioning and concurrency control. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.resource_type: Optional[str] = payload.get("resourceType") + self.created: Optional[datetime] = payload.get("created") + self.last_modified: Optional[datetime] = payload.get("lastModified") + self.version: Optional[str] = payload.get("version") + + def to_dict(self): + return { + "resourceType": self.resource_type, + "created": self.created, + "lastModified": self.last_modified, + "version": self.version, + } + + class ScimName(object): + """ + :ivar given_name: The user's first or given name + :ivar family_name: The user's last or family name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.given_name: Optional[str] = payload.get("givenName") + self.family_name: Optional[str] = payload.get("familyName") + + def to_dict(self): + return { + "givenName": self.given_name, + "familyName": self.family_name, + } + + class ScimPatchOperation(object): + """ + :ivar op: The operation to perform + :ivar path: + :ivar value: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.op: Optional[str] = payload.get("op") + self.path: Optional[str] = payload.get("path") + self.value: Optional[Dict[str, object]] = payload.get("value") + + def to_dict(self): + return { + "op": self.op, + "path": self.path, + "value": self.value, + } + + class ScimPatchRequest(object): + """ + :ivar schemas: + :ivar operations: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.schemas: Optional[List[str]] = payload.get("schemas") + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None + ) + + def to_dict(self): + return { + "schemas": self.schemas, + "Operations": ( + [operations.to_dict() for operations in self.operations] + if self.operations is not None + else None + ), + } + + class ScimUser(object): + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("externalId") + self.user_name: Optional[str] = payload.get("userName") + self.display_name: Optional[str] = payload.get("displayName") + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if isinstance(payload.get("name"), dict) + else payload.get("name") + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None + ) + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if isinstance(payload.get("meta"), dict) + else payload.get("meta") + ) + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scimType") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("moreInfo") + + def to_dict(self): + return { + "id": self.id, + "externalId": self.external_id, + "userName": self.user_name, + "displayName": self.display_name, + "name": self.name.to_dict() if self.name is not None else None, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "active": self.active, + "locale": self.locale, + "timezone": self.timezone, + "schemas": self.schemas, + "meta": self.meta.to_dict() if self.meta is not None else None, + "detail": self.detail, + "scimType": self.scim_type, + "status": self.status, + "code": self.code, + "moreInfo": self.more_info, + } + + def __init__(self, version: Version, organization_sid: str, user_sid: str): + """ + Initialize the UserContext + + :param version: Version that contains the resource + :param organization_sid: + :param user_sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "user_sid": user_sid, + } + self._uri = "/{organization_sid}/scim/Users/{user_sid}".format(**self._solution) + + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the UserInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the UserInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + def _fetch(self) -> tuple: + """ + Internal helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> UserInstance: + """ + Fetch the UserInstance + + + :returns: The fetched UserInstance + """ + payload, _, _ = self._fetch() + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the UserInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _fetch_async(self) -> tuple: + """ + Internal async helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return await self._version.fetch_with_response_info_async( + method="GET", uri=self._uri, headers=headers + ) + + async def fetch_async(self) -> UserInstance: + """ + Asynchronous coroutine to fetch the UserInstance + + + :returns: The fetched UserInstance + """ + payload, _, _ = await self._fetch_async() + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the UserInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _patch( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal helper for patch operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = scim_patch_request.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + return self._version.patch_with_response_info( + method="PATCH", uri=self._uri, data=data, headers=headers + ) + + def patch( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> UserInstance: + """ + Patch the UserInstance + + :param scim_patch_request: + :param if_match: + + :returns: The patched UserInstance + """ + payload, _, _ = self._patch( + scim_patch_request=scim_patch_request, if_match=if_match + ) + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + + def patch_with_http_info( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Patch the UserInstance and return response metadata + + :param scim_patch_request: + :param if_match: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._patch( + scim_patch_request=scim_patch_request, if_match=if_match + ) + instance = UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _patch_async( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal async helper for patch operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = scim_patch_request.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + return await self._version.patch_with_response_info_async( + method="PATCH", uri=self._uri, data=data, headers=headers + ) + + async def patch_async( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> UserInstance: + """ + Asynchronous coroutine to patch the UserInstance + + :param scim_patch_request: + :param if_match: + + :returns: The patched UserInstance + """ + payload, _, _ = await self._patch_async( + scim_patch_request=scim_patch_request, if_match=if_match + ) + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + + async def patch_with_http_info_async( + self, + scim_patch_request: ScimPatchRequest, + if_match: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to patch the UserInstance and return response metadata + + :param scim_patch_request: + :param if_match: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._patch_async( + scim_patch_request=scim_patch_request, if_match=if_match + ) + instance = UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = scim_user.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + return self._version.update_with_response_info( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + def update( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> UserInstance: + """ + Update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + payload, _, _ = self._update(scim_user=scim_user, if_match=if_match) + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + + def update_with_http_info( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> ApiResponse: + """ + Update the UserInstance and return response metadata + + :param scim_user: + :param if_match: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + scim_user=scim_user, if_match=if_match + ) + instance = UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = scim_user.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + return await self._version.update_with_response_info_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> UserInstance: + """ + Asynchronous coroutine to update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + payload, _, _ = await self._update_async(scim_user=scim_user, if_match=if_match) + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + + async def update_with_http_info_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> ApiResponse: + """ + Asynchronous coroutine to update the UserInstance and return response metadata + + :param scim_user: + :param if_match: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + scim_user=scim_user, if_match=if_match + ) + instance = UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + user_sid=self._solution["user_sid"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + 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 "".format(context) + + +class UserPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: + """ + Build an instance of UserInstance + + :param payload: Payload response from the API + """ + + return UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class UserList(ListResource): + + class ScimEmailAddress(object): + """ + :ivar primary: Indicates if this email address is the primary one + :ivar value: The actual email address value + :ivar type: The type of email address (e.g., work, home, etc.) + """ + + def __init__(self, payload: Dict[str, Any]): + + self.primary: Optional[bool] = payload.get("primary") + self.value: Optional[str] = payload.get("value") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "primary": self.primary, + "value": self.value, + "type": self.type, + } + + class ScimMeta(object): + """ + :ivar resource_type: Indicates the type of the resource + :ivar created: The date and time when the resource was created in the system + :ivar last_modified: The date and time when the resource was last modified + :ivar version: A version identifier for the resource. This can be used to manage resource versioning and concurrency control. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.resource_type: Optional[str] = payload.get("resourceType") + self.created: Optional[datetime] = payload.get("created") + self.last_modified: Optional[datetime] = payload.get("lastModified") + self.version: Optional[str] = payload.get("version") + + def to_dict(self): + return { + "resourceType": self.resource_type, + "created": self.created, + "lastModified": self.last_modified, + "version": self.version, + } + + class ScimName(object): + """ + :ivar given_name: The user's first or given name + :ivar family_name: The user's last or family name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.given_name: Optional[str] = payload.get("givenName") + self.family_name: Optional[str] = payload.get("familyName") + + def to_dict(self): + return { + "givenName": self.given_name, + "familyName": self.family_name, + } + + class ScimPatchOperation(object): + """ + :ivar op: The operation to perform + :ivar path: + :ivar value: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.op: Optional[str] = payload.get("op") + self.path: Optional[str] = payload.get("path") + self.value: Optional[Dict[str, object]] = payload.get("value") + + def to_dict(self): + return { + "op": self.op, + "path": self.path, + "value": self.value, + } + + class ScimPatchRequest(object): + """ + :ivar schemas: + :ivar operations: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.schemas: Optional[List[str]] = payload.get("schemas") + self.operations: Optional[List[UserList.ScimPatchOperation]] = ( + [ + ( + UserList.ScimPatchOperation(item) + if isinstance(item, dict) + else item + ) + for item in payload.get("Operations") + ] + if payload.get("Operations") is not None + else None + ) + + def to_dict(self): + return { + "schemas": self.schemas, + "Operations": ( + [operations.to_dict() for operations in self.operations] + if self.operations is not None + else None + ), + } + + class ScimUser(object): + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("externalId") + self.user_name: Optional[str] = payload.get("userName") + self.display_name: Optional[str] = payload.get("displayName") + self.name: Optional[UserList.ScimName] = ( + UserList.ScimName(payload.get("name")) + if isinstance(payload.get("name"), dict) + else payload.get("name") + ) + self.emails: Optional[List[UserList.ScimEmailAddress]] = ( + [ + UserList.ScimEmailAddress(item) if isinstance(item, dict) else item + for item in payload.get("emails") + ] + if payload.get("emails") is not None + else None + ) + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = ( + UserList.ScimMeta(payload.get("meta")) + if isinstance(payload.get("meta"), dict) + else payload.get("meta") + ) + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scimType") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("moreInfo") + + def to_dict(self): + return { + "id": self.id, + "externalId": self.external_id, + "userName": self.user_name, + "displayName": self.display_name, + "name": self.name.to_dict() if self.name is not None else None, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "active": self.active, + "locale": self.locale, + "timezone": self.timezone, + "schemas": self.schemas, + "meta": self.meta.to_dict() if self.meta is not None else None, + "detail": self.detail, + "scimType": self.scim_type, + "status": self.status, + "code": self.code, + "moreInfo": self.more_info, + } + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the UserList + + :param version: Version that contains the resource + :param organization_sid: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + } + self._uri = "/{organization_sid}/scim/Users".format(**self._solution) + + def _create(self, scim_user: ScimUser) -> tuple: + """ + Internal helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = scim_user.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + return self._version.create_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def create(self, scim_user: ScimUser) -> UserInstance: + """ + Create the UserInstance + + :param scim_user: + + :returns: The created UserInstance + """ + payload, _, _ = self._create(scim_user=scim_user) + return UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def create_with_http_info(self, scim_user: ScimUser) -> ApiResponse: + """ + Create the UserInstance and return response metadata + + :param scim_user: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._create(scim_user=scim_user) + instance = UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _create_async(self, scim_user: ScimUser) -> tuple: + """ + Internal async helper for create operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = scim_user.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + return await self._version.create_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def create_async(self, scim_user: ScimUser) -> UserInstance: + """ + Asynchronously create the UserInstance + + :param scim_user: + + :returns: The created UserInstance + """ + payload, _, _ = await self._create_async(scim_user=scim_user) + return UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + async def create_with_http_info_async(self, scim_user: ScimUser) -> ApiResponse: + """ + Asynchronously create the UserInstance and return response metadata + + :param scim_user: + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._create_async(scim_user=scim_user) + instance = UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def stream( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[UserInstance]: + """ + Streams UserInstance 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 filter: + :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(filter=filter, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[UserInstance]: + """ + Asynchronously streams UserInstance 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 filter: + :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(filter=filter, page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams UserInstance and returns headers from first page + + + :param str filter: + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info( + filter=filter, page_size=limits["page_size"] + ) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Asynchronously streams UserInstance and returns headers from first page + + + :param str filter: + :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: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + filter=filter, page_size=limits["page_size"] + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[UserInstance]: + """ + Lists UserInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str filter: + :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( + filter=filter, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[UserInstance]: + """ + Asynchronously lists UserInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str filter: + :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( + filter=filter, + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists UserInstance and returns headers from first page + + + :param str filter: + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + filter=filter, + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists UserInstance and returns headers from first page + + + :param str filter: + :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: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + filter=filter, + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + filter: 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, + ) -> UserPage: + """ + Retrieve a single page of UserInstance records from the API. + Request is executed immediately + + :param filter: + :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 UserInstance + """ + data = values.of( + { + "filter": filter, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/scim+json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return UserPage(self._version, response, solution=self._solution) + + async def page_async( + self, + filter: 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, + ) -> UserPage: + """ + Asynchronously retrieve a single page of UserInstance records from the API. + Request is executed immediately + + :param filter: + :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 UserInstance + """ + data = values.of( + { + "filter": filter, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/scim+json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return UserPage(self._version, response, solution=self._solution) + + def page_with_http_info( + self, + filter: 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, + ) -> ApiResponse: + """ + Retrieve a single page with response metadata + + + :param filter: + :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: ApiResponse with UserPage, status code, and headers + """ + data = values.of( + { + "filter": filter, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/scim+json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = UserPage(self._version, response, solution=self._solution) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + filter: 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, + ) -> ApiResponse: + """ + Asynchronously retrieve a single page with response metadata + + + :param filter: + :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: ApiResponse with UserPage, status code, and headers + """ + data = values.of( + { + "filter": filter, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/scim+json" + + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + ) + page = UserPage(self._version, response, solution=self._solution) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + def get_page(self, target_url: str) -> UserPage: + """ + Retrieve a specific page of UserInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of UserInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return UserPage(self._version, response, solution=self._solution) + + async def get_page_async(self, target_url: str) -> UserPage: + """ + Asynchronously retrieve a specific page of UserInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of UserInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return UserPage(self._version, response, solution=self._solution) + + def get(self, organization_sid: str, user_sid: str) -> UserContext: + """ + Constructs a UserContext + + :param organization_sid: + :param user_sid: + """ + return UserContext( + self._version, organization_sid=organization_sid, user_sid=user_sid + ) + + def __call__(self, organization_sid: str, user_sid: str) -> UserContext: + """ + Constructs a UserContext + + :param organization_sid: + :param user_sid: + """ + return UserContext( + self._version, organization_sid=organization_sid, user_sid=user_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/routes/v3/__init__.py b/twilio/rest/routes/v3/__init__.py index 07d47c0f6..e4458c94b 100644 --- a/twilio/rest/routes/v3/__init__.py +++ b/twilio/rest/routes/v3/__init__.py @@ -15,6 +15,7 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.routes.v3.iso_country_code import IsoCountryCodeList from twilio.rest.routes.v3.phone_number import PhoneNumberList @@ -29,6 +30,22 @@ def __init__(self, domain: Domain): super().__init__(domain, "v3") self._phone_numbers: Optional[PhoneNumberList] = None + def iso_country_code( + self, iso_country_code: str, short_code: str, iso_country_code_id: str = None + ): + """ + Access the IsoCountryCodeList resource + + :param iso_country_code: The ISO country code of the short code + + :param short_code: The short code + + :param iso_country_code_id: Optional instance ID to directly access IsoCountryCodeContext + :returns: IsoCountryCodeList instance if iso_country_code_id is None, otherwise IsoCountryCodeContext + """ + list_instance = IsoCountryCodeList(self) + return list_instance(iso_country_codeshort_code) + @property def phone_numbers(self) -> PhoneNumberList: if self._phone_numbers is None: diff --git a/twilio/rest/routes/v3/iso_country_code.py b/twilio/rest/routes/v3/iso_country_code.py new file mode 100644 index 000000000..7f6f770d2 --- /dev/null +++ b/twilio/rest/routes/v3/iso_country_code.py @@ -0,0 +1,518 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Routes + 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 __future__ import annotations + +from datetime import datetime +from typing import Any, Dict, Optional, Union +from twilio.base import deserialize, values +from twilio.base.api_response import ApiResponse +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class IsoCountryCodeInstance(InstanceResource): + """ + :ivar iso_country_code: The ISO country code of the short code + :ivar short_code: The short code + :ivar url: The absolute URL of the resource. + :ivar account_sid: The unique SID identifier of the Account. + :ivar friendly_name: A human readable description of the Inbound Processing Region assignment for this short code, up to 64 characters. + :ivar messaging_region: The Inbound Processing Region used for this short code for messaging. + :ivar date_created: The date that this short code was assigned an Inbound Processing Region, given in ISO 8601 format. + :ivar date_updated: The date that the Inbound Processing Region was updated for this short code, given in ISO 8601 format. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + iso_country_code: Optional[str] = None, + short_code: Optional[str] = None, + ): + super().__init__(version) + + self.iso_country_code: Optional[str] = payload.get("isoCountryCode") + self.short_code: Optional[str] = payload.get("shortCode") + self.url: Optional[str] = payload.get("url") + self.account_sid: Optional[str] = payload.get("accountSid") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.messaging_region: Optional[str] = payload.get("messagingRegion") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateCreated") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateUpdated") + ) + + # Only set _solution if path params are provided (not None) + if iso_country_code is not None or short_code is not None: + self._solution = { + "iso_country_code": iso_country_code, + "short_code": short_code, + } + + self._context: Optional[IsoCountryCodeContext] = None + + @property + def _proxy(self) -> "IsoCountryCodeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: IsoCountryCodeContext for this IsoCountryCodeInstance + """ + if self._context is None: + self._context = IsoCountryCodeContext( + self._version, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return self._context + + def fetch(self) -> "IsoCountryCodeInstance": + """ + Fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "IsoCountryCodeInstance": + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the IsoCountryCodeInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.fetch_with_http_info() + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "IsoCountryCodeInstance": + """ + Update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + return self._proxy.update( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + async def update_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "IsoCountryCodeInstance": + """ + Asynchronous coroutine to update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + return await self._proxy.update_async( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + def update_with_http_info( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Update the IsoCountryCodeInstance with HTTP info + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + async def update_with_http_info_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the IsoCountryCodeInstance with HTTP info + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + 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 "".format(context) + + +class IsoCountryCodeContext(InstanceContext): + + def __init__(self, version: Version, iso_country_code: str, short_code: str): + """ + Initialize the IsoCountryCodeContext + + :param version: Version that contains the resource + :param iso_country_code: The ISO country code of the short code + :param short_code: The short code + """ + super().__init__(version) + + # Path Solution + self._solution = { + "iso_country_code": iso_country_code, + "short_code": short_code, + } + self._uri = "/ShortCodes/{iso_country_code}/{short_code}".format( + **self._solution + ) + + def _fetch(self) -> tuple: + """ + Internal helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> IsoCountryCodeInstance: + """ + Fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + payload, _, _ = self._fetch() + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the IsoCountryCodeInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _fetch_async(self) -> tuple: + """ + Internal async helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.fetch_with_response_info_async( + method="GET", uri=self._uri, headers=headers + ) + + async def fetch_async(self) -> IsoCountryCodeInstance: + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + payload, _, _ = await self._fetch_async() + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of( + { + "messagingRegion": messaging_region, + "friendlyName": friendly_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> IsoCountryCodeInstance: + """ + Update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + payload, _, _ = self._update( + messaging_region=messaging_region, friendly_name=friendly_name + ) + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + def update_with_http_info( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Update the IsoCountryCodeInstance and return response metadata + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + messaging_region=messaging_region, friendly_name=friendly_name + ) + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of( + { + "messagingRegion": messaging_region, + "friendlyName": friendly_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> IsoCountryCodeInstance: + """ + Asynchronous coroutine to update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + payload, _, _ = await self._update_async( + messaging_region=messaging_region, friendly_name=friendly_name + ) + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + async def update_with_http_info_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the IsoCountryCodeInstance and return response metadata + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + messaging_region=messaging_region, friendly_name=friendly_name + ) + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + 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 "".format(context) + + +class IsoCountryCodeList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the IsoCountryCodeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, iso_country_code: str, short_code: str) -> IsoCountryCodeContext: + """ + Constructs a IsoCountryCodeContext + + :param iso_country_code: The ISO country code of the short code + :param short_code: The short code + """ + return IsoCountryCodeContext( + self._version, iso_country_code=iso_country_code, short_code=short_code + ) + + def __call__(self, iso_country_code: str, short_code: str) -> IsoCountryCodeContext: + """ + Constructs a IsoCountryCodeContext + + :param iso_country_code: The ISO country code of the short code + :param short_code: The short code + """ + return IsoCountryCodeContext( + self._version, iso_country_code=iso_country_code, short_code=short_code + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/verify/v2/service/approve_challenge.py b/twilio/rest/verify/v2/service/approve_challenge.py index d6d7e26ac..9d39ee76c 100644 --- a/twilio/rest/verify/v2/service/approve_challenge.py +++ b/twilio/rest/verify/v2/service/approve_challenge.py @@ -47,8 +47,8 @@ def __init__(self, payload: Dict[str, Any]): ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): @@ -177,8 +177,8 @@ def __init__(self, payload: Dict[str, Any]): ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): diff --git a/twilio/rest/verify/v2/service/new_factor.py b/twilio/rest/verify/v2/service/new_factor.py index de42d178d..e19603962 100644 --- a/twilio/rest/verify/v2/service/new_factor.py +++ b/twilio/rest/verify/v2/service/new_factor.py @@ -41,8 +41,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfig( payload.get("config") ) - if payload.get("config") is not None - else None + if isinstance(payload.get("config"), dict) + else payload.get("config") ) def to_dict(self): @@ -68,8 +68,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( payload.get("relying_party") ) - if payload.get("relying_party") is not None - else None + if isinstance(payload.get("relying_party"), dict) + else payload.get("relying_party") ) self.authenticator_attachment: Optional[str] = payload.get( "authenticator_attachment" @@ -185,8 +185,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfig( payload.get("config") ) - if payload.get("config") is not None - else None + if isinstance(payload.get("config"), dict) + else payload.get("config") ) def to_dict(self): @@ -212,8 +212,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( payload.get("relying_party") ) - if payload.get("relying_party") is not None - else None + if isinstance(payload.get("relying_party"), dict) + else payload.get("relying_party") ) self.authenticator_attachment: Optional[str] = payload.get( "authenticator_attachment" diff --git a/twilio/rest/verify/v2/service/new_verify_factor.py b/twilio/rest/verify/v2/service/new_verify_factor.py index ef884eb98..4153c2bdb 100644 --- a/twilio/rest/verify/v2/service/new_verify_factor.py +++ b/twilio/rest/verify/v2/service/new_verify_factor.py @@ -47,8 +47,8 @@ def __init__(self, payload: Dict[str, Any]): NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): @@ -158,8 +158,8 @@ def __init__(self, payload: Dict[str, Any]): NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): diff --git a/twilio/rest/voice/v2/recording.py b/twilio/rest/voice/v2/recording.py index 9f4ea179f..04ff95bac 100644 --- a/twilio/rest/voice/v2/recording.py +++ b/twilio/rest/voice/v2/recording.py @@ -62,8 +62,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -71,8 +71,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -80,8 +80,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -160,8 +160,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -444,8 +444,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -453,8 +453,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -462,8 +462,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -542,8 +542,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -944,8 +944,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -953,8 +953,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -962,8 +962,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -1042,8 +1042,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): diff --git a/twilio/rest/voice/v2/recording_account_default_configuration.py b/twilio/rest/voice/v2/recording_account_default_configuration.py index 6e24166aa..c88fc475f 100644 --- a/twilio/rest/voice/v2/recording_account_default_configuration.py +++ b/twilio/rest/voice/v2/recording_account_default_configuration.py @@ -39,8 +39,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingAccountDefaultConfigurationList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -71,8 +71,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -80,8 +80,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -89,8 +89,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -412,8 +412,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingAccountDefaultConfigurationList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -444,8 +444,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -453,8 +453,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -462,8 +462,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -944,8 +944,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingAccountDefaultConfigurationList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -976,8 +976,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -985,8 +985,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -994,8 +994,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] diff --git a/twilio/rest/voice/v2/transcription.py b/twilio/rest/voice/v2/transcription.py index 7c8dedda3..0c8959b90 100644 --- a/twilio/rest/voice/v2/transcription.py +++ b/twilio/rest/voice/v2/transcription.py @@ -49,8 +49,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" @@ -130,8 +130,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -398,8 +398,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" @@ -479,8 +479,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -865,8 +865,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" @@ -946,8 +946,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): diff --git a/twilio/rest/voice/v3/transcription.py b/twilio/rest/voice/v3/transcription.py index 7d557f734..bb0e3d46b 100644 --- a/twilio/rest/voice/v3/transcription.py +++ b/twilio/rest/voice/v3/transcription.py @@ -388,8 +388,8 @@ def __init__(self, payload: Dict[str, Any]): VoiceV3TranscriptionTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId"