ArtifactoryClient
ArtifactoryClient(params: dict)
params is a dictionary with following mandatory params:
Parameters:
-
url(str) –Artifactory host url
-
username(str) –User used in auth request
-
password(str) –Token used in auth request
get_artifact_properties
get_artifact_properties(path_to_artifact: str)
get_folder_files_list
get_folder_files_list(path_to_folder: str)
get_artifact_content_by_url
get_artifact_content_by_url(path_to_file: str)
ArtifactFinder
ArtifactFinder(artifact_provider: ArtifactProvider, **kwargs)
Allows searching for specific descriptor artifacts in different repositories without knowing full coordinates
(e.g. knowing only artifact_id and version, but not its group_id)
Supports different repository providers: Artifactory, Nexus, AWS, GCP, Azure
Provides different auth methods for Cloud Providers, implementing CloudCredentialsProvider interface
Start by initializing this client with one of implementations:
finder = ArtifactFinder(artifact_provider=ArtifactoryProvider(registry_url="https://our_url", username="user", password="password"))
Then find your artifacts using
resource_urls = finder.find_artifact_urls(artifact_id='art_id', version='1.0.0', extension='json')
Additionally, perform filtering of returned results (if you expect to find more than one artifact), and then download necessary artifacts with
finder.download_artifact(one_of_the_returned_resource_urls, './my_artifact.json')
For more complex providers (e.g. AWS Code Artifact), you need to use specific Credential Providers As an example:
aws_creds = AwsCredentialsProvider().with_assume_role(...all the required params...).get_credentials()
aws_code_artifact_provider = AwsCodeArtifactProvider(creds=creds, domain='our_domain', project='our_project')
finder = ArtifactFinder(artifact_provider=aws_code_artifact_provider)
GitClient
GitClient(host: str, username: str, password: str, email: str = None)
Parameters:
-
host(str) –Git instance URL
-
username(str) –User used in auth request
-
password(str) –Token used in auth request
-
email(str, default:None) –Email used when committing changes using client
clone
clone(repo_path: str, branch: str, temp_path: str, **kwargs)
clone_repo_from_commit_hash
clone_repo_from_commit_hash(repo_path: str, commit_hash: str, temp_path: str)
commit_and_push
commit_and_push(commit_message: str)
commit
commit(commit_message: str)
push
push()
pull
pull(**kwargs)
get_file_content_utf8
get_file_content_utf8(relative_path: str)
set_file_content_utf8
set_file_content_utf8(relative_path: str, content: str)
delete_by_path
delete_by_path(relative_path: str)
GithubClient
GithubClient(token: str = None, api_url: str = None, **kwargs)
Bases: GithubClient
This class is deprecated and will be removed in v3.0.0. Use class from v2 module instead. Arguments: token (str): Token used in auth request api_url (str): Optional Github Enterprise API URL, leave empty if using github.com **kwargs (Any): will be passed into Github API constructor
trigger_workflow
trigger_workflow(owner: str, repo_name: str, workflow_file_name: str, branch: str, pipeline_params: dict, timeout_seconds: float = 30.0, wait_seconds: float = 3.0, find_via_uuid: bool = False, uuid_param_name: str = DEFAULT_UUID_PARAM_NAME, uuid_artifact_name: str = DEFAULT_UUID_ARTIFACT_NAME, uuid_file_name: str = DEFAULT_UUID_FILE_NAME)
There's currently no reliable way to get ID of triggered workflow, without adding explicit ID as an input parameter to each workflow, dispatch is async and doesn't return anything This method supports two different ways to find and return started workflow: Unreliable - where we start looking for newly created runs of that workflow, filtering them as much as possible (might return wrong run in a concurrent scenario) Reliable: you need to add specific explicit ID param to the workflow you are triggering (e.g. 'workflow_run_uuid'), said workflow should have a step where it will save its input params, and then you run this method with 'find_via_uuid = True'
wait_workflow_run_execution
wait_workflow_run_execution(execution: ExecutionInfo, timeout_seconds: float = 60.0, break_status_list: list = None, wait_seconds: float = 10.0)
cancel_workflow_run_execution
cancel_workflow_run_execution(execution: ExecutionInfo, timeout: float = 1.0)
download_workflow_run_artifacts
download_workflow_run_artifacts(execution: ExecutionInfo, local_dir: str)
get_workflow_run_input_params
get_workflow_run_input_params(execution: ExecutionInfo, artifact_name: str = DEFAULT_UUID_ARTIFACT_NAME, file_name: str = DEFAULT_UUID_FILE_NAME)
GitlabClient
GitlabClient(host: str, username: str, password: str, email: str = None, **kwargs)
Bases: GitlabClient
This class is deprecated and will be removed in v3.0.0. Use class from v2 module instead. Arguments: host (str): Gitlab instance URL username (str): User used in auth request, might be empty string if no auth is required password (str): Token used in auth request email (str): Email used when committing changes using API **kwargs (Any): will be passed into Gitlab API constructor
trigger_pipeline
trigger_pipeline(project_id: str, ref: str, trigger_token: str = None, variables: dict = None, use_ci_job_token: bool = False)
create_pipeline
create_pipeline(project_id: str, ref: str, variables: dict)
get_file_content
get_file_content(project_id: str, ref: str, file_path: str)
create_file
create_file(project_id: str, file_path: str, content: str, ref: str, commit_message: str)
update_file
update_file(project_id: str, file_path: str, content: str, ref: str, commit_message: str, create_if_not_exists: bool = False)
delete_file
delete_file(project_id: str, file_path: str, ref: str, commit_message: str)
get_latest_commit_id
get_latest_commit_id(project_id: str, ref: str)
get_file_commit_info
get_file_commit_info(project_id: str, ref: str, file_path: str)
Returns dict with 'commit_id' and 'last_commit_id' from Gitlab API
wait_pipeline_execution
wait_pipeline_execution(execution: ExecutionInfo, timeout_seconds: float = 180.0, break_status_list: list = None, wait_seconds: float = 1.0)
get_repo_branch_path
staticmethod
get_repo_branch_path(url: str, branch: str = 'main')
Extracts 'repo', 'branch' and 'path' parts from possible Gitlab URLs. Needs to know branch beforehand
is_gitlab_project_exist
staticmethod
is_gitlab_project_exist(gitlab_url, gitlab_project, gitlab_token)
search_group_id
staticmethod
search_group_id(gitlab_url, gitlab_project, gitlab_token)
create_internal_gitlab_project
staticmethod
create_internal_gitlab_project(gitlab_url, gitlab_token, group_id, repo_name, repo_branch, visibility='internal')
make_first_commit_to_gitlab_project
staticmethod
make_first_commit_to_gitlab_project(gitlab_url, gitlab_token, project_id, repo_branch)
JenkinsClient
JenkinsClient(host: str, user: str, password: str)
Bases: JenkinsClient
This class is deprecated and will be removed in v3.0.0. Use class from v2 module instead. Arguments: host (str): Jenkins host URL user (str): User used in auth request password (str): Token used in auth request
run_pipeline
run_pipeline(job_name: str, job_params: dict, timeout_seconds: float = 180.0, wait_seconds: float = 1.0)
get_pipeline_execution_status
get_pipeline_execution_status(execution: ExecutionInfo, timeout_seconds: float = 30.0, wait_seconds: float = 1.0)
wait_pipeline_execution
wait_pipeline_execution(execution: ExecutionInfo, timeout_seconds: float = 180.0, wait_seconds: float = 1.0)
cancel_pipeline_execution
cancel_pipeline_execution(execution: ExecutionInfo, timeout_seconds: float = 30.0, wait_seconds: float = 1.0)
get_pipeline_execution_artifacts
get_pipeline_execution_artifacts(execution: ExecutionInfo, timeout_seconds: float = 30.0, wait_seconds: float = 1.0)
Returns list of artifact relative paths
save_pipeline_execution_artifact_to_file
save_pipeline_execution_artifact_to_file(execution: ExecutionInfo, artifact_path: str, file_path: str)
JiraClient
JiraClient(host: str, user: str, password: str, auth_type: str = BASIC)
KubeClient
KubeClient(endpoint: str = None, token: str = None, kubeconfig_path: str = None)
Needs either of endpoint and token or kubeconfig_path
Parameters:
-
endpoint(str, default:None) –Kubernetes API server URL
-
token(str, default:None) –Token used for cluster access
-
kubeconfig_path(str, default:None) –Path to local .kubeconfig file
list_namespaces
list_namespaces()
namespace_exists
namespace_exists(namespace: str)
deployments_exist
deployments_exist(namespace: str)
is_namespace_scaled_to_zero
is_namespace_scaled_to_zero(namespace: str)
list_not_ready_resources
list_not_ready_resources(namespace)
create_namespace
create_namespace(namespace: str)
delete_namespaces
delete_namespaces(namespaces: list[str], ignore_not_found: bool = False)
list_config_map_names
list_config_map_names(namespace: str)
read_config_map
read_config_map(namespace: str, config_map_name: str)
create_config_map
create_config_map(namespace: str, config_map_name: str, config_map_data: dict)
patch_config_map
patch_config_map(namespace: str, config_map_name: str, config_map_data: dict)
Patching allows adding/removing only specified keys in config map. Removes key-value pair when value is None
replace_config_map
replace_config_map(namespace: str, config_map_name: str, config_map_data: dict)
Replaces all data inside existing config map with value of 'config_map_data' argument
create_or_replace_config_map
create_or_replace_config_map(namespace: str, config_map_name: str, config_map_data: dict)
Creates map if it doesn't exist, replaces it otherwise
delete_config_map
delete_config_map(namespace: str, config_map_name: str)
scale_namespace
scale_namespace(namespace: str, scale_mode: ScaleMode, use_config_map: bool = True, replicas: int = 0)
scale_namespace_down
scale_namespace_down(namespace: str)
scale_namespace_up
scale_namespace_up(namespace: str, use_config_map: bool, replicas: int = 0)
MinioClient
MinioClient(endpoint: str, access_key: str, secret_key: str, secure: bool = True, cert_check: bool = True)
Parameters:
-
endpoint(str) –MiniO host URL
-
access_key(str) –Access key used in auth request
-
secret_key(str) –Secret key used in auth request
-
secure(bool, default:True) –Which protocol to use (in case it's not present in
endpoint) -
cert_check(bool, default:True) –Whether to verify certificate
list_objects
list_objects(bucket_name: str, path: str = None)
No leading slash in path - newer versions of MiniO don't support it,
Trailing slash in path must be present
e.g. don't do this: path="/folder1/folder2"
do this: path="folder/folder2/"
get_folder_names
get_folder_names(bucket_name: str, path: str = None)
get_file_names
get_file_names(bucket_name: str, path: str = None)
get_last_modified_file
get_last_modified_file(bucket_name: str, path: str = None)
get_last_modified_text_file_content
get_last_modified_text_file_content(bucket_name: str, path: str = None)
get_file
get_file(bucket_name: str, file_path: str, local_path: str)
put_file
put_file(bucket_name: str, path: str, local_path: str)
get_text_file_content
get_text_file_content(bucket_name: str, file_path: str)
WebexClient
WebexClient(bot_token: str, proxies: dict = None)
proxies dict for different protocols is passed to requests session.
e.g. proxies = { 'https' : 'https://user:password@ip:port' }
Parameters:
-
bot_token(str) –bot's auth token
-
proxies(dict, default:None) –dict with proxy connections for different protocols
send_message
send_message(room_id: str, msg: str = None, attachment_path: str = None, parent_id: str = None, to_person_id: str = None, to_person_email: str = None, markdown: str = None, **request_parameters)
Post a message to a room.
Parameters:
-
room_id(str) –The room ID.
-
to_person_id(str, default:None) –The ID of the recipient when sending a private 1:1 message.
-
to_person_email(str, default:None) –The email address of the recipient when sending a private 1:1 message.
-
msg(str, default:None) –The message, in plain text. If
markdownis specified this parameter may be optionally used to provide alternate text for UI clients that do not support rich text. -
markdown(str, default:None) –The message, in Markdown format.
-
attachment_path(str, default:None) –Path to file that will be attached to a message
-
parent_id(str, default:None) –The parent message to reply to. This will start or reply to a thread.
-
**request_parameters–Additional request parameters (provides support for parameters that may be added in the future).
-
Returns–dict: The API response containing details of the created message.