# Python Numbers SDK
## Needed tools
- Python >=3.7
- pip
## Requires
- future
- requests
## Install
```sh
pip install bandwidth-numbers-sdk
```
## Testing
Tests require the *mock* and *requests_mock* packages. You can install them
with
```sh
pip install -r test-requirements.txt
```
The tests can be run by issuing
```sh
pytest
```
## Usage
```python
from bandwidth_numbers import Account, Client
client = Client(url="https://dashboard.bandwidth.com/api", account_id=123456, username="foo",
password="bar")
```
or
```python
client = Client(filename=<path to config>)
```
### Config format
```ini
[account]
account_id = 123456789
username = spam
password = ham
[rest]
url = https://dashboard.bandwidth.com/api
```
## Examples
There is an 'examples' folder in the source tree that shows how each of the
API objects work with simple example code. To run these make a copy of
'config.cfg.example', rename to 'config.cfg', edit it to match your IRIS
credentials and run the examples individually, e.g.,
```console
python available_numbers.py
```
If an example takes command line parameters, you will get the usage info by
just executing it.
## API objects
### General principles
In most cases you should use an Account object as a starting point.
```python
account = Account(client=client)
```
Account has related entities such as Orders, Sites, etc.
```python
sites = account.sites.list()
for site in sites.items:
pass
```
### Pagination
Some resources provide paginated result sets and require the use of
page/size parameters. In these cases a Links object will be provided for
iterating over the results.
```python
in_service_numbers = account.in_service_numbers.list({"page": 1, "size": 10})
total = int(account.in_service_numbers.total_count)
total_displayed = len(in_service_numbers.items)
page = None
while total_displayed <= total:
if page is not None:
in_service_numbers = account.in_service_numbers.list(
{"page": page, "size": 10})
page = account.in_service_numbers.links.next
for phone_number in in_service_numbers.items:
print(phone_number)
total_displayed += len(in_service_numbers.items)
```
### Available numbers
```python
account.available_numbers.list({"areaCode": 818})
```
### Available Npa-Nxx
```python
account.available_npa_nxx.list({"state": "NJ"})
```
### Cities
```python
from bandwidth_numbers import Cities
cities = Cities(client=client)
cities.list({"state": "NC"})
```
### Covered rate centers
```python
from bandwidth_numbers import CoveredRateCenters
rate_centers = CoveredRateCenters(client=client)
rate_centers.list({"page": 1, "size": 10})
```
### Disconnected numbers
```python
account.disconnected_numbers.list({"areaCode": 919})
```
### Disconnecting telephone numbers
#### Creating disconnect orders
```python
disconnect = account.disconnects.create({
"name": "test disconnect order 4",
"customer_order_id": "Disconnect1234",
"disconnect_telephone_number_order_type": {
"telephone_number_list": {
"telephone_number": ["9192755378", "9192755703"]
}
}
})
```
#### Getting order data
```python
disconnect = account.disconnects.get("b902dee1-0585-4258-becd-5c7e51ccf5e1")
```
#### Adding notes
```python
disconnect.notes.create({"user_id": "spam", "description": "ham"})
```
#### Getting all order's notes
```python
notes = disconnect.notes.list()
```
### Dlda
#### Creating orders
```python
dlda = account.dldas.create({
"customer_order_id": "123",
"dlda_tn_groups": {
"dlda_tn_group": [{
"telephone_numbers": {
"telephone_number": ["4352154856"]
"account_type": "RESIDENTIAL",
"listing_type": "LISTED",
"list_address": "true",
"listing_name": {
"first_name": "FirstName",
"first_name2": "FirstName2",
"last_name": "LastName",
"designation": "Designation",
"title_of_lineage": "TitleOfLineage",
"title_of_address": "TitleOfAddress",
"title_of_address2": "TitleOfAddress2",
"title_of_lineage_name2": "TitleOfLineageName2",
"title_of_address_name2": "TitleOfAddressName2",
"title_of_address2_name2": "TitleOfAddress2Name2",
"place_listing_as": "PlaceListingAs",
},
"address": {
"house_prefix": "HousePrefix",
"house_number": "915",
"house_suffix": "HouseSuffix",
"pre_directional": "PreDirectional",
"street_name": "StreetName",
"street_suffix": "StreetSuffix",
"post_directional": "PostDirectional",
"address_line2": "AddressLine2",
"city": "City",
"state_code": "StateCode",
"zip": "Zip",
"plus_four": "PlusFour",
"country": "Country",
"address_type": "AddressType"
}
}
}]
}
})
```
#### Getting order data
```python
dlda = account.dldas.get("7802373f-4f52-4387-bdd1-c5b74833d6e2")
```
#### Retrieving dlda history
```python
dlda.history.list()
```
#### Getting a list of dldas
```python
account.dldas.list({"telephoneNumber": "9195551212"})
```
### Import TN Checker
```python
# returns an array of portable TN's
result = account.import_tn_checker(numbers=["3032281000", "9195551234"])
print(result) # ['3032281000', '9195551234']
```
### In-service numbers
```python
account.in_service_numbers.list({"areaCode": "919"})
```
### Lidb
#### Creating orders
```python
lidb = account.lidbs.create({
"lidb_tn_groups": {
"lidb_tn_group": [{
"telephone_numbers": {
"telephone_number": ["4352154856"]
},
"subscriber_information": "Steve",
"use_type": "RESIDENTIAL",
"visibility": "PUBLIC"
},
{
"telephone_numbers": {
"telephone_number": ["4352154855"]
},
"subscriber_information": "Steve",
"use_type": "RESIDENTIAL",
"visibility": "PUBLIC"
}]
}
})
```
#### Getting order data
```python
lidb = account.lidbs.get("7802373f-4f52-4387-bdd1-c5b74833d6e2")
```
#### Getting a list of lidbs
```python
lidbs = account.lidbs.list({"last_modified_after": "mm-dd-yy",
"telephone_number": "888"})
```
### LNP Checker
```python
account.lnpChecker(["4109255199", "9196190594"], "true")
```
### Phone numbers orders
#### Creating orders
```python
order = account.orders.create({
"name": "Available Telephone Number order",
"site_id": "2297",
"customer_order_id": "123456789",
"existing_telephone_number_order_type": {
"telephone_number_list": {
"telephone_number": ["9193752369", "9193752720", "9193752648"]
}
}
})
```
#### Getting order data
```python
response = account.orders.get("f30a31a1-1de4-4939-b094-4521bbe5c8df")
order = response.order
```
#### Getting a list of orders
```python
orders = account.orders.list()
```
#### Adding notes
```python
order.notes.create({"user_id": "spam", "description": "Test Note"})
```
#### Getting order's telephone numbers
```python
order.tns.list()
```
### Port-ins
#### Creating orders
```python
portin = account.portins.create({
"billing_telephone_number": "6882015002",
"subscriber": {
"subscriber_type": "BUSINESS",
"business_name": "Acme Corporation",
"service_address": {
"house_number": "1623",
"street_name": "Brockton Ave",
"city": "Los Angeles",
"state_code": "CA",
"zip": "90025",
"country": "USA"
}
},
"loa_authorizing_person": "John Doe",
"list_of_phone_numbers": {
"phone_number": ["9882015025", "9882015026"]
},
"site_id": "365",
"triggered": "false"
})
```
#### Getting order data
```python
portin = account.portinsget("d28b36f7-fa96-49eb-9556-a40fca49f7c6")
```
#### Getting a list of orders
```python
portins = account.portins.list({"pon": "a pon"})
```
#### Port-in instance methods and properties
```python
portin.save()
portin.delete()
portin.activation_status
status = portin.activation_status
status.auto_activation_date = "2014-08-30T18:30:00+03:00"
status.save()
portin.history
portin.totals
portin.notes
```
#### Port-in file management
```python
portin.loas.list({"metadata": "true"})
fname = portin.loas.create("loa.pdf", {'content-type': 'application/pdf'})
portin.loas.update(fname, "loa.pdf", {'content-type':'application/pdf'})
portin.loas.delete(fname)
portin.loas.metadata.get(fname)
portin.loas.metadata.document_name = "text.txt"
portin.loas.metadata.document_type = "invoice"
portin.loas.metadata.save()
portin.loas.metadata.delete()
```
### Rate Centers
```python
from bandwidth_numbers import RateCenters
rc = RateCenters(client=client)
centers = rc.list({"state": "CA", "available": "true"})
```
### SIP Peers
#### Creating a SIP peer
```python
sip_peer = account.sites.list().items[0].sip_peers.create({
"peer_name": name,
"is_default_peer": "true",
"short_messaging_protocol": "SMPP",
"voice_hosts": {
"host": [{
"host_name": "92.168.181.95"
}]
},
"sms_hosts": {
"host": [{
"host_name": "92.168.181.95"
}]
},
"termination_hosts": {
"termination_host": [{
"host_name": "92.168.181.95",
"port": "0",
"customer_traffic_allowed": "DOMESTIC",
"data_allowed": "true"
}]
}
})
```
#### Getting a peer
```python
sip_peer = account.sites.list().items[0].sip_peers.get("500651")
```
#### Getting a list of SIP peers
```python
sip_peers = account.sites.list().items[0].sip_peers.list()
```
#### Deleting SIP peers
```python
sip_peer.delete()
```
#### Moving telephone numbers
```python
sip_peer.movetns.add("9192000046")
sip_peer.movetns()
```
#### Getting peer telephone numbers
```python
tns = sip_peer.tns.list()
```
#### Getting a single phone number
```python
tn = sip_peer.tns.get("8183386251")
```
#### Getting total number of numbers for a SIP peer
```python
count = sip_peer.totaltns.get()
```
#### Setting telephone number options
```python
tn = sip_peer.tns.get("8183386251")
tn.rpid_format = "e164"
tn.save()
```
### Sites
#### Creating a site
```python
site = acc.sites.create({
"name": "test123456",
"address": {
"city": "Raleigh",
"address_type": "Service",
"house_number": "1",
"street_name": "Avenue",
"state_code": "NC",
"zip": "27606"
}
})
```
#### Updating a site
```python
site.name = "New Name"
site.save()
```
#### Deleting a site
```python
site.delete()
```
#### Getting a list of sites
```python
sites = account.sites.list()
```
#### Getting a list of site orders
```python
site.orders.list({"status": "disabled"})
```
#### Getting the total number of telephone numbers for a site
```python
site.totaltns.get()
```
#### Getting a list of site's port-in orders
```python
site.portins.list({"status": "disabled"})
```
### Subscriptions
#### Creating subscriptions
```python
subscription = account.subscriptions.create({
"order_type": "portins",
"order_id": "98939562-90b0-40e9-8335-5526432d9741",
"email_subscription": {
"email": "test@test.com",
"digest_requested": "DAILY"
}
})
```
#### Getting subscription information
```python
subscription = account.subscriptions.get(id)
```
#### Getting a list of subscriptions
```python
account.subscriptions.list({"orderType": "portins"})
```
#### Updating a subscription
```python
subscription.order_type = "portins"
subscription.save()
```
#### Deleting a subscription
```python
subscription.delete()
```
### TNs
#### Getting a phone number
```python
from bandwidth_numbers import Tns
tns = Tns(client=client)
tn = tns.get(id)
```
#### Getting a list of TNs
```python
tns.list({"page": 1, "size": 10 })
```
#### Telephone number instance methods and properties
```python
tn = tns.get("7576768750")
site = tn.site.get()
sip_peer = tn.sip_peer.get()
tnreservation = tn.tnreservation
tn.tndetails.get()
rc = tn.tn_rate_center.get()
lata = tn.tn_lata.get()
lca = tn.lca.get()
history = tn.history.list()
```
### Reserving phone numbers
#### Create a reservation
```python
account.tnreservation.reserved_tn = "2512027430"
account.tnreservation.save()
```
#### Getting reservation info
```python
reservation = account.tnreservation.get("0099ff73-da96-4303-8a0a-00ff316c07aa")
```
#### Deleting a reservation
```python
reservation.delete()
```
### Get TN Option Orders
```python
orders = account.tn_option_orders.list()
print(orders.total_count)
print(orders.tn_option_order_summary.items[0].account_id)
```
### Get TN Option Order
```python
order = account.tn_option_orders.get("order_id")
print(order.order_create_date)
```
### Get TN Option Order (error)
```python
order = account.tn_option_orders.get("order_id_with_error")
print(order.error_list.error.items[0].description)
```
### Create PortOut Passcode
```python
order = account.tn_option_orders.create({
"customer_order_id": "custom order",
"tn_option_groups": {
"tn_option_group": [
{
"port_out_passcode": "12abd38",
"telephone_numbers": {
"telephone_number": [
"2018551020"
]
}
}
]
}
})
print(order.order_create_date)
```
### Create Call Forward Number
```python
order = account.tn_option_orders.create({
"customer_order_id": "custom order",
"tn_option_groups": {
"tn_option_group": [
{
"call_forward": "2018551022",
"telephone_numbers": {
"telephone_number": [
"2018551020"
]
}
}
]
}
})
print(order.order_create_date)
```
### Enable SMS
```python
order = account.tn_option_orders.create({
"customer_order_id": "custom order",
"tn_option_groups": {
"tn_option_group": [
{
"sms": "on",
"telephone_numbers": {
"telephone_number": [
"2018551020"
]
}
}
]
}
})
print(order.order_create_date)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/bandwidth/python-numbers-sdk",
"name": "bandwidth-numbers-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "Bandwidth, Numbers",
"author": "Bandwidth",
"author_email": "letstalk@bandwidth.com",
"download_url": "https://files.pythonhosted.org/packages/35/49/76f83d2dfd4c47731d3ee9d8bfc25d5a1894a4b938aeb67c27286f085481/bandwidth-numbers-sdk-1.1.0.tar.gz",
"platform": null,
"description": "# Python Numbers SDK\n\n## Needed tools\n\n - Python >=3.7\n - pip\n\n## Requires\n\n - future\n - requests\n\n## Install\n```sh\npip install bandwidth-numbers-sdk\n```\n\n## Testing\n\nTests require the *mock* and *requests_mock* packages. You can install them\nwith\n\n```sh\npip install -r test-requirements.txt\n```\nThe tests can be run by issuing\n```sh\npytest\n```\n\n## Usage\n\n```python\nfrom bandwidth_numbers import Account, Client\n\nclient = Client(url=\"https://dashboard.bandwidth.com/api\", account_id=123456, username=\"foo\",\n password=\"bar\")\n```\nor\n```python\nclient = Client(filename=<path to config>)\n```\n\n### Config format\n```ini\n[account]\naccount_id = 123456789\nusername = spam\npassword = ham\n\n[rest]\nurl = https://dashboard.bandwidth.com/api\n```\n\n## Examples\n\nThere is an 'examples' folder in the source tree that shows how each of the\nAPI objects work with simple example code. To run these make a copy of\n'config.cfg.example', rename to 'config.cfg', edit it to match your IRIS\ncredentials and run the examples individually, e.g.,\n\n```console\npython available_numbers.py\n```\n\nIf an example takes command line parameters, you will get the usage info by\njust executing it.\n\n## API objects\n\n### General principles\n\nIn most cases you should use an Account object as a starting point.\n\n```python\naccount = Account(client=client)\n```\n\nAccount has related entities such as Orders, Sites, etc.\n\n```python\nsites = account.sites.list()\nfor site in sites.items:\n pass\n```\n\n### Pagination\n\nSome resources provide paginated result sets and require the use of\npage/size parameters. In these cases a Links object will be provided for\niterating over the results.\n\n```python\nin_service_numbers = account.in_service_numbers.list({\"page\": 1, \"size\": 10})\n\ntotal = int(account.in_service_numbers.total_count)\ntotal_displayed = len(in_service_numbers.items)\npage = None\n\nwhile total_displayed <= total:\n if page is not None:\n in_service_numbers = account.in_service_numbers.list(\n {\"page\": page, \"size\": 10})\n page = account.in_service_numbers.links.next\n for phone_number in in_service_numbers.items:\n print(phone_number)\n total_displayed += len(in_service_numbers.items)\n```\n\n### Available numbers\n\n```python\naccount.available_numbers.list({\"areaCode\": 818})\n```\n\n### Available Npa-Nxx\n\n```python\naccount.available_npa_nxx.list({\"state\": \"NJ\"})\n```\n\n### Cities\n\n```python\nfrom bandwidth_numbers import Cities\n\ncities = Cities(client=client)\ncities.list({\"state\": \"NC\"})\n```\n\n### Covered rate centers\n\n```python\nfrom bandwidth_numbers import CoveredRateCenters\n\nrate_centers = CoveredRateCenters(client=client)\nrate_centers.list({\"page\": 1, \"size\": 10})\n```\n\n### Disconnected numbers\n\n```python\naccount.disconnected_numbers.list({\"areaCode\": 919})\n```\n\n### Disconnecting telephone numbers\n\n#### Creating disconnect orders\n\n```python\ndisconnect = account.disconnects.create({\n \"name\": \"test disconnect order 4\",\n \"customer_order_id\": \"Disconnect1234\",\n \"disconnect_telephone_number_order_type\": {\n \"telephone_number_list\": {\n \"telephone_number\": [\"9192755378\", \"9192755703\"]\n }\n }\n})\n```\n\n#### Getting order data\n\n```python\ndisconnect = account.disconnects.get(\"b902dee1-0585-4258-becd-5c7e51ccf5e1\")\n```\n\n#### Adding notes\n\n```python\ndisconnect.notes.create({\"user_id\": \"spam\", \"description\": \"ham\"})\n```\n\n#### Getting all order's notes\n\n```python\nnotes = disconnect.notes.list()\n```\n\n### Dlda\n\n#### Creating orders\n\n```python\ndlda = account.dldas.create({\n \"customer_order_id\": \"123\",\n \"dlda_tn_groups\": {\n \"dlda_tn_group\": [{\n \"telephone_numbers\": {\n \"telephone_number\": [\"4352154856\"]\n \"account_type\": \"RESIDENTIAL\",\n \"listing_type\": \"LISTED\",\n \"list_address\": \"true\",\n \"listing_name\": {\n \"first_name\": \"FirstName\",\n \"first_name2\": \"FirstName2\",\n \"last_name\": \"LastName\",\n \"designation\": \"Designation\",\n \"title_of_lineage\": \"TitleOfLineage\",\n \"title_of_address\": \"TitleOfAddress\",\n \"title_of_address2\": \"TitleOfAddress2\",\n \"title_of_lineage_name2\": \"TitleOfLineageName2\",\n \"title_of_address_name2\": \"TitleOfAddressName2\",\n \"title_of_address2_name2\": \"TitleOfAddress2Name2\",\n \"place_listing_as\": \"PlaceListingAs\",\n },\n \"address\": {\n \"house_prefix\": \"HousePrefix\",\n \"house_number\": \"915\",\n \"house_suffix\": \"HouseSuffix\",\n \"pre_directional\": \"PreDirectional\",\n \"street_name\": \"StreetName\",\n \"street_suffix\": \"StreetSuffix\",\n \"post_directional\": \"PostDirectional\",\n \"address_line2\": \"AddressLine2\",\n \"city\": \"City\",\n \"state_code\": \"StateCode\",\n \"zip\": \"Zip\",\n \"plus_four\": \"PlusFour\",\n \"country\": \"Country\",\n \"address_type\": \"AddressType\"\n }\n }\n }]\n }\n})\n```\n\n#### Getting order data\n\n```python\ndlda = account.dldas.get(\"7802373f-4f52-4387-bdd1-c5b74833d6e2\")\n```\n\n#### Retrieving dlda history\n\n```python\ndlda.history.list()\n```\n\n#### Getting a list of dldas\n\n```python\naccount.dldas.list({\"telephoneNumber\": \"9195551212\"})\n```\n\n### Import TN Checker\n```python\n# returns an array of portable TN's\nresult = account.import_tn_checker(numbers=[\"3032281000\", \"9195551234\"])\nprint(result) # ['3032281000', '9195551234']\n```\n\n### In-service numbers\n\n```python\naccount.in_service_numbers.list({\"areaCode\": \"919\"})\n```\n\n### Lidb\n\n#### Creating orders\n\n```python\nlidb = account.lidbs.create({\n \"lidb_tn_groups\": {\n \"lidb_tn_group\": [{\n \"telephone_numbers\": {\n \"telephone_number\": [\"4352154856\"]\n },\n \"subscriber_information\": \"Steve\",\n \"use_type\": \"RESIDENTIAL\",\n \"visibility\": \"PUBLIC\"\n },\n {\n \"telephone_numbers\": {\n \"telephone_number\": [\"4352154855\"]\n },\n \"subscriber_information\": \"Steve\",\n \"use_type\": \"RESIDENTIAL\",\n \"visibility\": \"PUBLIC\"\n }]\n }\n})\n\n```\n\n#### Getting order data\n\n```python\nlidb = account.lidbs.get(\"7802373f-4f52-4387-bdd1-c5b74833d6e2\")\n```\n\n#### Getting a list of lidbs\n\n```python\nlidbs = account.lidbs.list({\"last_modified_after\": \"mm-dd-yy\",\n \"telephone_number\": \"888\"})\n```\n\n### LNP Checker\n\n```python\naccount.lnpChecker([\"4109255199\", \"9196190594\"], \"true\")\n```\n\n### Phone numbers orders\n\n#### Creating orders\n\n```python\norder = account.orders.create({\n \"name\": \"Available Telephone Number order\",\n \"site_id\": \"2297\",\n \"customer_order_id\": \"123456789\",\n \"existing_telephone_number_order_type\": {\n \"telephone_number_list\": {\n \"telephone_number\": [\"9193752369\", \"9193752720\", \"9193752648\"]\n }\n }\n})\n```\n\n#### Getting order data\n\n```python\nresponse = account.orders.get(\"f30a31a1-1de4-4939-b094-4521bbe5c8df\")\norder = response.order\n```\n\n#### Getting a list of orders\n\n```python\norders = account.orders.list()\n```\n\n#### Adding notes\n\n```python\norder.notes.create({\"user_id\": \"spam\", \"description\": \"Test Note\"})\n```\n\n#### Getting order's telephone numbers\n\n```python\norder.tns.list()\n```\n\n### Port-ins\n\n#### Creating orders\n\n```python\nportin = account.portins.create({\n \"billing_telephone_number\": \"6882015002\",\n \"subscriber\": {\n \"subscriber_type\": \"BUSINESS\",\n \"business_name\": \"Acme Corporation\",\n \"service_address\": {\n \"house_number\": \"1623\",\n \"street_name\": \"Brockton Ave\",\n \"city\": \"Los Angeles\",\n \"state_code\": \"CA\",\n \"zip\": \"90025\",\n \"country\": \"USA\"\n }\n },\n \"loa_authorizing_person\": \"John Doe\",\n \"list_of_phone_numbers\": {\n \"phone_number\": [\"9882015025\", \"9882015026\"]\n },\n \"site_id\": \"365\",\n \"triggered\": \"false\"\n})\n```\n\n#### Getting order data\n\n```python\nportin = account.portinsget(\"d28b36f7-fa96-49eb-9556-a40fca49f7c6\")\n```\n\n#### Getting a list of orders\n\n```python\nportins = account.portins.list({\"pon\": \"a pon\"})\n```\n\n#### Port-in instance methods and properties\n\n```python\nportin.save()\nportin.delete()\nportin.activation_status\n\nstatus = portin.activation_status\nstatus.auto_activation_date = \"2014-08-30T18:30:00+03:00\"\nstatus.save()\n\nportin.history\nportin.totals\nportin.notes\n```\n\n#### Port-in file management\n\n```python\nportin.loas.list({\"metadata\": \"true\"})\nfname = portin.loas.create(\"loa.pdf\", {'content-type': 'application/pdf'})\nportin.loas.update(fname, \"loa.pdf\", {'content-type':'application/pdf'})\nportin.loas.delete(fname)\nportin.loas.metadata.get(fname)\nportin.loas.metadata.document_name = \"text.txt\"\nportin.loas.metadata.document_type = \"invoice\"\nportin.loas.metadata.save()\nportin.loas.metadata.delete()\n```\n\n### Rate Centers\n\n```python\nfrom bandwidth_numbers import RateCenters\nrc = RateCenters(client=client)\ncenters = rc.list({\"state\": \"CA\", \"available\": \"true\"})\n```\n\n### SIP Peers\n\n#### Creating a SIP peer\n\n```python\nsip_peer = account.sites.list().items[0].sip_peers.create({\n \"peer_name\": name,\n \"is_default_peer\": \"true\",\n \"short_messaging_protocol\": \"SMPP\",\n \"voice_hosts\": {\n \"host\": [{\n \"host_name\": \"92.168.181.95\"\n }]\n },\n \"sms_hosts\": {\n \"host\": [{\n \"host_name\": \"92.168.181.95\"\n }]\n },\n \"termination_hosts\": {\n \"termination_host\": [{\n \"host_name\": \"92.168.181.95\",\n \"port\": \"0\",\n \"customer_traffic_allowed\": \"DOMESTIC\",\n \"data_allowed\": \"true\"\n }]\n }\n })\n```\n\n#### Getting a peer\n\n```python\nsip_peer = account.sites.list().items[0].sip_peers.get(\"500651\")\n```\n\n#### Getting a list of SIP peers\n\n```python\nsip_peers = account.sites.list().items[0].sip_peers.list()\n```\n\n#### Deleting SIP peers\n\n```python\nsip_peer.delete()\n```\n\n#### Moving telephone numbers\n\n```python\nsip_peer.movetns.add(\"9192000046\")\nsip_peer.movetns()\n```\n\n#### Getting peer telephone numbers\n\n```python\ntns = sip_peer.tns.list()\n```\n\n#### Getting a single phone number\n\n```python\ntn = sip_peer.tns.get(\"8183386251\")\n```\n\n#### Getting total number of numbers for a SIP peer\n\n```python\ncount = sip_peer.totaltns.get()\n```\n\n#### Setting telephone number options\n\n```python\ntn = sip_peer.tns.get(\"8183386251\")\ntn.rpid_format = \"e164\"\ntn.save()\n```\n\n### Sites\n\n#### Creating a site\n\n```python\nsite = acc.sites.create({\n \"name\": \"test123456\",\n \"address\": {\n \"city\": \"Raleigh\",\n \"address_type\": \"Service\",\n \"house_number\": \"1\",\n \"street_name\": \"Avenue\",\n \"state_code\": \"NC\",\n \"zip\": \"27606\"\n }\n})\n```\n\n#### Updating a site\n\n```python\nsite.name = \"New Name\"\nsite.save()\n```\n\n#### Deleting a site\n\n```python\nsite.delete()\n```\n\n#### Getting a list of sites\n\n```python\nsites = account.sites.list()\n```\n\n#### Getting a list of site orders\n\n```python\nsite.orders.list({\"status\": \"disabled\"})\n```\n\n#### Getting the total number of telephone numbers for a site\n\n```python\nsite.totaltns.get()\n```\n\n#### Getting a list of site's port-in orders\n\n```python\nsite.portins.list({\"status\": \"disabled\"})\n```\n\n### Subscriptions\n\n#### Creating subscriptions\n\n```python\nsubscription = account.subscriptions.create({\n \"order_type\": \"portins\",\n \"order_id\": \"98939562-90b0-40e9-8335-5526432d9741\",\n \"email_subscription\": {\n \"email\": \"test@test.com\",\n \"digest_requested\": \"DAILY\"\n }\n})\n```\n\n#### Getting subscription information\n\n```python\nsubscription = account.subscriptions.get(id)\n```\n\n#### Getting a list of subscriptions\n\n```python\naccount.subscriptions.list({\"orderType\": \"portins\"})\n```\n\n#### Updating a subscription\n\n```python\nsubscription.order_type = \"portins\"\nsubscription.save()\n```\n\n#### Deleting a subscription\n\n```python\nsubscription.delete()\n```\n\n### TNs\n\n#### Getting a phone number\n\n```python\nfrom bandwidth_numbers import Tns\n\ntns = Tns(client=client)\ntn = tns.get(id)\n```\n\n#### Getting a list of TNs\n\n```python\ntns.list({\"page\": 1, \"size\": 10 })\n```\n\n#### Telephone number instance methods and properties\n\n```python\ntn = tns.get(\"7576768750\")\nsite = tn.site.get()\nsip_peer = tn.sip_peer.get()\ntnreservation = tn.tnreservation\ntn.tndetails.get()\nrc = tn.tn_rate_center.get()\nlata = tn.tn_lata.get()\nlca = tn.lca.get()\nhistory = tn.history.list()\n```\n\n### Reserving phone numbers\n\n#### Create a reservation\n\n```python\naccount.tnreservation.reserved_tn = \"2512027430\"\naccount.tnreservation.save()\n```\n\n#### Getting reservation info\n\n```python\nreservation = account.tnreservation.get(\"0099ff73-da96-4303-8a0a-00ff316c07aa\")\n```\n\n#### Deleting a reservation\n\n```python\nreservation.delete()\n```\n\n### Get TN Option Orders\n```python\norders = account.tn_option_orders.list()\nprint(orders.total_count)\nprint(orders.tn_option_order_summary.items[0].account_id)\n```\n\n### Get TN Option Order\n```python\norder = account.tn_option_orders.get(\"order_id\")\nprint(order.order_create_date)\n```\n\n### Get TN Option Order (error)\n```python\norder = account.tn_option_orders.get(\"order_id_with_error\")\nprint(order.error_list.error.items[0].description)\n```\n\n### Create PortOut Passcode\n```python\norder = account.tn_option_orders.create({\n \"customer_order_id\": \"custom order\",\n \"tn_option_groups\": {\n \"tn_option_group\": [\n {\n \"port_out_passcode\": \"12abd38\",\n \"telephone_numbers\": {\n \"telephone_number\": [\n \"2018551020\"\n ]\n }\n }\n ]\n }\n})\n\nprint(order.order_create_date)\n```\n\n### Create Call Forward Number\n```python\norder = account.tn_option_orders.create({\n \"customer_order_id\": \"custom order\",\n \"tn_option_groups\": {\n \"tn_option_group\": [\n {\n \"call_forward\": \"2018551022\",\n \"telephone_numbers\": {\n \"telephone_number\": [\n \"2018551020\"\n ]\n }\n }\n ]\n }\n})\n\nprint(order.order_create_date)\n```\n\n### Enable SMS\n```python\norder = account.tn_option_orders.create({\n \"customer_order_id\": \"custom order\",\n \"tn_option_groups\": {\n \"tn_option_group\": [\n {\n \"sms\": \"on\",\n \"telephone_numbers\": {\n \"telephone_number\": [\n \"2018551020\"\n ]\n }\n }\n ]\n }\n})\n\nprint(order.order_create_date)\n```\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Bandwidth Numbers SDK",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/bandwidth/python-numbers-sdk"
},
"split_keywords": [
"bandwidth",
" numbers"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dab96223d9e811ceab905dd37ecc318ba622c5d768a4a83e97d9ffe647fb24f1",
"md5": "0b9e3fc5d787ff1fee4a5991c865ef47",
"sha256": "258183d58b7175e40f687b73bbe0dff72554de7c3cc1b05e2fa97eff20e31d0e"
},
"downloads": -1,
"filename": "bandwidth_numbers_sdk-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0b9e3fc5d787ff1fee4a5991c865ef47",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 161234,
"upload_time": "2024-09-03T13:32:50",
"upload_time_iso_8601": "2024-09-03T13:32:50.130671Z",
"url": "https://files.pythonhosted.org/packages/da/b9/6223d9e811ceab905dd37ecc318ba622c5d768a4a83e97d9ffe647fb24f1/bandwidth_numbers_sdk-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "354976f83d2dfd4c47731d3ee9d8bfc25d5a1894a4b938aeb67c27286f085481",
"md5": "e0691d5d1d7c06679c352d8c3841a8f2",
"sha256": "a5c3d880c9bef42eb78576d319970a8a093e8ab162725bd7705d9af3c61d3c2b"
},
"downloads": -1,
"filename": "bandwidth-numbers-sdk-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "e0691d5d1d7c06679c352d8c3841a8f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 48381,
"upload_time": "2024-09-03T13:32:51",
"upload_time_iso_8601": "2024-09-03T13:32:51.365481Z",
"url": "https://files.pythonhosted.org/packages/35/49/76f83d2dfd4c47731d3ee9d8bfc25d5a1894a4b938aeb67c27286f085481/bandwidth-numbers-sdk-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-03 13:32:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bandwidth",
"github_project": "python-numbers-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "bandwidth-numbers-sdk"
}