clusterpolicies

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

These APIs allow you to manage Cluster Policies, Policy Families, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterPoliciesAPI

type ClusterPoliciesAPI struct {
	// contains filtered or unexported fields
}

Cluster policy limits the ability to configure clusters based on a set of rules. The policy rules limit the attributes or attribute values available for cluster creation. Cluster policies have ACLs that limit their use to specific users and groups.

Cluster policies let you limit users to create clusters with prescribed settings, simplify the user interface and enable more users to create their own clusters (by fixing and hiding some values), control cost by limiting per cluster maximum cost (by setting limits on attributes whose values contribute to hourly price).

Cluster policy permissions limit which policies a user can select in the Policy drop-down when the user creates a cluster: - A user who has cluster create permission can select the Unrestricted policy and create fully-configurable clusters. - A user who has both cluster create permission and access to cluster policies can select the Unrestricted policy and policies they have access to. - A user that has access to only cluster policies, can select the policies they have access to.

If no policies have been created in the workspace, the Policy drop-down does not display.

Only admin users can create, edit, and delete policies. Admin users also have access to all policies.

func NewClusterPolicies

func NewClusterPolicies(client *client.DatabricksClient) *ClusterPoliciesAPI

func (*ClusterPoliciesAPI) Create

Create a new policy.

Creates a new policy with prescribed settings.

func (*ClusterPoliciesAPI) Delete

func (a *ClusterPoliciesAPI) Delete(ctx context.Context, request DeletePolicy) error

Delete a cluster policy.

Delete a policy for a cluster. Clusters governed by this policy can still run, but cannot be edited.

func (*ClusterPoliciesAPI) DeleteByPolicyId

func (a *ClusterPoliciesAPI) DeleteByPolicyId(ctx context.Context, policyId string) error

Delete a cluster policy.

Delete a policy for a cluster. Clusters governed by this policy can still run, but cannot be edited.

func (*ClusterPoliciesAPI) Edit

func (a *ClusterPoliciesAPI) Edit(ctx context.Context, request EditPolicy) error

Update a cluster policy.

Update an existing policy for cluster. This operation may make some clusters governed by the previous policy invalid.

func (*ClusterPoliciesAPI) Get

func (a *ClusterPoliciesAPI) Get(ctx context.Context, request Get) (*Policy, error)

Get entity.

Get a cluster policy entity. Creation and editing is available to admins only.

func (*ClusterPoliciesAPI) GetByName

func (a *ClusterPoliciesAPI) GetByName(ctx context.Context, name string) (*Policy, error)

GetByName calls ClusterPoliciesAPI.PolicyNameToPolicyIdMap and returns a single Policy.

Returns an error if there's more than one Policy with the same .Name.

Note: All Policy instances are loaded into memory before returning matching by name.

This method is generated by Databricks SDK Code Generator.

func (*ClusterPoliciesAPI) GetByPolicyId

func (a *ClusterPoliciesAPI) GetByPolicyId(ctx context.Context, policyId string) (*Policy, error)

Get entity.

Get a cluster policy entity. Creation and editing is available to admins only.

func (*ClusterPoliciesAPI) Impl

Impl returns low-level ClusterPolicies API implementation

func (*ClusterPoliciesAPI) ListAll

func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request List) ([]Policy, error)

Get a cluster policy.

Returns a list of policies accessible by the requesting user.

This method is generated by Databricks SDK Code Generator.

func (*ClusterPoliciesAPI) PolicyNameToPolicyIdMap

func (a *ClusterPoliciesAPI) PolicyNameToPolicyIdMap(ctx context.Context, request List) (map[string]string, error)

PolicyNameToPolicyIdMap calls ClusterPoliciesAPI.ListAll and creates a map of results with Policy.Name as key and Policy.PolicyId as value.

Returns an error if there's more than one Policy with the same .Name.

Note: All Policy instances are loaded into memory before creating a map.

This method is generated by Databricks SDK Code Generator.

func (*ClusterPoliciesAPI) WithImpl

WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.

type ClusterPoliciesService

type ClusterPoliciesService interface {

	// Create a new policy.
	//
	// Creates a new policy with prescribed settings.
	Create(ctx context.Context, request CreatePolicy) (*CreatePolicyResponse, error)

	// Delete a cluster policy.
	//
	// Delete a policy for a cluster. Clusters governed by this policy can still
	// run, but cannot be edited.
	Delete(ctx context.Context, request DeletePolicy) error

	// Update a cluster policy.
	//
	// Update an existing policy for cluster. This operation may make some
	// clusters governed by the previous policy invalid.
	Edit(ctx context.Context, request EditPolicy) error

	// Get entity.
	//
	// Get a cluster policy entity. Creation and editing is available to admins
	// only.
	Get(ctx context.Context, request Get) (*Policy, error)

	// Get a cluster policy.
	//
	// Returns a list of policies accessible by the requesting user.
	//
	// Use ListAll() to get all Policy instances
	List(ctx context.Context, request List) (*ListPoliciesResponse, error)
}

Cluster policy limits the ability to configure clusters based on a set of rules. The policy rules limit the attributes or attribute values available for cluster creation. Cluster policies have ACLs that limit their use to specific users and groups.

Cluster policies let you limit users to create clusters with prescribed settings, simplify the user interface and enable more users to create their own clusters (by fixing and hiding some values), control cost by limiting per cluster maximum cost (by setting limits on attributes whose values contribute to hourly price).

Cluster policy permissions limit which policies a user can select in the Policy drop-down when the user creates a cluster: - A user who has cluster create permission can select the Unrestricted policy and create fully-configurable clusters. - A user who has both cluster create permission and access to cluster policies can select the Unrestricted policy and policies they have access to. - A user that has access to only cluster policies, can select the policies they have access to.

If no policies have been created in the workspace, the Policy drop-down does not display.

Only admin users can create, edit, and delete policies. Admin users also have access to all policies.

type CreatePolicy

type CreatePolicy struct {
	// Policy definition document expressed in Databricks Cluster Policy
	// Definition Language.
	Definition string `json:"definition,omitempty"`
	// Additional human-readable description of the cluster policy.
	Description string `json:"description,omitempty"`
	// Max number of clusters per user that can be active using this policy. If
	// not present, there is no max limit.
	MaxClustersPerUser int64 `json:"max_clusters_per_user,omitempty"`
	// Cluster Policy name requested by the user. This has to be unique. Length
	// must be between 1 and 100 characters.
	Name string `json:"name"`
	// Policy definition JSON document expressed in Databricks Policy Definition
	// Language. The JSON document must be passed as a string and cannot be
	// embedded in the requests.
	//
	// You can use this to customize the policy definition inherited from the
	// policy family. Policy rules specified here are merged into the inherited
	// policy definition.
	PolicyFamilyDefinitionOverrides string `json:"policy_family_definition_overrides,omitempty"`
	// ID of the policy family. The cluster policy's policy definition inherits
	// the policy family's policy definition.
	//
	// Cannot be used with `definition`. Use
	// `policy_family_definition_overrides` instead to customize the policy
	// definition.
	PolicyFamilyId string `json:"policy_family_id,omitempty"`
}

type CreatePolicyResponse

type CreatePolicyResponse struct {
	// Canonical unique identifier for the cluster policy.
	PolicyId string `json:"policy_id,omitempty"`
}

type DeletePolicy

type DeletePolicy struct {
	// The ID of the policy to delete.
	PolicyId string `json:"policy_id"`
}

type EditPolicy

type EditPolicy struct {
	// Policy definition document expressed in Databricks Cluster Policy
	// Definition Language.
	Definition string `json:"definition,omitempty"`
	// Additional human-readable description of the cluster policy.
	Description string `json:"description,omitempty"`
	// Max number of clusters per user that can be active using this policy. If
	// not present, there is no max limit.
	MaxClustersPerUser int64 `json:"max_clusters_per_user,omitempty"`
	// Cluster Policy name requested by the user. This has to be unique. Length
	// must be between 1 and 100 characters.
	Name string `json:"name"`
	// Policy definition JSON document expressed in Databricks Policy Definition
	// Language. The JSON document must be passed as a string and cannot be
	// embedded in the requests.
	//
	// You can use this to customize the policy definition inherited from the
	// policy family. Policy rules specified here are merged into the inherited
	// policy definition.
	PolicyFamilyDefinitionOverrides string `json:"policy_family_definition_overrides,omitempty"`
	// ID of the policy family. The cluster policy's policy definition inherits
	// the policy family's policy definition.
	//
	// Cannot be used with `definition`. Use
	// `policy_family_definition_overrides` instead to customize the policy
	// definition.
	PolicyFamilyId string `json:"policy_family_id,omitempty"`
	// The ID of the policy to update.
	PolicyId string `json:"policy_id"`
}

type Get

type Get struct {
	// Canonical unique identifier for the cluster policy.
	PolicyId string `json:"-" url:"policy_id"`
}

Get entity

type GetPolicyFamilyRequest added in v0.2.0

type GetPolicyFamilyRequest struct {
	PolicyFamilyId string `json:"-" url:"-"`
}

type List added in v0.2.0

type List struct {
	// The cluster policy attribute to sort by. * `POLICY_CREATION_TIME` - Sort
	// result list by policy creation time. * `POLICY_NAME` - Sort result list
	// by policy name.
	SortColumn ListSortColumn `json:"-" url:"sort_column,omitempty"`
	// The order in which the policies get listed. * `DESC` - Sort result list
	// in descending order. * `ASC` - Sort result list in ascending order.
	SortOrder ListSortOrder `json:"-" url:"sort_order,omitempty"`
}

Get a cluster policy

type ListPoliciesResponse

type ListPoliciesResponse struct {
	// List of policies.
	Policies []Policy `json:"policies,omitempty"`
}

type ListPolicyFamiliesRequest added in v0.2.0

type ListPolicyFamiliesRequest struct {
	// The max number of policy families to return.
	MaxResults int64 `json:"-" url:"max_results,omitempty"`
	// A token that can be used to get the next page of results.
	PageToken string `json:"-" url:"page_token,omitempty"`
}

type ListPolicyFamiliesResponse added in v0.2.0

type ListPolicyFamiliesResponse struct {
	// A token that can be used to get the next page of results. If not present,
	// there are no more results to show.
	NextPageToken string `json:"next_page_token,omitempty"`
	// List of policy families.
	PolicyFamilies []PolicyFamily `json:"policy_families"`
}

type ListSortColumn added in v0.2.0

type ListSortColumn string
const ListSortColumnPolicyCreationTime ListSortColumn = `POLICY_CREATION_TIME`
const ListSortColumnPolicyName ListSortColumn = `POLICY_NAME`

func (*ListSortColumn) Set added in v0.2.0

func (lsc *ListSortColumn) Set(v string) error

Set raw string value and validate it against allowed values

func (*ListSortColumn) String added in v0.2.0

func (lsc *ListSortColumn) String() string

String representation for fmt.Print

func (*ListSortColumn) Type added in v0.2.0

func (lsc *ListSortColumn) Type() string

Type always returns ListSortColumn to satisfy [pflag.Value] interface

type ListSortOrder added in v0.2.0

type ListSortOrder string
const ListSortOrderAsc ListSortOrder = `ASC`
const ListSortOrderDesc ListSortOrder = `DESC`

func (*ListSortOrder) Set added in v0.2.0

func (lso *ListSortOrder) Set(v string) error

Set raw string value and validate it against allowed values

func (*ListSortOrder) String added in v0.2.0

func (lso *ListSortOrder) String() string

String representation for fmt.Print

func (*ListSortOrder) Type added in v0.2.0

func (lso *ListSortOrder) Type() string

Type always returns ListSortOrder to satisfy [pflag.Value] interface

type Policy

type Policy struct {
	// Creation time. The timestamp (in millisecond) when this Cluster Policy
	// was created.
	CreatedAtTimestamp int64 `json:"created_at_timestamp,omitempty"`
	// Creator user name. The field won't be included in the response if the
	// user has already been deleted.
	CreatorUserName string `json:"creator_user_name,omitempty"`
	// Policy definition document expressed in Databricks Cluster Policy
	// Definition Language.
	Definition string `json:"definition,omitempty"`
	// Additional human-readable description of the cluster policy.
	Description string `json:"description,omitempty"`
	// If true, policy is a default policy created and managed by Databricks.
	// Default policies cannot be deleted, and their policy families cannot be
	// changed.
	IsDefault bool `json:"is_default,omitempty"`
	// Max number of clusters per user that can be active using this policy. If
	// not present, there is no max limit.
	MaxClustersPerUser int64 `json:"max_clusters_per_user,omitempty"`
	// Cluster Policy name requested by the user. This has to be unique. Length
	// must be between 1 and 100 characters.
	Name string `json:"name,omitempty"`
	// Policy definition JSON document expressed in Databricks Policy Definition
	// Language. The JSON document must be passed as a string and cannot be
	// embedded in the requests.
	//
	// You can use this to customize the policy definition inherited from the
	// policy family. Policy rules specified here are merged into the inherited
	// policy definition.
	PolicyFamilyDefinitionOverrides string `json:"policy_family_definition_overrides,omitempty"`
	// ID of the policy family.
	PolicyFamilyId string `json:"policy_family_id,omitempty"`
	// Canonical unique identifier for the Cluster Policy.
	PolicyId string `json:"policy_id,omitempty"`
}

type PolicyFamiliesAPI added in v0.2.0

type PolicyFamiliesAPI struct {
	// contains filtered or unexported fields
}

View available policy families. A policy family contains a policy definition providing best practices for configuring clusters for a particular use case.

Databricks manages and provides policy families for several common cluster use cases. You cannot create, edit, or delete policy families.

Policy families cannot be used directly to create clusters. Instead, you create cluster policies using a policy family. Cluster policies created using a policy family inherit the policy family's policy definition.

func NewPolicyFamilies added in v0.2.0

func NewPolicyFamilies(client *client.DatabricksClient) *PolicyFamiliesAPI

func (*PolicyFamiliesAPI) Get added in v0.2.0

func (*PolicyFamiliesAPI) GetByPolicyFamilyId added in v0.2.0

func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamilyId string) (*PolicyFamily, error)

func (*PolicyFamiliesAPI) Impl added in v0.2.0

Impl returns low-level PolicyFamilies API implementation

func (*PolicyFamiliesAPI) ListAll added in v0.2.0

This method is generated by Databricks SDK Code Generator.

func (*PolicyFamiliesAPI) WithImpl added in v0.2.0

WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.

type PolicyFamiliesService added in v0.2.0

type PolicyFamiliesService interface {
	Get(ctx context.Context, request GetPolicyFamilyRequest) (*PolicyFamily, error)

	//
	// Use ListAll() to get all PolicyFamily instances, which will iterate over every result page.
	List(ctx context.Context, request ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error)
}

View available policy families. A policy family contains a policy definition providing best practices for configuring clusters for a particular use case.

Databricks manages and provides policy families for several common cluster use cases. You cannot create, edit, or delete policy families.

Policy families cannot be used directly to create clusters. Instead, you create cluster policies using a policy family. Cluster policies created using a policy family inherit the policy family's policy definition.

type PolicyFamily added in v0.2.0

type PolicyFamily struct {
	// Policy definition document expressed in Databricks Cluster Policy
	// Definition Language.
	Definition string `json:"definition"`
	// Human-readable description of the purpose of the policy family.
	Description string `json:"description"`
	// Name of the policy family.
	Name string `json:"name"`
	// ID of the policy family.
	PolicyFamilyId string `json:"policy_family_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL