dkutils.datakitchen_api.kitchen module¶
- class dkutils.datakitchen_api.kitchen.Kitchen(client: DataKitchenClient, name: str)[source]¶
Bases:
object
Kitchen object for performing kitchen related API requests.
- Parameters
client (DataKitchenClient) – Client for making requests.
name (str) – Name of existing kitchen.
- __init__(client: DataKitchenClient, name: str) None [source]¶
Kitchen object for performing kitchen related API requests.
- Parameters
client (DataKitchenClient) – Client for making requests.
name (str) – Name of existing kitchen.
- add_alerts(alerts: dict) None [source]¶
Add the provided alerts to the kitchen.
- Parameters
alerts (dict) –
Alerts to add in the form:
{ 'Start': ['foo@gmail.com'], 'Warning': None, 'OverDuration': ['foo@gmail.com', 'bar@gmail.com'], 'Success': None, 'Failure': ['foo@gmail.com'], }
- Raises
KeyError – If an unrecognized alert field is provided - valid fields are Start, Warning, OverDuration, Success, and Failure
- add_staff(staff_to_add: dict) requests.models.Response [source]¶
Add the provided staff to this kitchen.
- Parameters
staff_to_add (dict) –
Dictionary keyed by role and valued with list of users to add to that role in the form:
{ 'Admin': ['admin@gmail.com'], 'Developer': ['developer1@gmail.com', 'developer2@gmail.com'], }
- Raises
HTTPError – If the request fails.
PermissionError – If the current user is not an Admin
ValueError – If the provided staff are not new or unique across roles.
- Returns
Response
object- Return type
requests.Response
- static create(client: DataKitchenClient, parent_kitchen_name: str, new_kitchen_name: str, description: str = '') Kitchen [source]¶
Create a new kitchen and return a kitchen object
- Parameters
client (DataKitchenClient) –
parent_kitchen_name (str) – New kitchen will be a child of this parent kitchen
new_kitchen_name (str) – New kitchen name
description (str) – New kitchen description
- Returns
Kitchen
object- Return type
- Raises
HTTPError – If the request fails.
- delete() requests.models.Response [source]¶
Delete the current kitchen.
- Returns
Response
object- Return type
requests.Response
- Raises
HTTPError – If the request fails.
- delete_alerts(alerts: dict) None [source]¶
Delete the provided kitchen alerts.
- Parameters
alerts (dict) –
Alerts to delete in the form:
{ 'Start': ['foo@gmail.com'], 'Warning': None, 'OverDuration': ['foo@gmail.com', 'bar@gmail.com'], 'Success': None, 'Failure': ['foo@gmail.com'], }
- Raises
KeyError – If an unrecognized alert field is provided - valid fields are Start, Warning, OverDuration, Success, and Failure
- delete_staff(staff_to_delete: Union[set, list]) requests.models.Response [source]¶
Delete the provided staff from this kitchen.
- Parameters
staff_to_delete (set or list) – List or set of usernames to delete from this kitchen’s staff.
- Raises
HTTPError – If the request fails.
PermissionError – If the current user is not an Admin
- Returns
Response
object- Return type
requests.Response
- ensure_users_is_part_of_staff(users_to_check: Union[set, list], current_staff: Optional[Union[set, list]] = None) None [source]¶
Ensure a list of users is part of Kitchen Staff. Otherwise, raise a ValueError.
- Parameters
users_to_check (set or list) – List or set of emails of the users to check if they are part of the staff.
current_staff (set or list) – List or set of the current staff.
- Raises
ValueError – If the users to check are not part of the Kitchen Staff.
- get_alerts() dict [source]¶
Retrieve alerts set on this kitchen.
- Returns
alerts –
- Dictionary of current kitchen alerts of the form::
- {
‘Start’: [‘foo@gmail.com’], ‘Warning’: None, ‘OverDuration’: [‘foo@gmail.com’, ‘bar@gmail.com’], ‘Success’: None, ‘Failure’: [‘foo@gmail.com’],
}
- Return type
dict
- get_staff() dict [source]¶
Retrieve the staff and their associated roles assigned to this kitchen.
- Raises
HTTPError – If the request fails.
PermissionError – If the current user is not an Admin
- Returns
staff –
Dictionary of current kitchen staff and their associated roles of the form:
{ 'Admin': ['admin@gmail.com'], 'Developer': ['developer1@gmail.com', 'developer2@gmail.com'], }
- Return type
dict
- is_ingredient() bool [source]¶
Return true if this is an ingredient kitchen, False otherwise.
- Returns
True if this kitchen is an ingredient kitchen, False otherwise.
- Return type
bool
- update_staff(staff_to_update: dict) requests.models.Response [source]¶
Update roles for the provided staff to this kitchen.
- Parameters
staff_to_update (dict) –
Dictionary keyed by role and valued with list of users to update to that role in the form:
{ 'Admin': ['admin@gmail.com'], 'Developer': ['developer1@gmail.com', 'developer2@gmail.com'], }
- Raises
HTTPError – If the request fails.
PermissionError – If the current user is not an Admin
ValueError – If the provided staff are not new or unique across roles.
- Returns
Response
object- Return type
requests.Response
- property name: str¶
Kitchen name
- property parent_name: str¶
Parent kitchen name