Skip to content

API Examples

Za Wilgustus edited this page Dec 18, 2015 · 24 revisions

This page will document the BigIP API:

###Example of BigIP Resource Creation The intent is that the client using the f5-common-python REST API can access BigIP uri's as Python objects. For example, a user that wants to create a new Nat instance on the BigIP device can use any of the three following equivalent patterns:

Preamble:

from f5.bigip import BigIP

bigip = BigIP("HOSTNAME", "USERNAME", "PASSWORD")

all examples should start with the preamble.

nat_obj =  bigip.ltm.nat
nat_obj.create(folder="Common", instance_name="SOMEUSER")

The local Python object contains a complete representation of the JSON returned by calling HTTP GET against the corresponding uri on the BigIP. Elements of the JSON object are attributes of the Python object. This implies a second method for instantiating an ltm/nat service on the BigIP:

nat_obj = bigip.ltm.nat
nat_obj.folder = "Common"
nat_obj.instance_name = "SOMEUSER"
nat_obj.update()
nat_obj = bigip.ltm.nat.create(folder="Common", instance_name="SOMEUSER")

The Transaction Model

The API operates on the device using the "Create, Read, Update, Delete" meta-pattern (implemented via HTTP verbs). Data is serialized, and transmitted, as JSON objects, and manipulated by the client as corresponding Python objects.

Transactions with the Device's REST Server either raise an IncompleteTransaction Exception (Not Yet Implented), or result in the calling Python object being updated with the JSON returned from the transaction.

Plural Resources

Because the BigIP REST Server provides uri's that map to "singular" resource types (e.g. "ltm/nat" as opposed to "ltm/nats", it is necessary to make a design decision in the client API about how to handle plural resources. We have opted to include logic for "plural" operations in the parent Resource of the singular object.

For example invoke the following to get all ltm nats from the Device REST Server:

nats = bigip.ltm.get_nats()

Clone this wiki locally