Skip to content

Commit

Permalink
Mass rename/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SireInsectus committed Nov 23, 2023
1 parent be7f7f1 commit 9f49cc4
Show file tree
Hide file tree
Showing 87 changed files with 1,226 additions and 1,027 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/JacobParr.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions jobs/dbacademy_jobs/administration/bleed_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def __str__(self) -> str:

class Watchdog:
def __init__(self):
from dbacademy.clients.darest import accounts
from dbacademy.common import Cloud
from dbacademy.clients.darest import accounts_client

self.__results: List[Result] = list()

Expand All @@ -61,9 +62,10 @@ def __init__(self):
self.__username = os.environ.get("WORKSPACE_SETUP_PROSVC_USERNAME")
self.__password = os.environ.get("WORKSPACE_SETUP_PROSVC_PASSWORD")

self.accounts_client = accounts.from_args_aws(account_id=os.environ.get("WORKSPACE_SETUP_PROSVC_ACCOUNT_ID"),
username=self.username,
password=self.password)
self.accounts_client = accounts_client.from_args(cloud=Cloud.AWS,
account_id=os.environ.get("WORKSPACE_SETUP_PROSVC_ACCOUNT_ID"),
username=self.username,
password=self.password)

@property
def username(self) -> str:
Expand Down
22 changes: 11 additions & 11 deletions jobs/dbacademy_jobs/administration/delete-account-user.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
from dbacademy.clients.darest import accounts
from dbacademy.common import Cloud
from dbacademy.clients.darest import accounts_client


accounts = accounts.from_args_aws(account_id=os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID"),
username=os.environ.get("WORKSPACE_SETUP_CURR_USERNAME"),
password=os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD"))
accounts = accounts_client.from_args(cloud=Cloud.AWS,
account_id=os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID"),
username=os.environ.get("WORKSPACE_SETUP_CURR_USERNAME"),
password=os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD"))

for username in ["[email protected]"]:
user = accounts.scim.users.get_by_username(username)
if user is not None:
print(f"Deleting {username}.")
accounts.scim.users.delete_by_id(user.get("id"))

pass
# for username in ["[email protected]"]:
# user = accounts.scim.users.get_by_username(username)
# if user is not None:
# print(f"Deleting {username}.")
# accounts.scim.users.delete_by_id(user.get("id"))
13 changes: 7 additions & 6 deletions jobs/dbacademy_jobs/administration/list_workspace_admins.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os
from dbacademy import common
from dbacademy.common import load_databricks_cfg, Cloud
from dbacademy.clients import darest
from dbacademy.clients.darest import accounts
from dbacademy.clients.darest import accounts_client

accounts = accounts.from_args_aws(account_id=os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID"),
username=os.environ.get("WORKSPACE_SETUP_CURR_USERNAME"),
password=os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD"))
accounts = accounts_client.from_args(cloud=Cloud.AWS,
account_id=os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID"),
username=os.environ.get("WORKSPACE_SETUP_CURR_USERNAME"),
password=os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD"))

environment = "dev-aws"
configs = common.load_databricks_cfg(r"c:\users\JacobParr\.databrickscfg")
configs = load_databricks_cfg(r"c:\users\JacobParr\.databrickscfg")
token = configs.get(environment).get("token")
endpoint = configs.get(environment).get("host")
client = darest.from_token(token=token, endpoint=endpoint)
Expand Down
13 changes: 7 additions & 6 deletions jobs/dbacademy_jobs/administration/manage-groups.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
from typing import Dict, Any
from dbacademy import common
from dbacademy.common import Cloud, load_databricks_cfg
from dbacademy.clients import darest
from dbacademy.clients.darest import accounts
from dbacademy.clients.darest import accounts_client

accounts = accounts.from_args_aws(account_id=os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID"),
username=os.environ.get("WORKSPACE_SETUP_CURR_USERNAME"),
password=os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD"))
accounts = accounts_client.from_args(cloud=Cloud.AWS,
account_id=os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID"),
username=os.environ.get("WORKSPACE_SETUP_CURR_USERNAME"),
password=os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD"))

config_file = r"c:\users\JacobParr\.databrickscfg"

Expand Down Expand Up @@ -34,7 +35,7 @@ def add_to_participants(_user: Dict[str, Any]):


environment = "dev-aws"
configs = common.load_databricks_cfg(config_file)
configs = load_databricks_cfg(config_file)
token = configs.get(environment).get("token")
endpoint = configs.get(environment).get("host")

Expand Down
10 changes: 6 additions & 4 deletions jobs/dbacademy_jobs/administration/update_username.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os

from dbacademy.clients.darest import accounts
from dbacademy.common import Cloud
from dbacademy.clients.darest import accounts_client

account_id = os.environ.get("WORKSPACE_SETUP_CURR_ACCOUNT_ID")
username = os.environ.get("WORKSPACE_SETUP_CURR_USERNAME")
password = os.environ.get("WORKSPACE_SETUP_CURR_PASSWORD")

accounts = accounts.from_args_aws(account_id=account_id,
username=username,
password=password)
accounts = accounts_client.from_args(cloud=Cloud.AWS,
account_id=account_id,
username=username,
password=password)

for i in range(0, 250+1):
username = f"class+{i:03d}@databricks.com"
Expand Down
117 changes: 59 additions & 58 deletions src/dbacademy/clients/darest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,54 @@
from typing import Optional
from dbacademy.clients.rest.common import ApiClient
from dbacademy.clients import ClientErrorHandler

from dbacademy.clients.darest.secrets import SecretsClient
from dbacademy.clients.darest.clusters.cluster_client_class import ClustersClient
from dbacademy.clients.darest.cluster_policies import ClustersPolicyClient
from dbacademy.clients.darest.instance_pools import InstancePoolsClient
from dbacademy.clients.darest.jobs.jobs_client_class import JobsClient
from dbacademy.clients.darest.ml import MlClient
from dbacademy.clients.darest.permissions import Permissions
from dbacademy.clients.darest.pipelines import PipelinesClient
from dbacademy.clients.darest.repos import ReposClient
from dbacademy.clients.darest.runs import RunsClient
from dbacademy.clients.darest.scim import ScimClient
from dbacademy.clients.darest.sql import SqlClient
from dbacademy.clients.darest.tokens import TokensClient
from dbacademy.clients.darest.token_management import TokenManagementClient
from dbacademy.clients.darest.uc import UcApi
from dbacademy.clients.darest.workspace import WorkspaceClient
from dbacademy.clients.darest.workspace_config import WorkspaceConfigClient
from dbacademy.clients.darest.serving_endpoints import ServingEndpointsApi
from dbacademy.clients.darest.secrets_api import SecretsApi
from dbacademy.clients.darest.clusters_api import ClustersApi
from dbacademy.clients.darest.cluster_policies_api import ClustersPolicyApi
from dbacademy.clients.darest.instance_pools_api import InstancePoolsApi
from dbacademy.clients.darest.jobs_api import JobsApi
from dbacademy.clients.darest.ml_api import MlApi
from dbacademy.clients.darest.permissions_api import PermissionsApi
from dbacademy.clients.darest.pipelines_api import PipelinesApi
from dbacademy.clients.darest.repos_api import ReposApi
from dbacademy.clients.darest.runs_api import RunsApi
from dbacademy.clients.darest.scim_api import ScimApi
from dbacademy.clients.darest.sql_api import SqlApi
from dbacademy.clients.darest.tokens_api import TokensApi
from dbacademy.clients.darest.token_management_api import TokenManagementApi
from dbacademy.clients.darest.uc_api import UcApi
from dbacademy.clients.darest.workspace_api import WorkspaceApi
from dbacademy.clients.darest.workspace_config_api import WorkspaceConfigApi
from dbacademy.clients.darest.serving_endpoints_api import ServingEndpointsApi


# noinspection PyPep8Naming
class Constants:

def __init__(self):
pass

@property
def DEFAULT_SCOPE(self):
def DEFAULT_SCOPE(self) -> str:
return "DBACADEMY"

@property
def AUTH_HEADER(self):
def AUTH_HEADER(self) -> str:
return "AUTH_HEADER"

@property
def TOKEN(self):
def TOKEN(self) -> str:
return "TOKEN"

@property
def ENDPOINT(self):
def ENDPOINT(self) -> str:
return "ENDPOINT"

@property
def USERNAME(self):
def USERNAME(self) -> str:
return "USERNAME"

@property
def PASSWORD(self):
def PASSWORD(self) -> str:
return "PASSWORD"


Expand Down Expand Up @@ -114,76 +114,76 @@ def __init__(self, *,
error_handler=error_handler)

@property
def clusters(self) -> ClustersClient:
return ClustersClient(self)
def clusters(self) -> ClustersApi:
return ClustersApi(self)

@property
def cluster_policies(self) -> ClustersPolicyClient:
return ClustersPolicyClient(self)
def cluster_policies(self) -> ClustersPolicyApi:
return ClustersPolicyApi(self)

@property
def instance_pools(self) -> InstancePoolsClient:
return InstancePoolsClient(self)
def instance_pools(self) -> InstancePoolsApi:
return InstancePoolsApi(self)

@property
def jobs(self) -> JobsClient:
return JobsClient(self)
def jobs(self) -> JobsApi:
return JobsApi(self)

@property
def ml(self) -> MlClient:
return MlClient(self)
def ml(self) -> MlApi:
return MlApi(self)

@property
def permissions(self) -> Permissions:
return Permissions(self)
def permissions(self) -> PermissionsApi:
return PermissionsApi(self)

@property
def pipelines(self) -> PipelinesClient:
return PipelinesClient(self)
def pipelines(self) -> PipelinesApi:
return PipelinesApi(self)

@property
def repos(self) -> ReposClient:
return ReposClient(self)
def repos(self) -> ReposApi:
return ReposApi(self)

@property
def runs(self) -> RunsClient:
return RunsClient(self)
def runs(self) -> RunsApi:
return RunsApi(self)

@property
def scim(self) -> ScimClient:
return ScimClient(self)
def scim(self) -> ScimApi:
return ScimApi(self)

@property
def sql(self) -> SqlClient:
return SqlClient(self)
def sql(self) -> SqlApi:
return SqlApi(self)

@property
def tokens(self) -> TokensClient:
return TokensClient(self)
def tokens(self) -> TokensApi:
return TokensApi(self)

@property
def token_management(self) -> TokenManagementClient:
return TokenManagementClient(self)
def token_management(self) -> TokenManagementApi:
return TokenManagementApi(self)

@property
def uc(self) -> UcApi:
return UcApi(self)

@property
def workspace(self) -> WorkspaceClient:
return WorkspaceClient(self)
def workspace(self) -> WorkspaceApi:
return WorkspaceApi(self)

@property
def workspace_config(self) -> WorkspaceConfigClient:
return WorkspaceConfigClient(self)
def workspace_config(self) -> WorkspaceConfigApi:
return WorkspaceConfigApi(self)

@property
def serving_endpoints(self) -> ServingEndpointsApi:
return ServingEndpointsApi(self)

@property
def secrets(self) -> SecretsClient:
return SecretsClient(self)
def secrets(self) -> SecretsApi:
return SecretsApi(self)


# def none_reference() -> Optional[DBAcademyRestClient]:
Expand Down Expand Up @@ -275,8 +275,9 @@ def from_auth_header(*,


def from_client(client: ApiClient) -> DBAcademyRestClient:
from dbacademy.common import validate

return from_args(client=client,
return from_args(client=validate(client=client).required.as_type(ApiClient),
# Common parameters
verbose=client.verbose,
throttle_seconds=client.throttle_seconds,
Expand Down
Loading

0 comments on commit 9f49cc4

Please sign in to comment.