:py:mod:`k8s_client.views.groups` ================================= .. py:module:: k8s_client.views.groups Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: k8s_client.views.groups.get_groups k8s_client.views.groups.post_group k8s_client.views.groups.delete_group k8s_client.views.groups.update_group .. py:function:: get_groups(name=None) Get groups list Parameters ---------- ``"name"`` : `string` (optional) The name of the group of which showing the details. Returns ------- - ``[code: 200]`` JSON containing the full list of groups if ``_name`` is `None` - ``[code: 200]`` JSON containing the detail of the specified group if ``name`` is a `` - ``[code: 404]`` Error message if ``name`` is **NOT** a `` Notes ----- To each returned group will be added the context details Examples -------- >>> [ { "contexts": [ { "cluster_id": 1, "cost": 0, "id": 1, "kubeuser_id": 1, "max_cores_for_single_job": 105, "name": "context.dev.k8s.master.dafni.hydra.org.uk", "namespace": "default" } ], "id": 1, "name": "umwrg" } ] .. py:function:: post_group() Create a new group Parameters ---------- **Request Body** : `json` JSON containing data for the group: ``"name"`` : `string` The name of the group to create ``"contexts"`` : `list` [`dict`] List of dictionaries of the contexts to attach to the group, eventually empty It can contain the `name` or the `id` of the contexts. The `name` has higher priority, meaning if it is defined, the `id` is ignored If the context is not found, the group will be inserted anyway without contexts Returns ------- - ``[code: 409]`` Error message if ``name`` is already inside the DB - ``[code: 406]`` Error message if ``INPUT`` is **NOT** a `` - ``[code: 200]`` Empty array if ``INPUT`` is valid Examples -------- >>> Body = { "name": "test5", "contexts": [{"id":1}] } >>> Body = { "name": "test15", "contexts": [{"name":"context-test"}] } .. py:function:: delete_group(id=None) Delete a group Parameters ---------- ``"id"``: `int` The id of the group to delete Returns ------- - Error message with return code `409` if there is an integrity error - Error message with return code `404` if ``id`` is **NOT** a `` - JSON containing the deleted group id with return code `200` if ``INPUT`` is valid .. py:function:: update_group(id=None) updates a group Parameters ---------- ``"id"`` : `int` The id of the group to update **Request Body** : `json` JSON containing data for the group: ``"name"``: `string` The name of the group to update ``"contexts"`` : `list` [`dict`] List of dictionaries of the contexts to attach to the group, eventually empty It can contain the `name` or the `id` of the contexts. The `name` has higher priority, meaning if it is defined, the `id` is ignored If the context is not found, the group will be inserted anyway without contexts Returns ------- - ``[code: 404]`` Error message if ``id`` is not inside the DB - ``[code: 406]`` Error message if ``INPUT`` is **NOT** a `` - ``[code: 409]`` Error message if there is an integrity error - ``[code: 200]`` Empty array if ``INPUT`` is valid Examples -------- >>> Body = { "name": "test5", "contexts": [{"id":1}] } >>> Body = { "name": "test15", "contexts": [{"name":"context-test"}] }