toggl_api.WorkspaceBody
dataclass
¶
Bases: BaseBody
Source code in toggl_api/workspace.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 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 |
|
name: Optional[str] = field(default=None)
class-attribute
instance-attribute
¶
Name of the workspace. Check TogglWorkspace static method for validation.
admins: list[int] = field(default_factory=list, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
List of admins, optional.
only_admins_may_create_projects: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Only admins will be able to create projects, optional, only for existing WS, will be false initially
only_admins_may_create_tags: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Only admins will be able to create tags, optional, only for existing WS, will be false initially
only_admins_see_billable_rates: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Whether only admins will be able to see billable rates, premium feature, optional, only for existing WS. Will be false initially
only_admins_see_team_dashboard: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Only admins will be able to see the team dashboard, optional, only for existing WS, will be false initially
projects_billable_by_default: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Whether projects will be set as billable by default, premium feature, optional, only for existing WS. Will be true initially
projects_enforce_billable: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Whether tracking time to projects will enforce billable setting to be respected.
projects_private_by_default: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Whether projects will be set to private by default, optional. Will be true initially.
rate_change_mode: Optional[Literal['start-today', 'override-current', 'override-all']] = field(default=None, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
The rate change mode, premium feature, optional, only for existing WS. Can be 'start-today', 'override-current', 'override-all'
reports_collapse: bool = field(default=False, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Whether reports should be collapsed by default, optional, only for existing WS, will be true initially
rounding: Optional[int] = field(default=None, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Default rounding, premium feature, optional, only for existing WS
rounding_minutes: Optional[int] = field(default=None, metadata={'endpoints': frozenset(('add', 'edit'))})
class-attribute
instance-attribute
¶
Default rounding in minutes, premium feature, optional, only for existing WS
format(endpoint: str, **body: Any) -> dict[str, Any]
¶
Formats the body into a usable format for a request.
Gets called form within an endpoint method.
Parameters:
-
endpoint
(str
) –Which endpoint to target.
-
body
(Any
, default:{}
) –Prefilled body with extra arguments.
Returns:
-
dict
(dict[str, Any]
) –A JSON body with the relevant parameters prefilled.
Source code in toggl_api/workspace.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
toggl_api.WorkspaceEndpoint
¶
Bases: TogglCachedEndpoint[TogglWorkspace]
Specific endpoints for retrieving and modifying workspaces.
Examples:
>>> org_id = 123213324
>>> workspace_endpoint = WorkspaceEndpoint(org_id, BasicAuth(...), SqliteCache(...))
Parameters:
-
organization_id
(int | TogglOrganization
) –Workspace endpoint takes an organization id instead of a workspace id.
-
auth
(BasicAuth
) –Authentication for the client.
-
timeout
(int
, default:10
) –How long it takes for the client to timeout. Keyword Only. Defaults to 10 seconds.
-
re_raise
(bool
, default:False
) –Whether to raise all HTTPStatusError errors and not handle them internally. Keyword Only.
-
retries
(int
, default:3
) –Max retries to attempt if the server returns a 5xx status_code. Has no effect if re_raise is
True
. Keyword Only.
Source code in toggl_api/workspace.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
get(workspace: Optional[TogglWorkspace | int] = None, *, refresh: bool = False) -> TogglWorkspace | None
¶
Get the current workspace based on the workspace_id class attribute.
Parameters:
-
workspace
(Optional[TogglWorkspace | int]
, default:None
) –Workspace id or to get. Optional is DEPRECATED. type and will become required in the future.
-
refresh
(bool
, default:False
) –Whether to use cache or not.
Raises:
-
HTTPStatusError
–If anything that's not a '2xx' or '404' status_code is returned.
Returns:
-
TogglWorkspace | None
–Model of workspace if found else none.
Source code in toggl_api/workspace.py
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 |
|
add(body: WorkspaceBody) -> TogglWorkspace
¶
Create a new workspace.
Enterprise plan feature.
Parameters:
-
body
(WorkspaceBody
) –All settings for the workspace to be attached to as a body.
Returns:
-
TogglWorkspace
–A newly created workspace with the supplied params.
Source code in toggl_api/workspace.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
collect(since: Optional[datetime | int] = None, *, refresh: bool = False) -> list[TogglWorkspace]
¶
Lists workspaces for given user.
Parameters:
-
since
(Optional[datetime | int]
, default:None
) –Optional argument to filter any workspace after the timestamp.
-
refresh
(bool
, default:False
) –Whether to use cache or not.
Raises:
-
DateTimeError
–If the since argument is after the current time.
Returns:
-
list[TogglWorkspace]
–A list of workspaces or empty if there are None assocciated with the user.
Source code in toggl_api/workspace.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
edit(workspace_id: TogglWorkspace | int, body: WorkspaceBody) -> TogglWorkspace
¶
Update a specific workspace.
Raises:
-
HTTPStatusError
–For anything thats not an ok status code.
Returns:
-
TogglWorkspace
–A workspace model with the supplied edits.
Source code in toggl_api/workspace.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
|
tracker_constraints(workspace_id: TogglWorkspace | int) -> dict[str, bool]
¶
Get the time entry constraints for a given workspace.
Toggl premium feature.
Examples:
>>> workspace_endpoint.get_workspace_constraints(24214214)
{
"description_present": True,
"project_present": False,
"tag_present": False",
"task_present": False,
"time_entry_constraints_enabled": True,
}
Parameters:
-
workspace_id
(TogglWorkspace | int
) –Id of the workspace to retrieve constraints from.
Returns:
-
dict[str, bool]
–A dictionary of booleans containing the settings.
Source code in toggl_api/workspace.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
|
statistics(workspace_id: TogglWorkspace | int) -> WorkspaceStatistics
¶
Returns workspace admins list, members count and groups count.
Parameters:
-
workspace_id
(TogglWorkspace | int
) –Id of the workspace to fetch the statistics from.
Returns:
-
WorkspaceStatistics
–A dictionary containing relevant statistics. Refer to WorkspaceStatistics typed dict for reference.
Source code in toggl_api/workspace.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
Types¶
toggl_api.workspace.User
¶
Bases: TypedDict
Source code in toggl_api/workspace.py
178 179 180 |
|
toggl_api.workspace.WorkspaceStatistics
¶
Bases: TypedDict
Source code in toggl_api/workspace.py
183 184 185 186 |
|