testing
Project description
Getting Started with Verizon
Introduction
The Verizon Edge Discovery Service API can direct your application clients to connect to the optimal service endpoints for your Multi-access Edge Computing (MEC) applications for every session. The Edge Discovery Service takes into account the current location of a device, its IP anchor location, current network traffic and other factors to determine which 5G Edge platform a device should connect to.
Verizon Terms of Service: https://www.verizon.com/business/5g-edge-portal/legal.html
Install the Package
The package is compatible with Python versions 3 >=3.7, <= 3.11
.
Install the package from PyPi using the following pip command:
pip install tester-test-123asd==1.0.1
You can also view the package at: https://pypi.python.org/pypi/tester-test-123asd/1.0.1
Initialize the API Client
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
Parameter | Type | Description |
---|---|---|
vz_m2m_token |
string |
M2M Session Token |
environment |
Environment | The API environment. Default: Environment.PRODUCTION |
http_client_instance |
HttpClient |
The Http Client passed from the sdk user for making requests |
override_http_client_configuration |
bool |
The value which determines to override properties of the passed Http Client from the sdk user |
http_call_back |
HttpCallBack |
The callback value that is invoked before and after an HTTP call is made to an endpoint |
timeout |
float |
The value to use for connection timeout. Default: 60 |
max_retries |
int |
The number of times to retry an endpoint call if it fails. Default: 0 |
backoff_factor |
float |
A backoff factor to apply between attempts after the second try. Default: 2 |
retry_statuses |
Array of int |
The http statuses on which retry is to be done. Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524] |
retry_methods |
Array of string |
The http methods on which retry is to be done. Default: ['GET', 'PUT'] |
oauth_client_id |
string |
OAuth 2 Client ID |
oauth_client_secret |
string |
OAuth 2 Client Secret |
oauth_token |
OauthToken |
Object for storing information about the OAuth token |
oauth_scopes |
OauthScopeEnum |
The API client can be initialized as follows:
from verizon.verizon_client import VerizonClient
from verizon.configuration import Environment
client = VerizonClient(
vz_m2m_token='VZ-M2M-Token',
oauth_client_id='OAuthClientId',
oauth_client_secret='OAuthClientSecret',
oauth_scopes=[OauthScopeEnum.DISCOVERYREAD, OauthScopeEnum.SERVICEPROFILEREAD]
)
API calls return an ApiResponse
object that includes the following fields:
Field | Description |
---|---|
status_code |
Status code of the HTTP response |
reason_phrase |
Reason phrase of the HTTP response |
headers |
Headers of the HTTP response as a dictionary |
text |
The body of the HTTP response as a string |
request |
HTTP request info |
errors |
Errors, if they exist |
body |
The deserialized body of the HTTP response |
Authorization
This API uses OAuth 2 Client Credentials Grant
.
Client Credentials Grant
Your application must obtain user authorization before it can execute an endpoint call in case this SDK chooses to use OAuth 2.0 Client Credentials Grant. This authorization includes the following steps
The fetch_token()
method will exchange the OAuth client credentials for an access token. The access token is an object containing information for authorizing client requests and refreshing the token itself.
You must have initialized the client with scopes for which you need permission to access.
try:
client.auth_managers['global'].fetch_token()
except OauthProviderException as ex:
# handle exception
except APIException as ex:
# handle exception
The client can now make authorized endpoint calls.
Scopes
Scopes enable your application to only request access to the resources it needs while enabling users to control the amount of access they grant to your application. Available scopes are defined in the OauthScopeEnum
enumeration.
Scope Name | Description |
---|---|
DISCOVERYREAD |
Grant read-only access to discovery data |
SERVICEPROFILEREAD |
Grant read-only access to service profile data |
SERVICEPROFILEWRITE |
Grant write access to service profile data |
SERVICEREGISTRYREAD |
Grant read-only access to Service registry data |
SERVICEREGISTRYWRITE |
Grant write access to Service registry data |
TS_MEC_FULLACCESS |
Full access for /serviceprofiles and /serviceendpoints. |
TS_MEC_LIMITACCESS |
Limited access. Will not allow use of /serviceprofiles and /serviceendpoints but will allow discovery. |
TS_APPLICATION_RO |
|
EDGEDISCOVERYREAD |
|
EDGESERVICEPROFILEREAD |
|
EDGESERVICEPROFILEWRITE |
|
EDGESERVICEREGISTRYREAD |
|
EDGESERVICEREGISTRYWRITE |
|
READ |
read access |
WRITE |
read/write access |
Storing an access token for reuse
It is recommended that you store the access token for reuse.
# store token
save_token_to_database(client.config.oauth_token)
Creating a client from a stored token
To authorize a client from a stored access token, just set the access token in Configuration along with the other configuration parameters before creating the client:
client = VerizonClient()
client.config.oauth_token = load_token_from_database()
Complete example
from verizon.verizon_client import VerizonClient
from verizon.models.oauth_scope_enum import OauthScopeEnum
from verizon.exceptions.oauth_provider_exception import OauthProviderException
from verizon.exceptions.api_exception import APIException
# function for storing token to database
def save_token_to_database(oauth_token):
# code to save the token to database
# function for loading token from database
def load_token_from_database():
# load token from database and return it (return None if no token exists)
pass
from verizon.verizon_client import VerizonClient
from verizon.configuration import Environment
client = VerizonClient(
vz_m2m_token='VZ-M2M-Token',
oauth_client_id='OAuthClientId',
oauth_client_secret='OAuthClientSecret',
oauth_scopes=[OauthScopeEnum.DISCOVERYREAD, OauthScopeEnum.SERVICEPROFILEREAD]
)
# obtain access token, needed for client to be authorized
previous_token = load_token_from_database()
if previous_token:
# restore previous access token
config = client.config.clone_with(oauth_token=previous_token)
client = VerizonClient(config)
else:
# obtain new access token
try:
token = client.auth_managers['global'].fetch_token()
save_token_to_database(token)
config = client.config.clone_with(oauth_token=token)
client = VerizonClient(config)
except OauthProviderException as ex:
# handle exception
except APIException as ex:
# handle exception
# the client is now authorized and you can use controllers to make endpoint calls
List of APIs
- 5G Edge Platforms
- Service Endpoints
- Service Profiles
- Device Management
- Device Groups
- Session Management
- Connectivity Callbacks
- Account Requests
- Service Plans
- Device Profile Management
- Device Monitoring
- UICC Device Profile Management
- Devices Locations
- Devices Location Subscriptions
- Device Location Callbacks
- Usage Trigger Management
- Software Management Subscriptions V1
- Software Management Licenses V1
- Firmware V1
- Software Management Callbacks V1
- Software Management Reports V1
- Software Management Subscriptions V2
- Software Management Licenses V2
- Campaigns V2
- Software Management Callbacks V2
- Software Management Reports V2
- Client Logging
- Server Logging
- Configuration Files
- Software Management Subscriptions V3
- Software Management Licenses V3
- Campaigns V3
- Software Management Reports V3
- Firmware V3
- Account Devices
- Software Management Callbacks V3
- SIM Securefor Io T Licenses
- Account Subscriptions
- Performance Metrics
- Diagnostics Subscriptions
- Diagnostics Observations
- Diagnostics History
- Diagnostics Settings
- Diagnostics Callbacks
- Diagnostics Factory Reset
- Cloud Connector Subscriptions
- Cloud Connector Devices
- Device Service Management
- Device Reports
- Hyper Precise Location Callbacks
- Anomaly Settings
- Anomaly Triggers
- MEC Sites
- Service Launch Profiles
- Service Launch Requests
- Service Instances
- Service Instance Operations
- Service Onboarding
- Service Metadata
- CSP Profiles
- Service Claims
- Wireless Network Performance
- Fixed Wireless Qualification
- OAuth Authorization
- Accounts
- SMS
- Exclusions
- Billing
- Targets
- Repositories
Classes Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tester_test_123asd-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdba3428dcdeff7baa13ff9ef9cb8fdbdada4218bdd100f62c633f5272970bc1 |
|
MD5 | f9d24ea4126f514e99975ac0928a7c44 |
|
BLAKE2b-256 | 67032145f7a933f3eed4f38fe259332b6852b31a3be9cc223393c697ec8ae191 |