f5sdk.cs

Python module for F5 Cloud Services

Example - Basic:

from f5sdk.cs import ManagementClient
from f5sdk.cs.accounts import AccountClient
from f5sdk.cs.subscriptions import SubscriptionClient

mgmt_client = ManagementClient(user='admin', password='admin')
account_client = AccountClient(mgmt_client)
subscription_client = SubscriptionClient(mgmt_client)

# discover account/subscription ID
account_id = account_client.show_user()['primary_account_id']
subscription_id = subscription_client.list(
    query_parameters={
        'account_id': account_id
    }
)['subscriptions'][0]['subscription_id']

# configure subscription - GSLB, etc.
subscription_client.update(
    name=subscription_id,
    config_file='./decl.json'
)

f5sdk.cs.accounts

Module for Accounts API

Example - Show Current User:

from f5sdk.cs.accounts import AccountClient

account_client = SubscriptionClient(mgmt_client)

# show current user information
account_client.show_user()

f5sdk.cs.subscriptions

Module for Cloud Services subscriptions

Example - Update Subscription:

from f5sdk.cs.subscriptions import SubscriptionClient

subscription_client = SubscriptionClient(mgmt_client)

# configure subscription - DNS zones, records, etc.
subscription_client.update(
    name='subscription_id',
    config_file='./decl.json'
)

Example - List Subscriptions:

from f5sdk.cs.subscriptions import SubscriptionClient

subscription_client = SubscriptionClient(mgmt_client)

# configure subscription - DNS zones, records, etc.
subscription_client.list(
    query_parameters={
        'account_id': ''
    }
)

f5sdk.cs.beacon.declare

Module for Beacon Declarative API

Example - Get Declaration (Applications, Monitors, etc.):

from f5sdk.cs.beacon.declare import DeclareClient

declare_client = DeclareClient(mgmt_client)
declare_client.create(config={'action': 'get'})

Example - Create Application:

from f5sdk.cs.beacon.declare import DeclareClient

declare_client = DeclareClient(mgmt_client)
declare_client.create(config={
    'action': 'deploy',
    'declaration': [
        {
            'application': {
                'name': 'Test Application',
                'description': 'Test Description',
                'labels':{ 'test_label': 'test_value'},
                'dependencies': [],
                'metrics': []
            }
        }
    ]
})

Example - Create Monitor:

from f5sdk.cs.beacon.declare import DeclareClient

declare_client = DeclareClient(mgmt_client)
declare_client.create(config={
    'action': 'deploy',
    'declaration': [
        {
            'monitor': {
                'name': 'Test Monitor',
                'description': 'Test Description',
                'url': 'http://example.com',
                'method': 'HEAD',
                'interval': '30',
                'type': 'MONITOR_TYPE_HEALTH_CHECK'
            }
        }
    ]
})

f5sdk.cs.beacon.insights

Module for Beacon Insights

Example - List Insights:

from f5sdk.cs.beacon.insights import InsightClient

insight_client = InsightClient(mgmt_client)
insight_client.list()

Example - Create/Update Insights:

from f5sdk.cs.beacon.insights import InsightClient

insight_client = InsightClient(mgmt_client)
insight_client.create(config=insight_info)

Example - Get Insight:

from f5sdk.cs.beacon.insights import InsightClient

insight_client = InsightClient(mgmt_client)
insight_client.show(name=example-insight)

Example - Delete Insight:

from f5sdk.cs.beacon.insights import InsightClient

insight_client = InsightClient(mgmt_client)
insight_client.delete(name=example-insight)

f5sdk.cs.beacon.token

Module for Beacon Token

Example - List Token:

from f5sdk.cs.beacon.token import TokenClient

token_client = TokenClient(mgmt_client)
token_client.list()

Example - Create Token:

from f5sdk.cs.beacon.token import TokenClient

token_client = TokenClient(mgmt_client)
token_client.create(config=token_info)

Example - Get Token:

from f5sdk.cs.beacon.token import TokenClient

token_client = TokenClient(mgmt_client)
token_client.show(name=example-token)

Example - Delete Token:

from f5sdk.cs.beacon.token import TokenClient

token_client = TokenClient(mgmt_client)
token_client.delete(name=example-token)

f5sdk.cs.beacon.sources

Module for Beacon Sources

Example - List Sources:

from f5sdk.cs.beacon.sources import SourcesClient

sources_client = SourcesClient(mgmt_client)
sources_client.list()

Example - Delete Source:

from f5sdk.cs.beacon.sources import SourcesClient

sources_client = SourcesClient(mgmt_client)
sources_client.delete(source_type='monitor', name='source_name')

Note

The F5 SDK-Python is currently in early development and we want to hear from you! To provide feedback on F5 SDK-Python or this documentation, you can file a GitHub Issue.