Workspace Entity¶
The Workspace entity is kept under the following import statement:
Attributes¶
Below we have the most common attributes used in the Workspace entity:
-
name: The name of the Workspace entity. Also serves as the unique identifier (idis an alias forname). -
description: The current description of the workspace. -
group: An optional group label used to organize workspaces together.
Instantiating a Workspace Entity and Passing Attributes¶
To instantiate a Workspace entity, we can use the following code snippet:
Now we can manually set the class attributes in order to properly configure our Workspace entity.
workspace.name = 'my-workspace'
workspace.description = 'Production workspace'
workspace.group = 'production'
Convert Workspace to a Dictionary¶
Most times when working with entities, there might be a point where we need to convert the entity to a dictionary, and to achieve this we simply use the to_dict() method:
workspace = Workspace()
type(workspace)
everysk.sdk.entities.workspace.base.Workspace
to_dict = workspace.to_dict()
type(to_dict)
# dict
Validating a Workspace Entity¶
The validate() method from the Workspace entity is used as a lazy validation method in order to check if the entity is valid or not by returning a boolean value:
In the case of an invalid entity, meaning that some field is missing or has an invalid value, the validate() method will raise a FieldValueError: