Python API Reference Documentation¶
This chapter of python-cratonclient’s documentation focuses entirely on the API of the different objects involved in the use of cratonclient’s Python API.
Version-less Objects¶
-
class
cratonclient.session.
Session
(session=None, username=None, token=None, project_id=None)¶ Management class to allow different types of sessions to be used.
If an instance of Craton is deployed with Keystone Middleware, this allows for a keystoneauth session to be used so authentication will happen immediately.
v1 API Documentation¶
-
class
cratonclient.v1.client.
Client
(session, url)¶ Craton v1 API Client.
-
cells
¶ The canonical way to list, get, delete, or update cell objects via a
CellManager
instance.
-
clouds
¶ The canonical way to list, get, delete, or update cloud objects via a
CloudManager
instance.
-
devices
¶ The canonical way to list devicess via a
DeviceManager
instance.
-
hosts
¶ The canonical way to list, get, delete, or update host objects via a
HostManager
instance.
-
projects
¶ The canonical way to list, get, delete, or update project objects via a
ProjectManager
instance.
-
regions
¶ The canonical way to list, get, delete, or update region objects via a
RegionManager
instance.
-
Cells¶
-
class
cratonclient.v1.cells.
Cell
(manager, info, loaded=False)¶ Representation of a Region.
-
delete
()¶ Delete the resource from the service.
-
get
()¶ Support for lazy loading details.
Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.
-
human_id
¶ Human-readable ID which can be used for bash completion.
-
is_loaded
()¶ Check if the resource has been loaded.
-
-
class
cratonclient.v1.cells.
CellManager
(session, url, **extra_request_kwargs)¶ A manager for cells.
-
create
(skip_merge=False, **kwargs)¶ Create a new item based on the keyword arguments provided.
-
delete
(item_id=None, skip_merge=True, json=None, **kwargs)¶ Delete the item based on the keyword arguments provided.
-
get
(item_id=None, skip_merge=True, **kwargs)¶ Retrieve the item based on the keyword arguments provided.
-
list
(skip_merge=False, **kwargs)¶ Generate the items from this endpoint.
-
update
(item_id=None, skip_merge=True, **kwargs)¶ Update the item based on the keyword arguments provided.
-
Clouds¶
-
class
cratonclient.v1.clouds.
Cloud
(manager, info, loaded=False)¶ Representation of a Cloud.
-
delete
()¶ Delete the resource from the service.
-
get
()¶ Support for lazy loading details.
Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.
-
human_id
¶ Human-readable ID which can be used for bash completion.
-
is_loaded
()¶ Check if the resource has been loaded.
-
-
class
cratonclient.v1.clouds.
CloudManager
(session, url, **extra_request_kwargs)¶ A manager for clouds.
-
create
(skip_merge=False, **kwargs)¶ Create a new item based on the keyword arguments provided.
-
delete
(item_id=None, skip_merge=True, json=None, **kwargs)¶ Delete the item based on the keyword arguments provided.
-
get
(item_id=None, skip_merge=True, **kwargs)¶ Retrieve the item based on the keyword arguments provided.
-
list
(skip_merge=False, **kwargs)¶ Generate the items from this endpoint.
-
update
(item_id=None, skip_merge=True, **kwargs)¶ Update the item based on the keyword arguments provided.
-
Devices¶
-
class
cratonclient.v1.devices.
Device
(manager, info, loaded=False)¶ Representation of a Device.
-
delete
()¶ Delete the resource from the service.
-
get
()¶ Support for lazy loading details.
Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.
-
human_id
¶ Human-readable ID which can be used for bash completion.
-
is_loaded
()¶ Check if the resource has been loaded.
-
Hosts¶
-
class
cratonclient.v1.hosts.
Host
(manager, info, loaded=False)¶ Representation of a Host.
-
delete
()¶ Delete the resource from the service.
-
get
()¶ Support for lazy loading details.
Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.
-
human_id
¶ Human-readable ID which can be used for bash completion.
-
is_loaded
()¶ Check if the resource has been loaded.
-
-
class
cratonclient.v1.hosts.
HostManager
(session, url, **extra_request_kwargs)¶ A manager for hosts.
-
create
(skip_merge=False, **kwargs)¶ Create a new item based on the keyword arguments provided.
-
delete
(item_id=None, skip_merge=True, json=None, **kwargs)¶ Delete the item based on the keyword arguments provided.
-
get
(item_id=None, skip_merge=True, **kwargs)¶ Retrieve the item based on the keyword arguments provided.
-
list
(skip_merge=False, **kwargs)¶ Generate the items from this endpoint.
-
update
(item_id=None, skip_merge=True, **kwargs)¶ Update the item based on the keyword arguments provided.
-
Projects¶
-
class
cratonclient.v1.projects.
Project
(manager, info, loaded=False)¶ Representation of a Project.
-
delete
()¶ Delete the resource from the service.
-
get
()¶ Support for lazy loading details.
Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.
-
human_id
¶ Human-readable ID which can be used for bash completion.
-
is_loaded
()¶ Check if the resource has been loaded.
-
-
class
cratonclient.v1.projects.
ProjectManager
(session, url, **extra_request_kwargs)¶ A manager for projects.
-
create
(skip_merge=False, **kwargs)¶ Create a new item based on the keyword arguments provided.
-
delete
(item_id=None, skip_merge=True, json=None, **kwargs)¶ Delete the item based on the keyword arguments provided.
-
get
(item_id=None, skip_merge=True, **kwargs)¶ Retrieve the item based on the keyword arguments provided.
-
list
(skip_merge=False, **kwargs)¶ Generate the items from this endpoint.
-
update
(item_id=None, skip_merge=True, **kwargs)¶ Update the item based on the keyword arguments provided.
-
Regions¶
-
class
cratonclient.v1.regions.
Region
(manager, info, loaded=False)¶ Representation of a Region.
-
delete
()¶ Delete the resource from the service.
-
get
()¶ Support for lazy loading details.
Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.
-
human_id
¶ Human-readable ID which can be used for bash completion.
-
is_loaded
()¶ Check if the resource has been loaded.
-
-
class
cratonclient.v1.regions.
RegionManager
(session, url, **extra_request_kwargs)¶ A manager for regions.
-
create
(skip_merge=False, **kwargs)¶ Create a new item based on the keyword arguments provided.
-
delete
(item_id=None, skip_merge=True, json=None, **kwargs)¶ Delete the item based on the keyword arguments provided.
-
get
(item_id=None, skip_merge=True, **kwargs)¶ Retrieve the item based on the keyword arguments provided.
-
list
(skip_merge=False, **kwargs)¶ Generate the items from this endpoint.
-
update
(item_id=None, skip_merge=True, **kwargs)¶ Update the item based on the keyword arguments provided.
-
Variables¶
-
class
cratonclient.v1.variables.
Variable
(name, value)¶ Represents a Craton variable key/value pair.
-
class
cratonclient.v1.variables.
Variables
(manager, info, loaded=False)¶ Represents a dictionary of Variables.
-
class
cratonclient.v1.variables.
VariableManager
(session, url, **extra_request_kwargs)¶ A CRUD manager for variables.
-
create
(skip_merge=False, **kwargs)¶ Create a new item based on the keyword arguments provided.
-
delete
(*args, **kwargs)¶ Wrap crud.CRUDClient’s delete to simplify for the variables.
One can pass in a series of keys to delete, and this will pass the correct arguments to the crud.CRUDClient.delete function.
>>> craton.hosts.get(1234).variables.delete('var-a', 'var-b') <Response [204]>
-
get
(item_id=None, skip_merge=True, **kwargs)¶ Retrieve the item based on the keyword arguments provided.
-
list
(skip_merge=False, **kwargs)¶ Generate the items from this endpoint.
-
update
(item_id=None, skip_merge=True, **kwargs)¶ Update the item based on the keyword arguments provided.
-
Authentication Helpers¶
-
cratonclient.auth.
craton_auth
(username, token, project_id, verify=True)¶ Configure a cratonclient Session to authenticate to Craton.
This will create, configure, and return a Session object that will use Craton’s built-in authentication method.
Parameters: - username (str) – The username with which to authentiate against the API.
- token (str) – The token with which to authenticate against the API.
- project_id (str) – The project ID that the user belongs to.
- verify (bool) – (Optional) Whether or not to verify HTTPS certificates provided by the server. Default: True
Returns: Configured cratonclient session.
Return type: Example:
from cratonclient import auth from cratonclient.v1 import client craton = client.Client(session=auth.craton_auth( username='demo', token='demo', project_id='b9f10eca66ac4c279c139d01e65f96b4', ))
-
cratonclient.auth.
keystone_auth
(auth_url, username, password, verify=True, project_name=None, project_id=None, project_domain_name=None, project_domain_id=None, user_domain_name=None, user_domain_id=None, **auth_parameters)¶ Configure a cratonclient Session to authenticate with Keystone.
This will create, configure, and return a Session using thet appropriate Keystone authentication plugin to be able to communicate and authenticate to Craton.
Note
Presently, this function supports only V3 Password based authentication to Keystone. We also do not validate that you specify required attributes. For example, Keystone will require you provide
project_name
orproject_id
but we will not enforce whether or not you’ve specified one.Parameters: - auth_url (str) – The URL of the Keystone instance to authenticate to.
- username (str) – The username with which we will authenticate to Keystone.
- password (str) – The password used to authenticate to Keystone.
- project_name (str) – (Optional) The name of the project the user belongs to.
- project_id (str) – (Optional) The ID of the project the user belongs to.
- project_domain_name (str) – (Optional) The name of the project’s domain.
- project_domain_id (str) – (Optional) The ID of the project’s domain.
- user_domain_name (str) – (Optional) The name of the user’s domain.
- user_domain_id (str) – (Optional) The ID of the user’s domain.
- verify (bool) – (Optional) Whether or not to verify HTTPS certificates provided by the server. Default: True
- **auth_parameters – Any extra authentication parameters used to authenticate to Keystone.
See the Keystone documentation for usage of:
-
trust_id
-domain_id
-domain_name
-reauthenticate
Returns: Configured cratonclient session.
Return type: Example:
from cratonclient import auth from cratonclient.v1 import client craton = client.Client(session=auth.keystone_auth( auth_url='https://keystone.cloud.org/v3', username='admin', password='s3cr373p@55w0rd', project_name='admin', project_domain_name='Default', user_domain_name='Default', ))