def get_cli(api_client, policy_id): """ Retrieves metadata about a cluster policy. """ click.echo( pretty_format( ClusterPolicyApi(api_client).get_cluster_policy(policy_id)))
def delete_cli(api_client, policy_id): """ Removes a Databricks cluster policy given its ID. Use ``databricks cluster_olicies get --policy-id POLICY_ID`` to check termination states. """ ClusterPolicyApi(api_client).delete_cluster_policy(policy_id)
def create_cli(api_client, json_file, json): """ Creates a Databricks cluster Policy. The specification for the request json can be found at https://docs.databricks.com/dev-tools/api/latest/policies.html#create """ json_cli_base( json_file, json, lambda json: ClusterPolicyApi(api_client).create_cluster_policy(json))
def edit_cli(api_client, json_file, json): """ Edits a Databricks cluster Policy. The specification for the request json can be found at https://docs.databricks.com/dev-tools/api/latest/policies.html#edit """ if not bool(json_file) ^ bool(json): raise RuntimeError('Either --json-file or --json should be provided') if json_file: with open(json_file, 'r') as f: json = f.read() deser_json = json_loads(json) ClusterPolicyApi(api_client).edit_cluster_policy(deser_json)
def list_cli(api_client, output): """ Lists cluster olicies. Returns information about all currently cluster olicies. By default the output format will be a human readable table with the following fields - Policy ID - Policy Name - Policy Definition """ policies_json = ClusterPolicyApi(api_client).list_cluster_policies() if OutputClickType.is_json(output): click.echo(pretty_format(policies_json)) else: click.echo( tabulate(_cluster_policies_to_table(policies_json), tablefmt='plain'))