cosmotech.coal.cosmotech_api.workspace¶
workspace
¶
download_workspace_file(api_client, organization_id, workspace_id, file_name, target_dir)
¶
Downloads a given file from a workspace to a given directory If the file is inside a directory in the workspace, sub-directories will be created.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_client
|
ApiClient
|
An api client used to connect to the Cosmo Tech API |
required |
organization_id
|
str
|
An ID of an Organization in the Cosmo Tech API |
required |
workspace_id
|
str
|
An ID of a Workspace in the Cosmo Tech API |
required |
file_name
|
str
|
The file to download to the workspace |
required |
target_dir
|
Path
|
The directory in which to write the file |
required |
Returns:
Type | Description |
---|---|
Path
|
The path to the created file |
Source code in cosmotech/coal/cosmotech_api/workspace.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
list_workspace_files(api_client, organization_id, workspace_id, file_prefix)
¶
Helper function to list all workspace files using a pre-given file prefix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_client
|
ApiClient
|
An api client used to connect to the Cosmo Tech API |
required |
organization_id
|
str
|
An ID of an Organization in the Cosmo Tech API |
required |
workspace_id
|
str
|
An ID of a Workspace in the Cosmo Tech API |
required |
file_prefix
|
str
|
The prefix of the files to find in the Workspace |
required |
Returns:
Type | Description |
---|---|
list[str]
|
A list of existing files inside the workspace |
Source code in cosmotech/coal/cosmotech_api/workspace.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
upload_workspace_file(api_client, organization_id, workspace_id, file_path, workspace_path, overwrite=True)
¶
Upload a local file to a given workspace
If workspace_path ends with a "/" it will be considered as a folder inside the workspace and the file will keep its current name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_client
|
ApiClient
|
An api client used to connect to the Cosmo Tech API |
required |
organization_id
|
str
|
An ID of an Organization in the Cosmo Tech API |
required |
workspace_id
|
str
|
An ID of a Workspace in the Cosmo Tech API |
required |
file_path
|
str
|
Path to the file to upload in the workspace |
required |
workspace_path
|
str
|
The path inside the workspace to upload the file to |
required |
overwrite
|
bool
|
Overwrite existing file in the workspace |
True
|
Returns:
Type | Description |
---|---|
str
|
The final name of the file uploaded to the workspace |
Source code in cosmotech/coal/cosmotech_api/workspace.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|