Skip to content

Commit

Permalink
Fixed EVERYTHING
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-beauregard committed Mar 5, 2021
1 parent 545fcb0 commit a7d0a0c
Show file tree
Hide file tree
Showing 19 changed files with 370 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def begin_update_phone_number_capabilities(
:type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType
:param sms: Capability value for SMS.
:type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
Expand Down Expand Up @@ -194,7 +193,6 @@ def get_phone_number(
:param phone_number: The acquired phone number whose details are to be fetched in E.164 format,
e.g. +11234567890.
:type phone_number: str
:keyword callable cls: A custom type or function that will be passed the direct response
:rtype: ~azure.communication.phonenumbers.models.AcquiredPhoneNumber
"""
return self._phone_number_client.phone_numbers.get_by_number(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def begin_purchase_phone_numbers(
search_id, # type: str
**kwargs # type: Any
):
# type: (...) -> AsyncLROPoller[PhoneNumberSearchResult]
# type: (...) -> AsyncLROPoller[None]
"""Purchases phone numbers.
:param search_id: The search id.
Expand Down Expand Up @@ -89,7 +89,6 @@ async def begin_release_phone_number(
:param phone_number: Phone number to be released, e.g. +11234567890.
:type phone_number: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
Expand All @@ -110,7 +109,6 @@ async def begin_search_available_phone_numbers(
phone_number_type, # type: str
assignment_type, # type: str
capabilities,
quantity=None, # type: int
**kwargs
):
# type: (...) -> AsyncLROPoller[PhoneNumberSearchResult]
Expand All @@ -128,10 +126,9 @@ async def begin_search_available_phone_numbers(
~azure.communication.phonenumbers.models.PhoneNumberAssignmentType
:param capabilities: Required. Capabilities of a phone number.
:type capabilities: ~azure.communication.phonenumbers.models.PhoneNumberCapabilities
:param quantity: The quantity of phone numbers in the search. Should be at least 1.
:type quantity: int
:keyword str area_code: The area code of the desired phone number, e.g. 425. If not set,
any area code could be used in the final search.
:keyword int quantity: The quantity of phone numbers in the search. Default is 1.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
Expand All @@ -144,7 +141,7 @@ async def begin_search_available_phone_numbers(
phone_number_type=phone_number_type,
assignment_type=assignment_type,
capabilities=capabilities,
quantity=quantity,
quantity=kwargs.pop('quantity', None),
area_code=kwargs.pop('area_code', None)
)
return await self._phone_number_client.phone_numbers.begin_search_available_phone_numbers(
Expand All @@ -171,7 +168,6 @@ async def begin_update_phone_number_capabilities(
:type calling: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType
:param sms: Capability value for SMS.
:type sms: str or ~azure.communication.phonenumbers.models.PhoneNumberCapabilityType
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: Pass in True if you'd like the LROBasePolling polling method,
False for no polling, or your own initialized polling object for a personal polling strategy.
Expand Down Expand Up @@ -199,7 +195,6 @@ async def get_phone_number(
:param phone_number: The acquired phone number whose details are to be fetched in E.164 format,
e.g. +11234567890.
:type phone_number: str
:keyword callable cls: A custom type or function that will be passed the direct response
:rtype: ~azure.communication.phonenumbers.models.AcquiredPhoneNumber
"""
return await self._phone_number_client.phone_numbers.get_by_number(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@ def __init__(self, keys=None, replacement="sanitized"):
self._replacement = replacement

def process_response(self, response):
def sanitize_dict(dictionary):
import json
try:
body = json.loads(response['body']['string'])
if 'phoneNumbers' in body:
for item in body["phoneNumbers"]:
if isinstance(item, str):
body["phoneNumbers"] = [self._replacement]
break
elif "phoneNumber" in item:
item['phoneNumber'] = self._replacement
response['body']['string'] = json.dumps(body)
response['url'] = self._replacement
return response
except (KeyError, ValueError):
return response

'''def sanitize_dict(dictionary):
for key in dictionary:
value = dictionary[key]
if isinstance(value, str):
Expand All @@ -30,7 +46,7 @@ def sanitize_dict(dictionary):
sanitize_dict(response)
return response
return response'''

class BodyReplacerProcessor(RecordingProcessor):
"""Sanitize the sensitive info inside request or response bodies"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interactions:
Connection:
- keep-alive
Date:
- Thu, 04 Mar 2021 20:09:28 GMT
- Fri, 05 Mar 2021 17:31:53 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
Expand All @@ -26,16 +26,17 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 04 Mar 2021 20:09:30 GMT
- Fri, 05 Mar 2021 17:31:55 GMT
ms-cv:
- b1QfQvNXJUCmudxXTNXVYw.0
- 0XgNRxFgsU+jtkYdzUXCig.0
request-context:
- appId=
transfer-encoding:
- chunked
x-processing-time:
- 1995ms
- 1782ms
status:
code: 200
message: OK
url: sanitized
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interactions:
Connection:
- keep-alive
Date:
- Thu, 04 Mar 2021 20:09:31 GMT
- Fri, 05 Mar 2021 17:31:55 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
Expand All @@ -18,21 +18,41 @@ interactions:
uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07
response:
body:
string: '{"phoneNumbers": ["sanitized"]}'
string: '{"phoneNumbers": [{"id": "16194895581", "phoneNumber": "sanitized",
"countryCode": "US", "phoneNumberType": "Geographic", "capabilities": {"calling":
"outbound", "sms": "none"}, "assignmentType": "Person", "purchaseDate": "2021-01-13T20:01:52.0795301+00:00",
"cost": {"amount": 1.0, "currencyCode": "USD", "billingFrequency": "Monthly"}},
{"id": "16194895593", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"Geographic", "capabilities": {"calling": "outbound", "sms": "none"}, "assignmentType":
"Person", "purchaseDate": "2021-01-13T20:57:24.5482566+00:00", "cost": {"amount":
1.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": "18332143261",
"phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": "TollFree",
"capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType":
"Application", "purchaseDate": "2020-11-30T17:51:21.2991518+00:00", "cost":
{"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id":
"18443281555", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"},
"assignmentType": "Application", "purchaseDate": "2020-11-12T21:53:12.2088187+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}},
{"id": "18445492606", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"},
"assignmentType": "Application", "purchaseDate": "2021-03-04T19:24:10.3004481+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}]}'
headers:
content-type:
- application/json; charset=utf-8
date:
- Thu, 04 Mar 2021 20:09:34 GMT
- Fri, 05 Mar 2021 17:32:00 GMT
ms-cv:
- Aa07dXCJ1Eiv8sLy5yURtA.0
- KdBSgkLB20KwA9de1Xr6AA.0
request-context:
- appId=
transfer-encoding:
- chunked
x-processing-time:
- 4239ms
- 4581ms
status:
code: 200
message: OK
url: sanitized
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://sanitized.communication.azure.com/phoneNumbers?skip=0&top=100&api-version=2021-03-07
response:
body:
string: '{"phoneNumbers": [{"id": "18332272412", "phoneNumber": "sanitized",
"countryCode": "US", "phoneNumberType": "TollFree", "capabilities": {"calling":
"inbound", "sms": "inbound+outbound"}, "assignmentType": "Application", "purchaseDate":
"2021-02-09T23:00:10.4372681+00:00", "cost": {"amount": 2.0, "currencyCode":
"USD", "billingFrequency": "Monthly"}}, {"id": "18332272430", "phoneNumber":
"sanitized", "countryCode": "US", "phoneNumberType": "TollFree", "capabilities":
{"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType": "Application",
"purchaseDate": "2021-02-09T22:58:41.2504122+00:00", "cost": {"amount": 2.0,
"currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id": "18332272445",
"phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType": "TollFree",
"capabilities": {"calling": "inbound", "sms": "inbound+outbound"}, "assignmentType":
"Application", "purchaseDate": "2021-02-09T23:03:57.6969271+00:00", "cost":
{"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}, {"id":
"18332321209", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"},
"assignmentType": "Application", "purchaseDate": "2021-02-10T17:51:13.4876763+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}},
{"id": "18332321221", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"},
"assignmentType": "Application", "purchaseDate": "2021-02-10T17:52:41.818335+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}},
{"id": "18332321226", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "none", "sms": "inbound+outbound"},
"assignmentType": "Application", "purchaseDate": "2021-02-10T18:01:46.4199999+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}},
{"id": "18335260208", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "inbound", "sms": "inbound+outbound"},
"assignmentType": "Application", "purchaseDate": "2000-01-01T00:00:00+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}},
{"id": "18336369501", "phoneNumber": "sanitized", "countryCode": "US", "phoneNumberType":
"TollFree", "capabilities": {"calling": "inbound+outbound", "sms": "none"},
"assignmentType": "Application", "purchaseDate": "2020-09-18T15:03:19.5370985+00:00",
"cost": {"amount": 2.0, "currencyCode": "USD", "billingFrequency": "Monthly"}}]}'
headers:
content-type:
- application/json; charset=utf-8
date:
- Fri, 05 Mar 2021 17:57:40 GMT
ms-cv:
- RfWp91uvd02ICqvPQgnxlA.0
request-context:
- appId=
transfer-encoding:
- chunked
x-processing-time:
- 5011ms
status:
code: 200
message: OK
url: sanitized
version: 1
Loading

0 comments on commit a7d0a0c

Please sign in to comment.