| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ API examples | |||
| 19 | 19 | gl_objects/environments | |
| 20 | 20 | gl_objects/events | |
| 21 | 21 | gl_objects/features | |
| 22 | + gl_objects/geo_nodes | ||
| 22 | 23 | gl_objects/groups | |
| 23 | 24 | gl_objects/issues | |
| 24 | 25 | gl_objects/boards | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,43 @@ | |||
| 1 | + ######### | ||
| 2 | + Geo nodes | ||
| 3 | + ######### | ||
| 4 | + | ||
| 5 | + Reference | ||
| 6 | + --------- | ||
| 7 | + | ||
| 8 | + * v4 API: | ||
| 9 | + | ||
| 10 | + + :class:`gitlab.v4.objects.GeoNode` | ||
| 11 | + + :class:`gitlab.v4.objects.GeoNodeManager` | ||
| 12 | + + :attr:`gitlab.Gitlab.geonodes` | ||
| 13 | + | ||
| 14 | + * GitLab API: https://docs.gitlab.com/ee/api/geo_nodes.html | ||
| 15 | + | ||
| 16 | + Examples | ||
| 17 | + -------- | ||
| 18 | + | ||
| 19 | + List the geo nodes:: | ||
| 20 | + | ||
| 21 | + nodes = gl.geonodes.list() | ||
| 22 | + | ||
| 23 | + Get the status of all the nodes:: | ||
| 24 | + | ||
| 25 | + status = gl.geonodes.status() | ||
| 26 | + | ||
| 27 | + Get a specific node and its status:: | ||
| 28 | + | ||
| 29 | + node = gl.geonodes.get(node_id) | ||
| 30 | + node.status() | ||
| 31 | + | ||
| 32 | + Edit a node configuration:: | ||
| 33 | + | ||
| 34 | + node.url = 'https://secondary.mygitlab.domain' | ||
| 35 | + node.save() | ||
| 36 | + | ||
| 37 | + Delete a node:: | ||
| 38 | + | ||
| 39 | + node.delete() | ||
| 40 | + | ||
| 41 | + List the sync failure on the current node:: | ||
| 42 | + | ||
| 43 | + failures = gl.geonodes.current_failures() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,6 +105,7 @@ def __init__(self, url, private_token=None, oauth_token=None, email=None, | |||
| 105 | 105 | ||
| 106 | 106 | self.broadcastmessages = objects.BroadcastMessageManager(self) | |
| 107 | 107 | self.deploykeys = objects.DeployKeyManager(self) | |
| 108 | + self.geonodes = objects.GeoNodeManager(self) | ||
| 108 | 109 | self.gitlabciymls = objects.GitlabciymlManager(self) | |
| 109 | 110 | self.gitignores = objects.GitignoreManager(self) | |
| 110 | 111 | self.groups = objects.GroupManager(self) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,6 +217,10 @@ class GitlabRenderError(GitlabOperationError): | |||
| 217 | 217 | pass | |
| 218 | 218 | ||
| 219 | 219 | ||
| 220 | + class GitlabRepairError(GitlabOperationError): | ||
| 221 | + pass | ||
| 222 | + | ||
| 223 | + | ||
| 220 | 224 | def on_http_error(error): | |
| 221 | 225 | """Manage GitlabHttpError exceptions. | |
| 222 | 226 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3444,3 +3444,80 @@ def mark_all_as_done(self, **kwargs): | |||
| 3444 | 3444 | return int(result) | |
| 3445 | 3445 | except ValueError: | |
| 3446 | 3446 | return 0 | |
| 3447 | + | ||
| 3448 | + | ||
| 3449 | + class GeoNode(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 3450 | + @cli.register_custom_action('GeoNode') | ||
| 3451 | + @exc.on_http_error(exc.GitlabRepairError) | ||
| 3452 | + def repair(self, **kwargs): | ||
| 3453 | + """Repair the OAuth authentication of the geo node. | ||
| 3454 | + | ||
| 3455 | + Args: | ||
| 3456 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 3457 | + | ||
| 3458 | + Raises: | ||
| 3459 | + GitlabAuthenticationError: If authentication is not correct | ||
| 3460 | + GitlabRepairError: If the server failed to perform the request | ||
| 3461 | + """ | ||
| 3462 | + path = '/geo_nodes/%s/repair' % self.get_id() | ||
| 3463 | + server_data = self.manager.gitlab.http_post(path, **kwargs) | ||
| 3464 | + self._update_attrs(server_data) | ||
| 3465 | + | ||
| 3466 | + @cli.register_custom_action('GeoNode') | ||
| 3467 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 3468 | + def status(self, **kwargs): | ||
| 3469 | + """Get the status of the geo node. | ||
| 3470 | + | ||
| 3471 | + Args: | ||
| 3472 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 3473 | + | ||
| 3474 | + Raises: | ||
| 3475 | + GitlabAuthenticationError: If authentication is not correct | ||
| 3476 | + GitlabGetError: If the server failed to perform the request | ||
| 3477 | + | ||
| 3478 | + Returns: | ||
| 3479 | + dict: The status of the geo node | ||
| 3480 | + """ | ||
| 3481 | + path = '/geo_nodes/%s/status' % self.get_id() | ||
| 3482 | + return self.manager.gitlab.http_get(path, **kwargs) | ||
| 3483 | + | ||
| 3484 | + | ||
| 3485 | + class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager): | ||
| 3486 | + _path = '/geo_nodes' | ||
| 3487 | + _obj_cls = GeoNode | ||
| 3488 | + _update_attrs = (tuple(), ('enabled', 'url', 'files_max_capacity', | ||
| 3489 | + 'repos_max_capacity')) | ||
| 3490 | + | ||
| 3491 | + @cli.register_custom_action('GeoNodeManager') | ||
| 3492 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 3493 | + def status(self, **kwargs): | ||
| 3494 | + """Get the status of all the geo nodes. | ||
| 3495 | + | ||
| 3496 | + Args: | ||
| 3497 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 3498 | + | ||
| 3499 | + Raises: | ||
| 3500 | + GitlabAuthenticationError: If authentication is not correct | ||
| 3501 | + GitlabGetError: If the server failed to perform the request | ||
| 3502 | + | ||
| 3503 | + Returns: | ||
| 3504 | + list: The status of all the geo nodes | ||
| 3505 | + """ | ||
| 3506 | + return self.gitlab.http_list('/geo_nodes/status', **kwargs) | ||
| 3507 | + | ||
| 3508 | + @cli.register_custom_action('GeoNodeManager') | ||
| 3509 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 3510 | + def current_failures(self, **kwargs): | ||
| 3511 | + """Get the list of failures on the current geo node. | ||
| 3512 | + | ||
| 3513 | + Args: | ||
| 3514 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 3515 | + | ||
| 3516 | + Raises: | ||
| 3517 | + GitlabAuthenticationError: If authentication is not correct | ||
| 3518 | + GitlabGetError: If the server failed to perform the request | ||
| 3519 | + | ||
| 3520 | + Returns: | ||
| 3521 | + list: The list of failures | ||
| 3522 | + """ | ||
| 3523 | + return self.gitlab.http_list('/geo_nodes/current/failures', **kwargs) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,3 +27,9 @@ def end_log(): | |||
| 27 | 27 | approval = project.approvals.get() | |
| 28 | 28 | assert(approval.approvers[0]['user']['id'] == 1) | |
| 29 | 29 | end_log() | |
| 30 | + | ||
| 31 | + start_log('geo nodes') | ||
| 32 | + # very basic tests because we only have 1 node... | ||
| 33 | + nodes = gl.geonodes.list() | ||
| 34 | + status = gl.geonodes.status() | ||
| 35 | + end_log() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments