Giter Site home page Giter Site logo

esisdk's Introduction

esisdk

Unified SDK for ESI

Use the SDK in python scripts

Install ESI SDK:

python setup.py install

Create a connection to ESI SDK

There are several methods to establish a connection using the ESI SDK. Since the esi.connection.ESIConnection class inherits from openstack.connection.Connection, methods applicable for creating connections in the OpenStack SDK can also be used with the ESI SDK. Below are some common ways to create an ESIConnection:

Create a connection using only keyword arguments

from esi import connection

conn = connection.ESIConnection(
    region_name='example-region',
    auth={
        'auth_url': 'https://auth.example.com',
        'username': 'user',
        'password': 'password',
        'project_name': 'project_name',
        'user_domain_name': 'user_domain_name',
        'project_domain_name': 'project_domain_name'
    },
    interface='public'
)

Create a connection from existing CloudRegion

from esi import connection
import openstack.config

config = openstack.config.get_cloud_region(
    cloud='example',
    region_name='earth'
)
conn = connection.ESIConnectionn(config=config)

Make API calls

Detailed APIs can be found in the esi/lease/v1/_proxy.py file. Below are simple examples demonstrating lease resource CRUD operations.

import esi
import os

TEST_CLOUD = os.getenv('OS_TEST_CLOUD', 'devstack-admin')
conn = esi.connect(cloud=TEST_CLOUD)

# Create a lease
def lease_create(conn, resource_uuid, project_id, **kwargs):
    lease = conn.lease.create_lease(resource_uuid=resource_uuid,
                                    project_id=project_id,
                                    **kwargs)

# List leases
def lease_list(conn, **kwargs):
    leases = conn.lease.leases(**kwargs)

# Update a lease
def lease_update(conn, lease, **kwargs):
    lease_dict = conn.lease.update_lease(lease, **kwargs)

# Delete a lease
def lease_delete(conn, lease_id):
    leases = conn.lease.delete_lease(lease_id)

esisdk's People

Contributors

tzumainn avatar danniesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.