Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A client library for CloudFoundry

Project Description
Cloudfoundry python client
==========================
.. image:: https://img.shields.io/pypi/v/cloudfoundry-client.svg
:target: https://pypi.python.org/pypi/cloudfoundry-client
.. image:: https://img.shields.io/github/license/antechrestos/cf-python-client.svg
:target: https://raw.githubusercontent.com/antechrestos/cf-python-client/master/LICENSE

The cf-python-client repo contains a Python client library for Cloud Foundry.

Installing
----------

From pip
~~~~~~~~
.. code-block:: bash

$ pip install cloudfoundry-client

From sources
~~~~~~~~~~~~

To build the library run :

.. code-block:: bash

$ python setup.py install


Run the client
--------------
To run the client, enter the following command :

.. code-block:: bash

$ cloudfoundry-client

This will explains you how the client works. At first execution, it will ask you information about the platform you want to reach (url, login and so on).
Please note that your credentials won't be saved on your disk: only tokens will be kept for further use.

Use the client in your code
---------------------------
You may build the client and use it in your code

Client
~~~~~~
To instanciate the client, nothing easier

.. code-block:: python

from cloudfoundry_client.client import CloudFoundryClient
target_endpoint = 'https://somewhere.org'
proxy = dict(http=os.environ.get('HTTP_PROXY', ''), https=os.environ.get('HTTPS_PROXY', ''))
client = CloudFoundryClient(target_endpoint, proxy=proxy, skip_verification=True)
client.init_with_user_credentials('login', 'password')

And then you can use it as follows:

.. code-block:: python

for organization in client.organizations:
print organization['metadata']['guid']

Entities
~~~~~~~~
Entities returned by client calls (*organization*, *space*, *app*..) are navigable ie you can call the method associated with the *xxx_url* entity attribute
(note that if the attribute's name ends with a list, it will be interpreted as a list of object. Other wise you will get a single entity).

.. code-block:: python

for organization in client.organizations:
for space in organization.spaces(): # perform a GET on spaces_url attribute
organization_reloaded = space.organization() # perform a GET on organization_url attribute

Application object provides more methods such as
- instances
- stats
- start
- stop
- summary

As instance, you can get all the summaries as follows:

Or else:

.. code-block:: python

for app in client.apps:
print app.summary()

Available managers
~~~~~~~~~~~~~~~~~~
So far the implemented managers that are available are:

- ``service_plans``
- ``service_instances``
- ``service_keys``
- ``service_bindings``
- ``service_brokers``
- ``apps``
- ``buildpacks``
- ``organizations``
- ``spaces``
- ``services``
- ``routes``

Note that even if, while navigating, you reach an entity manager that does not exist, the get will be performed and you will get the expected entities.
For example, event entity manager is not yet implemented but you can do

.. code-block:: python

for app in client.apps:
for event in app.events():
handle_event_object()

All managers provide the following methods:

- ``list(**kwargs)``: return an *iterator* on entities, according to the given filtered parameters
- ``get_first(**kwargs)``: return the first matching entity according to the given parameters. Returns ```None`` if none returned
- ``get``: perform a **GET** on the entity. If the entity cannot be find it will raise an exception due to http *NOT FOUND* response status
- ``__iter__``: iteration on the manager itself. Alias for a no-filter list
- ``__getitem__``: alias for the ``get`` operation
- ``_create``: the create operation. Since it is a generic operation (only takes a *dict* object), this operation is protected
- ``_update``: the update operation. Since it is a generic operation (only takes a the resource id and a *dict* object), this operation is protected
- ``_remove``: the delete operation. This operation is maintained protected.

Command Line Interface
----------------------

The client comes with a command line interface. Run ``cloudfoundry-client`` command. At first execution, it will ask you
information about the target platform and your credential (do not worry they are not saved). After that you may have a help
by running ``cloudfoundry-client -h``

Issues and contributions
------------------------
Please submit issue/pull request.
Release History

Release History

This version
History Node

0.0.21

History Node

0.0.20

History Node

0.0.19

History Node

0.0.18

History Node

0.0.17

History Node

0.0.16

History Node

0.0.15

History Node

0.0.14

History Node

0.0.13

History Node

0.0.12

History Node

0.0.11

History Node

0.0.10

History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cloudfoundry-client-0.0.21.tar.gz (18.8 kB) Copy SHA256 Checksum SHA256 Source Jul 29, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting