The following are the classes that are part of the lscsde-workspace-mgmt python package

datasourcebindingclient

AnalyticsDataSourceBindingClient Objects

class AnalyticsDataSourceBindingClient(KubernetesNamespacedCustomClient)

This class allows developers to interact with AnalyticsDataSourceBinding objects on kubernetes

get

async def get(namespace, name)

Gets an individual AnalyticsDataSourceBinding

list

async def list(namespace, **kwargs)

Lists the AnalyticsDataSourceBindings in a specified namespace

list_by_workspace

async def list_by_workspace(namespace, workspace)

Lists the AnalyticsDataSourceBindings in a specified namespace which belong to a specific workspace

If a binding does not have the relevant labels defined, the service will assign the label automatically based upon the workspace. This makes the query more performant when querying etcd.

create

async def create(body: AnalyticsDataSourceBinding, append_label: bool = True)

Creates a AnalyticsDataSourceBinding resource

patch

async def patch(namespace: str = None,
                name: str = None,
                patch_body: dict = None,
                body: AnalyticsDataSourceBinding = None)

Patches a AnalyticsDataSourceBinding resource

patch_status

async def patch_status(namespace: str, name: str,
                       status: AnalyticsDataSourceBindingStatus)

Patches a AnalyticsDataSourceBinding resources status segment

replace

async def replace(body: AnalyticsDataSourceBinding, append_label: bool = True)

Replaces a AnalyticsDataSourceBinding resource with the one provided

delete

async def delete(body: AnalyticsDataSourceBinding = None,
                 namespace: str = None,
                 name: str = None)

Deletes a AnalyticsDataSourceBinding resource

k8sio

eventclient

EventClient Objects

class EventClient()

A class for interacting with Events objects in kubernetes

RegisterWorkspaceEvent

async def RegisterWorkspaceEvent(workspace: AnalyticsWorkspace, reason: str,
                                 note: str)

Records a workspace event

RegisterWorkspaceBindingEvent

async def RegisterWorkspaceBindingEvent(binding: AnalyticsWorkspaceBinding,
                                        reason: str, note: str)

Records a workspace binding event

RegisterDataSourceEvent

async def RegisterDataSourceEvent(datasource: AnalyticsDataSource, reason: str,
                                  note: str)

Records a datasource event

RegisterDataSourceBindingEvent

async def RegisterDataSourceBindingEvent(binding: AnalyticsDataSourceBinding,
                                         reason: str, note: str)

Records a datasource binding event

WorkspaceCreated

async def WorkspaceCreated(workspace: AnalyticsWorkspace, note: str = None)

Records a workspace was created

WorkspaceUpdated

async def WorkspaceUpdated(workspace: AnalyticsWorkspace, note: str = None)

Records a workspace was updates

WorkspaceDeleted

async def WorkspaceDeleted(workspace: AnalyticsWorkspace, note: str = None)

Records a workspace was deleted

WorkspaceBindingCreated

async def WorkspaceBindingCreated(binding: AnalyticsWorkspaceBinding,
                                  note: str = None)

Records a workspace binding was created

WorkspaceBindingUpdated

async def WorkspaceBindingUpdated(binding: AnalyticsWorkspaceBinding,
                                  note: str = None)

Records a workspace binding was updated

WorkspaceBindingDeleted

async def WorkspaceBindingDeleted(binding: AnalyticsWorkspaceBinding,
                                  note: str = None)

Records a workspace binding was deleted

DataSourceCreated

async def DataSourceCreated(datasource: AnalyticsDataSource, note: str = None)

Records a data source was created

DataSourceUpdated

async def DataSourceUpdated(datasource: AnalyticsDataSource, note: str = None)

Records a data source was updated

DataSourceDeleted

async def DataSourceDeleted(datasource: AnalyticsDataSource, note: str = None)

Records a data source was deleted

DataSourceBindingCreated

async def DataSourceBindingCreated(binding: AnalyticsDataSourceBinding,
                                   note: str = None)

Records a data source binding was created

DataSourceBindingUpdated

async def DataSourceBindingUpdated(binding: AnalyticsDataSourceBinding,
                                   note: str = None)

Records a data source binding was updated

DataSourceBindingDeleted

async def DataSourceBindingDeleted(binding: AnalyticsDataSourceBinding,
                                   note: str = None)

Records a data source binding was deleted

exceptions

NoAssignedValidWorkspaces Objects

class NoAssignedValidWorkspaces(Exception)

Represents an error where a user is not assigned any valid workspaces

WorkspaceNotFoundException Objects

class WorkspaceNotFoundException(Exception)

Represents an exception where a workspace is not found in the labels from jupyterhub

__init__

workspaceclient

AnalyticsWorkspaceClient Objects

class AnalyticsWorkspaceClient(KubernetesNamespacedCustomClient)

Client for interacting with AnalyticsWorkspacess

get

async def get(namespace, name)

Gets a specific AnalyticsWorkspace resource

list

async def list(namespace, **kwargs)

Lists AnalyticsWorkspace resources in the namespace supplied

list_by_username

async def list_by_username(binding_client: AnalyticsWorkspaceBindingClient,
                           namespace: str, username: str)

Lists AnalyticsWorkspace resources in the namespace supplied that match the username

create

async def create(body: AnalyticsWorkspace)

Creates a AnalyticsWorkspace resource in the namespace supplied

patch

async def patch(namespace: str = None,
                name: str = None,
                patch_body: dict = None,
                body: AnalyticsWorkspace = None)

Patches a AnalyticsWorkspace resource in the namespace supplied

patch_status

async def patch_status(namespace: str, name: str,
                       status: AnalyticsWorkspaceStatus)

Patches the status of an AnalyticsWorkspace resource in the namespace supplied

replace

async def replace(body: AnalyticsWorkspace)

Replaces a AnalyticsWorkspace resource with the one supplied

delete

async def delete(body: AnalyticsWorkspace = None,
                 namespace: str = None,
                 name: str = None)

Deletes a AnalyticsWorkspace resource in the namespace supplied

pvclient

PersistentVolumeClaimClient Objects

class PersistentVolumeClaimClient()

Client used for interacting with PersistentVolumeClaim resources in kubernetes

get

async def get(name: str, namespace: str) -> V1PersistentVolumeClaim

Gets a specific PVC

create_if_not_exists

async def create_if_not_exists(name: str,
                               namespace: str,
                               storage_class_name: str = None,
                               labels: dict[str, str] = {},
                               access_modes: list[str] = None,
                               storage_requested: str = None)

Create a specific PVC if it doesn’t already exist

mount

async def mount(pod: V1Pod,
                storage_name: str,
                namespace: str,
                storage_class_name: str,
                mount_path: str,
                read_only: bool = False) -> V1Pod

mounts a PVC into a pod

managers

AnalyticsDataSourceManager Objects

class AnalyticsDataSourceManager()

creates a manager for Analytics Data sources, their associated bindings, events and pvc’s.

AnalyticsWorkspaceManager Objects

class AnalyticsWorkspaceManager()

creates a manager for Analytics Workspaces, their associated bindings, events and pvc’s.

get_workspaces_for_user

async def get_workspaces_for_user(namespace: str, username: str)

Gets a workspace for a user

get_permitted_workspaces

async def get_permitted_workspaces(namespace: str,
                                   username: str,
                                   date_now=datetime.today())

Gets the workspaces that are permitted for a user

mount_workspace

async def mount_workspace(pod: V1Pod,
                          storage_class_name,
                          mount_prefix,
                          storage_prefix: str = "",
                          read_only: bool = False,
                          mount_path="")

Mounts the workspace persistent volume claims

AnalyticsManager Objects

class AnalyticsManager()

A high level manager for both workspace and datasource

namespacedclient

KubernetesNamespacedCustomClient Objects

class KubernetesNamespacedCustomClient()

Represents a namespaced client for interacting with kubernetes objects

get_api_version

def get_api_version()

Gets the API version

get

async def get(namespace, name)

Gets the requested resource

list

async def list(namespace, **kwargs)

Lists the requested resources

patch

async def patch(namespace: str, name: str, body: dict)

Patches the requested resource

patch_status

async def patch_status(namespace: str, name: str, body: dict)

Patches the status of the requested resource

replace

async def replace(namespace: str, name: str, body: dict)

Replaces the requested resource with the one supplied

create

async def create(namespace: str, body: dict)

Creates the requested resource

delete

async def delete(namespace: str, name: str)

Deletes the requested resource

objects

AnalyticsWorkspaceConverter Objects

class AnalyticsWorkspaceConverter()

The converter allows us to perform operations against an analytics workspace to convert them for use in other platforms

days_until_expiry

def days_until_expiry(time_str, date_now=datetime.today())

Calculates the number of days until the workspace or workspace binding expires

to_workspace_dict

def to_workspace_dict(workspace: AnalyticsWorkspace,
                      date_now=datetime.today())

Converts the workspace to the dictionary used by kubespawner to create the pod resource

_version

datasourceclient

AnalyticsDataSourceClient Objects

class AnalyticsDataSourceClient(KubernetesNamespacedCustomClient)

This class allows developers to interact with AnalyticsDataSource objects on kubernetes

get

async def get(namespace, name)

Gets an individual AnalyticsDataSource

list

async def list(namespace, **kwargs)

Lists the AnalyticsDataSource in a specified namespace

list_by_workspace

async def list_by_workspace(binding_client: AnalyticsDataSourceBindingClient,
                            namespace: str, workspace: str)

Lists the AnalyticsDataSource in a specified namespace for the workspace specified

create

async def create(body: AnalyticsDataSource)

Creates a AnalyticsDataSource resource

patch

async def patch(namespace: str = None,
                name: str = None,
                patch_body: dict = None,
                body: AnalyticsDataSource = None)

Patches a AnalyticsDataSource resource

patch_status

async def patch_status(namespace: str, name: str,
                       status: AnalyticsDataSourceStatus)

Patches a AnalyticsDataSource resources status segment

replace

async def replace(body: AnalyticsDataSource)

Replaces a AnalyticsDataSource resource with the one provided

delete

async def delete(body: AnalyticsDataSource = None,
                 namespace: str = None,
                 name: str = None)

Deletes a AnalyticsDataSource resource

models

KubernetesHelper Objects

class KubernetesHelper()

A helper to help us interact with kubernetes as it would like

format_as_label

def format_as_label(username: str)

reformats a string to make it compatible for use in kubernetes label field

KubernetesMetadata Objects

class KubernetesMetadata(BaseModel)

A standard Kubernetes Metadata object

name

Name of the resource in kubernetes

namespace

Namespace that the resource is deployed to in kubernetes

annotations

A dictionary of any annotations assigned to the resource in kubernetes

labels

A dictionary of any labels assigned to the resource in kubernetes

resource_version

The version of the resource in kubernetes

AnalyticsWorkspaceValidity Objects

class AnalyticsWorkspaceValidity(BaseModel)

Represents the validity of the a workspace

https://lsc-sde.github.io/lsc-sde/imported/iac/helm/analytics-workspace-management/docs/Custom-Resources/AnalyticsWorkspaces.html#analyticsworkspacevalidity

available_from

The date that the workspace is valid from (in open API date format)

expires

The date that the workspace expires

VirtualMachineWorkspaceSpec Objects

class VirtualMachineWorkspaceSpec(BaseModel)

https://lsc-sde.github.io/lsc-sde/imported/iac/helm/analytics-workspace-management/docs/Custom-Resources/AnalyticsWorkspaces.html#analyticsworkspacevirtualmachine

max_hosts

The maximum number of hosts

JupyterWorkspaceStorage Objects

class JupyterWorkspaceStorage(BaseModel)

https://lsc-sde.github.io/lsc-sde/imported/iac/helm/analytics-workspace-management/docs/Custom-Resources/AnalyticsWorkspaces.html#analyticsworkspacejupyterworkspaceadditionalstorage

mount_path

The directory to mount this storage in the claim

persistent_volume_claim

The name of the persistent volume claim to apply

storage_class_name

The storage class name applied to the persistent volume claim (if it doesn’t already exist).

JupyterWorkspacePersistentVolumeClaim Objects

class JupyterWorkspacePersistentVolumeClaim(BaseModel)

https://lsc-sde.github.io/lsc-sde/imported/iac/helm/analytics-workspace-management/docs/Custom-Resources/AnalyticsWorkspaces.html#analyticsworkspacejupyterworkspacepersistentvolumeclaim

name

The name of the default persistent volume claim to associate with this workspace. If not populated, it will use the workspace name to generate a new name for the PVC automatically

storage_class_name

The name of the storage class to create the persistent volume claim. If not populated, it will default to the system default. This is only applied when a PVC is initially created, it is ignored otherwise.

JupyterWorkspaceSpecResources Objects

class JupyterWorkspaceSpecResources(TypedDict)

Represents the resources object on a jupyter workspace

TODO: This needs to be converted to use https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1ResourceRequirements.md

JupyterWorkspaceSpecNodeSelector Objects

class JupyterWorkspaceSpecNodeSelector(TypedDict)

Represents a node selector

TODO: Convert to a dict of strings of a jupyter workspace

JupyterWorkspaceSpecToleration Objects

class JupyterWorkspaceSpecToleration(BaseModel)

Represents a toleration property of a jupyter workspace

TODO: This needs to be converted to use https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Toleration.md

JupyterWorkspaceSpec Objects

class JupyterWorkspaceSpec(BaseModel)

Represents the jupyterWorkspace property

https://lsc-sde.github.io/lsc-sde/imported/iac/helm/analytics-workspace-management/docs/Custom-Resources/AnalyticsWorkspaces.html#analyticsworkspacejupyterworkspace

image

The image used when provisioning the pod created by jupyter hub

extra_labels

A map of labels to append to the pod created

default_uri

The URI that jupyter will use when the items are provisioned.

node_selector

A dictionary of node selector tags per the kubernetes documentation

tolerations

The pods tolerations.

resources

Describes the compute resource requirements.

Per https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1ResourceRequirements.md

additional_storage

A list of additional persistent volume claims to map to the pods created for this environment.

persistent_volume_claim

A description of the persistent volume claim provisioned for the workspace

AnalyticsWorkspaceStatus Objects

class AnalyticsWorkspaceStatus(BaseModel)

Represents the status field of the analyticsworkspace resource

status_text

A text field describing the current status of the workspace

persistent_volume_claim

The name of the assigned pvc for the workspace (if none provided)

additional_storage

A dictionary containing the name of the various additional storage associated with the workspace

AnalyticsWorkspaceBindingStatus Objects

class AnalyticsWorkspaceBindingStatus(BaseModel)

Represents the status field of the analyticsworkspacebinding resource

AnalyticsWorkspaceSpec Objects

class AnalyticsWorkspaceSpec(BaseModel)

Represents the spec segment of the analyticsworkspace resource

display_name

The short display name used as the title for the workspace.

description

A simple description which can be multiple lines describing the workspace

validity

An object describing variables which are validated to ensure that the workspace is still valid

jupyter_workspace

Represents a jupyter workspace

virtual_machine_workspace

This is not yet implemented, it is to test validation of the CRD is functioning correctly

AnalyticsWorkspaceBindingClaim Objects

class AnalyticsWorkspaceBindingClaim(BaseModel)

Represents the claims segment on a AnalyticsWorkspaceBinding resource

This has not yet been implemented

name

The name of the claim

operator

The operator to test against

value

The value to look for

AnalyticsWorkspaceBindingSpec Objects

class AnalyticsWorkspaceBindingSpec(BaseModel)

Represents the spec segment of an AnalyticsWorkspaceBinding resource

workspace

The name of the workspace in kubernetes.

It is assumed that the workspace will be located in the same namespace as the current binding

expires

The date at which this binding expires

username

The username to match

comments

Any comments relating to this binding.

claims

This is not yet implemented

username_as_label

def username_as_label()

Reads the username formatted as a kubernetes label

AnalyticsWorkspaceBinding Objects

class AnalyticsWorkspaceBinding(BaseModel)

Represents an AnalyticsWorkspaceBinding object

api_version

The API Version in kubernetes to use

kind

The Kind of object being defined

metadata

The metadata surrounding the resource

spec

The specification of the resource

status

The status of the resource

AnalyticsWorkspace Objects

class AnalyticsWorkspace(BaseModel)

Represents an AnalyticsWorkspace resource

api_version

The API Version in kubernetes to use

kind

The Kind of object being defined

metadata

The metadata surrounding the resource

spec

The specification of the resource

status

The status of the resource

AnalyticsDataSourcePublisherContact Objects

class AnalyticsDataSourcePublisherContact(BaseModel)

Represents the publisher contact of a datasource object

name

The name of the contact

role

The role of the contact

AnalyticsDataSourcePublisher Objects

class AnalyticsDataSourcePublisher(BaseModel)

Represents the publisher of a datasource object

organisation

The organisation publishing the resource

contact

The contact for the publisher of the resource

AnalyticsDataSourceProject Objects

class AnalyticsDataSourceProject(BaseModel)

Represents the project of a datasource object

id

The Id of the project for cross reference in other systems

AnalyticsDataSourceConnectionString Objects

class AnalyticsDataSourceConnectionString(BaseModel)

Represents the connection string of a datasource object

secret_name

The name of the secret

value

The value of the connection string

AnalyticsDataSourceSecret Objects

class AnalyticsDataSourceSecret(BaseModel)

Represents a datasource secret

secret_name

The name of the secret

AnalyticsDataSourceSecretWithKey Objects

class AnalyticsDataSourceSecretWithKey(AnalyticsDataSourceSecret)

Represents a datasource secret with a key

secret_key

The key to use when accessing the secret

AnalyticsDataSourceDataBricksConnection Objects

class AnalyticsDataSourceDataBricksConnection(BaseModel)

Represents a databricks connection

host_name

The host name of the databricks cluster

http_path

The path of the databricks cluster

personal_access_token

The personal access token to use when connecting if using this auth model

oauth2_token

The oauth2 token to use when connecting if using this auth model

service_principle

The service principle to use when connecting if using this auth model

AnalyticsApproval Objects

class AnalyticsApproval(BaseModel)

Represents an analytics approval object

type

The type of approval being given

name

The name of the approver

email

The email of the approver

job_title

The job title of the approver

approval_given

The date stamp for when approval was given

AnalyticsDataSourceConnection Objects

class AnalyticsDataSourceConnection(BaseModel)

Represents an connection on a datasource object

type

The Type of datasource

name

The name of the datasource

connection_string

The connection string for the datasource

databricks_connection

The databricks connection to use

AnalyticsDataSourceSpec Objects

class AnalyticsDataSourceSpec(BaseModel)

represents a spec segment of an AnalyticsDataSource object

type

The type of datasource

display_name

A short title for the data source

description

A description of the data source

license

Details of what license this datasource has associated with it

publisher

The publisher of the datasource

project

The project that this data source is associated with

connections

The connections used to access this data

approvals

List of approvals given for this project

AnalyticsDataSourceBindingStatus Objects

class AnalyticsDataSourceBindingStatus(BaseModel)

Represents the status segment of a AnalyticsDataSourceBinding object

status_text

The current status of the resource

AnalyticsDataSourceStatus Objects

class AnalyticsDataSourceStatus(BaseModel)

Represents a status of an AnalyticsDataSource object

status_text

The current status of the resource

last_active_check

The last time that the solution was active

AnalyticsDataSourceBindingSpec Objects

class AnalyticsDataSourceBindingSpec(BaseModel)

Represents the spec of an AnalyticsDataSourceBinding object

comments

Comments regarding the data source binding

workspace

The name of the workspace associated with this datasource

expires

When the binding expires

datasource

The name of the datasource resource

approvals

The list of approvals for this binding

AnalyticsDataSource Objects

class AnalyticsDataSource(BaseModel)

Represents the AnalyticsDataSource Resource

api_version

The API Version in kubernetes to use

kind

The Kind of object being defined

metadata

The metadata surrounding the resource

spec

The specification for the resource

status

The status of the resource

AnalyticsDataSourceBinding Objects

class AnalyticsDataSourceBinding(BaseModel)

Represents the AnalyticsDataSourceBinding resource

api_version

The API Version in kubernetes to use

kind

The Kind of object being defined

metadata

The metadata surrounding the resource

spec

The specification for the resource

status

The status of the resource

AnalyticsCrateSpecRepository Objects

class AnalyticsCrateSpecRepository(BaseModel)

Represents repository on a AnalyticsCrateSpec object

url

The URL of the repository

branch

The branch to use. Defaults to main branch

secret_name

The name of the secret resource to use to get the PAT Token.

secret_key

The key of the secret resource to get the PAT Token.

AnalyticsCrateSpec Objects

class AnalyticsCrateSpec(BaseModel)

Represents the spec segment of a AnalyticsCrate Object

display_name

A short title for the resource

description

A short description of the crate

path

The path to the ro-crate metadata file

repo

The repository where the data relating to this crate is stored

AnalyticsCrateStatus Objects

class AnalyticsCrateStatus(BaseModel)

Represents the status field of a AnalyticsCrate object

status_text

The current status of the resource

commit_id

The commit id for the resource, so we know if it’s already been processed

workspace

The workspace to associate with this crate

AnalyticsCrate Objects

class AnalyticsCrate(BaseModel)

Represents an AnalyticsCrate resource

api_version

The API Version in kubernetes to use

kind

The Kind of object being defined

metadata

The metadata surrounding the resource

spec

The specification of this resource

status

The status of this resource

integrationtest

workspacebindingclient

AnalyticsWorkspaceBindingClient Objects

class AnalyticsWorkspaceBindingClient(KubernetesNamespacedCustomClient)

Client for interacting with AnalyticsWorkspaceBindings

get

async def get(namespace, name)

Gets a specific AnalyticsWorkspaceBinding resource

list

async def list(namespace, **kwargs)

Lists AnalyticsWorkspaceBinding resources in the namespace supplied

list_by_username

async def list_by_username(namespace, username)

Lists AnalyticsWorkspaceBinding resources in the namespace supplied that match the username

If the label doesn’t exist, it will be patched into the definition to increase performance in etcd

create

async def create(body: AnalyticsWorkspaceBinding, append_label: bool = True)

Creates a AnalyticsWorkspaceBinding resource in the namespace supplied

patch

async def patch(namespace: str = None,
                name: str = None,
                patch_body: dict = None,
                body: AnalyticsWorkspaceBinding = None)

Patches a AnalyticsWorkspaceBinding resource in the namespace supplied

patch_status

async def patch_status(namespace: str, name: str,
                       status: AnalyticsWorkspaceBindingStatus)

Patches the status of a AnalyticsWorkspaceBinding resource in the namespace supplied

replace

async def replace(body: AnalyticsWorkspaceBinding, append_label: bool = True)

Replaces a AnalyticsWorkspaceBinding resource with the one supplied

delete

async def delete(body: AnalyticsWorkspaceBinding = None,
                 namespace: str = None,
                 name: str = None)

Deletes a AnalyticsWorkspaceBinding resource in the namespace supplied