Connection
Connection ¶
Connection(api_token, host, workspace=None, project=None)
Connect to the Vectice backend (application).
The Connection class encapsulates a connection to the Vectice App. Thus, it authenticates and connects to Vectice. This allows you to start interacting with your Vectice assets.
A Connection can be initialized in three ways:
-
Passing the relevant arguments to authenticate and connect to Vectice:
import vectice connection = vectice.connect( api_token="API_TOKEN_FROM_VECTICE", host="https://app.vectice.com", )
-
Passing the path to a configuration file:
import vectice connection = vectice.connect(config="vectice_config.json")
-
Letting Vectice find the configuration file in specific locations:
import vectice connection = vectice.connect()
See Connection.connect
for more info.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_token |
str
|
Your private api token. |
required |
host |
str
|
The address of the Vectice application. |
required |
workspace |
str | int | None
|
The workspace you want to work in. |
None
|
project |
str | int | None
|
The project you want to work in. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
When the API and backend versions are incompatible. |
Source code in src/vectice/connection.py
77 78 79 80 81 82 83 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 |
|
last_workspace
property
¶
last_workspace: Workspace
Retrieve last workspace with activity.
Returns:
Type | Description |
---|---|
Workspace
|
Last workspace with activity. |
my_workspace
property
¶
my_workspace: Workspace
workspaces
property
¶
workspaces: list[Workspace] | None
connect
staticmethod
¶
connect(
api_token=None,
host=None,
config=None,
workspace=None,
project=None,
)
Method to connect to the Vectice backend (application).
Authentication credentials are retrieved, in order, from:
- keyword arguments
- configuration file (
config
parameter) - environment variables
- environment files in the following order
.vectice
of the working directory.vectice
of the user home directory.env
of the working directory.env
of the user home directory/etc/vectice/api.cfg
file
This method uses the api_token
, host
, workspace
, project
arguments
or the JSON config provided. The JSON config file is available from the Vectice
webapp when creating an API token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_token |
str | None
|
The api token provided by the Vectice webapp. |
None
|
host |
str | None
|
The backend host to which the client will connect. If not found, the default endpoint https://app.vectice.com is used. |
None
|
config |
str | None
|
A JSON config file containing keys VECTICE_API_TOKEN and VECTICE_API_ENDPOINT as well as optionally WORKSPACE and PROJECT. |
None
|
workspace |
str | int | None
|
The name of an optional workspace to return. |
None
|
project |
str | None
|
The name of an optional project to return. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
When a project is specified without a workspace. |
Returns:
Type | Description |
---|---|
Connection | Workspace | Project | None
|
A Connection, Workspace, or Project. |
Source code in src/vectice/connection.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
list_workspaces ¶
list_workspaces()
Prints a list of workspaces in a tabular format, limited to the first 10 items. A link is provided to view the remaining workspaces.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in src/vectice/connection.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
workspace ¶
workspace(workspace)
Get a workspace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
workspace |
str | int
|
The id or the name of the desired workspace. |
required |
Returns:
Type | Description |
---|---|
Workspace
|
The desired workspace. |
Source code in src/vectice/connection.py
127 128 129 130 131 132 133 134 135 136 137 138 139 |
|