Documentation ¶
Overview ¶
The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs.
Index ¶
- type CreateTokenRequest
- type CreateTokenResponse
- type ListTokensResponse
- type PublicTokenInfo
- type RevokeTokenRequest
- type TokensAPI
- func (a *TokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error)
- func (a *TokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) error
- func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error
- func (a *TokensAPI) GetByComment(ctx context.Context, name string) (*PublicTokenInfo, error)
- func (a *TokensAPI) Impl() TokensService
- func (a *TokensAPI) ListAll(ctx context.Context) ([]PublicTokenInfo, error)
- func (a *TokensAPI) PublicTokenInfoCommentToTokenIdMap(ctx context.Context) (map[string]string, error)
- func (a *TokensAPI) WithImpl(impl TokensService) *TokensAPI
- type TokensService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateTokenRequest ¶
type CreateTokenRequest struct { // Optional description to attach to the token. Comment string `json:"comment,omitempty"` // The lifetime of the token, in seconds. // // If the ifetime is not specified, this token remains valid indefinitely. LifetimeSeconds int64 `json:"lifetime_seconds,omitempty"` }
type CreateTokenResponse ¶
type CreateTokenResponse struct { // The information for the new token. TokenInfo *PublicTokenInfo `json:"token_info,omitempty"` // The value of the new token. TokenValue string `json:"token_value,omitempty"` }
type ListTokensResponse ¶
type ListTokensResponse struct { // The information for each token. TokenInfos []PublicTokenInfo `json:"token_infos,omitempty"` }
type PublicTokenInfo ¶
type PublicTokenInfo struct { // Comment the token was created with, if applicable. Comment string `json:"comment,omitempty"` // Server time (in epoch milliseconds) when the token was created. CreationTime int64 `json:"creation_time,omitempty"` // Server time (in epoch milliseconds) when the token will expire, or -1 if // not applicable. ExpiryTime int64 `json:"expiry_time,omitempty"` // The ID of this token. TokenId string `json:"token_id,omitempty"` }
type RevokeTokenRequest ¶
type RevokeTokenRequest struct { // The ID of the token to be revoked. TokenId string `json:"token_id"` }
type TokensAPI ¶
type TokensAPI struct {
// contains filtered or unexported fields
}
The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs.
func NewTokens ¶
func NewTokens(client *client.DatabricksClient) *TokensAPI
func (*TokensAPI) Create ¶
func (a *TokensAPI) Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error)
Create a user token.
Creates and returns a token for a user. If this call is made through token authentication, it creates a token with the same client ID as the authenticated token. If the user's token quota is exceeded, this call returns an error **QUOTA_EXCEEDED**.
func (*TokensAPI) Delete ¶
func (a *TokensAPI) Delete(ctx context.Context, request RevokeTokenRequest) error
Revoke token.
Revokes an access token.
If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**.
func (*TokensAPI) DeleteByTokenId ¶
Revoke token.
Revokes an access token.
If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**.
func (*TokensAPI) GetByComment ¶
GetByComment calls TokensAPI.PublicTokenInfoCommentToTokenIdMap and returns a single PublicTokenInfo.
Returns an error if there's more than one PublicTokenInfo with the same .Comment.
Note: All PublicTokenInfo instances are loaded into memory before returning matching by name.
This method is generated by Databricks SDK Code Generator.
func (*TokensAPI) Impl ¶
func (a *TokensAPI) Impl() TokensService
Impl returns low-level Tokens API implementation
func (*TokensAPI) ListAll ¶
func (a *TokensAPI) ListAll(ctx context.Context) ([]PublicTokenInfo, error)
List tokens.
Lists all the valid tokens for a user-workspace pair.
This method is generated by Databricks SDK Code Generator.
func (*TokensAPI) PublicTokenInfoCommentToTokenIdMap ¶
func (a *TokensAPI) PublicTokenInfoCommentToTokenIdMap(ctx context.Context) (map[string]string, error)
PublicTokenInfoCommentToTokenIdMap calls TokensAPI.ListAll and creates a map of results with PublicTokenInfo.Comment as key and PublicTokenInfo.TokenId as value.
Returns an error if there's more than one PublicTokenInfo with the same .Comment.
Note: All PublicTokenInfo instances are loaded into memory before creating a map.
This method is generated by Databricks SDK Code Generator.
func (*TokensAPI) WithImpl ¶
func (a *TokensAPI) WithImpl(impl TokensService) *TokensAPI
WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.
type TokensService ¶
type TokensService interface { // Create a user token. // // Creates and returns a token for a user. If this call is made through // token authentication, it creates a token with the same client ID as the // authenticated token. If the user's token quota is exceeded, this call // returns an error **QUOTA_EXCEEDED**. Create(ctx context.Context, request CreateTokenRequest) (*CreateTokenResponse, error) // Revoke token. // // Revokes an access token. // // If a token with the specified ID is not valid, this call returns an error // **RESOURCE_DOES_NOT_EXIST**. Delete(ctx context.Context, request RevokeTokenRequest) error // List tokens. // // Lists all the valid tokens for a user-workspace pair. // // Use ListAll() to get all PublicTokenInfo instances List(ctx context.Context) (*ListTokensResponse, error) }
The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs.