Package cm_api :: Module api_client :: Class ApiResource
[hide private]
[frames] | no frames]

Class ApiResource

source code

       object --+    
                |    
resource.Resource --+
                    |
                   ApiResource

Resource object that provides methods for managing the top-level API resources.

Instance Methods [hide private]
 
__init__(self, server_host, server_port=None, username='admin', password='admin', use_tls=False, version=17, ssl_context=None)
Creates a Resource object that provides API endpoints.
source code
 
get_cloudera_manager(self)
Returns a Cloudera Manager object.
source code
 
create_cluster(self, name, version=None, fullVersion=None)
Create a new cluster.
source code
 
delete_cluster(self, name)
Delete a cluster by name.
source code
 
get_all_clusters(self, view=None)
Retrieve a list of all clusters.
source code
 
get_cluster(self, name)
Look up a cluster by name.
source code
 
create_host(self, host_id, name, ipaddr, rack_id=None)
Create a host.
source code
 
delete_host(self, host_id)
Delete a host by id.
source code
 
get_all_hosts(self, view=None)
Get all hosts
source code
 
get_host(self, host_id)
Look up a host by id.
source code
 
get_all_users(self, view=None)
Get all users.
source code
 
get_user(self, username)
Look up a user by username.
source code
 
create_user(self, username, password, roles)
Create a user.
source code
 
delete_user(self, username)
Delete user by username.
source code
 
update_user(self, user)
Update user with the supplied new user object.
source code
 
query_events(self, query_str=None)
Query events.
source code
 
get_event(self, event_id)
Retrieve a particular event by ID.
source code
 
echo(self, message)
Have the server echo a message back.
source code
 
echo_error(self, message)
Generate an error, but we get to set the error message.
source code
 
get_metrics(self, path, from_time, to_time, metrics, view, params=None)
Generic function for querying metrics.
source code
 
query_timeseries(self, query, from_time=None, to_time=None, by_post=False)
Query time series.
source code
 
get_metric_schema(self)
Get the schema for all of the metrics.
source code
 
do_batch(self, elements)
Execute a batch request with one or more elements.
source code
 
get_supported_external_account_categories(self)
Lookup all supported categories.
source code
 
get_supported_external_account_types(self, category_name)
Lookup all supported types in a category.
source code
 
create_external_account(self, name, display_name, type_name, account_configs=None)
Create an external account
source code
 
get_external_account(self, name, view=None)
Lookup an external account by name
source code
 
get_external_account_by_display_name(self, display_name, view=None)
Lookup an external account by display name
source code
 
get_all_external_accounts(self, type_name, view=None)
Lookup all external accounts of a particular type, by type name.
source code
 
update_external_account(self, account)
Update an external account
source code
 
delete_external_account(self, name)
Delete an external account by name
source code
 
list_external_account_commands_by_name(self, type_name)
Lists all the commands that can be executed by name on the provided external account type.
source code

Inherited from resource.Resource: delete, get, invoke, post, put

Inherited from resource.Resource (private): _join_uri, _make_headers

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  version
Returns the API version (integer) being used.

Inherited from resource.Resource: base_url

Inherited from object: __class__

Method Details [hide private]

__init__(self, server_host, server_port=None, username='admin', password='admin', use_tls=False, version=17, ssl_context=None)
(Constructor)

source code 

Creates a Resource object that provides API endpoints.

Parameters:
  • server_host - The hostname of the Cloudera Manager server.
  • server_port - The port of the server. Defaults to 7180 (http) or 7183 (https).
  • username - Login name.
  • password - Login password.
  • use_tls - Whether to use tls (https).
  • version - API version.
  • ssl_context - A custom SSL context to use for HTTPS (Python 2.7.9+)
Returns:
Resource object referring to the root.
Overrides: object.__init__

create_cluster(self, name, version=None, fullVersion=None)

source code 

Create a new cluster.

Parameters:
  • name - Cluster name.
  • version - Cluster major CDH version, e.g. 'CDH5'. Ignored if fullVersion is specified.
  • fullVersion - Complete CDH version, e.g. '5.1.2'. Overrides major version if both specified.
Returns:
The created cluster.

delete_cluster(self, name)

source code 

Delete a cluster by name.

Parameters:
  • name - Cluster name
Returns:
The deleted ApiCluster object

get_all_clusters(self, view=None)

source code 

Retrieve a list of all clusters.

Parameters:
  • view - View to materialize ('full' or 'summary').
Returns:
A list of ApiCluster objects.

get_cluster(self, name)

source code 

Look up a cluster by name.

Parameters:
  • name - Cluster name.
Returns:
An ApiCluster object.

create_host(self, host_id, name, ipaddr, rack_id=None)

source code 

Create a host.

Parameters:
  • host_id - The host id.
  • name - Host name
  • ipaddr - IP address
  • rack_id - Rack id. Default None.
Returns:
An ApiHost object

delete_host(self, host_id)

source code 

Delete a host by id.

Parameters:
  • host_id - Host id
Returns:
The deleted ApiHost object

get_all_hosts(self, view=None)

source code 

Get all hosts

Parameters:
  • view - View to materialize ('full' or 'summary').
Returns:
A list of ApiHost objects.

get_host(self, host_id)

source code 

Look up a host by id.

Parameters:
  • host_id - Host id
Returns:
An ApiHost object

get_all_users(self, view=None)

source code 

Get all users.

Parameters:
  • view - View to materialize ('full' or 'summary').
Returns:
A list of ApiUser objects.

get_user(self, username)

source code 

Look up a user by username.

Parameters:
  • username - Username to look up
Returns:
An ApiUser object

create_user(self, username, password, roles)

source code 

Create a user.

Parameters:
  • username - Username
  • password - Password
  • roles - List of roles for the user. This should be [] for a regular user, or ['ROLE_ADMIN'] for an admin.
Returns:
An ApiUser object

delete_user(self, username)

source code 

Delete user by username.

Parameters:
  • username - Username
Returns:
An ApiUser object

update_user(self, user)

source code 

Update user with the supplied new user object.

Parameters:
  • user - ApiUser object to be applied
Returns:
An ApiUser object

query_events(self, query_str=None)

source code 

Query events.

Parameters:
  • query_str - Query string.
Returns:
A list of ApiEvent.

get_event(self, event_id)

source code 

Retrieve a particular event by ID.

Parameters:
  • event_id - The event ID.
Returns:
An ApiEvent.

get_metrics(self, path, from_time, to_time, metrics, view, params=None)

source code 

Generic function for querying metrics.

Parameters:
  • from_time - A datetime; start of the period to query (optional).
  • to_time - A datetime; end of the period to query (default = now).
  • metrics - List of metrics to query (default = all).
  • view - View to materialize ('full' or 'summary')
  • params - Other query parameters.
Returns:
List of metrics and their readings.

query_timeseries(self, query, from_time=None, to_time=None, by_post=False)

source code 

Query time series.

Parameters:
  • query - Query string.
  • from_time - Start of the period to query (optional).
  • to_time - End of the period to query (default = now).
Returns:
A list of ApiTimeSeriesResponse.

get_metric_schema(self)

source code 

Get the schema for all of the metrics.

Returns:
A list of ApiMetricSchema.

do_batch(self, elements)

source code 

Execute a batch request with one or more elements. If any element fails, the entire request is rolled back and subsequent elements are ignored.

Parameters:
  • elements - A list of ApiBatchRequestElements
Returns:
2-tuple (overall success, list of ApiBatchResponseElements).

get_supported_external_account_categories(self)

source code 

Lookup all supported categories.

Returns:
An ApiExternalAcccountCategory list

get_supported_external_account_types(self, category_name)

source code 

Lookup all supported types in a category.

Parameters:
  • category_name - The category name
Returns:
An ApiExternalAcccountType list

create_external_account(self, name, display_name, type_name, account_configs=None)

source code 

Create an external account

Parameters:
  • name - Immutable external account name
  • display_name - Display name
  • type_name - Account type
  • account_configs - Optional account configuration
Returns:
An ApiExternalAccount object

get_external_account(self, name, view=None)

source code 

Lookup an external account by name

Parameters:
  • name - Account name
  • view - View
Returns:
An ApiExternalAccount object

get_external_account_by_display_name(self, display_name, view=None)

source code 

Lookup an external account by display name

Parameters:
  • display_name - Account display name
  • view - View
Returns:
An ApiExternalAccount object

get_all_external_accounts(self, type_name, view=None)

source code 

Lookup all external accounts of a particular type, by type name.

Parameters:
  • type_name - Type name
  • view - View
Returns:
A list of ApiExternalAccount objects.

update_external_account(self, account)

source code 

Update an external account

Parameters:
  • account - Account to update, account name must be specified.
Returns:
An ApiExternalAccount object

delete_external_account(self, name)

source code 

Delete an external account by name

Parameters:
  • name - Account name
Returns:
An ApiExternalAccount object

list_external_account_commands_by_name(self, type_name)

source code 

Lists all the commands that can be executed by name on the provided external account type.

Parameters:
  • type_name - Account type
Returns:
A list of ApiCommandMetadata objects

Since: API v16


Property Details [hide private]

version

Returns the API version (integer) being used.

Get Method:
unreachable.version(self) - Returns the API version (integer) being used.