f5-icontrol-rest Documentation

Similar documents
django-oauth2-provider Documentation

Nasuni Data API Nasuni Corporation Boston, MA

Nasuni Data API Nasuni Corporation Boston, MA

DCLI User's Guide. Data Center Command-Line Interface

MyGeotab Python SDK Documentation

DCLI User's Guide. Modified on 20 SEP 2018 Data Center Command-Line Interface

Connexion Documentation

DreamFactory Security Guide

DCLI User's Guide. Data Center Command-Line Interface 2.9.1

Apache Karaf Cave 4.x - Documentation

ExtraHop 7.3 ExtraHop Trace REST API Guide

Building on the Globus Python SDK

Gearthonic Documentation

Building the Modern Research Data Portal using the Globus Platform. Rachana Ananthakrishnan GlobusWorld 2017

bottle-rest Release 0.5.0

GitHub-Flask Documentation

How to Configure Authentication and Access Control (AAA)

Canonical Identity Provider Documentation

bzz Documentation Release Rafael Floriano and Bernardo Heynemann

iqoptionapi Release Jan 13, 2018

External HTTPS Trigger AXIS Camera Station 5.06 and above

Leveraging the Globus Platform in your Web Applications

API Wrapper Documentation

Django-CSP Documentation

Requests Mock Documentation

F5 Python SDK Documentation

Leveraging the Globus Platform in your Web Applications. GlobusWorld April 26, 2018 Greg Nawrocki

django-ratelimit-backend Documentation

sanction Documentation

tapioca-wrapper Documentation

Flask-Cors Documentation

Apache Directory Studio Apache DS. User's Guide

jumpssh Documentation

flask-jwt-simple Documentation

pydas Documentation Release Kitware, Inc.

Bitdock. Release 0.1.0

GEL Scripts Advanced. Your Guides: Ben Rimmasch, Yogesh Renapure

Using the YANG Development Kit (YDK) with Cisco IOS XE

PyZabbixObj Documentation

Flask-Twilio Documentation

scieloapi.py Documentation

ClickToCall SkypeTest Documentation

Authorization and Authentication

flask-ldap3-login Documentation

User Plugins. About Plugins. Deploying Plugins

PyOTP Documentation. Release PyOTP contributors

Ramses Documentation. Release. Brandicted

petfinder-api Documentation

Building the Modern Research Data Portal. Developer Tutorial

certbot-dns-rfc2136 Documentation

.. Documentation. Release 0.4 beta. Author

KIWIRE 2.0 API Documentation. Version (February 2017)

NQF ONLINE MEASURE SUBMISSION FORM USERS GUIDE

Informatica Enterprise Data Catalog REST API Reference

Identity Services Engine Guest Portal Local Web Authentication Configuration Example

django-mama-cas Documentation

RedBarrel Documentation

ForeScout CounterACT. Configuration Guide. Version 3.4

Patch Server for Jamf Pro Documentation

Log4Delphi Coding Standards

DCLI User's Guide. Data Center Command-Line Interface 2.7.0

ejpiaj Documentation Release Marek Wywiał

yagmail Documentation

pyshk Documentation Release Jeremy Low

How To Embed EventTracker Widget to an External Site

AppScaler SSO Active Directory Guide

Novell Identity Manager

Flask-SimpleLDAP Documentation

Central Authentication Service Integration 2.0 Administration Guide May 2014

ANGULAR 2.X,4.X + TYPESRCIPT by Sindhu

CIS192 Python Programming

REST Binding Component User's Guide

Release Joris Beckers

Administering Jive Mobile Apps for ios and Android

Pure Storage REST Client Documentation

StorageGRID Webscale 11.0 Tenant Administrator Guide

Installation Guide for antegma accallio OX Version 1.0

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

Oracle Java CAPS REST Binding Component User's Guide

TAXII 2.0 Specification Pre Draft

AWS Remote Access VPC Bundle

flask-jwt Documentation

plone.restapi Documentation

nacelle Documentation

SAML-Based SSO Configuration

Configuring User VPN For Azure

Open-O Command- Line Interface (CLI)

User Authentication APIs

django-push Documentation

ForeScout Open Integration Module: Data Exchange Plugin

django-contact-form Documentation

NIELSEN API PORTAL USER REGISTRATION GUIDE

ska Documentation Release Artur Barseghyan

Bambu API Documentation

Pulse Secure Client for Chrome OS

Data Avenue REST API. Ákos Hajnal, Zoltán Farkas November, 2015

Way2mint SMS Mobile Terminate (MT) API Guide for HTTP HTTPS

Understanding RESTful APIs and documenting them with Swagger. Presented by: Tanya Perelmuter Date: 06/18/2018

uick Start Guide 1. Install Oracle Java SE Development Kit (JDK) version or later or 1.7.* and set the JAVA_HOME environment variable.

py-couchdb Documentation

Transcription:

f5-icontrol-rest Documentation Release 1.3.10 F5 Networks Aug 04, 2018

Contents 1 Overview 1 2 Installation 3 2.1 Using Pip................................................. 3 2.2 GitHub.................................................. 3 3 Examples 5 4 Module Documentation 7 4.1 icontrol.................................................. 7 4.1.1 icontrol package......................................... 7 4.1.1.1 Submodules...................................... 7 4.1.1.2 icontrol.authtoken module............................... 7 4.1.1.3 icontrol.exceptions module.............................. 8 4.1.1.4 icontrol.session module................................ 8 4.1.1.5 Module contents.................................... 12 5 License 13 5.1 Apache V2.0............................................... 13 5.2 Contributor License Agreement..................................... 13 Python Module Index 15 i

ii

CHAPTER 1 Overview The F5 Networks icontrol module is used to send commands to the BIGIP icontrol REST API. The library maintains a HTTP session (which is a requests.session) and does URL validation and logging. 1

f5-icontrol-rest Documentation, Release 1.3.10 2 Chapter 1. Overview

CHAPTER 2 Installation 2.1 Using Pip $ pip install f5-icontrol-rest 2.2 GitHub F5Networks/f5-icontrol-rest-python 3

f5-icontrol-rest Documentation, Release 1.3.10 4 Chapter 2. Installation

CHAPTER 3 Examples from icontrol.session import icontrolrestsession icr_session = icontrolrestsession('myuser', 'mypass') # GET to https://bigip.example.com/mgmt/tm/ltm/nat/~common~mynat icr_session.get( 'https://bigip.example.com/mgmt/tm/ltm/nat', name='mynat', partition='common') # GET to https://bigip.example.com/mgmt/tm/ltm/nat icr_session.get('https://bigip.example.com/mgmt/tm/ltm/nat') # POST with json data icr_session.post('https://bigip.example.com/mgmt/tm/ltm/nat', \ json={'name': 'myname', 'partition': 'Common'}) 5

f5-icontrol-rest Documentation, Release 1.3.10 6 Chapter 3. Examples

CHAPTER 4 Module Documentation 4.1 icontrol 4.1.1 icontrol package 4.1.1.1 Submodules 4.1.1.2 icontrol.authtoken module A requests-compatible system for BIG-IP token-based authentication. BIG-IP only allows users with the Administrator role to authenticate to icontrol using HTTP Basic auth. Administrator users can use the token-based authentication scheme described at: https://devcentral.f5.com/wiki/icontrol.authentication_with_the_f5_rest_api.ashx Use this module with requests to automatically get a new token, and attach requests.session object, so that it is used to authenticate future requests. Instead of using this module directly, it is easiest to enable it by passing a token=true argument when creating the icontrolrestsession: >>> icrs = icontrolrestsession('bob', 'secret', token=true) class icontrol.authtoken.icontrolresttokenauth(username, password, login_provider_name= tmos, verify=false, auth_provider=none) Bases: requests.auth.authbase Acquire and renew BigIP icontrol REST authentication tokens. Parameters username (str) The username on BigIP password (str) The password for username on BigIP Non- 7

f5-icontrol-rest Documentation, Release 1.3.10 login_provider_name (str) The name of the login provider that BigIP should consult when creating the token. verify (str) The path to a CA bundle containing the CA certificate for SSL validation If username is configured locally on the BigIP, login_provider_name should be "tmos" (default). Otherwise (for example, username is configured on LDAP that BigIP consults), consult BigIP documentation or your system administrator for the value of login_provider_name. get_auth_providers(netloc) BIG-IQ specific query for auth providers BIG-IP doesn t really need this because BIG-IP s multiple auth providers seem to handle fallthrough just fine. BIG-IQ on the other hand, needs to have its auth provider specified if you re using one of the nondefault ones. Parameters netloc Returns get_new_token(netloc) Get a new token from BIG-IP and store it internally. Throws relevant exception if it fails to get a new token. This method will be called automatically if a request is attempted but there is no authentication token, or the authentication token is expired. It is usually not necessary for users to call it, but it can be called if it is known that the authentication token has been invalidated by other means. 4.1.1.3 icontrol.exceptions module Exceptions that can be emitted by the icontrol package. exception icontrol.exceptions.bigipinvalidurl Bases: exceptions.exception exception icontrol.exceptions.invalidbigip_icruri Bases: icontrol.exceptions.bigipinvalidurl exception icontrol.exceptions.invalidinstancenameorfolder Bases: icontrol.exceptions.bigipinvalidurl exception icontrol.exceptions.invalidprefixcollection Bases: icontrol.exceptions.bigipinvalidurl exception icontrol.exceptions.invalidscheme Bases: icontrol.exceptions.bigipinvalidurl exception icontrol.exceptions.invalidsuffixcollection Bases: icontrol.exceptions.bigipinvalidurl exception icontrol.exceptions.invaliduricomponentpart Bases: icontrol.exceptions.bigipinvalidurl exception icontrol.exceptions.icontrolunexpectedhttperror(*args, **kwargs) Bases: requests.exceptions.httperror 4.1.1.4 icontrol.session module A BigIP-RESTServer URI handler. REST-APIs use it on the requests library. Use this module to make calls to a BigIP-REST server. It will handle: 8 Chapter 4. Module Documentation

f5-icontrol-rest Documentation, Release 1.3.10 1. URI Sanitization uri s produced by this module are checked to ensure compliance with the BigIP-REST server interface 2. Session Construction the icontrolrestsession wraps a requests.session object. 3. Logging pre- and post- request state is logged. 4. Exception generation Errors in URL construction generate BigIPInvalidURL subclasses; unexpected HTTP status codes raise icontrolunexpectedhttperror. The core functionality of the module is implemented via the icontrolrestsession class. Calls to its HTTPmethods are checked, pre-logged, submitted, and post-logged. There are 2 modes of operation full_uri, and uri_as_parts, toggled by the uri_as_parts boolean keyword param that can be passed to methods. It defaults to False. Use uri_as_parts when you want to leverage the full functionality of this library, and have it construct your uri for you. Example Use in uri_as_parts mode: >>> icrs = icontrolrestsession('jrandomhacker', 'insecure') >>> icrs.get('https://192.168.1.1/mgmt/tm/ltm/nat/', partition='common', name= 'VALIDNAME', uri_as_parts=true) In full_uri mode: >>> icrs.get('https://192.168.1.1/mgmt/tm/ltm/nat/~common~validname') NOTE: If used via the f5-common-python library the typical mode is full_uri since that library binds uris to Python objects. Available functions: icrs.{get, post, put, delete, patch}: requests.session.verb wrappers decorate_http_verb_method: this function preps, logs, and handles requests against the BigIP REST Server, by pre- and post- processing the above methods. icontrol.session.debug_prepared_request(request) icontrol.session.decorate_http_verb_method(method) Prepare and Post-Process HTTP VERB method for BigIP-RESTServer request. This function decorates all of the HTTP VERB methods in the icontrolrestsession class. It provides the core logic for this module. If necessary it validates and assembles a uri from parts with a call to generate_bigip_uri. Then it: 1. pre-logs the details of the request 2. submits the request 3. logs the response, included expected status codes 4. raises exceptions for unexpected status codes. (i.e. not doc d as BigIP RESTServer codes.) icontrol.session.generate_bigip_uri(base_uri, partition, name, sub_path, suffix, **kwargs) (str, str, str) > str This function checks the supplied elements to see if each conforms to the specification for the appropriate part of the URI. These validations are conducted by the helper function _validate_uri_parts. After validation the parts are assembled into a valid BigIP REST URI string which is then submitted with appropriate metadata. >>> generate_bigip_uri('https://0.0.0.0/mgmt/tm/ltm/nat/', 'CUSTOMER1', 'nat52 ', params={'a':1}) 'https://0.0.0.0/mgmt/tm/ltm/nat/~customer1~nat52' (continues on next page) 4.1. icontrol 9

f5-icontrol-rest Documentation, Release 1.3.10 (continued from previous page) >>> generate_bigip_uri('https://0.0.0.0/mgmt/tm/ltm/nat/', 'CUSTOMER1', 'nat52 ', params={'a':1}, suffix='/wacky') 'https://0.0.0.0/mgmt/tm/ltm/nat/~customer1~nat52/wacky' >>> generate_bigip_uri('https://0.0.0.0/mgmt/tm/ltm/nat/', '', '', params={'a ':1}, suffix='/thwocky') 'https://0.0.0.0/mgmt/tm/ltm/nat/thwocky' ::Warning: There are cases where / and ~ characters are valid in the object name. This is indicated by passing transform_name boolean as True, by default this is set to False. icontrol.session.get_request_args(kwargs) icontrol.session.get_send_args(kwargs) class icontrol.session.icontrolrestsession(username, password, **kwargs) Bases: object Represents a requests.session that communicates with a BigIP. Instantiate one of these when you want to communicate with a BigIP-REST Server, it will handle BigIP-specific details of the uri s. In the f5-common-python library, an icontrolrestsession is instantiated during BigIP instantiation and associated with it as an attribute of the BigIP (a compositional vs. inheritable association). Objects instantiated from this class provide an HTTP 1.1 style session, via the requests.session object, and HTTP-methods that are specialized to the BigIP-RESTServer interface. Pass token=true in **kwargs to use token-based authentication. This is required for users that do not have the Administrator role on BigIP. append_user_agent(user_agent) Append text to the User-Agent header for the request. debug Use this method to update the User-Agent header by appending the given string to the session s User-Agent header separated by a space. debug_output Parameters user_agent (str) A string to append to the User-Agent header delete(ric_base_uri, **kwargs) Sends a HTTP DELETE command to the BIGIP REST Server. Use this method to send a DELETE command to the BIGIP. When calling this method with the optional arguments name and partition as part of **kwargs they will be added to the uri passed in separated by ~ to create a proper BIGIP REST API URL for objects. All other parameters passed in as **kwargs are passed directly to the requests.session. delete() Parameters uri (str) A HTTP URI name (str) The object name that will be appended to the uri partition (str) The partition name that will be appened to the uri **kwargs The reqeusts.session.delete() optional params 10 Chapter 4. Module Documentation

f5-icontrol-rest Documentation, Release 1.3.10 get(ric_base_uri, **kwargs) Sends a HTTP GET command to the BIGIP REST Server. Use this method to send a GET command to the BIGIP. When calling this method with the optional arguments name and partition as part of **kwargs they will be added to the uri passed in separated by ~ to create a proper BIGIP REST API URL for objects. All other parameters passed in as **kwargs are passed directly to the requests.session.get() Parameters uri (str) A HTTP URI name (str) The object name that will be appended to the uri partition (str) The partition name that will be appened to the uri **kwargs The reqeusts.session.get() optional params patch(ric_base_uri, **kwargs) Sends a HTTP PATCH command to the BIGIP REST Server. Use this method to send a PATCH command to the BIGIP. When calling this method with the optional arguments name and partition as part of **kwargs they will be added to the uri passed in separated by ~ to create a proper BIGIP REST API URL for objects. All other parameters passed in as **kwargs are passed directly to the requests.session. patch() Parameters uri (str) A HTTP URI data (str) The data to be sent with the PATCH command name (str) The object name that will be appended to the uri partition (str) The partition name that will be appened to the uri **kwargs The reqeusts.session.patch() optional params post(ric_base_uri, **kwargs) Sends a HTTP POST command to the BIGIP REST Server. Use this method to send a POST command to the BIGIP. When calling this method with the optional arguments name and partition as part of **kwargs they will be added to the uri passed in separated by ~ to create a proper BIGIP REST API URL for objects. All other parameters passed in as **kwargs are passed directly to the requests.session.post() Parameters uri (str) A HTTP URI data (str) The data to be sent with the POST command json (dict) The JSON data to be sent with the POST command name (str) The object name that will be appended to the uri partition (str) The partition name that will be appened to the uri **kwargs The reqeusts.session.post() optional params put(ric_base_uri, **kwargs) Sends a HTTP PUT command to the BIGIP REST Server. 4.1. icontrol 11

f5-icontrol-rest Documentation, Release 1.3.10 Use this method to send a PUT command to the BIGIP. When calling this method with the optional arguments name and partition as part of **kwargs they will be added to the uri passed in separated by ~ to create a proper BIGIP REST API URL for objects. All other parameters passed in as **kwargs are passed directly to the requests.session.put() Parameters uri (str) A HTTP URI data (str) The data to be sent with the PUT command json (dict) The JSON data to be sent with the PUT command name (str) The object name that will be appended to the uri partition (str) The partition name that will be appended to the uri **kwargs The reqeusts.session.put() optional params token Convenience wrapper around returning the current token Returns: result (str): The current token being sent in session headers. 4.1.1.5 Module contents 12 Chapter 4. Module Documentation

CHAPTER 5 License 5.1 Apache V2.0 Licensed under the Apache License, Version 2.0 (the License ); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/license-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 5.2 Contributor License Agreement Individuals or business entities who contribute to this project must have completed and submitted the F5 Contributor License Agreement to Openstack_CLA@f5.com prior to their code submission being included in this project. 13

f5-icontrol-rest Documentation, Release 1.3.10 14 Chapter 5. License

Python Module Index i icontrol, 12 icontrol.authtoken, 7 icontrol.exceptions, 8 icontrol.session, 8 15

f5-icontrol-rest Documentation, Release 1.3.10 16 Python Module Index

Index A (icon- method), append_user_agent() trol.session.icontrolrestsession 10 B BigIPInvalidURL, 8 D debug (icontrol.session.icontrolrestsession attribute), 10 debug_output (icontrol.session.icontrolrestsession attribute), 10 debug_prepared_request() (in module icontrol.session), 9 decorate_http_verb_method() (in module icontrol.session), 9 delete() (icontrol.session.icontrolrestsession method), 10 G generate_bigip_uri() (in module icontrol.session), 9 get() (icontrol.session.icontrolrestsession method), 10 get_auth_providers() (icon- trol.authtoken.icontrolresttokenauth method), 8 get_new_token() trol.authtoken.icontrolresttokenauth method), 8 get_request_args() (in module icontrol.session), 10 get_send_args() (in module icontrol.session), 10 (icon- I icontrol (module), 12 icontrol.authtoken (module), 7 icontrol.exceptions (module), 8 icontrol.session (module), 8 icontrolrestsession (class in icontrol.session), 10 icontrolresttokenauth (class in icontrol.authtoken), 7 icontrolunexpectedhttperror, 8 InvalidBigIP_ICRURI, 8 InvalidInstanceNameOrFolder, 8 InvalidPrefixCollection, 8 InvalidScheme, 8 InvalidSuffixCollection, 8 InvalidURIComponentPart, 8 P patch() (icontrol.session.icontrolrestsession method), 11 post() (icontrol.session.icontrolrestsession method), 11 put() (icontrol.session.icontrolrestsession method), 11 T token (icontrol.session.icontrolrestsession attribute), 12 17