id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
232,700 | IdentityPython/pysaml2 | src/saml2/httputil.py | make_cookie | def make_cookie(name, load, seed, expire=0, domain="", path="",
timestamp=""):
"""
Create and return a cookie
:param name: Cookie name
:param load: Cookie load
:param seed: A seed for the HMAC function
:param expire: Number of minutes before this cookie goes stale
:param domain: The domain of the cookie
:param path: The path specification for the cookie
:return: A tuple to be added to headers
"""
cookie = SimpleCookie()
if not timestamp:
timestamp = str(int(time.mktime(time.gmtime())))
signature = cookie_signature(seed, load, timestamp)
cookie[name] = "|".join([load, timestamp, signature])
if path:
cookie[name]["path"] = path
if domain:
cookie[name]["domain"] = domain
if expire:
cookie[name]["expires"] = _expiration(expire,
"%a, %d-%b-%Y %H:%M:%S GMT")
return tuple(cookie.output().split(": ", 1)) | python | def make_cookie(name, load, seed, expire=0, domain="", path="",
timestamp=""):
cookie = SimpleCookie()
if not timestamp:
timestamp = str(int(time.mktime(time.gmtime())))
signature = cookie_signature(seed, load, timestamp)
cookie[name] = "|".join([load, timestamp, signature])
if path:
cookie[name]["path"] = path
if domain:
cookie[name]["domain"] = domain
if expire:
cookie[name]["expires"] = _expiration(expire,
"%a, %d-%b-%Y %H:%M:%S GMT")
return tuple(cookie.output().split(": ", 1)) | [
"def",
"make_cookie",
"(",
"name",
",",
"load",
",",
"seed",
",",
"expire",
"=",
"0",
",",
"domain",
"=",
"\"\"",
",",
"path",
"=",
"\"\"",
",",
"timestamp",
"=",
"\"\"",
")",
":",
"cookie",
"=",
"SimpleCookie",
"(",
")",
"if",
"not",
"timestamp",
... | Create and return a cookie
:param name: Cookie name
:param load: Cookie load
:param seed: A seed for the HMAC function
:param expire: Number of minutes before this cookie goes stale
:param domain: The domain of the cookie
:param path: The path specification for the cookie
:return: A tuple to be added to headers | [
"Create",
"and",
"return",
"a",
"cookie"
] | d3aa78eeb7d37c12688f783cb4db1c7263a14ad6 | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/httputil.py#L320-L346 |
232,701 | cloudera/cm_api | python/src/cm_api/http_client.py | HttpClient.set_basic_auth | def set_basic_auth(self, username, password, realm):
"""
Set up basic auth for the client
@param username: Login name.
@param password: Login password.
@param realm: The authentication realm.
@return: The current object
"""
self._passmgr.add_password(realm, self._base_url, username, password)
return self | python | def set_basic_auth(self, username, password, realm):
self._passmgr.add_password(realm, self._base_url, username, password)
return self | [
"def",
"set_basic_auth",
"(",
"self",
",",
"username",
",",
"password",
",",
"realm",
")",
":",
"self",
".",
"_passmgr",
".",
"add_password",
"(",
"realm",
",",
"self",
".",
"_base_url",
",",
"username",
",",
"password",
")",
"return",
"self"
] | Set up basic auth for the client
@param username: Login name.
@param password: Login password.
@param realm: The authentication realm.
@return: The current object | [
"Set",
"up",
"basic",
"auth",
"for",
"the",
"client"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/http_client.py#L115-L124 |
232,702 | cloudera/cm_api | python/src/cm_api/endpoints/timeseries.py | query_timeseries | def query_timeseries(resource_root, query, from_time=None, to_time=None,
desired_rollup=None, must_use_desired_rollup=None, by_post=False):
"""
Query for time series data from the CM time series data store.
@param query: Query string.
@param from_time: Start of the period to query (optional).
@type from_time: datetime.datetime Note the that datetime must either be time
zone aware or specified in the server time zone. See the
python datetime documentation for more details about python's
time zone handling.
@param to_time: End of the period to query (default = now).
This may be an ISO format string, or a datetime object.
@type to_time: datetime.datetime Note the that datetime must either be time
zone aware or specified in the server time zone. See the
python datetime documentation for more details about python's
time zone handling.
@param desired_rollup: The aggregate rollup to get data for. This can be
RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, or
WEEKLY. Note that rollup desired is only a hint unless
must_use_desired_rollup is set to true.
@param must_use_desired_rollup: Indicates that the monitoring server should
return the data at the rollup desired.
@param by_post: If true, an HTTP POST request will be made to server. This
allows longer query string to be accepted compared to HTTP
GET request.
@return: List of ApiTimeSeriesResponse
"""
data = None
params = {}
request_method = resource_root.get
if by_post:
request = ApiTimeSeriesRequest(resource_root,
query=query)
data = request
request_method = resource_root.post
elif query:
params['query'] = query
if from_time:
params['from'] = from_time.isoformat()
if to_time:
params['to'] = to_time.isoformat()
if desired_rollup:
params['desiredRollup'] = desired_rollup
if must_use_desired_rollup:
params['mustUseDesiredRollup'] = must_use_desired_rollup
return call(request_method, TIME_SERIES_PATH,
ApiTimeSeriesResponse, True, params=params, data=data) | python | def query_timeseries(resource_root, query, from_time=None, to_time=None,
desired_rollup=None, must_use_desired_rollup=None, by_post=False):
data = None
params = {}
request_method = resource_root.get
if by_post:
request = ApiTimeSeriesRequest(resource_root,
query=query)
data = request
request_method = resource_root.post
elif query:
params['query'] = query
if from_time:
params['from'] = from_time.isoformat()
if to_time:
params['to'] = to_time.isoformat()
if desired_rollup:
params['desiredRollup'] = desired_rollup
if must_use_desired_rollup:
params['mustUseDesiredRollup'] = must_use_desired_rollup
return call(request_method, TIME_SERIES_PATH,
ApiTimeSeriesResponse, True, params=params, data=data) | [
"def",
"query_timeseries",
"(",
"resource_root",
",",
"query",
",",
"from_time",
"=",
"None",
",",
"to_time",
"=",
"None",
",",
"desired_rollup",
"=",
"None",
",",
"must_use_desired_rollup",
"=",
"None",
",",
"by_post",
"=",
"False",
")",
":",
"data",
"=",
... | Query for time series data from the CM time series data store.
@param query: Query string.
@param from_time: Start of the period to query (optional).
@type from_time: datetime.datetime Note the that datetime must either be time
zone aware or specified in the server time zone. See the
python datetime documentation for more details about python's
time zone handling.
@param to_time: End of the period to query (default = now).
This may be an ISO format string, or a datetime object.
@type to_time: datetime.datetime Note the that datetime must either be time
zone aware or specified in the server time zone. See the
python datetime documentation for more details about python's
time zone handling.
@param desired_rollup: The aggregate rollup to get data for. This can be
RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, or
WEEKLY. Note that rollup desired is only a hint unless
must_use_desired_rollup is set to true.
@param must_use_desired_rollup: Indicates that the monitoring server should
return the data at the rollup desired.
@param by_post: If true, an HTTP POST request will be made to server. This
allows longer query string to be accepted compared to HTTP
GET request.
@return: List of ApiTimeSeriesResponse | [
"Query",
"for",
"time",
"series",
"data",
"from",
"the",
"CM",
"time",
"series",
"data",
"store",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/timeseries.py#L28-L75 |
232,703 | cloudera/cm_api | python/src/cm_api/endpoints/parcels.py | get_parcel | def get_parcel(resource_root, product, version, cluster_name="default"):
"""
Lookup a parcel by name
@param resource_root: The root Resource object.
@param product: Parcel product name
@param version: Parcel version
@param cluster_name: Cluster name
@return: An ApiService object
"""
return _get_parcel(resource_root, PARCEL_PATH % (cluster_name, product, version)) | python | def get_parcel(resource_root, product, version, cluster_name="default"):
return _get_parcel(resource_root, PARCEL_PATH % (cluster_name, product, version)) | [
"def",
"get_parcel",
"(",
"resource_root",
",",
"product",
",",
"version",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"_get_parcel",
"(",
"resource_root",
",",
"PARCEL_PATH",
"%",
"(",
"cluster_name",
",",
"product",
",",
"version",
")",
")"
... | Lookup a parcel by name
@param resource_root: The root Resource object.
@param product: Parcel product name
@param version: Parcel version
@param cluster_name: Cluster name
@return: An ApiService object | [
"Lookup",
"a",
"parcel",
"by",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/parcels.py#L24-L33 |
232,704 | cloudera/cm_api | python/src/cm_api/endpoints/parcels.py | get_all_parcels | def get_all_parcels(resource_root, cluster_name="default", view=None):
"""
Get all parcels
@param resource_root: The root Resource object.
@param cluster_name: Cluster name
@return: A list of ApiParcel objects.
@since: API v3
"""
return call(resource_root.get, PARCELS_PATH % (cluster_name,),
ApiParcel, True, params=view and dict(view=view) or None, api_version=3) | python | def get_all_parcels(resource_root, cluster_name="default", view=None):
return call(resource_root.get, PARCELS_PATH % (cluster_name,),
ApiParcel, True, params=view and dict(view=view) or None, api_version=3) | [
"def",
"get_all_parcels",
"(",
"resource_root",
",",
"cluster_name",
"=",
"\"default\"",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"PARCELS_PATH",
"%",
"(",
"cluster_name",
",",
")",
",",
"ApiParcel",
",",
... | Get all parcels
@param resource_root: The root Resource object.
@param cluster_name: Cluster name
@return: A list of ApiParcel objects.
@since: API v3 | [
"Get",
"all",
"parcels"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/parcels.py#L38-L47 |
232,705 | cloudera/cm_api | python/examples/bulk_config_update.py | do_bulk_config_update | def do_bulk_config_update(hostnames):
"""
Given a list of hostnames, update the configs of all the
datanodes, tasktrackers and regionservers on those hosts.
"""
api = ApiResource(CM_HOST, username=CM_USER, password=CM_PASSWD)
hosts = collect_hosts(api, hostnames)
# Set config
for h in hosts:
configure_roles_on_host(api, h) | python | def do_bulk_config_update(hostnames):
api = ApiResource(CM_HOST, username=CM_USER, password=CM_PASSWD)
hosts = collect_hosts(api, hostnames)
# Set config
for h in hosts:
configure_roles_on_host(api, h) | [
"def",
"do_bulk_config_update",
"(",
"hostnames",
")",
":",
"api",
"=",
"ApiResource",
"(",
"CM_HOST",
",",
"username",
"=",
"CM_USER",
",",
"password",
"=",
"CM_PASSWD",
")",
"hosts",
"=",
"collect_hosts",
"(",
"api",
",",
"hostnames",
")",
"# Set config",
... | Given a list of hostnames, update the configs of all the
datanodes, tasktrackers and regionservers on those hosts. | [
"Given",
"a",
"list",
"of",
"hostnames",
"update",
"the",
"configs",
"of",
"all",
"the",
"datanodes",
"tasktrackers",
"and",
"regionservers",
"on",
"those",
"hosts",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/examples/bulk_config_update.py#L108-L118 |
232,706 | cloudera/cm_api | python/examples/bulk_config_update.py | collect_hosts | def collect_hosts(api, wanted_hostnames):
"""
Return a list of ApiHost objects for the set of hosts that
we want to change config for.
"""
all_hosts = api.get_all_hosts(view='full')
all_hostnames = set([ h.hostname for h in all_hosts])
wanted_hostnames = set(wanted_hostnames)
unknown_hosts = wanted_hostnames.difference(all_hostnames)
if len(unknown_hosts) != 0:
msg = "The following hosts are not found in Cloudera Manager. "\
"Please check for typos:\n%s" % ('\n'.join(unknown_hosts))
LOG.error(msg)
raise RuntimeError(msg)
return [ h for h in all_hosts if h.hostname in wanted_hostnames ] | python | def collect_hosts(api, wanted_hostnames):
all_hosts = api.get_all_hosts(view='full')
all_hostnames = set([ h.hostname for h in all_hosts])
wanted_hostnames = set(wanted_hostnames)
unknown_hosts = wanted_hostnames.difference(all_hostnames)
if len(unknown_hosts) != 0:
msg = "The following hosts are not found in Cloudera Manager. "\
"Please check for typos:\n%s" % ('\n'.join(unknown_hosts))
LOG.error(msg)
raise RuntimeError(msg)
return [ h for h in all_hosts if h.hostname in wanted_hostnames ] | [
"def",
"collect_hosts",
"(",
"api",
",",
"wanted_hostnames",
")",
":",
"all_hosts",
"=",
"api",
".",
"get_all_hosts",
"(",
"view",
"=",
"'full'",
")",
"all_hostnames",
"=",
"set",
"(",
"[",
"h",
".",
"hostname",
"for",
"h",
"in",
"all_hosts",
"]",
")",
... | Return a list of ApiHost objects for the set of hosts that
we want to change config for. | [
"Return",
"a",
"list",
"of",
"ApiHost",
"objects",
"for",
"the",
"set",
"of",
"hosts",
"that",
"we",
"want",
"to",
"change",
"config",
"for",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/examples/bulk_config_update.py#L121-L137 |
232,707 | cloudera/cm_api | python/examples/bulk_config_update.py | configure_roles_on_host | def configure_roles_on_host(api, host):
"""
Go through all the roles on this host, and configure them if they
match the role types that we care about.
"""
for role_ref in host.roleRefs:
# Mgmt service/role has no cluster name. Skip over those.
if role_ref.get('clusterName') is None:
continue
# Get the role and inspect the role type
role = api.get_cluster(role_ref['clusterName'])\
.get_service(role_ref['serviceName'])\
.get_role(role_ref['roleName'])
LOG.debug("Evaluating %s (%s)" % (role.name, host.hostname))
config = None
if role.type == 'DATANODE':
config = DATANODE_CONF
elif role.type == 'TASKTRACKER':
config = TASKTRACKER_CONF
elif role.type == 'REGIONSERVER':
config = REGIONSERVER_CONF
else:
continue
# Set the config
LOG.info("Configuring %s (%s)" % (role.name, host.hostname))
role.update_config(config) | python | def configure_roles_on_host(api, host):
for role_ref in host.roleRefs:
# Mgmt service/role has no cluster name. Skip over those.
if role_ref.get('clusterName') is None:
continue
# Get the role and inspect the role type
role = api.get_cluster(role_ref['clusterName'])\
.get_service(role_ref['serviceName'])\
.get_role(role_ref['roleName'])
LOG.debug("Evaluating %s (%s)" % (role.name, host.hostname))
config = None
if role.type == 'DATANODE':
config = DATANODE_CONF
elif role.type == 'TASKTRACKER':
config = TASKTRACKER_CONF
elif role.type == 'REGIONSERVER':
config = REGIONSERVER_CONF
else:
continue
# Set the config
LOG.info("Configuring %s (%s)" % (role.name, host.hostname))
role.update_config(config) | [
"def",
"configure_roles_on_host",
"(",
"api",
",",
"host",
")",
":",
"for",
"role_ref",
"in",
"host",
".",
"roleRefs",
":",
"# Mgmt service/role has no cluster name. Skip over those.",
"if",
"role_ref",
".",
"get",
"(",
"'clusterName'",
")",
"is",
"None",
":",
"co... | Go through all the roles on this host, and configure them if they
match the role types that we care about. | [
"Go",
"through",
"all",
"the",
"roles",
"on",
"this",
"host",
"and",
"configure",
"them",
"if",
"they",
"match",
"the",
"role",
"types",
"that",
"we",
"care",
"about",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/examples/bulk_config_update.py#L140-L168 |
232,708 | cloudera/cm_api | python/examples/bulk_config_update.py | read_host_file | def read_host_file(path):
"""
Read the host file. Return a list of hostnames.
"""
res = []
for l in file(path).xreadlines():
hostname = l.strip()
if hostname:
res.append(hostname)
return res | python | def read_host_file(path):
res = []
for l in file(path).xreadlines():
hostname = l.strip()
if hostname:
res.append(hostname)
return res | [
"def",
"read_host_file",
"(",
"path",
")",
":",
"res",
"=",
"[",
"]",
"for",
"l",
"in",
"file",
"(",
"path",
")",
".",
"xreadlines",
"(",
")",
":",
"hostname",
"=",
"l",
".",
"strip",
"(",
")",
"if",
"hostname",
":",
"res",
".",
"append",
"(",
... | Read the host file. Return a list of hostnames. | [
"Read",
"the",
"host",
"file",
".",
"Return",
"a",
"list",
"of",
"hostnames",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/examples/bulk_config_update.py#L171-L180 |
232,709 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.get_commands | def get_commands(self, view=None):
"""
Retrieve a list of running global commands.
@param view: View to materialize ('full' or 'summary')
@return: A list of running commands.
"""
return self._get("commands", ApiCommand, True,
params = view and dict(view=view) or None) | python | def get_commands(self, view=None):
return self._get("commands", ApiCommand, True,
params = view and dict(view=view) or None) | [
"def",
"get_commands",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get",
"(",
"\"commands\"",
",",
"ApiCommand",
",",
"True",
",",
"params",
"=",
"view",
"and",
"dict",
"(",
"view",
"=",
"view",
")",
"or",
"None",
")"
] | Retrieve a list of running global commands.
@param view: View to materialize ('full' or 'summary')
@return: A list of running commands. | [
"Retrieve",
"a",
"list",
"of",
"running",
"global",
"commands",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L44-L52 |
232,710 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.update_license | def update_license(self, license_text):
"""
Install or update the Cloudera Manager license.
@param license_text: the license in text form
"""
content = (
'--MULTI_BOUNDARY',
'Content-Disposition: form-data; name="license"',
'',
license_text,
'--MULTI_BOUNDARY--',
'')
resp = self._get_resource_root().post('cm/license',
data="\r\n".join(content),
contenttype='multipart/form-data; boundary=MULTI_BOUNDARY')
return ApiLicense.from_json_dict(resp, self._get_resource_root()) | python | def update_license(self, license_text):
content = (
'--MULTI_BOUNDARY',
'Content-Disposition: form-data; name="license"',
'',
license_text,
'--MULTI_BOUNDARY--',
'')
resp = self._get_resource_root().post('cm/license',
data="\r\n".join(content),
contenttype='multipart/form-data; boundary=MULTI_BOUNDARY')
return ApiLicense.from_json_dict(resp, self._get_resource_root()) | [
"def",
"update_license",
"(",
"self",
",",
"license_text",
")",
":",
"content",
"=",
"(",
"'--MULTI_BOUNDARY'",
",",
"'Content-Disposition: form-data; name=\"license\"'",
",",
"''",
",",
"license_text",
",",
"'--MULTI_BOUNDARY--'",
",",
"''",
")",
"resp",
"=",
"self... | Install or update the Cloudera Manager license.
@param license_text: the license in text form | [
"Install",
"or",
"update",
"the",
"Cloudera",
"Manager",
"license",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L87-L103 |
232,711 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.import_admin_credentials | def import_admin_credentials(self, username, password):
"""
Imports the KDC Account Manager credentials needed by Cloudera
Manager to create kerberos principals needed by CDH services.
@param username Username of the Account Manager. Full name including the Kerberos
realm must be specified.
@param password Password for the Account Manager.
@return: Information about the submitted command.
@since API v7
"""
return self._cmd('importAdminCredentials', params=dict(username=username, password=password)) | python | def import_admin_credentials(self, username, password):
return self._cmd('importAdminCredentials', params=dict(username=username, password=password)) | [
"def",
"import_admin_credentials",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"return",
"self",
".",
"_cmd",
"(",
"'importAdminCredentials'",
",",
"params",
"=",
"dict",
"(",
"username",
"=",
"username",
",",
"password",
"=",
"password",
")",
"... | Imports the KDC Account Manager credentials needed by Cloudera
Manager to create kerberos principals needed by CDH services.
@param username Username of the Account Manager. Full name including the Kerberos
realm must be specified.
@param password Password for the Account Manager.
@return: Information about the submitted command.
@since API v7 | [
"Imports",
"the",
"KDC",
"Account",
"Manager",
"credentials",
"needed",
"by",
"Cloudera",
"Manager",
"to",
"create",
"kerberos",
"principals",
"needed",
"by",
"CDH",
"services",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L134-L147 |
232,712 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.collect_diagnostic_data | def collect_diagnostic_data(self, start_datetime, end_datetime, includeInfoLog=False):
"""
This method is deprecated as of CM 4.5.
You should use collect_diagnostic_data_45.
Issue the command to collect diagnostic data.
@param start_datetime: The start of the collection period. Type datetime.
@param end_datetime: The end of the collection period. Type datetime.
@param includeInfoLog: Whether to include INFO level log messages.
"""
args = {
'startTime': start_datetime.isoformat(),
'endTime': end_datetime.isoformat(),
'includeInfoLog': includeInfoLog,
}
# This method is deprecated as of CM API version 3 which was introduced
# in CM 4.5.
return self._cmd('collectDiagnosticData', data=args, api_version=2) | python | def collect_diagnostic_data(self, start_datetime, end_datetime, includeInfoLog=False):
args = {
'startTime': start_datetime.isoformat(),
'endTime': end_datetime.isoformat(),
'includeInfoLog': includeInfoLog,
}
# This method is deprecated as of CM API version 3 which was introduced
# in CM 4.5.
return self._cmd('collectDiagnosticData', data=args, api_version=2) | [
"def",
"collect_diagnostic_data",
"(",
"self",
",",
"start_datetime",
",",
"end_datetime",
",",
"includeInfoLog",
"=",
"False",
")",
":",
"args",
"=",
"{",
"'startTime'",
":",
"start_datetime",
".",
"isoformat",
"(",
")",
",",
"'endTime'",
":",
"end_datetime",
... | This method is deprecated as of CM 4.5.
You should use collect_diagnostic_data_45.
Issue the command to collect diagnostic data.
@param start_datetime: The start of the collection period. Type datetime.
@param end_datetime: The end of the collection period. Type datetime.
@param includeInfoLog: Whether to include INFO level log messages. | [
"This",
"method",
"is",
"deprecated",
"as",
"of",
"CM",
"4",
".",
"5",
".",
"You",
"should",
"use",
"collect_diagnostic_data_45",
".",
"Issue",
"the",
"command",
"to",
"collect",
"diagnostic",
"data",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L175-L192 |
232,713 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.collect_diagnostic_data_45 | def collect_diagnostic_data_45(self, end_datetime, bundle_size_bytes, cluster_name=None,
roles=None, collect_metrics=False, start_datetime=None):
"""
Issue the command to collect diagnostic data.
If start_datetime is specified, diagnostic data is collected for the entire period between
start_datetime and end_datetime provided that bundle size is less than or equal to
bundle_size_bytes. Diagnostics data collection fails if the bundle size is greater than
bundle_size_bytes.
If start_datetime is not specified, diagnostic data is collected starting from end_datetime
and collecting backwards upto a maximum of bundle_size_bytes.
@param end_datetime: The end of the collection period. Type datetime.
@param bundle_size_bytes: The target size for the support bundle in bytes
@param cluster_name: The cluster to collect or None for all clusters
@param roles: Role ids of roles to restrict log and metric collection to. Valid since v10.
@param collect_metrics: Whether to collect metrics for viewing as charts. Valid since v13.
@param start_datetime: The start of the collection period. Type datetime. Valid since v13.
"""
args = {
'endTime': end_datetime.isoformat(),
'bundleSizeBytes': bundle_size_bytes,
'clusterName': cluster_name
}
if self._get_resource_root().version >= 10:
args['roles'] = roles
if self._get_resource_root().version >= 13:
args['enableMonitorMetricsCollection'] = collect_metrics
if start_datetime is not None:
args['startTime'] = start_datetime.isoformat()
return self._cmd('collectDiagnosticData', data=args) | python | def collect_diagnostic_data_45(self, end_datetime, bundle_size_bytes, cluster_name=None,
roles=None, collect_metrics=False, start_datetime=None):
args = {
'endTime': end_datetime.isoformat(),
'bundleSizeBytes': bundle_size_bytes,
'clusterName': cluster_name
}
if self._get_resource_root().version >= 10:
args['roles'] = roles
if self._get_resource_root().version >= 13:
args['enableMonitorMetricsCollection'] = collect_metrics
if start_datetime is not None:
args['startTime'] = start_datetime.isoformat()
return self._cmd('collectDiagnosticData', data=args) | [
"def",
"collect_diagnostic_data_45",
"(",
"self",
",",
"end_datetime",
",",
"bundle_size_bytes",
",",
"cluster_name",
"=",
"None",
",",
"roles",
"=",
"None",
",",
"collect_metrics",
"=",
"False",
",",
"start_datetime",
"=",
"None",
")",
":",
"args",
"=",
"{",
... | Issue the command to collect diagnostic data.
If start_datetime is specified, diagnostic data is collected for the entire period between
start_datetime and end_datetime provided that bundle size is less than or equal to
bundle_size_bytes. Diagnostics data collection fails if the bundle size is greater than
bundle_size_bytes.
If start_datetime is not specified, diagnostic data is collected starting from end_datetime
and collecting backwards upto a maximum of bundle_size_bytes.
@param end_datetime: The end of the collection period. Type datetime.
@param bundle_size_bytes: The target size for the support bundle in bytes
@param cluster_name: The cluster to collect or None for all clusters
@param roles: Role ids of roles to restrict log and metric collection to. Valid since v10.
@param collect_metrics: Whether to collect metrics for viewing as charts. Valid since v13.
@param start_datetime: The start of the collection period. Type datetime. Valid since v13. | [
"Issue",
"the",
"command",
"to",
"collect",
"diagnostic",
"data",
".",
"If",
"start_datetime",
"is",
"specified",
"diagnostic",
"data",
"is",
"collected",
"for",
"the",
"entire",
"period",
"between",
"start_datetime",
"and",
"end_datetime",
"provided",
"that",
"bu... | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L194-L224 |
232,714 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.create_peer | def create_peer(self, name, url, username, password, peer_type="REPLICATION"):
"""
Create a new peer for replication.
@param name: The name of the peer.
@param url: The url of the peer.
@param username: The admin username to use to setup the remote side of the peer connection.
@param password: The password of the admin user.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The newly created peer.
@since: API v3
"""
if self._get_resource_root().version < 11:
peer_type = None
peer = ApiCmPeer(self._get_resource_root(),
name=name,
url=url,
username=username,
password=password,
type=peer_type)
return self._post("peers", ApiCmPeer, data=peer, api_version=3) | python | def create_peer(self, name, url, username, password, peer_type="REPLICATION"):
if self._get_resource_root().version < 11:
peer_type = None
peer = ApiCmPeer(self._get_resource_root(),
name=name,
url=url,
username=username,
password=password,
type=peer_type)
return self._post("peers", ApiCmPeer, data=peer, api_version=3) | [
"def",
"create_peer",
"(",
"self",
",",
"name",
",",
"url",
",",
"username",
",",
"password",
",",
"peer_type",
"=",
"\"REPLICATION\"",
")",
":",
"if",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"version",
"<",
"11",
":",
"peer_type",
"=",
"None",... | Create a new peer for replication.
@param name: The name of the peer.
@param url: The url of the peer.
@param username: The admin username to use to setup the remote side of the peer connection.
@param password: The password of the admin user.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The newly created peer.
@since: API v3 | [
"Create",
"a",
"new",
"peer",
"for",
"replication",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L275-L295 |
232,715 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager._get_peer_type_param | def _get_peer_type_param(self, peer_type):
"""
Checks if the resource_root's API version is >= 11 and construct type param.
"""
params = None
if self._get_resource_root().version >= 11:
params = {
'type': peer_type,
}
return params | python | def _get_peer_type_param(self, peer_type):
params = None
if self._get_resource_root().version >= 11:
params = {
'type': peer_type,
}
return params | [
"def",
"_get_peer_type_param",
"(",
"self",
",",
"peer_type",
")",
":",
"params",
"=",
"None",
"if",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"version",
">=",
"11",
":",
"params",
"=",
"{",
"'type'",
":",
"peer_type",
",",
"}",
"return",
"params... | Checks if the resource_root's API version is >= 11 and construct type param. | [
"Checks",
"if",
"the",
"resource_root",
"s",
"API",
"version",
"is",
">",
"=",
"11",
"and",
"construct",
"type",
"param",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L297-L306 |
232,716 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.delete_peer | def delete_peer(self, name, peer_type="REPLICATION"):
"""
Delete a replication peer.
@param name: The name of the peer.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The deleted peer.
@since: API v3
"""
params = self._get_peer_type_param(peer_type)
return self._delete("peers/" + name, ApiCmPeer, params=params, api_version=3) | python | def delete_peer(self, name, peer_type="REPLICATION"):
params = self._get_peer_type_param(peer_type)
return self._delete("peers/" + name, ApiCmPeer, params=params, api_version=3) | [
"def",
"delete_peer",
"(",
"self",
",",
"name",
",",
"peer_type",
"=",
"\"REPLICATION\"",
")",
":",
"params",
"=",
"self",
".",
"_get_peer_type_param",
"(",
"peer_type",
")",
"return",
"self",
".",
"_delete",
"(",
"\"peers/\"",
"+",
"name",
",",
"ApiCmPeer",... | Delete a replication peer.
@param name: The name of the peer.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The deleted peer.
@since: API v3 | [
"Delete",
"a",
"replication",
"peer",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L308-L318 |
232,717 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.update_peer | def update_peer(self,
current_name,
new_name, new_url, username, password, peer_type="REPLICATION"):
"""
Update a replication peer.
@param current_name: The name of the peer to updated.
@param new_name: The new name for the peer.
@param new_url: The new url for the peer.
@param username: The admin username to use to setup the remote side of the peer connection.
@param password: The password of the admin user.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The updated peer.
@since: API v3
"""
if self._get_resource_root().version < 11:
peer_type = None
peer = ApiCmPeer(self._get_resource_root(),
name=new_name,
url=new_url,
username=username,
password=password,
type=peer_type)
return self._put("peers/" + current_name, ApiCmPeer, data=peer, api_version=3) | python | def update_peer(self,
current_name,
new_name, new_url, username, password, peer_type="REPLICATION"):
if self._get_resource_root().version < 11:
peer_type = None
peer = ApiCmPeer(self._get_resource_root(),
name=new_name,
url=new_url,
username=username,
password=password,
type=peer_type)
return self._put("peers/" + current_name, ApiCmPeer, data=peer, api_version=3) | [
"def",
"update_peer",
"(",
"self",
",",
"current_name",
",",
"new_name",
",",
"new_url",
",",
"username",
",",
"password",
",",
"peer_type",
"=",
"\"REPLICATION\"",
")",
":",
"if",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"version",
"<",
"11",
":"... | Update a replication peer.
@param current_name: The name of the peer to updated.
@param new_name: The new name for the peer.
@param new_url: The new url for the peer.
@param username: The admin username to use to setup the remote side of the peer connection.
@param password: The password of the admin user.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The updated peer.
@since: API v3 | [
"Update",
"a",
"replication",
"peer",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L320-L343 |
232,718 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.get_peer | def get_peer(self, name, peer_type="REPLICATION"):
"""
Retrieve a replication peer by name.
@param name: The name of the peer.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The peer.
@since: API v3
"""
params = self._get_peer_type_param(peer_type)
return self._get("peers/" + name, ApiCmPeer, params=params, api_version=3) | python | def get_peer(self, name, peer_type="REPLICATION"):
params = self._get_peer_type_param(peer_type)
return self._get("peers/" + name, ApiCmPeer, params=params, api_version=3) | [
"def",
"get_peer",
"(",
"self",
",",
"name",
",",
"peer_type",
"=",
"\"REPLICATION\"",
")",
":",
"params",
"=",
"self",
".",
"_get_peer_type_param",
"(",
"peer_type",
")",
"return",
"self",
".",
"_get",
"(",
"\"peers/\"",
"+",
"name",
",",
"ApiCmPeer",
","... | Retrieve a replication peer by name.
@param name: The name of the peer.
@param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'.
@return: The peer.
@since: API v3 | [
"Retrieve",
"a",
"replication",
"peer",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L354-L364 |
232,719 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.host_install | def host_install(self, user_name, host_names, ssh_port=None, password=None,
private_key=None, passphrase=None, parallel_install_count=None,
cm_repo_url=None, gpg_key_custom_url=None,
java_install_strategy=None, unlimited_jce=None):
"""
Install Cloudera Manager Agent on a set of hosts.
@param user_name: The username used to authenticate with the hosts. Root access
to your hosts is required to install Cloudera packages. The
installer will connect to your hosts via SSH and log in either
directly as root or as another user with password-less sudo
privileges to become root.
@param host_names: List of names of hosts to configure for use with
Cloudera Manager. A host may be specified by a
hostname(FQDN) or an IP address.
@param ssh_port: SSH port. If unset, defaults to 22.
@param password: The password used to authenticate with the hosts. Specify
either this or a private key. For password-less login, use
an empty string as password.
@param private_key: The private key to authenticate with the hosts. Specify
either this or a password.
@param passphrase: The passphrase associated with the private key used to
authenticate with the hosts (optional).
@param parallel_install_count: Number of simultaneous installations.
Defaults to 10. Running a large number of
installations at once can consume large amounts
of network bandwidth and other system resources.
@param cm_repo_url: The Cloudera Manager repository URL to use (optional).
Example for SLES, Redhat or other RPM based distributions:
http://archive-primary.cloudera.com/cm5/redhat/6/x86_64/cm/5/
Example for Ubuntu or other Debian based distributions:
"deb http://archive.cloudera.com/cm5/ubuntu/lucid/amd64/cm/ lucid-cm5 contrib"
@param gpg_key_custom_url: The Cloudera Manager public GPG key (optional).
Example for SLES, Redhat or other RPM based distributions:
http://archive-primary.cloudera.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera
Example for Ubuntu or other Debian based distributions:
http://archive.cloudera.com/debian/archive.key
@param java_install_strategy: Added in v8: Strategy to use for JDK installation. Valid values are 1.
AUTO (default): Cloudera Manager will install the JDK versions that are
required when the "AUTO" option is selected. Cloudera Manager may
overwrite any of the existing JDK installations. 2. NONE: Cloudera
Manager will not install any JDK when "NONE" option is selected. It
should be used if an existing JDK installation has to be used.
@param unlimited_jce: Added in v8: Flag for unlimited strength JCE policy files installation If
unset, defaults to false
@return: Information about the submitted command.
@since: API v6
"""
host_install_args = {}
if user_name:
host_install_args['userName'] = user_name
if host_names:
host_install_args['hostNames'] = host_names
if ssh_port:
host_install_args['sshPort'] = ssh_port
if password:
host_install_args['password'] = password
if private_key:
host_install_args['privateKey'] = private_key
if passphrase:
host_install_args['passphrase'] = passphrase
if parallel_install_count:
host_install_args['parallelInstallCount'] = parallel_install_count
if cm_repo_url:
host_install_args['cmRepoUrl'] = cm_repo_url
if gpg_key_custom_url:
host_install_args['gpgKeyCustomUrl'] = gpg_key_custom_url
if java_install_strategy is not None:
host_install_args['javaInstallStrategy'] = java_install_strategy
if unlimited_jce:
host_install_args['unlimitedJCE'] = unlimited_jce
return self._cmd('hostInstall', data=host_install_args) | python | def host_install(self, user_name, host_names, ssh_port=None, password=None,
private_key=None, passphrase=None, parallel_install_count=None,
cm_repo_url=None, gpg_key_custom_url=None,
java_install_strategy=None, unlimited_jce=None):
host_install_args = {}
if user_name:
host_install_args['userName'] = user_name
if host_names:
host_install_args['hostNames'] = host_names
if ssh_port:
host_install_args['sshPort'] = ssh_port
if password:
host_install_args['password'] = password
if private_key:
host_install_args['privateKey'] = private_key
if passphrase:
host_install_args['passphrase'] = passphrase
if parallel_install_count:
host_install_args['parallelInstallCount'] = parallel_install_count
if cm_repo_url:
host_install_args['cmRepoUrl'] = cm_repo_url
if gpg_key_custom_url:
host_install_args['gpgKeyCustomUrl'] = gpg_key_custom_url
if java_install_strategy is not None:
host_install_args['javaInstallStrategy'] = java_install_strategy
if unlimited_jce:
host_install_args['unlimitedJCE'] = unlimited_jce
return self._cmd('hostInstall', data=host_install_args) | [
"def",
"host_install",
"(",
"self",
",",
"user_name",
",",
"host_names",
",",
"ssh_port",
"=",
"None",
",",
"password",
"=",
"None",
",",
"private_key",
"=",
"None",
",",
"passphrase",
"=",
"None",
",",
"parallel_install_count",
"=",
"None",
",",
"cm_repo_ur... | Install Cloudera Manager Agent on a set of hosts.
@param user_name: The username used to authenticate with the hosts. Root access
to your hosts is required to install Cloudera packages. The
installer will connect to your hosts via SSH and log in either
directly as root or as another user with password-less sudo
privileges to become root.
@param host_names: List of names of hosts to configure for use with
Cloudera Manager. A host may be specified by a
hostname(FQDN) or an IP address.
@param ssh_port: SSH port. If unset, defaults to 22.
@param password: The password used to authenticate with the hosts. Specify
either this or a private key. For password-less login, use
an empty string as password.
@param private_key: The private key to authenticate with the hosts. Specify
either this or a password.
@param passphrase: The passphrase associated with the private key used to
authenticate with the hosts (optional).
@param parallel_install_count: Number of simultaneous installations.
Defaults to 10. Running a large number of
installations at once can consume large amounts
of network bandwidth and other system resources.
@param cm_repo_url: The Cloudera Manager repository URL to use (optional).
Example for SLES, Redhat or other RPM based distributions:
http://archive-primary.cloudera.com/cm5/redhat/6/x86_64/cm/5/
Example for Ubuntu or other Debian based distributions:
"deb http://archive.cloudera.com/cm5/ubuntu/lucid/amd64/cm/ lucid-cm5 contrib"
@param gpg_key_custom_url: The Cloudera Manager public GPG key (optional).
Example for SLES, Redhat or other RPM based distributions:
http://archive-primary.cloudera.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera
Example for Ubuntu or other Debian based distributions:
http://archive.cloudera.com/debian/archive.key
@param java_install_strategy: Added in v8: Strategy to use for JDK installation. Valid values are 1.
AUTO (default): Cloudera Manager will install the JDK versions that are
required when the "AUTO" option is selected. Cloudera Manager may
overwrite any of the existing JDK installations. 2. NONE: Cloudera
Manager will not install any JDK when "NONE" option is selected. It
should be used if an existing JDK installation has to be used.
@param unlimited_jce: Added in v8: Flag for unlimited strength JCE policy files installation If
unset, defaults to false
@return: Information about the submitted command.
@since: API v6 | [
"Install",
"Cloudera",
"Manager",
"Agent",
"on",
"a",
"set",
"of",
"hosts",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L427-L498 |
232,720 | cloudera/cm_api | python/src/cm_api/endpoints/cms.py | ClouderaManager.import_cluster_template | def import_cluster_template(self, api_cluster_template, add_repositories=False):
"""
Create a cluster according to the provided template
@param api_cluster_template: cluster template to import
@param add_repositories: if true the parcels repositories in the cluster template will be added.
@return: Command handing cluster import
@since: API v12
"""
return self._post("importClusterTemplate", ApiCommand, False, api_cluster_template, params=dict(addRepositories=add_repositories), api_version=12) | python | def import_cluster_template(self, api_cluster_template, add_repositories=False):
return self._post("importClusterTemplate", ApiCommand, False, api_cluster_template, params=dict(addRepositories=add_repositories), api_version=12) | [
"def",
"import_cluster_template",
"(",
"self",
",",
"api_cluster_template",
",",
"add_repositories",
"=",
"False",
")",
":",
"return",
"self",
".",
"_post",
"(",
"\"importClusterTemplate\"",
",",
"ApiCommand",
",",
"False",
",",
"api_cluster_template",
",",
"params"... | Create a cluster according to the provided template
@param api_cluster_template: cluster template to import
@param add_repositories: if true the parcels repositories in the cluster template will be added.
@return: Command handing cluster import
@since: API v12 | [
"Create",
"a",
"cluster",
"according",
"to",
"the",
"provided",
"template"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/cms.py#L519-L528 |
232,721 | cloudera/cm_api | python/examples/schema.py | do_get_aliases | def do_get_aliases(name):
"""
Get aliases for given metric name
"""
metric_schemas = MetricSchemas()
aliases = metric_schemas.get_aliases(name)
for alias in aliases:
do_print(alias) | python | def do_get_aliases(name):
metric_schemas = MetricSchemas()
aliases = metric_schemas.get_aliases(name)
for alias in aliases:
do_print(alias) | [
"def",
"do_get_aliases",
"(",
"name",
")",
":",
"metric_schemas",
"=",
"MetricSchemas",
"(",
")",
"aliases",
"=",
"metric_schemas",
".",
"get_aliases",
"(",
"name",
")",
"for",
"alias",
"in",
"aliases",
":",
"do_print",
"(",
"alias",
")"
] | Get aliases for given metric name | [
"Get",
"aliases",
"for",
"given",
"metric",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/examples/schema.py#L99-L106 |
232,722 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | get_supported_types | def get_supported_types(resource_root, category_name):
"""
Lookup all supported types in a category.
@param resource_root: The root Resource object.
@param category_name: The category name
@return: An ApiExternalAcccountType list
"""
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("supportedTypes", category_name,),
ApiExternalAccountType, True) | python | def get_supported_types(resource_root, category_name):
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("supportedTypes", category_name,),
ApiExternalAccountType, True) | [
"def",
"get_supported_types",
"(",
"resource_root",
",",
"category_name",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"EXTERNAL_ACCOUNT_FETCH_PATH",
"%",
"(",
"\"supportedTypes\"",
",",
"category_name",
",",
")",
",",
"ApiExternalAccountType",
... | Lookup all supported types in a category.
@param resource_root: The root Resource object.
@param category_name: The category name
@return: An ApiExternalAcccountType list | [
"Lookup",
"all",
"supported",
"types",
"in",
"a",
"category",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L39-L48 |
232,723 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | get_external_account | def get_external_account(resource_root, name, view=None):
"""
Lookup an external account by name
@param resource_root: The root Resource object.
@param name: Account name
@param view: View
@return: An ApiExternalAccount object
"""
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("account", name,),
ApiExternalAccount, False, params=view and dict(view=view) or None) | python | def get_external_account(resource_root, name, view=None):
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("account", name,),
ApiExternalAccount, False, params=view and dict(view=view) or None) | [
"def",
"get_external_account",
"(",
"resource_root",
",",
"name",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"EXTERNAL_ACCOUNT_FETCH_PATH",
"%",
"(",
"\"account\"",
",",
"name",
",",
")",
",",
"ApiExternalAccou... | Lookup an external account by name
@param resource_root: The root Resource object.
@param name: Account name
@param view: View
@return: An ApiExternalAccount object | [
"Lookup",
"an",
"external",
"account",
"by",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L70-L80 |
232,724 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | get_external_account_by_display_name | def get_external_account_by_display_name(resource_root,
display_name, view=None):
"""
Lookup an external account by display name
@param resource_root: The root Resource object.
@param display_name: Account display name
@param view: View
@return: An ApiExternalAccount object
"""
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("accountByDisplayName", display_name,),
ApiExternalAccount, False, params=view and dict(view=view) or None) | python | def get_external_account_by_display_name(resource_root,
display_name, view=None):
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("accountByDisplayName", display_name,),
ApiExternalAccount, False, params=view and dict(view=view) or None) | [
"def",
"get_external_account_by_display_name",
"(",
"resource_root",
",",
"display_name",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"EXTERNAL_ACCOUNT_FETCH_PATH",
"%",
"(",
"\"accountByDisplayName\"",
",",
"display_na... | Lookup an external account by display name
@param resource_root: The root Resource object.
@param display_name: Account display name
@param view: View
@return: An ApiExternalAccount object | [
"Lookup",
"an",
"external",
"account",
"by",
"display",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L82-L93 |
232,725 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | get_all_external_accounts | def get_all_external_accounts(resource_root, type_name, view=None):
"""
Lookup all external accounts of a particular type, by type name.
@param resource_root: The root Resource object.
@param type_name: Type name
@param view: View
@return: An ApiList of ApiExternalAccount objects matching the specified type
"""
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("type", type_name,),
ApiExternalAccount, True, params=view and dict(view=view) or None) | python | def get_all_external_accounts(resource_root, type_name, view=None):
return call(resource_root.get,
EXTERNAL_ACCOUNT_FETCH_PATH % ("type", type_name,),
ApiExternalAccount, True, params=view and dict(view=view) or None) | [
"def",
"get_all_external_accounts",
"(",
"resource_root",
",",
"type_name",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"EXTERNAL_ACCOUNT_FETCH_PATH",
"%",
"(",
"\"type\"",
",",
"type_name",
",",
")",
",",
"ApiE... | Lookup all external accounts of a particular type, by type name.
@param resource_root: The root Resource object.
@param type_name: Type name
@param view: View
@return: An ApiList of ApiExternalAccount objects matching the specified type | [
"Lookup",
"all",
"external",
"accounts",
"of",
"a",
"particular",
"type",
"by",
"type",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L95-L105 |
232,726 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | update_external_account | def update_external_account(resource_root, account):
"""
Update an external account
@param resource_root: The root Resource object.
@param account: Account to update, account name must be specified.
@return: An ApiExternalAccount object, representing the updated external account
"""
return call(resource_root.put,
EXTERNAL_ACCOUNT_PATH % ("update",),
ApiExternalAccount, False, data=account) | python | def update_external_account(resource_root, account):
return call(resource_root.put,
EXTERNAL_ACCOUNT_PATH % ("update",),
ApiExternalAccount, False, data=account) | [
"def",
"update_external_account",
"(",
"resource_root",
",",
"account",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"put",
",",
"EXTERNAL_ACCOUNT_PATH",
"%",
"(",
"\"update\"",
",",
")",
",",
"ApiExternalAccount",
",",
"False",
",",
"data",
"=",
"ac... | Update an external account
@param resource_root: The root Resource object.
@param account: Account to update, account name must be specified.
@return: An ApiExternalAccount object, representing the updated external account | [
"Update",
"an",
"external",
"account"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L107-L116 |
232,727 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | delete_external_account | def delete_external_account(resource_root, name):
"""
Delete an external account by name
@param resource_root: The root Resource object.
@param name: Account name
@return: The deleted ApiExternalAccount object
"""
return call(resource_root.delete,
EXTERNAL_ACCOUNT_FETCH_PATH % ("delete", name,),
ApiExternalAccount, False) | python | def delete_external_account(resource_root, name):
return call(resource_root.delete,
EXTERNAL_ACCOUNT_FETCH_PATH % ("delete", name,),
ApiExternalAccount, False) | [
"def",
"delete_external_account",
"(",
"resource_root",
",",
"name",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"delete",
",",
"EXTERNAL_ACCOUNT_FETCH_PATH",
"%",
"(",
"\"delete\"",
",",
"name",
",",
")",
",",
"ApiExternalAccount",
",",
"False",
")"
... | Delete an external account by name
@param resource_root: The root Resource object.
@param name: Account name
@return: The deleted ApiExternalAccount object | [
"Delete",
"an",
"external",
"account",
"by",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L118-L127 |
232,728 | cloudera/cm_api | python/src/cm_api/endpoints/external_accounts.py | ApiExternalAccount.external_account_cmd_by_name | def external_account_cmd_by_name(self, command_name):
"""
Executes a command on the external account specified
by name.
@param command_name: The name of the command.
@return: Reference to the submitted command.
@since: API v16
"""
return self._cmd(command_name, data=self.name, api_version=16) | python | def external_account_cmd_by_name(self, command_name):
return self._cmd(command_name, data=self.name, api_version=16) | [
"def",
"external_account_cmd_by_name",
"(",
"self",
",",
"command_name",
")",
":",
"return",
"self",
".",
"_cmd",
"(",
"command_name",
",",
"data",
"=",
"self",
".",
"name",
",",
"api_version",
"=",
"16",
")"
] | Executes a command on the external account specified
by name.
@param command_name: The name of the command.
@return: Reference to the submitted command.
@since: API v16 | [
"Executes",
"a",
"command",
"on",
"the",
"external",
"account",
"specified",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/external_accounts.py#L196-L205 |
232,729 | cloudera/cm_api | python/src/cm_api/endpoints/dashboards.py | create_dashboards | def create_dashboards(resource_root, dashboard_list):
"""
Creates the list of dashboards. If any of the dashboards already exist
this whole command will fail and no dashboards will be created.
@since: API v6
@return: The list of dashboards created.
"""
return call(resource_root.post, DASHBOARDS_PATH, ApiDashboard, \
ret_is_list=True, data=dashboard_list) | python | def create_dashboards(resource_root, dashboard_list):
return call(resource_root.post, DASHBOARDS_PATH, ApiDashboard, \
ret_is_list=True, data=dashboard_list) | [
"def",
"create_dashboards",
"(",
"resource_root",
",",
"dashboard_list",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"post",
",",
"DASHBOARDS_PATH",
",",
"ApiDashboard",
",",
"ret_is_list",
"=",
"True",
",",
"data",
"=",
"dashboard_list",
")"
] | Creates the list of dashboards. If any of the dashboards already exist
this whole command will fail and no dashboards will be created.
@since: API v6
@return: The list of dashboards created. | [
"Creates",
"the",
"list",
"of",
"dashboards",
".",
"If",
"any",
"of",
"the",
"dashboards",
"already",
"exist",
"this",
"whole",
"command",
"will",
"fail",
"and",
"no",
"dashboards",
"will",
"be",
"created",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/dashboards.py#L26-L34 |
232,730 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | create_cluster | def create_cluster(resource_root, name, version=None, fullVersion=None):
"""
Create a cluster
@param resource_root: The root Resource object.
@param name: Cluster name
@param version: Cluster CDH major version (eg: "CDH4")
- The CDH minor version will be assumed to be the
latest released version for CDH4, or 5.0 for CDH5.
@param fullVersion: Cluster's full CDH version. (eg: "5.1.1")
- If specified, 'version' will be ignored.
- Since: v6
@return: An ApiCluster object
"""
if version is None and fullVersion is None:
raise Exception("Either 'version' or 'fullVersion' must be specified")
if fullVersion is not None:
api_version = 6
version = None
else:
api_version = 1
apicluster = ApiCluster(resource_root, name, version, fullVersion)
return call(resource_root.post, CLUSTERS_PATH, ApiCluster, True,
data=[apicluster], api_version=api_version)[0] | python | def create_cluster(resource_root, name, version=None, fullVersion=None):
if version is None and fullVersion is None:
raise Exception("Either 'version' or 'fullVersion' must be specified")
if fullVersion is not None:
api_version = 6
version = None
else:
api_version = 1
apicluster = ApiCluster(resource_root, name, version, fullVersion)
return call(resource_root.post, CLUSTERS_PATH, ApiCluster, True,
data=[apicluster], api_version=api_version)[0] | [
"def",
"create_cluster",
"(",
"resource_root",
",",
"name",
",",
"version",
"=",
"None",
",",
"fullVersion",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
"and",
"fullVersion",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Either 'version' or 'fullV... | Create a cluster
@param resource_root: The root Resource object.
@param name: Cluster name
@param version: Cluster CDH major version (eg: "CDH4")
- The CDH minor version will be assumed to be the
latest released version for CDH4, or 5.0 for CDH5.
@param fullVersion: Cluster's full CDH version. (eg: "5.1.1")
- If specified, 'version' will be ignored.
- Since: v6
@return: An ApiCluster object | [
"Create",
"a",
"cluster"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L25-L48 |
232,731 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | get_all_clusters | def get_all_clusters(resource_root, view=None):
"""
Get all clusters
@param resource_root: The root Resource object.
@return: A list of ApiCluster objects.
"""
return call(resource_root.get, CLUSTERS_PATH, ApiCluster, True,
params=view and dict(view=view) or None) | python | def get_all_clusters(resource_root, view=None):
return call(resource_root.get, CLUSTERS_PATH, ApiCluster, True,
params=view and dict(view=view) or None) | [
"def",
"get_all_clusters",
"(",
"resource_root",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"CLUSTERS_PATH",
",",
"ApiCluster",
",",
"True",
",",
"params",
"=",
"view",
"and",
"dict",
"(",
"view",
"=",
"v... | Get all clusters
@param resource_root: The root Resource object.
@return: A list of ApiCluster objects. | [
"Get",
"all",
"clusters"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L59-L66 |
232,732 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster._put_cluster | def _put_cluster(self, dic, params=None):
"""Change cluster attributes"""
cluster = self._put('', ApiCluster, data=dic, params=params)
self._update(cluster)
return self | python | def _put_cluster(self, dic, params=None):
cluster = self._put('', ApiCluster, data=dic, params=params)
self._update(cluster)
return self | [
"def",
"_put_cluster",
"(",
"self",
",",
"dic",
",",
"params",
"=",
"None",
")",
":",
"cluster",
"=",
"self",
".",
"_put",
"(",
"''",
",",
"ApiCluster",
",",
"data",
"=",
"dic",
",",
"params",
"=",
"params",
")",
"self",
".",
"_update",
"(",
"clust... | Change cluster attributes | [
"Change",
"cluster",
"attributes"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L100-L104 |
232,733 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.get_service_types | def get_service_types(self):
"""
Get all service types supported by this cluster.
@return: A list of service types (strings)
"""
resp = self._get_resource_root().get(self._path() + '/serviceTypes')
return resp[ApiList.LIST_KEY] | python | def get_service_types(self):
resp = self._get_resource_root().get(self._path() + '/serviceTypes')
return resp[ApiList.LIST_KEY] | [
"def",
"get_service_types",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"get",
"(",
"self",
".",
"_path",
"(",
")",
"+",
"'/serviceTypes'",
")",
"return",
"resp",
"[",
"ApiList",
".",
"LIST_KEY",
"]"
] | Get all service types supported by this cluster.
@return: A list of service types (strings) | [
"Get",
"all",
"service",
"types",
"supported",
"by",
"this",
"cluster",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L106-L113 |
232,734 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.rename | def rename(self, newname):
"""
Rename a cluster.
@param newname: New cluster name
@return: An ApiCluster object
@since: API v2
"""
dic = self.to_json_dict()
if self._get_resource_root().version < 6:
dic['name'] = newname
else:
dic['displayName'] = newname
return self._put_cluster(dic) | python | def rename(self, newname):
dic = self.to_json_dict()
if self._get_resource_root().version < 6:
dic['name'] = newname
else:
dic['displayName'] = newname
return self._put_cluster(dic) | [
"def",
"rename",
"(",
"self",
",",
"newname",
")",
":",
"dic",
"=",
"self",
".",
"to_json_dict",
"(",
")",
"if",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"version",
"<",
"6",
":",
"dic",
"[",
"'name'",
"]",
"=",
"newname",
"else",
":",
"di... | Rename a cluster.
@param newname: New cluster name
@return: An ApiCluster object
@since: API v2 | [
"Rename",
"a",
"cluster",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L125-L138 |
232,735 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.update_cdh_version | def update_cdh_version(self, new_cdh_version):
"""
Manually set the CDH version.
@param new_cdh_version: New CDH version, e.g. 4.5.1
@return: An ApiCluster object
@since: API v6
"""
dic = self.to_json_dict()
dic['fullVersion'] = new_cdh_version
return self._put_cluster(dic) | python | def update_cdh_version(self, new_cdh_version):
dic = self.to_json_dict()
dic['fullVersion'] = new_cdh_version
return self._put_cluster(dic) | [
"def",
"update_cdh_version",
"(",
"self",
",",
"new_cdh_version",
")",
":",
"dic",
"=",
"self",
".",
"to_json_dict",
"(",
")",
"dic",
"[",
"'fullVersion'",
"]",
"=",
"new_cdh_version",
"return",
"self",
".",
"_put_cluster",
"(",
"dic",
")"
] | Manually set the CDH version.
@param new_cdh_version: New CDH version, e.g. 4.5.1
@return: An ApiCluster object
@since: API v6 | [
"Manually",
"set",
"the",
"CDH",
"version",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L140-L150 |
232,736 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.delete_service | def delete_service(self, name):
"""
Delete a service by name.
@param name: Service name
@return: The deleted ApiService object
"""
return services.delete_service(self._get_resource_root(), name, self.name) | python | def delete_service(self, name):
return services.delete_service(self._get_resource_root(), name, self.name) | [
"def",
"delete_service",
"(",
"self",
",",
"name",
")",
":",
"return",
"services",
".",
"delete_service",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"name",
",",
"self",
".",
"name",
")"
] | Delete a service by name.
@param name: Service name
@return: The deleted ApiService object | [
"Delete",
"a",
"service",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L163-L170 |
232,737 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.get_service | def get_service(self, name):
"""
Lookup a service by name.
@param name: Service name
@return: An ApiService object
"""
return services.get_service(self._get_resource_root(), name, self.name) | python | def get_service(self, name):
return services.get_service(self._get_resource_root(), name, self.name) | [
"def",
"get_service",
"(",
"self",
",",
"name",
")",
":",
"return",
"services",
".",
"get_service",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"name",
",",
"self",
".",
"name",
")"
] | Lookup a service by name.
@param name: Service name
@return: An ApiService object | [
"Lookup",
"a",
"service",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L172-L179 |
232,738 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.get_all_services | def get_all_services(self, view = None):
"""
Get all services in this cluster.
@return: A list of ApiService objects.
"""
return services.get_all_services(self._get_resource_root(), self.name, view) | python | def get_all_services(self, view = None):
return services.get_all_services(self._get_resource_root(), self.name, view) | [
"def",
"get_all_services",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"return",
"services",
".",
"get_all_services",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"view",
")"
] | Get all services in this cluster.
@return: A list of ApiService objects. | [
"Get",
"all",
"services",
"in",
"this",
"cluster",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L181-L187 |
232,739 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.get_parcel | def get_parcel(self, product, version):
"""
Lookup a parcel by product and version.
@param product: the product name
@param version: the product version
@return: An ApiParcel object
"""
return parcels.get_parcel(self._get_resource_root(), product, version, self.name) | python | def get_parcel(self, product, version):
return parcels.get_parcel(self._get_resource_root(), product, version, self.name) | [
"def",
"get_parcel",
"(",
"self",
",",
"product",
",",
"version",
")",
":",
"return",
"parcels",
".",
"get_parcel",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"product",
",",
"version",
",",
"self",
".",
"name",
")"
] | Lookup a parcel by product and version.
@param product: the product name
@param version: the product version
@return: An ApiParcel object | [
"Lookup",
"a",
"parcel",
"by",
"product",
"and",
"version",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L189-L197 |
232,740 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.get_all_parcels | def get_all_parcels(self, view = None):
"""
Get all parcels in this cluster.
@return: A list of ApiParcel objects.
"""
return parcels.get_all_parcels(self._get_resource_root(), self.name, view) | python | def get_all_parcels(self, view = None):
return parcels.get_all_parcels(self._get_resource_root(), self.name, view) | [
"def",
"get_all_parcels",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"return",
"parcels",
".",
"get_all_parcels",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"view",
")"
] | Get all parcels in this cluster.
@return: A list of ApiParcel objects. | [
"Get",
"all",
"parcels",
"in",
"this",
"cluster",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L199-L205 |
232,741 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.add_hosts | def add_hosts(self, hostIds):
"""
Adds a host to the cluster.
@param hostIds: List of IDs of hosts to add to cluster.
@return: A list of ApiHostRef objects of the new
hosts that were added to the cluster
@since: API v3
"""
hostRefList = [ApiHostRef(self._get_resource_root(), x) for x in hostIds]
return self._post("hosts", ApiHostRef, True, data=hostRefList,
api_version=3) | python | def add_hosts(self, hostIds):
hostRefList = [ApiHostRef(self._get_resource_root(), x) for x in hostIds]
return self._post("hosts", ApiHostRef, True, data=hostRefList,
api_version=3) | [
"def",
"add_hosts",
"(",
"self",
",",
"hostIds",
")",
":",
"hostRefList",
"=",
"[",
"ApiHostRef",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"x",
")",
"for",
"x",
"in",
"hostIds",
"]",
"return",
"self",
".",
"_post",
"(",
"\"hosts\"",
",",
... | Adds a host to the cluster.
@param hostIds: List of IDs of hosts to add to cluster.
@return: A list of ApiHostRef objects of the new
hosts that were added to the cluster
@since: API v3 | [
"Adds",
"a",
"host",
"to",
"the",
"cluster",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L234-L245 |
232,742 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.restart | def restart(self, restart_only_stale_services=None,
redeploy_client_configuration=None,
restart_service_names=None):
"""
Restart all services in the cluster.
Services are restarted in the appropriate order given their dependencies.
@param restart_only_stale_services: Only restart services that have stale
configuration and their dependent
services. Default is False.
@param redeploy_client_configuration: Re-deploy client configuration for
all services in the cluster. Default
is False.
@param restart_service_names: Only restart services that are specified and their dependent services.
Available since API v11.
@since API v6
@return: Reference to the submitted command.
"""
if self._get_resource_root().version < 6:
return self._cmd('restart')
else:
args = dict()
args['restartOnlyStaleServices'] = restart_only_stale_services
args['redeployClientConfiguration'] = redeploy_client_configuration
if self._get_resource_root().version >= 11:
args['restartServiceNames'] = restart_service_names
return self._cmd('restart', data=args, api_version=6) | python | def restart(self, restart_only_stale_services=None,
redeploy_client_configuration=None,
restart_service_names=None):
if self._get_resource_root().version < 6:
return self._cmd('restart')
else:
args = dict()
args['restartOnlyStaleServices'] = restart_only_stale_services
args['redeployClientConfiguration'] = redeploy_client_configuration
if self._get_resource_root().version >= 11:
args['restartServiceNames'] = restart_service_names
return self._cmd('restart', data=args, api_version=6) | [
"def",
"restart",
"(",
"self",
",",
"restart_only_stale_services",
"=",
"None",
",",
"redeploy_client_configuration",
"=",
"None",
",",
"restart_service_names",
"=",
"None",
")",
":",
"if",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"version",
"<",
"6",
... | Restart all services in the cluster.
Services are restarted in the appropriate order given their dependencies.
@param restart_only_stale_services: Only restart services that have stale
configuration and their dependent
services. Default is False.
@param redeploy_client_configuration: Re-deploy client configuration for
all services in the cluster. Default
is False.
@param restart_service_names: Only restart services that are specified and their dependent services.
Available since API v11.
@since API v6
@return: Reference to the submitted command. | [
"Restart",
"all",
"services",
"in",
"the",
"cluster",
".",
"Services",
"are",
"restarted",
"in",
"the",
"appropriate",
"order",
"given",
"their",
"dependencies",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L263-L290 |
232,743 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.enter_maintenance_mode | def enter_maintenance_mode(self):
"""
Put the cluster in maintenance mode.
@return: Reference to the completed command.
@since: API v2
"""
cmd = self._cmd('enterMaintenanceMode')
if cmd.success:
self._update(get_cluster(self._get_resource_root(), self.name))
return cmd | python | def enter_maintenance_mode(self):
cmd = self._cmd('enterMaintenanceMode')
if cmd.success:
self._update(get_cluster(self._get_resource_root(), self.name))
return cmd | [
"def",
"enter_maintenance_mode",
"(",
"self",
")",
":",
"cmd",
"=",
"self",
".",
"_cmd",
"(",
"'enterMaintenanceMode'",
")",
"if",
"cmd",
".",
"success",
":",
"self",
".",
"_update",
"(",
"get_cluster",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
","... | Put the cluster in maintenance mode.
@return: Reference to the completed command.
@since: API v2 | [
"Put",
"the",
"cluster",
"in",
"maintenance",
"mode",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L340-L350 |
232,744 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.get_host_template | def get_host_template(self, name):
"""
Retrieves a host templates by name.
@param name: Host template name.
@return: An ApiHostTemplate object.
"""
return host_templates.get_host_template(self._get_resource_root(), name, self.name) | python | def get_host_template(self, name):
return host_templates.get_host_template(self._get_resource_root(), name, self.name) | [
"def",
"get_host_template",
"(",
"self",
",",
"name",
")",
":",
"return",
"host_templates",
".",
"get_host_template",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"name",
",",
"self",
".",
"name",
")"
] | Retrieves a host templates by name.
@param name: Host template name.
@return: An ApiHostTemplate object. | [
"Retrieves",
"a",
"host",
"templates",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L371-L377 |
232,745 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.create_host_template | def create_host_template(self, name):
"""
Creates a host template.
@param name: Name of the host template to create.
@return: An ApiHostTemplate object.
"""
return host_templates.create_host_template(self._get_resource_root(), name, self.name) | python | def create_host_template(self, name):
return host_templates.create_host_template(self._get_resource_root(), name, self.name) | [
"def",
"create_host_template",
"(",
"self",
",",
"name",
")",
":",
"return",
"host_templates",
".",
"create_host_template",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"name",
",",
"self",
".",
"name",
")"
] | Creates a host template.
@param name: Name of the host template to create.
@return: An ApiHostTemplate object. | [
"Creates",
"a",
"host",
"template",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L379-L385 |
232,746 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.delete_host_template | def delete_host_template(self, name):
"""
Deletes a host template.
@param name: Name of the host template to delete.
@return: An ApiHostTemplate object.
"""
return host_templates.delete_host_template(self._get_resource_root(), name, self.name) | python | def delete_host_template(self, name):
return host_templates.delete_host_template(self._get_resource_root(), name, self.name) | [
"def",
"delete_host_template",
"(",
"self",
",",
"name",
")",
":",
"return",
"host_templates",
".",
"delete_host_template",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"name",
",",
"self",
".",
"name",
")"
] | Deletes a host template.
@param name: Name of the host template to delete.
@return: An ApiHostTemplate object. | [
"Deletes",
"a",
"host",
"template",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L387-L393 |
232,747 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.rolling_restart | def rolling_restart(self, slave_batch_size=None,
slave_fail_count_threshold=None,
sleep_seconds=None,
stale_configs_only=None,
unupgraded_only=None,
roles_to_include=None,
restart_service_names=None):
"""
Command to do a "best-effort" rolling restart of the given cluster,
i.e. it does plain restart of services that cannot be rolling restarted,
followed by first rolling restarting non-slaves and then rolling restarting
the slave roles of services that can be rolling restarted. The slave restarts
are done host-by-host.
@param slave_batch_size: Number of hosts with slave roles to restart at a time
Must be greater than 0. Default is 1.
@param slave_fail_count_threshold: The threshold for number of slave host batches that
are allowed to fail to restart before the entire command is considered failed.
Must be >= 0. Default is 0.
@param sleep_seconds: Number of seconds to sleep between restarts of slave host batches.
Must be >=0. Default is 0.
@param stale_configs_only: Restart roles with stale configs only. Default is false.
@param unupgraded_only: Restart roles that haven't been upgraded yet. Default is false.
@param roles_to_include: Role types to restart. Default is slave roles only.
@param restart_service_names: List of specific services to restart.
@return: Reference to the submitted command.
@since: API v4
"""
args = dict()
if slave_batch_size:
args['slaveBatchSize'] = slave_batch_size
if slave_fail_count_threshold:
args['slaveFailCountThreshold'] = slave_fail_count_threshold
if sleep_seconds:
args['sleepSeconds'] = sleep_seconds
if stale_configs_only:
args['staleConfigsOnly'] = stale_configs_only
if unupgraded_only:
args['unUpgradedOnly'] = unupgraded_only
if roles_to_include:
args['rolesToInclude'] = roles_to_include
if restart_service_names:
args['restartServiceNames'] = restart_service_names
return self._cmd('rollingRestart', data=args, api_version=4) | python | def rolling_restart(self, slave_batch_size=None,
slave_fail_count_threshold=None,
sleep_seconds=None,
stale_configs_only=None,
unupgraded_only=None,
roles_to_include=None,
restart_service_names=None):
args = dict()
if slave_batch_size:
args['slaveBatchSize'] = slave_batch_size
if slave_fail_count_threshold:
args['slaveFailCountThreshold'] = slave_fail_count_threshold
if sleep_seconds:
args['sleepSeconds'] = sleep_seconds
if stale_configs_only:
args['staleConfigsOnly'] = stale_configs_only
if unupgraded_only:
args['unUpgradedOnly'] = unupgraded_only
if roles_to_include:
args['rolesToInclude'] = roles_to_include
if restart_service_names:
args['restartServiceNames'] = restart_service_names
return self._cmd('rollingRestart', data=args, api_version=4) | [
"def",
"rolling_restart",
"(",
"self",
",",
"slave_batch_size",
"=",
"None",
",",
"slave_fail_count_threshold",
"=",
"None",
",",
"sleep_seconds",
"=",
"None",
",",
"stale_configs_only",
"=",
"None",
",",
"unupgraded_only",
"=",
"None",
",",
"roles_to_include",
"=... | Command to do a "best-effort" rolling restart of the given cluster,
i.e. it does plain restart of services that cannot be rolling restarted,
followed by first rolling restarting non-slaves and then rolling restarting
the slave roles of services that can be rolling restarted. The slave restarts
are done host-by-host.
@param slave_batch_size: Number of hosts with slave roles to restart at a time
Must be greater than 0. Default is 1.
@param slave_fail_count_threshold: The threshold for number of slave host batches that
are allowed to fail to restart before the entire command is considered failed.
Must be >= 0. Default is 0.
@param sleep_seconds: Number of seconds to sleep between restarts of slave host batches.
Must be >=0. Default is 0.
@param stale_configs_only: Restart roles with stale configs only. Default is false.
@param unupgraded_only: Restart roles that haven't been upgraded yet. Default is false.
@param roles_to_include: Role types to restart. Default is slave roles only.
@param restart_service_names: List of specific services to restart.
@return: Reference to the submitted command.
@since: API v4 | [
"Command",
"to",
"do",
"a",
"best",
"-",
"effort",
"rolling",
"restart",
"of",
"the",
"given",
"cluster",
"i",
".",
"e",
".",
"it",
"does",
"plain",
"restart",
"of",
"services",
"that",
"cannot",
"be",
"rolling",
"restarted",
"followed",
"by",
"first",
"... | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L395-L438 |
232,748 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.rolling_upgrade | def rolling_upgrade(self, upgrade_from_cdh_version,
upgrade_to_cdh_version,
upgrade_service_names,
slave_batch_size=None,
slave_fail_count_threshold=None,
sleep_seconds=None):
"""
Command to do a rolling upgrade of services in the given cluster
This command does not handle any services that don't support rolling
upgrades. The command will throw an error and not start if upgrade of
any such service is requested.
This command does not upgrade the full CDH Cluster. You should normally
use the upgradeCDH Command for upgrading the cluster. This is primarily
helpful if you need to need to recover from an upgrade failure or for
advanced users to script an alternative to the upgradeCdhCommand.
This command expects the binaries to be available on hosts and activated.
It does not change any binaries on the hosts.
@param upgrade_from_cdh_version: Current CDH Version of the services.
Example versions are: "5.1.0", "5.2.2" or "5.4.0"
@param upgrade_to_cdh_version: Target CDH Version for the services.
The CDH version should already be present and activated on the nodes.
Example versions are: "5.1.0", "5.2.2" or "5.4.0"
@param upgrade_service_names: List of specific services to be upgraded and restarted.
@param slave_batch_size: Number of hosts with slave roles to restart at a time
Must be greater than 0. Default is 1.
@param slave_fail_count_threshold: The threshold for number of slave host batches that
are allowed to fail to restart before the entire command is considered failed.
Must be >= 0. Default is 0.
@param sleep_seconds: Number of seconds to sleep between restarts of slave host batches.
Must be >=0. Default is 0.
@return: Reference to the submitted command.
@since: API v10
"""
args = dict()
args['upgradeFromCdhVersion'] = upgrade_from_cdh_version
args['upgradeToCdhVersion'] = upgrade_to_cdh_version
args['upgradeServiceNames'] = upgrade_service_names
if slave_batch_size:
args['slaveBatchSize'] = slave_batch_size
if slave_fail_count_threshold:
args['slaveFailCountThreshold'] = slave_fail_count_threshold
if sleep_seconds:
args['sleepSeconds'] = sleep_seconds
return self._cmd('rollingUpgrade', data=args, api_version=10) | python | def rolling_upgrade(self, upgrade_from_cdh_version,
upgrade_to_cdh_version,
upgrade_service_names,
slave_batch_size=None,
slave_fail_count_threshold=None,
sleep_seconds=None):
args = dict()
args['upgradeFromCdhVersion'] = upgrade_from_cdh_version
args['upgradeToCdhVersion'] = upgrade_to_cdh_version
args['upgradeServiceNames'] = upgrade_service_names
if slave_batch_size:
args['slaveBatchSize'] = slave_batch_size
if slave_fail_count_threshold:
args['slaveFailCountThreshold'] = slave_fail_count_threshold
if sleep_seconds:
args['sleepSeconds'] = sleep_seconds
return self._cmd('rollingUpgrade', data=args, api_version=10) | [
"def",
"rolling_upgrade",
"(",
"self",
",",
"upgrade_from_cdh_version",
",",
"upgrade_to_cdh_version",
",",
"upgrade_service_names",
",",
"slave_batch_size",
"=",
"None",
",",
"slave_fail_count_threshold",
"=",
"None",
",",
"sleep_seconds",
"=",
"None",
")",
":",
"arg... | Command to do a rolling upgrade of services in the given cluster
This command does not handle any services that don't support rolling
upgrades. The command will throw an error and not start if upgrade of
any such service is requested.
This command does not upgrade the full CDH Cluster. You should normally
use the upgradeCDH Command for upgrading the cluster. This is primarily
helpful if you need to need to recover from an upgrade failure or for
advanced users to script an alternative to the upgradeCdhCommand.
This command expects the binaries to be available on hosts and activated.
It does not change any binaries on the hosts.
@param upgrade_from_cdh_version: Current CDH Version of the services.
Example versions are: "5.1.0", "5.2.2" or "5.4.0"
@param upgrade_to_cdh_version: Target CDH Version for the services.
The CDH version should already be present and activated on the nodes.
Example versions are: "5.1.0", "5.2.2" or "5.4.0"
@param upgrade_service_names: List of specific services to be upgraded and restarted.
@param slave_batch_size: Number of hosts with slave roles to restart at a time
Must be greater than 0. Default is 1.
@param slave_fail_count_threshold: The threshold for number of slave host batches that
are allowed to fail to restart before the entire command is considered failed.
Must be >= 0. Default is 0.
@param sleep_seconds: Number of seconds to sleep between restarts of slave host batches.
Must be >=0. Default is 0.
@return: Reference to the submitted command.
@since: API v10 | [
"Command",
"to",
"do",
"a",
"rolling",
"upgrade",
"of",
"services",
"in",
"the",
"given",
"cluster"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L440-L490 |
232,749 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.configure_for_kerberos | def configure_for_kerberos(self, datanode_transceiver_port=None,
datanode_web_port=None):
"""
Command to configure the cluster to use Kerberos for authentication.
This command will configure all relevant services on a cluster for
Kerberos usage. This command will trigger a GenerateCredentials command
to create Kerberos keytabs for all roles in the cluster.
@param datanode_transceiver_port: The HDFS DataNode transceiver port to use.
This will be applied to all DataNode role configuration groups. If
not specified, this will default to 1004.
@param datanode_web_port: The HDFS DataNode web port to use. This will be
applied to all DataNode role configuration groups. If not specified,
this will default to 1006.
@return: Reference to the submitted command.
@since: API v11
"""
args = dict()
if datanode_transceiver_port:
args['datanodeTransceiverPort'] = datanode_transceiver_port
if datanode_web_port:
args['datanodeWebPort'] = datanode_web_port
return self._cmd('configureForKerberos', data=args, api_version=11) | python | def configure_for_kerberos(self, datanode_transceiver_port=None,
datanode_web_port=None):
args = dict()
if datanode_transceiver_port:
args['datanodeTransceiverPort'] = datanode_transceiver_port
if datanode_web_port:
args['datanodeWebPort'] = datanode_web_port
return self._cmd('configureForKerberos', data=args, api_version=11) | [
"def",
"configure_for_kerberos",
"(",
"self",
",",
"datanode_transceiver_port",
"=",
"None",
",",
"datanode_web_port",
"=",
"None",
")",
":",
"args",
"=",
"dict",
"(",
")",
"if",
"datanode_transceiver_port",
":",
"args",
"[",
"'datanodeTransceiverPort'",
"]",
"=",... | Command to configure the cluster to use Kerberos for authentication.
This command will configure all relevant services on a cluster for
Kerberos usage. This command will trigger a GenerateCredentials command
to create Kerberos keytabs for all roles in the cluster.
@param datanode_transceiver_port: The HDFS DataNode transceiver port to use.
This will be applied to all DataNode role configuration groups. If
not specified, this will default to 1004.
@param datanode_web_port: The HDFS DataNode web port to use. This will be
applied to all DataNode role configuration groups. If not specified,
this will default to 1006.
@return: Reference to the submitted command.
@since: API v11 | [
"Command",
"to",
"configure",
"the",
"cluster",
"to",
"use",
"Kerberos",
"for",
"authentication",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L586-L609 |
232,750 | cloudera/cm_api | python/src/cm_api/endpoints/clusters.py | ApiCluster.export | def export(self, export_auto_config=False):
"""
Export the cluster template for the given cluster. ccluster must have host
templates defined. It cluster does not have host templates defined it will
export host templates based on roles assignment.
@param export_auto_config: Also export auto configured configs
@return: Return cluster template
@since: API v12
"""
return self._get("export", ApiClusterTemplate, False,
params=dict(exportAutoConfig=export_auto_config), api_version=12) | python | def export(self, export_auto_config=False):
return self._get("export", ApiClusterTemplate, False,
params=dict(exportAutoConfig=export_auto_config), api_version=12) | [
"def",
"export",
"(",
"self",
",",
"export_auto_config",
"=",
"False",
")",
":",
"return",
"self",
".",
"_get",
"(",
"\"export\"",
",",
"ApiClusterTemplate",
",",
"False",
",",
"params",
"=",
"dict",
"(",
"exportAutoConfig",
"=",
"export_auto_config",
")",
"... | Export the cluster template for the given cluster. ccluster must have host
templates defined. It cluster does not have host templates defined it will
export host templates based on roles assignment.
@param export_auto_config: Also export auto configured configs
@return: Return cluster template
@since: API v12 | [
"Export",
"the",
"cluster",
"template",
"for",
"the",
"given",
"cluster",
".",
"ccluster",
"must",
"have",
"host",
"templates",
"defined",
".",
"It",
"cluster",
"does",
"not",
"have",
"host",
"templates",
"defined",
"it",
"will",
"export",
"host",
"templates",... | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/clusters.py#L611-L623 |
232,751 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | check_api_version | def check_api_version(resource_root, min_version):
"""
Checks if the resource_root's API version it at least the given minimum
version.
"""
if resource_root.version < min_version:
raise Exception("API version %s is required but %s is in use."
% (min_version, resource_root.version)) | python | def check_api_version(resource_root, min_version):
if resource_root.version < min_version:
raise Exception("API version %s is required but %s is in use."
% (min_version, resource_root.version)) | [
"def",
"check_api_version",
"(",
"resource_root",
",",
"min_version",
")",
":",
"if",
"resource_root",
".",
"version",
"<",
"min_version",
":",
"raise",
"Exception",
"(",
"\"API version %s is required but %s is in use.\"",
"%",
"(",
"min_version",
",",
"resource_root",
... | Checks if the resource_root's API version it at least the given minimum
version. | [
"Checks",
"if",
"the",
"resource_root",
"s",
"API",
"version",
"it",
"at",
"least",
"the",
"given",
"minimum",
"version",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L109-L116 |
232,752 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | call | def call(method, path, ret_type,
ret_is_list=False, data=None, params=None, api_version=1):
"""
Generic function for calling a resource method and automatically dealing with
serialization of parameters and deserialization of return values.
@param method: method to call (must be bound to a resource;
e.g., "resource_root.get").
@param path: the full path of the API method to call.
@param ret_type: return type of the call.
@param ret_is_list: whether the return type is an ApiList.
@param data: Optional data to send as payload to the call.
@param params: Optional query parameters for the call.
@param api_version: minimum API version for the call.
"""
check_api_version(method.im_self, api_version)
if data is not None:
data = json.dumps(Attr(is_api_list=True).to_json(data, False))
ret = method(path, data=data, params=params)
else:
ret = method(path, params=params)
if ret_type is None:
return
elif ret_is_list:
return ApiList.from_json_dict(ret, method.im_self, ret_type)
elif isinstance(ret, list):
return [ ret_type.from_json_dict(x, method.im_self) for x in ret ]
else:
return ret_type.from_json_dict(ret, method.im_self) | python | def call(method, path, ret_type,
ret_is_list=False, data=None, params=None, api_version=1):
check_api_version(method.im_self, api_version)
if data is not None:
data = json.dumps(Attr(is_api_list=True).to_json(data, False))
ret = method(path, data=data, params=params)
else:
ret = method(path, params=params)
if ret_type is None:
return
elif ret_is_list:
return ApiList.from_json_dict(ret, method.im_self, ret_type)
elif isinstance(ret, list):
return [ ret_type.from_json_dict(x, method.im_self) for x in ret ]
else:
return ret_type.from_json_dict(ret, method.im_self) | [
"def",
"call",
"(",
"method",
",",
"path",
",",
"ret_type",
",",
"ret_is_list",
"=",
"False",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
",",
"api_version",
"=",
"1",
")",
":",
"check_api_version",
"(",
"method",
".",
"im_self",
",",
"api_ve... | Generic function for calling a resource method and automatically dealing with
serialization of parameters and deserialization of return values.
@param method: method to call (must be bound to a resource;
e.g., "resource_root.get").
@param path: the full path of the API method to call.
@param ret_type: return type of the call.
@param ret_is_list: whether the return type is an ApiList.
@param data: Optional data to send as payload to the call.
@param params: Optional query parameters for the call.
@param api_version: minimum API version for the call. | [
"Generic",
"function",
"for",
"calling",
"a",
"resource",
"method",
"and",
"automatically",
"dealing",
"with",
"serialization",
"of",
"parameters",
"and",
"deserialization",
"of",
"return",
"values",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L119-L147 |
232,753 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | config_to_api_list | def config_to_api_list(dic):
"""
Converts a python dictionary into a list containing the proper
ApiConfig encoding for configuration data.
@param dic: Key-value pairs to convert.
@return: JSON dictionary of an ApiConfig list (*not* an ApiList).
"""
config = [ ]
for k, v in dic.iteritems():
config.append({ 'name' : k, 'value': v })
return { ApiList.LIST_KEY : config } | python | def config_to_api_list(dic):
config = [ ]
for k, v in dic.iteritems():
config.append({ 'name' : k, 'value': v })
return { ApiList.LIST_KEY : config } | [
"def",
"config_to_api_list",
"(",
"dic",
")",
":",
"config",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"dic",
".",
"iteritems",
"(",
")",
":",
"config",
".",
"append",
"(",
"{",
"'name'",
":",
"k",
",",
"'value'",
":",
"v",
"}",
")",
"return",
... | Converts a python dictionary into a list containing the proper
ApiConfig encoding for configuration data.
@param dic: Key-value pairs to convert.
@return: JSON dictionary of an ApiConfig list (*not* an ApiList). | [
"Converts",
"a",
"python",
"dictionary",
"into",
"a",
"list",
"containing",
"the",
"proper",
"ApiConfig",
"encoding",
"for",
"configuration",
"data",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L1285-L1296 |
232,754 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | json_to_config | def json_to_config(dic, full = False):
"""
Converts a JSON-decoded config dictionary to a python dictionary.
When materializing the full view, the values in the dictionary will be
instances of ApiConfig, instead of strings.
@param dic: JSON-decoded config dictionary.
@param full: Whether to materialize the full view of the config data.
@return: Python dictionary with config data.
"""
config = { }
for entry in dic['items']:
k = entry['name']
if full:
config[k] = ApiConfig.from_json_dict(entry, None)
else:
config[k] = entry.get('value')
return config | python | def json_to_config(dic, full = False):
config = { }
for entry in dic['items']:
k = entry['name']
if full:
config[k] = ApiConfig.from_json_dict(entry, None)
else:
config[k] = entry.get('value')
return config | [
"def",
"json_to_config",
"(",
"dic",
",",
"full",
"=",
"False",
")",
":",
"config",
"=",
"{",
"}",
"for",
"entry",
"in",
"dic",
"[",
"'items'",
"]",
":",
"k",
"=",
"entry",
"[",
"'name'",
"]",
"if",
"full",
":",
"config",
"[",
"k",
"]",
"=",
"A... | Converts a JSON-decoded config dictionary to a python dictionary.
When materializing the full view, the values in the dictionary will be
instances of ApiConfig, instead of strings.
@param dic: JSON-decoded config dictionary.
@param full: Whether to materialize the full view of the config data.
@return: Python dictionary with config data. | [
"Converts",
"a",
"JSON",
"-",
"decoded",
"config",
"dictionary",
"to",
"a",
"python",
"dictionary",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L1310-L1328 |
232,755 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | Attr.to_json | def to_json(self, value, preserve_ro):
"""
Returns the JSON encoding of the given attribute value.
If the value has a 'to_json_dict' object, that method is called. Otherwise,
the following values are returned for each input type:
- datetime.datetime: string with the API representation of a date.
- dictionary: if 'atype' is ApiConfig, a list of ApiConfig objects.
- python list: python list (or ApiList) with JSON encoding of items
- the raw value otherwise
"""
if hasattr(value, 'to_json_dict'):
return value.to_json_dict(preserve_ro)
elif isinstance(value, dict) and self._atype == ApiConfig:
return config_to_api_list(value)
elif isinstance(value, datetime.datetime):
return value.strftime(self.DATE_FMT)
elif isinstance(value, list) or isinstance(value, tuple):
if self._is_api_list:
return ApiList(value).to_json_dict()
else:
return [ self.to_json(x, preserve_ro) for x in value ]
else:
return value | python | def to_json(self, value, preserve_ro):
if hasattr(value, 'to_json_dict'):
return value.to_json_dict(preserve_ro)
elif isinstance(value, dict) and self._atype == ApiConfig:
return config_to_api_list(value)
elif isinstance(value, datetime.datetime):
return value.strftime(self.DATE_FMT)
elif isinstance(value, list) or isinstance(value, tuple):
if self._is_api_list:
return ApiList(value).to_json_dict()
else:
return [ self.to_json(x, preserve_ro) for x in value ]
else:
return value | [
"def",
"to_json",
"(",
"self",
",",
"value",
",",
"preserve_ro",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'to_json_dict'",
")",
":",
"return",
"value",
".",
"to_json_dict",
"(",
"preserve_ro",
")",
"elif",
"isinstance",
"(",
"value",
",",
"dict",
"... | Returns the JSON encoding of the given attribute value.
If the value has a 'to_json_dict' object, that method is called. Otherwise,
the following values are returned for each input type:
- datetime.datetime: string with the API representation of a date.
- dictionary: if 'atype' is ApiConfig, a list of ApiConfig objects.
- python list: python list (or ApiList) with JSON encoding of items
- the raw value otherwise | [
"Returns",
"the",
"JSON",
"encoding",
"of",
"the",
"given",
"attribute",
"value",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L41-L64 |
232,756 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | Attr.from_json | def from_json(self, resource_root, data):
"""
Parses the given JSON value into an appropriate python object.
This means:
- a datetime.datetime if 'atype' is datetime.datetime
- a converted config dictionary or config list if 'atype' is ApiConfig
- if the attr is an API list, an ApiList with instances of 'atype'
- an instance of 'atype' if it has a 'from_json_dict' method
- a python list with decoded versions of the member objects if the input
is a python list.
- the raw value otherwise
"""
if data is None:
return None
if self._atype == datetime.datetime:
return datetime.datetime.strptime(data, self.DATE_FMT)
elif self._atype == ApiConfig:
# ApiConfig is special. We want a python dictionary for summary views,
# but an ApiList for full views. Try to detect each case from the JSON
# data.
if not data['items']:
return { }
first = data['items'][0]
return json_to_config(data, len(first) == 2)
elif self._is_api_list:
return ApiList.from_json_dict(data, resource_root, self._atype)
elif isinstance(data, list):
return [ self.from_json(resource_root, x) for x in data ]
elif hasattr(self._atype, 'from_json_dict'):
return self._atype.from_json_dict(data, resource_root)
else:
return data | python | def from_json(self, resource_root, data):
if data is None:
return None
if self._atype == datetime.datetime:
return datetime.datetime.strptime(data, self.DATE_FMT)
elif self._atype == ApiConfig:
# ApiConfig is special. We want a python dictionary for summary views,
# but an ApiList for full views. Try to detect each case from the JSON
# data.
if not data['items']:
return { }
first = data['items'][0]
return json_to_config(data, len(first) == 2)
elif self._is_api_list:
return ApiList.from_json_dict(data, resource_root, self._atype)
elif isinstance(data, list):
return [ self.from_json(resource_root, x) for x in data ]
elif hasattr(self._atype, 'from_json_dict'):
return self._atype.from_json_dict(data, resource_root)
else:
return data | [
"def",
"from_json",
"(",
"self",
",",
"resource_root",
",",
"data",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"_atype",
"==",
"datetime",
".",
"datetime",
":",
"return",
"datetime",
".",
"datetime",
".",
"strptime",
... | Parses the given JSON value into an appropriate python object.
This means:
- a datetime.datetime if 'atype' is datetime.datetime
- a converted config dictionary or config list if 'atype' is ApiConfig
- if the attr is an API list, an ApiList with instances of 'atype'
- an instance of 'atype' if it has a 'from_json_dict' method
- a python list with decoded versions of the member objects if the input
is a python list.
- the raw value otherwise | [
"Parses",
"the",
"given",
"JSON",
"value",
"into",
"an",
"appropriate",
"python",
"object",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L66-L99 |
232,757 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | BaseApiObject._update | def _update(self, api_obj):
"""Copy state from api_obj to this object."""
if not isinstance(self, api_obj.__class__):
raise ValueError(
"Class %s does not derive from %s; cannot update attributes." %
(self.__class__, api_obj.__class__))
for name in self._get_attributes().keys():
try:
val = getattr(api_obj, name)
setattr(self, name, val)
except AttributeError, ignored:
pass | python | def _update(self, api_obj):
if not isinstance(self, api_obj.__class__):
raise ValueError(
"Class %s does not derive from %s; cannot update attributes." %
(self.__class__, api_obj.__class__))
for name in self._get_attributes().keys():
try:
val = getattr(api_obj, name)
setattr(self, name, val)
except AttributeError, ignored:
pass | [
"def",
"_update",
"(",
"self",
",",
"api_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
",",
"api_obj",
".",
"__class__",
")",
":",
"raise",
"ValueError",
"(",
"\"Class %s does not derive from %s; cannot update attributes.\"",
"%",
"(",
"self",
".",
"__... | Copy state from api_obj to this object. | [
"Copy",
"state",
"from",
"api_obj",
"to",
"this",
"object",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L246-L258 |
232,758 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | BaseApiResource._require_min_api_version | def _require_min_api_version(self, version):
"""
Raise an exception if the version of the api is less than the given version.
@param version: The minimum required version.
"""
actual_version = self._get_resource_root().version
version = max(version, self._api_version())
if actual_version < version:
raise Exception("API version %s is required but %s is in use."
% (version, actual_version)) | python | def _require_min_api_version(self, version):
actual_version = self._get_resource_root().version
version = max(version, self._api_version())
if actual_version < version:
raise Exception("API version %s is required but %s is in use."
% (version, actual_version)) | [
"def",
"_require_min_api_version",
"(",
"self",
",",
"version",
")",
":",
"actual_version",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"version",
"version",
"=",
"max",
"(",
"version",
",",
"self",
".",
"_api_version",
"(",
")",
")",
"if",
"act... | Raise an exception if the version of the api is less than the given version.
@param version: The minimum required version. | [
"Raise",
"an",
"exception",
"if",
"the",
"version",
"of",
"the",
"api",
"is",
"less",
"than",
"the",
"given",
"version",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L313-L323 |
232,759 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | BaseApiResource._get_config | def _get_config(self, rel_path, view, api_version=1):
"""
Retrieves an ApiConfig list from the given relative path.
"""
self._require_min_api_version(api_version)
params = view and dict(view=view) or None
resp = self._get_resource_root().get(self._path() + '/' + rel_path,
params=params)
return json_to_config(resp, view == 'full') | python | def _get_config(self, rel_path, view, api_version=1):
self._require_min_api_version(api_version)
params = view and dict(view=view) or None
resp = self._get_resource_root().get(self._path() + '/' + rel_path,
params=params)
return json_to_config(resp, view == 'full') | [
"def",
"_get_config",
"(",
"self",
",",
"rel_path",
",",
"view",
",",
"api_version",
"=",
"1",
")",
":",
"self",
".",
"_require_min_api_version",
"(",
"api_version",
")",
"params",
"=",
"view",
"and",
"dict",
"(",
"view",
"=",
"view",
")",
"or",
"None",
... | Retrieves an ApiConfig list from the given relative path. | [
"Retrieves",
"an",
"ApiConfig",
"list",
"from",
"the",
"given",
"relative",
"path",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L333-L341 |
232,760 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | ApiCommand.fetch | def fetch(self):
"""
Retrieve updated data about the command from the server.
@return: A new ApiCommand object.
"""
if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
return self
resp = self._get_resource_root().get(self._path())
return ApiCommand.from_json_dict(resp, self._get_resource_root()) | python | def fetch(self):
if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
return self
resp = self._get_resource_root().get(self._path())
return ApiCommand.from_json_dict(resp, self._get_resource_root()) | [
"def",
"fetch",
"(",
"self",
")",
":",
"if",
"self",
".",
"id",
"==",
"ApiCommand",
".",
"SYNCHRONOUS_COMMAND_ID",
":",
"return",
"self",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"get",
"(",
"self",
".",
"_path",
"(",
")",
")",
... | Retrieve updated data about the command from the server.
@return: A new ApiCommand object. | [
"Retrieve",
"updated",
"data",
"about",
"the",
"command",
"from",
"the",
"server",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L515-L525 |
232,761 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | ApiCommand.wait | def wait(self, timeout=None):
"""
Wait for command to finish.
@param timeout: (Optional) Max amount of time (in seconds) to wait. Wait
forever by default.
@return: The final ApiCommand object, containing the last known state.
The command may still be running in case of timeout.
"""
if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
return self
SLEEP_SEC = 5
if timeout is None:
deadline = None
else:
deadline = time.time() + timeout
while True:
cmd = self.fetch()
if not cmd.active:
return cmd
if deadline is not None:
now = time.time()
if deadline < now:
return cmd
else:
time.sleep(min(SLEEP_SEC, deadline - now))
else:
time.sleep(SLEEP_SEC) | python | def wait(self, timeout=None):
if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
return self
SLEEP_SEC = 5
if timeout is None:
deadline = None
else:
deadline = time.time() + timeout
while True:
cmd = self.fetch()
if not cmd.active:
return cmd
if deadline is not None:
now = time.time()
if deadline < now:
return cmd
else:
time.sleep(min(SLEEP_SEC, deadline - now))
else:
time.sleep(SLEEP_SEC) | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"id",
"==",
"ApiCommand",
".",
"SYNCHRONOUS_COMMAND_ID",
":",
"return",
"self",
"SLEEP_SEC",
"=",
"5",
"if",
"timeout",
"is",
"None",
":",
"deadline",
"=",
"None",
"e... | Wait for command to finish.
@param timeout: (Optional) Max amount of time (in seconds) to wait. Wait
forever by default.
@return: The final ApiCommand object, containing the last known state.
The command may still be running in case of timeout. | [
"Wait",
"for",
"command",
"to",
"finish",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L527-L558 |
232,762 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | ApiCommand.abort | def abort(self):
"""
Abort a running command.
@return: A new ApiCommand object with the updated information.
"""
if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
return self
path = self._path() + '/abort'
resp = self._get_resource_root().post(path)
return ApiCommand.from_json_dict(resp, self._get_resource_root()) | python | def abort(self):
if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
return self
path = self._path() + '/abort'
resp = self._get_resource_root().post(path)
return ApiCommand.from_json_dict(resp, self._get_resource_root()) | [
"def",
"abort",
"(",
"self",
")",
":",
"if",
"self",
".",
"id",
"==",
"ApiCommand",
".",
"SYNCHRONOUS_COMMAND_ID",
":",
"return",
"self",
"path",
"=",
"self",
".",
"_path",
"(",
")",
"+",
"'/abort'",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
... | Abort a running command.
@return: A new ApiCommand object with the updated information. | [
"Abort",
"a",
"running",
"command",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L561-L572 |
232,763 | cloudera/cm_api | python/src/cm_api/endpoints/types.py | ApiCommand.retry | def retry(self):
"""
Retry a failed or aborted command.
@return: A new ApiCommand object with the updated information.
"""
path = self._path() + '/retry'
resp = self._get_resource_root().post(path)
return ApiCommand.from_json_dict(resp, self._get_resource_root()) | python | def retry(self):
path = self._path() + '/retry'
resp = self._get_resource_root().post(path)
return ApiCommand.from_json_dict(resp, self._get_resource_root()) | [
"def",
"retry",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"_path",
"(",
")",
"+",
"'/retry'",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"post",
"(",
"path",
")",
"return",
"ApiCommand",
".",
"from_json_dict",
"(",
"resp",
... | Retry a failed or aborted command.
@return: A new ApiCommand object with the updated information. | [
"Retry",
"a",
"failed",
"or",
"aborted",
"command",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L574-L582 |
232,764 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | create_role_config_groups | def create_role_config_groups(resource_root, service_name, apigroup_list,
cluster_name="default"):
"""
Create role config groups.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param apigroup_list: List of role config groups to create.
@param cluster_name: Cluster name.
@return: New ApiRoleConfigGroup object.
@since: API v3
"""
return call(resource_root.post,
_get_role_config_groups_path(cluster_name, service_name),
ApiRoleConfigGroup, True, data=apigroup_list, api_version=3) | python | def create_role_config_groups(resource_root, service_name, apigroup_list,
cluster_name="default"):
return call(resource_root.post,
_get_role_config_groups_path(cluster_name, service_name),
ApiRoleConfigGroup, True, data=apigroup_list, api_version=3) | [
"def",
"create_role_config_groups",
"(",
"resource_root",
",",
"service_name",
",",
"apigroup_list",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"post",
",",
"_get_role_config_groups_path",
"(",
"cluster_name",
",",
... | Create role config groups.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param apigroup_list: List of role config groups to create.
@param cluster_name: Cluster name.
@return: New ApiRoleConfigGroup object.
@since: API v3 | [
"Create",
"role",
"config",
"groups",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L35-L48 |
232,765 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | get_role_config_group | def get_role_config_group(resource_root, service_name, name,
cluster_name="default"):
"""
Find a role config group by name.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param name: Role config group name.
@param cluster_name: Cluster name.
@return: An ApiRoleConfigGroup object.
"""
return _get_role_config_group(resource_root, _get_role_config_group_path(
cluster_name, service_name, name)) | python | def get_role_config_group(resource_root, service_name, name,
cluster_name="default"):
return _get_role_config_group(resource_root, _get_role_config_group_path(
cluster_name, service_name, name)) | [
"def",
"get_role_config_group",
"(",
"resource_root",
",",
"service_name",
",",
"name",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"_get_role_config_group",
"(",
"resource_root",
",",
"_get_role_config_group_path",
"(",
"cluster_name",
",",
"service_na... | Find a role config group by name.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param name: Role config group name.
@param cluster_name: Cluster name.
@return: An ApiRoleConfigGroup object. | [
"Find",
"a",
"role",
"config",
"group",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L66-L77 |
232,766 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | get_all_role_config_groups | def get_all_role_config_groups(resource_root, service_name,
cluster_name="default"):
"""
Get all role config groups in the specified service.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param cluster_name: Cluster name.
@return: A list of ApiRoleConfigGroup objects.
@since: API v3
"""
return call(resource_root.get,
_get_role_config_groups_path(cluster_name, service_name),
ApiRoleConfigGroup, True, api_version=3) | python | def get_all_role_config_groups(resource_root, service_name,
cluster_name="default"):
return call(resource_root.get,
_get_role_config_groups_path(cluster_name, service_name),
ApiRoleConfigGroup, True, api_version=3) | [
"def",
"get_all_role_config_groups",
"(",
"resource_root",
",",
"service_name",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"_get_role_config_groups_path",
"(",
"cluster_name",
",",
"service_name",
")",
... | Get all role config groups in the specified service.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param cluster_name: Cluster name.
@return: A list of ApiRoleConfigGroup objects.
@since: API v3 | [
"Get",
"all",
"role",
"config",
"groups",
"in",
"the",
"specified",
"service",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L82-L94 |
232,767 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | update_role_config_group | def update_role_config_group(resource_root, service_name, name, apigroup,
cluster_name="default"):
"""
Update a role config group by name.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param name: Role config group name.
@param apigroup: The updated role config group.
@param cluster_name: Cluster name.
@return: The updated ApiRoleConfigGroup object.
@since: API v3
"""
return call(resource_root.put,
_get_role_config_group_path(cluster_name, service_name, name),
ApiRoleConfigGroup, data=apigroup, api_version=3) | python | def update_role_config_group(resource_root, service_name, name, apigroup,
cluster_name="default"):
return call(resource_root.put,
_get_role_config_group_path(cluster_name, service_name, name),
ApiRoleConfigGroup, data=apigroup, api_version=3) | [
"def",
"update_role_config_group",
"(",
"resource_root",
",",
"service_name",
",",
"name",
",",
"apigroup",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"put",
",",
"_get_role_config_group_path",
"(",
"cluster_name"... | Update a role config group by name.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param name: Role config group name.
@param apigroup: The updated role config group.
@param cluster_name: Cluster name.
@return: The updated ApiRoleConfigGroup object.
@since: API v3 | [
"Update",
"a",
"role",
"config",
"group",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L96-L110 |
232,768 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | move_roles | def move_roles(resource_root, service_name, name, role_names,
cluster_name="default"):
"""
Moves roles to the specified role config group.
The roles can be moved from any role config group belonging
to the same service. The role type of the destination group
must match the role type of the roles.
@param name: The name of the group the roles will be moved to.
@param role_names: The names of the roles to move.
@return: List of roles which have been moved successfully.
@since: API v3
"""
return call(resource_root.put,
_get_role_config_group_path(cluster_name, service_name, name) + '/roles',
ApiRole, True, data=role_names, api_version=3) | python | def move_roles(resource_root, service_name, name, role_names,
cluster_name="default"):
return call(resource_root.put,
_get_role_config_group_path(cluster_name, service_name, name) + '/roles',
ApiRole, True, data=role_names, api_version=3) | [
"def",
"move_roles",
"(",
"resource_root",
",",
"service_name",
",",
"name",
",",
"role_names",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"put",
",",
"_get_role_config_group_path",
"(",
"cluster_name",
",",
"... | Moves roles to the specified role config group.
The roles can be moved from any role config group belonging
to the same service. The role type of the destination group
must match the role type of the roles.
@param name: The name of the group the roles will be moved to.
@param role_names: The names of the roles to move.
@return: List of roles which have been moved successfully.
@since: API v3 | [
"Moves",
"roles",
"to",
"the",
"specified",
"role",
"config",
"group",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L127-L143 |
232,769 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | move_roles_to_base_role_config_group | def move_roles_to_base_role_config_group(resource_root, service_name,
role_names, cluster_name="default"):
"""
Moves roles to the base role config group.
The roles can be moved from any role config group belonging to the same
service. The role type of the roles may vary. Each role will be moved to
its corresponding base group depending on its role type.
@param role_names: The names of the roles to move.
@return: List of roles which have been moved successfully.
@since: API v3
"""
return call(resource_root.put,
_get_role_config_groups_path(cluster_name, service_name) + '/roles',
ApiRole, True, data=role_names, api_version=3) | python | def move_roles_to_base_role_config_group(resource_root, service_name,
role_names, cluster_name="default"):
return call(resource_root.put,
_get_role_config_groups_path(cluster_name, service_name) + '/roles',
ApiRole, True, data=role_names, api_version=3) | [
"def",
"move_roles_to_base_role_config_group",
"(",
"resource_root",
",",
"service_name",
",",
"role_names",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"put",
",",
"_get_role_config_groups_path",
"(",
"cluster_name",
... | Moves roles to the base role config group.
The roles can be moved from any role config group belonging to the same
service. The role type of the roles may vary. Each role will be moved to
its corresponding base group depending on its role type.
@param role_names: The names of the roles to move.
@return: List of roles which have been moved successfully.
@since: API v3 | [
"Moves",
"roles",
"to",
"the",
"base",
"role",
"config",
"group",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L145-L160 |
232,770 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | ApiRoleConfigGroup.update_config | def update_config(self, config):
"""
Update the group's configuration.
@param config: Dictionary with configuration to update.
@return: Dictionary with updated configuration.
"""
path = self._path() + '/config'
resp = self._get_resource_root().put(path, data = config_to_json(config))
return json_to_config(resp) | python | def update_config(self, config):
path = self._path() + '/config'
resp = self._get_resource_root().put(path, data = config_to_json(config))
return json_to_config(resp) | [
"def",
"update_config",
"(",
"self",
",",
"config",
")",
":",
"path",
"=",
"self",
".",
"_path",
"(",
")",
"+",
"'/config'",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"put",
"(",
"path",
",",
"data",
"=",
"config_to_json",
"(",
"... | Update the group's configuration.
@param config: Dictionary with configuration to update.
@return: Dictionary with updated configuration. | [
"Update",
"the",
"group",
"s",
"configuration",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L210-L219 |
232,771 | cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | ApiRoleConfigGroup.move_roles | def move_roles(self, roles):
"""
Moves roles to this role config group.
The roles can be moved from any role config group belonging
to the same service. The role type of the destination group
must match the role type of the roles.
@param roles: The names of the roles to move.
@return: List of roles which have been moved successfully.
"""
return move_roles(self._get_resource_root(), self.serviceRef.serviceName,
self.name, roles, self.serviceRef.clusterName) | python | def move_roles(self, roles):
return move_roles(self._get_resource_root(), self.serviceRef.serviceName,
self.name, roles, self.serviceRef.clusterName) | [
"def",
"move_roles",
"(",
"self",
",",
"roles",
")",
":",
"return",
"move_roles",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"serviceRef",
".",
"serviceName",
",",
"self",
".",
"name",
",",
"roles",
",",
"self",
".",
"serviceRef"... | Moves roles to this role config group.
The roles can be moved from any role config group belonging
to the same service. The role type of the destination group
must match the role type of the roles.
@param roles: The names of the roles to move.
@return: List of roles which have been moved successfully. | [
"Moves",
"roles",
"to",
"this",
"role",
"config",
"group",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L229-L241 |
232,772 | cloudera/cm_api | python/src/cm_api/endpoints/roles.py | get_role | def get_role(resource_root, service_name, name, cluster_name="default"):
"""
Lookup a role by name
@param resource_root: The root Resource object.
@param service_name: Service name
@param name: Role name
@param cluster_name: Cluster name
@return: An ApiRole object
"""
return _get_role(resource_root, _get_role_path(cluster_name, service_name, name)) | python | def get_role(resource_root, service_name, name, cluster_name="default"):
return _get_role(resource_root, _get_role_path(cluster_name, service_name, name)) | [
"def",
"get_role",
"(",
"resource_root",
",",
"service_name",
",",
"name",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"_get_role",
"(",
"resource_root",
",",
"_get_role_path",
"(",
"cluster_name",
",",
"service_name",
",",
"name",
")",
")"
] | Lookup a role by name
@param resource_root: The root Resource object.
@param service_name: Service name
@param name: Role name
@param cluster_name: Cluster name
@return: An ApiRole object | [
"Lookup",
"a",
"role",
"by",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/roles.py#L55-L64 |
232,773 | cloudera/cm_api | python/src/cm_api/endpoints/roles.py | get_all_roles | def get_all_roles(resource_root, service_name, cluster_name="default", view=None):
"""
Get all roles
@param resource_root: The root Resource object.
@param service_name: Service name
@param cluster_name: Cluster name
@return: A list of ApiRole objects.
"""
return call(resource_root.get,
_get_roles_path(cluster_name, service_name),
ApiRole, True, params=view and dict(view=view) or None) | python | def get_all_roles(resource_root, service_name, cluster_name="default", view=None):
return call(resource_root.get,
_get_roles_path(cluster_name, service_name),
ApiRole, True, params=view and dict(view=view) or None) | [
"def",
"get_all_roles",
"(",
"resource_root",
",",
"service_name",
",",
"cluster_name",
"=",
"\"default\"",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"_get_roles_path",
"(",
"cluster_name",
",",
"service_name",
... | Get all roles
@param resource_root: The root Resource object.
@param service_name: Service name
@param cluster_name: Cluster name
@return: A list of ApiRole objects. | [
"Get",
"all",
"roles"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/roles.py#L69-L79 |
232,774 | cloudera/cm_api | python/src/cm_api/endpoints/roles.py | get_roles_by_type | def get_roles_by_type(resource_root, service_name, role_type,
cluster_name="default", view=None):
"""
Get all roles of a certain type in a service
@param resource_root: The root Resource object.
@param service_name: Service name
@param role_type: Role type
@param cluster_name: Cluster name
@return: A list of ApiRole objects.
"""
roles = get_all_roles(resource_root, service_name, cluster_name, view)
return [ r for r in roles if r.type == role_type ] | python | def get_roles_by_type(resource_root, service_name, role_type,
cluster_name="default", view=None):
roles = get_all_roles(resource_root, service_name, cluster_name, view)
return [ r for r in roles if r.type == role_type ] | [
"def",
"get_roles_by_type",
"(",
"resource_root",
",",
"service_name",
",",
"role_type",
",",
"cluster_name",
"=",
"\"default\"",
",",
"view",
"=",
"None",
")",
":",
"roles",
"=",
"get_all_roles",
"(",
"resource_root",
",",
"service_name",
",",
"cluster_name",
"... | Get all roles of a certain type in a service
@param resource_root: The root Resource object.
@param service_name: Service name
@param role_type: Role type
@param cluster_name: Cluster name
@return: A list of ApiRole objects. | [
"Get",
"all",
"roles",
"of",
"a",
"certain",
"type",
"in",
"a",
"service"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/roles.py#L81-L92 |
232,775 | cloudera/cm_api | python/src/cm_api/endpoints/roles.py | delete_role | def delete_role(resource_root, service_name, name, cluster_name="default"):
"""
Delete a role by name
@param resource_root: The root Resource object.
@param service_name: Service name
@param name: Role name
@param cluster_name: Cluster name
@return: The deleted ApiRole object
"""
return call(resource_root.delete,
_get_role_path(cluster_name, service_name, name), ApiRole) | python | def delete_role(resource_root, service_name, name, cluster_name="default"):
return call(resource_root.delete,
_get_role_path(cluster_name, service_name, name), ApiRole) | [
"def",
"delete_role",
"(",
"resource_root",
",",
"service_name",
",",
"name",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"delete",
",",
"_get_role_path",
"(",
"cluster_name",
",",
"service_name",
",",
"name",
... | Delete a role by name
@param resource_root: The root Resource object.
@param service_name: Service name
@param name: Role name
@param cluster_name: Cluster name
@return: The deleted ApiRole object | [
"Delete",
"a",
"role",
"by",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/roles.py#L94-L104 |
232,776 | cloudera/cm_api | python/src/cm_api/endpoints/users.py | get_all_users | def get_all_users(resource_root, view=None):
"""
Get all users.
@param resource_root: The root Resource object
@param view: View to materialize ('full' or 'summary').
@return: A list of ApiUser objects.
"""
return call(resource_root.get, USERS_PATH, ApiUser, True,
params=view and dict(view=view) or None) | python | def get_all_users(resource_root, view=None):
return call(resource_root.get, USERS_PATH, ApiUser, True,
params=view and dict(view=view) or None) | [
"def",
"get_all_users",
"(",
"resource_root",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"USERS_PATH",
",",
"ApiUser",
",",
"True",
",",
"params",
"=",
"view",
"and",
"dict",
"(",
"view",
"=",
"view",
"... | Get all users.
@param resource_root: The root Resource object
@param view: View to materialize ('full' or 'summary').
@return: A list of ApiUser objects. | [
"Get",
"all",
"users",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/users.py#L21-L30 |
232,777 | cloudera/cm_api | python/src/cm_api/endpoints/users.py | ApiUser.grant_admin_role | def grant_admin_role(self):
"""
Grant admin access to a user. If the user already has admin access, this
does nothing. If the user currently has a non-admin role, it will be replaced
with the admin role.
@return: An ApiUser object
"""
apiuser = ApiUser(self._get_resource_root(), self.name, roles=['ROLE_ADMIN'])
return self._put('', ApiUser, data=apiuser) | python | def grant_admin_role(self):
apiuser = ApiUser(self._get_resource_root(), self.name, roles=['ROLE_ADMIN'])
return self._put('', ApiUser, data=apiuser) | [
"def",
"grant_admin_role",
"(",
"self",
")",
":",
"apiuser",
"=",
"ApiUser",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"roles",
"=",
"[",
"'ROLE_ADMIN'",
"]",
")",
"return",
"self",
".",
"_put",
"(",
"''",
",",
... | Grant admin access to a user. If the user already has admin access, this
does nothing. If the user currently has a non-admin role, it will be replaced
with the admin role.
@return: An ApiUser object | [
"Grant",
"admin",
"access",
"to",
"a",
"user",
".",
"If",
"the",
"user",
"already",
"has",
"admin",
"access",
"this",
"does",
"nothing",
".",
"If",
"the",
"user",
"currently",
"has",
"a",
"non",
"-",
"admin",
"role",
"it",
"will",
"be",
"replaced",
"wi... | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/users.py#L96-L105 |
232,778 | cloudera/cm_api | python/src/cm_api/endpoints/batch.py | do_batch | def do_batch(resource_root, elements):
"""
Execute a batch request with one or more elements. If any element fails,
the entire request is rolled back and subsequent elements are ignored.
@param elements: A list of ApiBatchRequestElements
@return: an ApiBatchResponseList
@since: API v6
"""
return call(resource_root.post, BATCH_PATH, ApiBatchResponseList,
data=elements, api_version=6) | python | def do_batch(resource_root, elements):
return call(resource_root.post, BATCH_PATH, ApiBatchResponseList,
data=elements, api_version=6) | [
"def",
"do_batch",
"(",
"resource_root",
",",
"elements",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"post",
",",
"BATCH_PATH",
",",
"ApiBatchResponseList",
",",
"data",
"=",
"elements",
",",
"api_version",
"=",
"6",
")"
] | Execute a batch request with one or more elements. If any element fails,
the entire request is rolled back and subsequent elements are ignored.
@param elements: A list of ApiBatchRequestElements
@return: an ApiBatchResponseList
@since: API v6 | [
"Execute",
"a",
"batch",
"request",
"with",
"one",
"or",
"more",
"elements",
".",
"If",
"any",
"element",
"fails",
"the",
"entire",
"request",
"is",
"rolled",
"back",
"and",
"subsequent",
"elements",
"are",
"ignored",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/batch.py#L23-L33 |
232,779 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | get_all_services | def get_all_services(resource_root, cluster_name="default", view=None):
"""
Get all services
@param resource_root: The root Resource object.
@param cluster_name: Cluster name
@return: A list of ApiService objects.
"""
return call(resource_root.get,
SERVICES_PATH % (cluster_name,),
ApiService, True, params=view and dict(view=view) or None) | python | def get_all_services(resource_root, cluster_name="default", view=None):
return call(resource_root.get,
SERVICES_PATH % (cluster_name,),
ApiService, True, params=view and dict(view=view) or None) | [
"def",
"get_all_services",
"(",
"resource_root",
",",
"cluster_name",
"=",
"\"default\"",
",",
"view",
"=",
"None",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"SERVICES_PATH",
"%",
"(",
"cluster_name",
",",
")",
",",
"ApiService",
","... | Get all services
@param resource_root: The root Resource object.
@param cluster_name: Cluster name
@return: A list of ApiService objects. | [
"Get",
"all",
"services"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L59-L68 |
232,780 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | delete_service | def delete_service(resource_root, name, cluster_name="default"):
"""
Delete a service by name
@param resource_root: The root Resource object.
@param name: Service name
@param cluster_name: Cluster name
@return: The deleted ApiService object
"""
return call(resource_root.delete,
"%s/%s" % (SERVICES_PATH % (cluster_name,), name),
ApiService) | python | def delete_service(resource_root, name, cluster_name="default"):
return call(resource_root.delete,
"%s/%s" % (SERVICES_PATH % (cluster_name,), name),
ApiService) | [
"def",
"delete_service",
"(",
"resource_root",
",",
"name",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"delete",
",",
"\"%s/%s\"",
"%",
"(",
"SERVICES_PATH",
"%",
"(",
"cluster_name",
",",
")",
",",
"name"... | Delete a service by name
@param resource_root: The root Resource object.
@param name: Service name
@param cluster_name: Cluster name
@return: The deleted ApiService object | [
"Delete",
"a",
"service",
"by",
"name"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L70-L80 |
232,781 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService._parse_svc_config | def _parse_svc_config(self, json_dic, view = None):
"""
Parse a json-decoded ApiServiceConfig dictionary into a 2-tuple.
@param json_dic: The json dictionary with the config data.
@param view: View to materialize.
@return: 2-tuple (service config dictionary, role type configurations)
"""
svc_config = json_to_config(json_dic, view == 'full')
rt_configs = { }
if json_dic.has_key(ROLETYPES_CFG_KEY):
for rt_config in json_dic[ROLETYPES_CFG_KEY]:
rt_configs[rt_config['roleType']] = \
json_to_config(rt_config, view == 'full')
return (svc_config, rt_configs) | python | def _parse_svc_config(self, json_dic, view = None):
svc_config = json_to_config(json_dic, view == 'full')
rt_configs = { }
if json_dic.has_key(ROLETYPES_CFG_KEY):
for rt_config in json_dic[ROLETYPES_CFG_KEY]:
rt_configs[rt_config['roleType']] = \
json_to_config(rt_config, view == 'full')
return (svc_config, rt_configs) | [
"def",
"_parse_svc_config",
"(",
"self",
",",
"json_dic",
",",
"view",
"=",
"None",
")",
":",
"svc_config",
"=",
"json_to_config",
"(",
"json_dic",
",",
"view",
"==",
"'full'",
")",
"rt_configs",
"=",
"{",
"}",
"if",
"json_dic",
".",
"has_key",
"(",
"ROL... | Parse a json-decoded ApiServiceConfig dictionary into a 2-tuple.
@param json_dic: The json dictionary with the config data.
@param view: View to materialize.
@return: 2-tuple (service config dictionary, role type configurations) | [
"Parse",
"a",
"json",
"-",
"decoded",
"ApiServiceConfig",
"dictionary",
"into",
"a",
"2",
"-",
"tuple",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L130-L145 |
232,782 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.add_watched_directory | def add_watched_directory(self, dir_path):
"""
Adds a directory to the watching list.
@param dir_path: The path of the directory to be added to the watching list
@return: The added directory, or null if failed
@since: API v14
"""
req = ApiWatchedDir(self._get_resource_root(), path=dir_path)
return self._post("watcheddir", ApiWatchedDir, data=req, api_version=14) | python | def add_watched_directory(self, dir_path):
req = ApiWatchedDir(self._get_resource_root(), path=dir_path)
return self._post("watcheddir", ApiWatchedDir, data=req, api_version=14) | [
"def",
"add_watched_directory",
"(",
"self",
",",
"dir_path",
")",
":",
"req",
"=",
"ApiWatchedDir",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"path",
"=",
"dir_path",
")",
"return",
"self",
".",
"_post",
"(",
"\"watcheddir\"",
",",
"ApiWatchedD... | Adds a directory to the watching list.
@param dir_path: The path of the directory to be added to the watching list
@return: The added directory, or null if failed
@since: API v14 | [
"Adds",
"a",
"directory",
"to",
"the",
"watching",
"list",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L176-L185 |
232,783 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_impala_queries | def get_impala_queries(self, start_time, end_time, filter_str="", limit=100,
offset=0):
"""
Returns a list of queries that satisfy the filter
@type start_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param start_time: Queries must have ended after this time
@type end_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param end_time: Queries must have started before this time
@param filter_str: A filter to apply to the queries. For example:
'user = root and queryDuration > 5s'
@param limit: The maximum number of results to return
@param offset: The offset into the return list
@since: API v4
"""
params = {
'from': start_time.isoformat(),
'to': end_time.isoformat(),
'filter': filter_str,
'limit': limit,
'offset': offset,
}
return self._get("impalaQueries", ApiImpalaQueryResponse,
params=params, api_version=4) | python | def get_impala_queries(self, start_time, end_time, filter_str="", limit=100,
offset=0):
params = {
'from': start_time.isoformat(),
'to': end_time.isoformat(),
'filter': filter_str,
'limit': limit,
'offset': offset,
}
return self._get("impalaQueries", ApiImpalaQueryResponse,
params=params, api_version=4) | [
"def",
"get_impala_queries",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"filter_str",
"=",
"\"\"",
",",
"limit",
"=",
"100",
",",
"offset",
"=",
"0",
")",
":",
"params",
"=",
"{",
"'from'",
":",
"start_time",
".",
"isoformat",
"(",
")",
",",... | Returns a list of queries that satisfy the filter
@type start_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param start_time: Queries must have ended after this time
@type end_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param end_time: Queries must have started before this time
@param filter_str: A filter to apply to the queries. For example:
'user = root and queryDuration > 5s'
@param limit: The maximum number of results to return
@param offset: The offset into the return list
@since: API v4 | [
"Returns",
"a",
"list",
"of",
"queries",
"that",
"satisfy",
"the",
"filter"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L197-L226 |
232,784 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_query_details | def get_query_details(self, query_id, format='text'):
"""
Get the query details
@param query_id: The query ID
@param format: The format of the response ('text' or 'thrift_encoded')
@return: The details text
@since: API v4
"""
return self._get("impalaQueries/" + query_id, ApiImpalaQueryDetailsResponse,
params=dict(format=format), api_version=4) | python | def get_query_details(self, query_id, format='text'):
return self._get("impalaQueries/" + query_id, ApiImpalaQueryDetailsResponse,
params=dict(format=format), api_version=4) | [
"def",
"get_query_details",
"(",
"self",
",",
"query_id",
",",
"format",
"=",
"'text'",
")",
":",
"return",
"self",
".",
"_get",
"(",
"\"impalaQueries/\"",
"+",
"query_id",
",",
"ApiImpalaQueryDetailsResponse",
",",
"params",
"=",
"dict",
"(",
"format",
"=",
... | Get the query details
@param query_id: The query ID
@param format: The format of the response ('text' or 'thrift_encoded')
@return: The details text
@since: API v4 | [
"Get",
"the",
"query",
"details"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L239-L249 |
232,785 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.enable_llama_rm | def enable_llama_rm(self, llama1_host_id, llama1_role_name=None,
llama2_host_id=None, llama2_role_name=None,
zk_service_name=None, skip_restart=False):
"""
Enable Llama-based resource management for Impala.
This command only applies to CDH 5.1+ Impala services.
This command configures YARN and Impala for Llama resource management,
and then creates one or two Llama roles, as specified by the parameters.
When two Llama roles are created, they are configured as an active-standby
pair. Auto-failover from active to standby Llama will be enabled using
ZooKeeper.
If optional role name(s) are specified, the new Llama role(s) will be
named accordingly; otherwise, role name(s) will be automatically generated.
By default, YARN, Impala, and any dependent services will be restarted,
and client configuration will be re-deployed across the cluster. These
default actions may be suppressed.
In order to enable Llama resource management, a YARN service must be
present in the cluster, and Cgroup-based resource management must be
enabled for all hosts with NodeManager roles. If these preconditions
are not met, the command will fail.
@param llama1_host_id: id of the host where the first Llama role will
be created.
@param llama1_role_name: Name of the first Llama role. If omitted, a
name will be generated automatically.
@param llama2_host_id: id of the host where the second Llama role will
be created. If omitted, only one Llama role will
be created (i.e., high availability will not be
enabled).
@param llama2_role_name: Name of the second Llama role. If omitted, a
name will be generated automatically.
@param zk_service_name: Name of the ZooKeeper service to use for
auto-failover. Only relevant when enabling
Llama RM in HA mode (i.e., when creating two
Llama roles). If Impala's ZooKeeper dependency
is already set, then that ZooKeeper service will
be used for auto-failover, and this parameter
may be omitted.
@param skip_restart: true to skip the restart of Yarn, Impala, and
their dependent services, and to skip deployment
of client configuration. Default is False (i.e.,
by default dependent services are restarted and
client configuration is deployed).
@return: Reference to the submitted command.
@since: API v8
"""
args = dict(
llama1HostId = llama1_host_id,
llama1RoleName = llama1_role_name,
llama2HostId = llama2_host_id,
llama2RoleName = llama2_role_name,
zkServiceName = zk_service_name,
skipRestart = skip_restart
)
return self._cmd('impalaEnableLlamaRm', data=args, api_version=8) | python | def enable_llama_rm(self, llama1_host_id, llama1_role_name=None,
llama2_host_id=None, llama2_role_name=None,
zk_service_name=None, skip_restart=False):
args = dict(
llama1HostId = llama1_host_id,
llama1RoleName = llama1_role_name,
llama2HostId = llama2_host_id,
llama2RoleName = llama2_role_name,
zkServiceName = zk_service_name,
skipRestart = skip_restart
)
return self._cmd('impalaEnableLlamaRm', data=args, api_version=8) | [
"def",
"enable_llama_rm",
"(",
"self",
",",
"llama1_host_id",
",",
"llama1_role_name",
"=",
"None",
",",
"llama2_host_id",
"=",
"None",
",",
"llama2_role_name",
"=",
"None",
",",
"zk_service_name",
"=",
"None",
",",
"skip_restart",
"=",
"False",
")",
":",
"arg... | Enable Llama-based resource management for Impala.
This command only applies to CDH 5.1+ Impala services.
This command configures YARN and Impala for Llama resource management,
and then creates one or two Llama roles, as specified by the parameters.
When two Llama roles are created, they are configured as an active-standby
pair. Auto-failover from active to standby Llama will be enabled using
ZooKeeper.
If optional role name(s) are specified, the new Llama role(s) will be
named accordingly; otherwise, role name(s) will be automatically generated.
By default, YARN, Impala, and any dependent services will be restarted,
and client configuration will be re-deployed across the cluster. These
default actions may be suppressed.
In order to enable Llama resource management, a YARN service must be
present in the cluster, and Cgroup-based resource management must be
enabled for all hosts with NodeManager roles. If these preconditions
are not met, the command will fail.
@param llama1_host_id: id of the host where the first Llama role will
be created.
@param llama1_role_name: Name of the first Llama role. If omitted, a
name will be generated automatically.
@param llama2_host_id: id of the host where the second Llama role will
be created. If omitted, only one Llama role will
be created (i.e., high availability will not be
enabled).
@param llama2_role_name: Name of the second Llama role. If omitted, a
name will be generated automatically.
@param zk_service_name: Name of the ZooKeeper service to use for
auto-failover. Only relevant when enabling
Llama RM in HA mode (i.e., when creating two
Llama roles). If Impala's ZooKeeper dependency
is already set, then that ZooKeeper service will
be used for auto-failover, and this parameter
may be omitted.
@param skip_restart: true to skip the restart of Yarn, Impala, and
their dependent services, and to skip deployment
of client configuration. Default is False (i.e.,
by default dependent services are restarted and
client configuration is deployed).
@return: Reference to the submitted command.
@since: API v8 | [
"Enable",
"Llama",
"-",
"based",
"resource",
"management",
"for",
"Impala",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L302-L361 |
232,786 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.enable_llama_ha | def enable_llama_ha(self, new_llama_host_id, zk_service_name=None,
new_llama_role_name=None):
"""
Enable high availability for an Impala Llama ApplicationMaster.
This command only applies to CDH 5.1+ Impala services.
@param new_llama_host_id: id of the host where the second Llama role
will be added.
@param zk_service_name: Name of the ZooKeeper service to use for
auto-failover. If Impala's ZooKeeper dependency
is already set, then that ZooKeeper service will
be used for auto-failover, and this parameter
may be omitted.
@param new_llama_role_name: Name of the new Llama role. If omitted, a
name will be generated automatically.
@return: Reference to the submitted command.
@since: API v8
"""
args = dict(
newLlamaHostId = new_llama_host_id,
zkServiceName = zk_service_name,
newLlamaRoleName = new_llama_role_name
)
return self._cmd('impalaEnableLlamaHa', data=args, api_version=8) | python | def enable_llama_ha(self, new_llama_host_id, zk_service_name=None,
new_llama_role_name=None):
args = dict(
newLlamaHostId = new_llama_host_id,
zkServiceName = zk_service_name,
newLlamaRoleName = new_llama_role_name
)
return self._cmd('impalaEnableLlamaHa', data=args, api_version=8) | [
"def",
"enable_llama_ha",
"(",
"self",
",",
"new_llama_host_id",
",",
"zk_service_name",
"=",
"None",
",",
"new_llama_role_name",
"=",
"None",
")",
":",
"args",
"=",
"dict",
"(",
"newLlamaHostId",
"=",
"new_llama_host_id",
",",
"zkServiceName",
"=",
"zk_service_na... | Enable high availability for an Impala Llama ApplicationMaster.
This command only applies to CDH 5.1+ Impala services.
@param new_llama_host_id: id of the host where the second Llama role
will be added.
@param zk_service_name: Name of the ZooKeeper service to use for
auto-failover. If Impala's ZooKeeper dependency
is already set, then that ZooKeeper service will
be used for auto-failover, and this parameter
may be omitted.
@param new_llama_role_name: Name of the new Llama role. If omitted, a
name will be generated automatically.
@return: Reference to the submitted command.
@since: API v8 | [
"Enable",
"high",
"availability",
"for",
"an",
"Impala",
"Llama",
"ApplicationMaster",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L379-L403 |
232,787 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_yarn_applications | def get_yarn_applications(self, start_time, end_time, filter_str="", limit=100,
offset=0):
"""
Returns a list of YARN applications that satisfy the filter
@type start_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param start_time: Applications must have ended after this time
@type end_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param filter_str: A filter to apply to the applications. For example:
'user = root and applicationDuration > 5s'
@param limit: The maximum number of results to return
@param offset: The offset into the return list
@since: API v6
"""
params = {
'from': start_time.isoformat(),
'to': end_time.isoformat(),
'filter': filter_str,
'limit': limit,
'offset': offset
}
return self._get("yarnApplications", ApiYarnApplicationResponse,
params=params, api_version=6) | python | def get_yarn_applications(self, start_time, end_time, filter_str="", limit=100,
offset=0):
params = {
'from': start_time.isoformat(),
'to': end_time.isoformat(),
'filter': filter_str,
'limit': limit,
'offset': offset
}
return self._get("yarnApplications", ApiYarnApplicationResponse,
params=params, api_version=6) | [
"def",
"get_yarn_applications",
"(",
"self",
",",
"start_time",
",",
"end_time",
",",
"filter_str",
"=",
"\"\"",
",",
"limit",
"=",
"100",
",",
"offset",
"=",
"0",
")",
":",
"params",
"=",
"{",
"'from'",
":",
"start_time",
".",
"isoformat",
"(",
")",
"... | Returns a list of YARN applications that satisfy the filter
@type start_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param start_time: Applications must have ended after this time
@type end_time: datetime.datetime. Note that the datetime must either be
time zone aware or specified in the server time zone. See
the python datetime documentation for more details about
python's time zone handling.
@param filter_str: A filter to apply to the applications. For example:
'user = root and applicationDuration > 5s'
@param limit: The maximum number of results to return
@param offset: The offset into the return list
@since: API v6 | [
"Returns",
"a",
"list",
"of",
"YARN",
"applications",
"that",
"satisfy",
"the",
"filter"
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L423-L450 |
232,788 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.create_yarn_application_diagnostics_bundle | def create_yarn_application_diagnostics_bundle(self, application_ids, ticket_number=None, comments=None):
"""
Collects the Diagnostics data for Yarn applications.
@param application_ids: An array of strings containing the ids of the
yarn applications.
@param ticket_number: If applicable, the support ticket number of the issue
being experienced on the cluster.
@param comments: Additional comments
@return: Reference to the submitted command.
@since: API v10
"""
args = dict(applicationIds = application_ids,
ticketNumber = ticket_number,
comments = comments)
return self._cmd('yarnApplicationDiagnosticsCollection', api_version=10, data=args) | python | def create_yarn_application_diagnostics_bundle(self, application_ids, ticket_number=None, comments=None):
args = dict(applicationIds = application_ids,
ticketNumber = ticket_number,
comments = comments)
return self._cmd('yarnApplicationDiagnosticsCollection', api_version=10, data=args) | [
"def",
"create_yarn_application_diagnostics_bundle",
"(",
"self",
",",
"application_ids",
",",
"ticket_number",
"=",
"None",
",",
"comments",
"=",
"None",
")",
":",
"args",
"=",
"dict",
"(",
"applicationIds",
"=",
"application_ids",
",",
"ticketNumber",
"=",
"tick... | Collects the Diagnostics data for Yarn applications.
@param application_ids: An array of strings containing the ids of the
yarn applications.
@param ticket_number: If applicable, the support ticket number of the issue
being experienced on the cluster.
@param comments: Additional comments
@return: Reference to the submitted command.
@since: API v10 | [
"Collects",
"the",
"Diagnostics",
"data",
"for",
"Yarn",
"applications",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L515-L531 |
232,789 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_config | def get_config(self, view = None):
"""
Retrieve the service's configuration.
Retrieves both the service configuration and role type configuration
for each of the service's supported role types. The role type
configurations are returned as a dictionary, whose keys are the
role type name, and values are the respective configuration dictionaries.
The 'summary' view contains strings as the dictionary values. The full
view contains ApiConfig instances as the values.
@param view: View to materialize ('full' or 'summary')
@return: 2-tuple (service config dictionary, role type configurations)
"""
path = self._path() + '/config'
resp = self._get_resource_root().get(path,
params = view and dict(view=view) or None)
return self._parse_svc_config(resp, view) | python | def get_config(self, view = None):
path = self._path() + '/config'
resp = self._get_resource_root().get(path,
params = view and dict(view=view) or None)
return self._parse_svc_config(resp, view) | [
"def",
"get_config",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"path",
"=",
"self",
".",
"_path",
"(",
")",
"+",
"'/config'",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"get",
"(",
"path",
",",
"params",
"=",
"view",
"and... | Retrieve the service's configuration.
Retrieves both the service configuration and role type configuration
for each of the service's supported role types. The role type
configurations are returned as a dictionary, whose keys are the
role type name, and values are the respective configuration dictionaries.
The 'summary' view contains strings as the dictionary values. The full
view contains ApiConfig instances as the values.
@param view: View to materialize ('full' or 'summary')
@return: 2-tuple (service config dictionary, role type configurations) | [
"Retrieve",
"the",
"service",
"s",
"configuration",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L533-L551 |
232,790 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.update_config | def update_config(self, svc_config, **rt_configs):
"""
Update the service's configuration.
@param svc_config: Dictionary with service configuration to update.
@param rt_configs: Dict of role type configurations to update.
@return: 2-tuple (service config dictionary, role type configurations)
"""
path = self._path() + '/config'
if svc_config:
data = config_to_api_list(svc_config)
else:
data = { }
if rt_configs:
rt_list = [ ]
for rt, cfg in rt_configs.iteritems():
rt_data = config_to_api_list(cfg)
rt_data['roleType'] = rt
rt_list.append(rt_data)
data[ROLETYPES_CFG_KEY] = rt_list
resp = self._get_resource_root().put(path, data = json.dumps(data))
return self._parse_svc_config(resp) | python | def update_config(self, svc_config, **rt_configs):
path = self._path() + '/config'
if svc_config:
data = config_to_api_list(svc_config)
else:
data = { }
if rt_configs:
rt_list = [ ]
for rt, cfg in rt_configs.iteritems():
rt_data = config_to_api_list(cfg)
rt_data['roleType'] = rt
rt_list.append(rt_data)
data[ROLETYPES_CFG_KEY] = rt_list
resp = self._get_resource_root().put(path, data = json.dumps(data))
return self._parse_svc_config(resp) | [
"def",
"update_config",
"(",
"self",
",",
"svc_config",
",",
"*",
"*",
"rt_configs",
")",
":",
"path",
"=",
"self",
".",
"_path",
"(",
")",
"+",
"'/config'",
"if",
"svc_config",
":",
"data",
"=",
"config_to_api_list",
"(",
"svc_config",
")",
"else",
":",... | Update the service's configuration.
@param svc_config: Dictionary with service configuration to update.
@param rt_configs: Dict of role type configurations to update.
@return: 2-tuple (service config dictionary, role type configurations) | [
"Update",
"the",
"service",
"s",
"configuration",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L553-L576 |
232,791 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.create_role | def create_role(self, role_name, role_type, host_id):
"""
Create a role.
@param role_name: Role name
@param role_type: Role type
@param host_id: ID of the host to assign the role to
@return: An ApiRole object
"""
return roles.create_role(self._get_resource_root(), self.name, role_type,
role_name, host_id, self._get_cluster_name()) | python | def create_role(self, role_name, role_type, host_id):
return roles.create_role(self._get_resource_root(), self.name, role_type,
role_name, host_id, self._get_cluster_name()) | [
"def",
"create_role",
"(",
"self",
",",
"role_name",
",",
"role_type",
",",
"host_id",
")",
":",
"return",
"roles",
".",
"create_role",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"role_type",
",",
"role_name",
",",
"... | Create a role.
@param role_name: Role name
@param role_type: Role type
@param host_id: ID of the host to assign the role to
@return: An ApiRole object | [
"Create",
"a",
"role",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L578-L588 |
232,792 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.delete_role | def delete_role(self, name):
"""
Delete a role by name.
@param name: Role name
@return: The deleted ApiRole object
"""
return roles.delete_role(self._get_resource_root(), self.name, name,
self._get_cluster_name()) | python | def delete_role(self, name):
return roles.delete_role(self._get_resource_root(), self.name, name,
self._get_cluster_name()) | [
"def",
"delete_role",
"(",
"self",
",",
"name",
")",
":",
"return",
"roles",
".",
"delete_role",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"name",
",",
"self",
".",
"_get_cluster_name",
"(",
")",
")"
] | Delete a role by name.
@param name: Role name
@return: The deleted ApiRole object | [
"Delete",
"a",
"role",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L590-L598 |
232,793 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_role | def get_role(self, name):
"""
Lookup a role by name.
@param name: Role name
@return: An ApiRole object
"""
return roles.get_role(self._get_resource_root(), self.name, name,
self._get_cluster_name()) | python | def get_role(self, name):
return roles.get_role(self._get_resource_root(), self.name, name,
self._get_cluster_name()) | [
"def",
"get_role",
"(",
"self",
",",
"name",
")",
":",
"return",
"roles",
".",
"get_role",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"name",
",",
"self",
".",
"_get_cluster_name",
"(",
")",
")"
] | Lookup a role by name.
@param name: Role name
@return: An ApiRole object | [
"Lookup",
"a",
"role",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L600-L608 |
232,794 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_all_roles | def get_all_roles(self, view = None):
"""
Get all roles in the service.
@param view: View to materialize ('full' or 'summary')
@return: A list of ApiRole objects.
"""
return roles.get_all_roles(self._get_resource_root(), self.name,
self._get_cluster_name(), view) | python | def get_all_roles(self, view = None):
return roles.get_all_roles(self._get_resource_root(), self.name,
self._get_cluster_name(), view) | [
"def",
"get_all_roles",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"return",
"roles",
".",
"get_all_roles",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"self",
".",
"_get_cluster_name",
"(",
")",
",",
"view",
... | Get all roles in the service.
@param view: View to materialize ('full' or 'summary')
@return: A list of ApiRole objects. | [
"Get",
"all",
"roles",
"in",
"the",
"service",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L610-L618 |
232,795 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_roles_by_type | def get_roles_by_type(self, role_type, view = None):
"""
Get all roles of a certain type in a service.
@param role_type: Role type
@param view: View to materialize ('full' or 'summary')
@return: A list of ApiRole objects.
"""
return roles.get_roles_by_type(self._get_resource_root(), self.name,
role_type, self._get_cluster_name(), view) | python | def get_roles_by_type(self, role_type, view = None):
return roles.get_roles_by_type(self._get_resource_root(), self.name,
role_type, self._get_cluster_name(), view) | [
"def",
"get_roles_by_type",
"(",
"self",
",",
"role_type",
",",
"view",
"=",
"None",
")",
":",
"return",
"roles",
".",
"get_roles_by_type",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"role_type",
",",
"self",
".",
"_... | Get all roles of a certain type in a service.
@param role_type: Role type
@param view: View to materialize ('full' or 'summary')
@return: A list of ApiRole objects. | [
"Get",
"all",
"roles",
"of",
"a",
"certain",
"type",
"in",
"a",
"service",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L620-L629 |
232,796 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_role_types | def get_role_types(self):
"""
Get a list of role types in a service.
@return: A list of role types (strings)
"""
resp = self._get_resource_root().get(self._path() + '/roleTypes')
return resp[ApiList.LIST_KEY] | python | def get_role_types(self):
resp = self._get_resource_root().get(self._path() + '/roleTypes')
return resp[ApiList.LIST_KEY] | [
"def",
"get_role_types",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_get_resource_root",
"(",
")",
".",
"get",
"(",
"self",
".",
"_path",
"(",
")",
"+",
"'/roleTypes'",
")",
"return",
"resp",
"[",
"ApiList",
".",
"LIST_KEY",
"]"
] | Get a list of role types in a service.
@return: A list of role types (strings) | [
"Get",
"a",
"list",
"of",
"role",
"types",
"in",
"a",
"service",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L631-L638 |
232,797 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_all_role_config_groups | def get_all_role_config_groups(self):
"""
Get a list of role configuration groups in the service.
@return: A list of ApiRoleConfigGroup objects.
@since: API v3
"""
return role_config_groups.get_all_role_config_groups(
self._get_resource_root(), self.name, self._get_cluster_name()) | python | def get_all_role_config_groups(self):
return role_config_groups.get_all_role_config_groups(
self._get_resource_root(), self.name, self._get_cluster_name()) | [
"def",
"get_all_role_config_groups",
"(",
"self",
")",
":",
"return",
"role_config_groups",
".",
"get_all_role_config_groups",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"self",
".",
"_get_cluster_name",
"(",
")",
")"
] | Get a list of role configuration groups in the service.
@return: A list of ApiRoleConfigGroup objects.
@since: API v3 | [
"Get",
"a",
"list",
"of",
"role",
"configuration",
"groups",
"in",
"the",
"service",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L640-L648 |
232,798 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.get_role_config_group | def get_role_config_group(self, name):
"""
Get a role configuration group in the service by name.
@param name: The name of the role config group.
@return: An ApiRoleConfigGroup object.
@since: API v3
"""
return role_config_groups.get_role_config_group(
self._get_resource_root(), self.name, name, self._get_cluster_name()) | python | def get_role_config_group(self, name):
return role_config_groups.get_role_config_group(
self._get_resource_root(), self.name, name, self._get_cluster_name()) | [
"def",
"get_role_config_group",
"(",
"self",
",",
"name",
")",
":",
"return",
"role_config_groups",
".",
"get_role_config_group",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"name",
",",
"self",
".",
"_get_cluster_name",
"(... | Get a role configuration group in the service by name.
@param name: The name of the role config group.
@return: An ApiRoleConfigGroup object.
@since: API v3 | [
"Get",
"a",
"role",
"configuration",
"group",
"in",
"the",
"service",
"by",
"name",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L650-L659 |
232,799 | cloudera/cm_api | python/src/cm_api/endpoints/services.py | ApiService.update_role_config_group | def update_role_config_group(self, name, apigroup):
"""
Update a role config group.
@param name: Role config group name.
@param apigroup: The updated role config group.
@return: The updated ApiRoleConfigGroup object.
@since: API v3
"""
return role_config_groups.update_role_config_group(
self._get_resource_root(), self.name, name, apigroup,
self._get_cluster_name()) | python | def update_role_config_group(self, name, apigroup):
return role_config_groups.update_role_config_group(
self._get_resource_root(), self.name, name, apigroup,
self._get_cluster_name()) | [
"def",
"update_role_config_group",
"(",
"self",
",",
"name",
",",
"apigroup",
")",
":",
"return",
"role_config_groups",
".",
"update_role_config_group",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"name",
",",
"apigroup",
"... | Update a role config group.
@param name: Role config group name.
@param apigroup: The updated role config group.
@return: The updated ApiRoleConfigGroup object.
@since: API v3 | [
"Update",
"a",
"role",
"config",
"group",
"."
] | 5d2512375bd94684b4da36df9e0d9177865ffcbb | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L675-L686 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.