Skip to main content

A client library for CloudFoundry

Project description

https://img.shields.io/pypi/v/cloudfoundry-client.svg https://img.shields.io/github/license/antechrestos/cf-python-client.svg

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

Installing

From pip

$ pip install cloudfoundry-client

From sources

To build the library run :

$ python setup.py install

Run the client

To run the client, enter the following command :

$ 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

from cloudfoundry_client.client import CloudFoundryClient
target_endpoint = 'https://somewhere.org'
for organization in client.organizations:
    print organization['metadata']['guid']

Entities

Entities returned by client calls (organzation, 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).

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

Available managers

So far the implemented managers that are available are:

  • service_plans

  • service_instances

  • 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

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_one(**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.

Issues and contributions

Please submit issue/pull request.

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

cloudfoundry-client-0.0.15.zip (22.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page