models.Scope¶
- class Scope(json: Dict, **kwargs)[source]¶
A virtual object representing a KE-chain scope.
- Variables:
id – id of the activity
name – name of the activity
created_at – created datetime of the activity
updated_at – updated datetime of the activity
description – description of the activity
workflow_root – uuid of the workflow root object
status – status of the scope. One of
pykechain.enums.ScopeStatus
type – Type of the Scope. One of
pykechain.enums.ScopeType
for WIM version 2
Construct a scope from provided json data.
- property options: Dict¶
Options of the Scope.
- property representations: List[BaseRepresentation]¶
Get and set the scope representations.
- property workflow_root_process: Activity¶
Retrieve the Activity root object with classification WORKFLOW.
- property catalog_root_process: Activity¶
Retrieve the Activity root object with classification CATALOG.
- property product_root_model: Part¶
Retrieve the Part root object with classification PRODUCT and category MODEL.
- property product_root_instance: Part¶
Retrieve the Part root object with classification PRODUCT and category INSTANCE.
- property catalog_root_model: Part¶
Retrieve the Part root object with classification CATALOG and category MODEL.
- property catalog_root_instance: Part¶
Retrieve the Part root object with classification CATALOG and category INSTANCE.
- get_project_info()[source]¶
Retrieve the project info attribute set on the Scope.
- Returns:
the project info
- set_project_info(project_info: list) None [source]¶
Set the project info attribute on the Scope.
The Scope attribute project_info hold scope ‘meta’ information for end-user to add some user-defined fields and values. This project_info can be displayed in a WidgetType.PROJECTINFO widget that can be included on every Activity or StatusForm.
The structure of the project_info is the following: ``` :param project_info = [
- {
“id”: 0, “name”:”fieldname”, “value”:”field value”, “property_type”:PropertyType.CHARVALUE, “unit”:”kg”, # optional “description”: “a short description” # optional
}, {…}
] :type project_info: list of dicts ``` The allowed propertypes are: CHAR, TEXT, INT, FLOAT, LINK, DATETIME, DATE, TIME, DURATION
- Returns:
the updated forms
- edit(name: str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, description: str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, start_date: ~datetime.datetime | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, due_date: ~datetime.datetime | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, status: str | ~pykechain.enums.ScopeStatus | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, category: str | ~pykechain.enums.ScopeCategory | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, tags: ~typing.List[str] | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, team: ~pykechain.models.team.Team | str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, project_info: ~typing.List[~typing.Dict] | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, options: ~typing.Dict | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, **kwargs) None [source]¶
Edit the details of a scope.
Setting an input to None will clear out the value (exception being name and status).
- Parameters:
name – (optionally) edit the name of the scope. Name cannot be cleared.
description – (optionally) edit the description of the scope or clear it
start_date – (optionally) edit the start date of the scope as a datetime object (UTC time/timezone aware preferred) or clear it
due_date – (optionally) edit the due_date of the scope as a datetime object (UTC time/timzeone aware preferred) or clear it
status – (optionally) edit the status of the scope as a string based. Status cannot be cleared.
:param category (optionally) edit the category of the scope :param tags: (optionally) replace the tags on a scope, which is a list of strings [“one”,”two”,”three”] or
clear them
- Parameters:
team – (optionally) add the scope to a team. Team cannot be cleared.
project_info – (optionally) update the project_info on a scope.
options – (optionally) custom options dictionary stored on the scope object
- Raises:
IllegalArgumentError – if the type of the inputs is not correct
APIError – if another Error occurs
- Warns:
UserWarning - When a naive datetime is provided. Defaults to UTC.
Examples
>>> from datetime import datetime >>> project.edit(name='New project name',description='Changing the description just because I can', ... start_date=datetime.now(),status=ScopeStatus.CLOSED)
If we want to provide timezone aware datetime objects we can use the 3rd party convenience library
pytz
. Mind that we need to fetch the timezone first and use <timezone>.localize(<your datetime>) to make it work correctly.Using datetime(2017,6,1,23,59,0 tzinfo=<tz>) does NOT work for most timezones with a daylight saving time. Check the pytz documentation.
To make it work using
pytz
and timezone awaredatetime
see the following example:>>> import pytz >>> start_date_tzaware = datetime.now(pytz.utc) >>> mytimezone = pytz.timezone('Europe/Amsterdam') >>> due_date_tzaware = mytimezone.localize(datetime(2019, 10, 27, 23, 59, 0)) >>> project.edit(start_date=start_date_tzaware,due_date=due_date_tzaware)
To assign a scope to a team see the following example:
>>> my_team = client.team(name='My own team') >>> project.edit(team=my_team)
Not mentioning an input parameter in the function will leave it unchanged. Setting a parameter as None will clear its value (where that is possible). The example below will clear the due_date, but leave everything else unchanged.
>>> project.edit(due_date=None)
- clone(**kwargs) Scope [source]¶
Clone a scope.
See :method:`pykechain.Client.clone_scope()` for available parameters.
- delete(asynchronous=True)[source]¶
Delete the scope.
Only works with enough permissions.
See :method:`pykechain.Client.delete_scope()` for available parameters. :raises ForbiddenError: if you do not have the permissions to delete a scope
- parts(*args, **kwargs) List[Part] [source]¶
Retrieve parts belonging to this scope.
This uses
See
pykechain.Client.parts
for available parameters.
- part(*args, **kwargs) Part [source]¶
Retrieve a single part belonging to this scope.
See
pykechain.Client.part
for available parameters.
- properties(*args, **kwargs) List[Property] [source]¶
Retrieve properties belonging to this scope.
See
pykechain.Client.properties
for available parameters.
- property(*args, **kwargs) Property [source]¶
Retrieve a single property belonging to this scope.
See
pykechain.Client.property
for available parameters.
- model(*args, **kwargs) Part [source]¶
Retrieve a single model belonging to this scope.
See
pykechain.Client.model
for available parameters.
- create_model(parent, name, multiplicity='ZERO_MANY') Part [source]¶
Create a single part model in this scope.
See
pykechain.Client.create_model
for available parameters.
- create_model_with_properties(parent, name, multiplicity='ZERO_MANY', properties_fvalues=None, **kwargs) Part [source]¶
Create a model with its properties in a single API request.
See
pykechain.Client.create_model_with_properties()
for available parameters.
- activities(*args, **kwargs) List[Activity] [source]¶
Retrieve activities belonging to this scope.
See
pykechain.Client.activities
for available parameters.
- activity(*args, **kwargs) Activity [source]¶
Retrieve a single activity belonging to this scope.
See
pykechain.Client.activity
for available parameters.
- create_activity(*args, **kwargs) Activity [source]¶
Create a new activity belonging to this scope.
See
pykechain.Client.create_activity
for available parameters.
- side_bar(*args, **kwargs) SideBarManager | None [source]¶
Retrieve the side-bar manager.
- set_landing_page(activity: Activity | KEChainPages, task_display_mode: SubprocessDisplayMode | None = 'activities') None [source]¶
Update the landing page of the scope.
- Parameters:
activity ((Activity, KEChainPages)) – Activity object or KEChainPages option
task_display_mode (SubprocessDisplayMode) – display mode of the activity in KE-chain
- Returns:
None
:rtype None
- get_landing_page_url() str | None [source]¶
Retrieve the landing page URL, if it is set in the options.
- Returns:
Landing page url
- services(*args, **kwargs) List[Service] [source]¶
Retrieve services belonging to this scope.
See
pykechain.Client.services
for available parameters.New in version 1.13.
- create_service(*args, **kwargs) Service [source]¶
Create a service to current scope.
See
pykechain.Client.create_service
for available parameters.New in version 1.13.
- service(*args, **kwargs) Service [source]¶
Retrieve a single service belonging to this scope.
See
pykechain.Client.service
for available parameters.New in version 1.13.
- service_executions(*args, **kwargs) List[ServiceExecution] [source]¶
Retrieve services belonging to this scope.
See
pykechain.Client.service_executions
for available parameters.New in version 1.13.
- service_execution(*args, **kwargs) ServiceExecution [source]¶
Retrieve a single service execution belonging to this scope.
See
pykechain.Client.service_execution
for available parameters.New in version 1.13.
- members(is_manager: bool | None = None, is_supervisor: bool | None = None, is_leadmember: bool | None = None) List[Dict] [source]¶
Retrieve members of the scope.
Changed in version 3.7: we added the supervisor members for backend that support this.
- Parameters:
is_manager (bool) – (otional) set to True/False to filter members that are/aren’t managers, resp.
is_supervisor (bool) – (optional) set to True/False to filter members that are/aren’t supervisors, resp.
is_leadmember (bool) – (optional) set to True/False to filter members that are/aren’t leadmembers, resp.
- Returns:
List of members, each defined as a dict
Examples
>>> members = project.members() >>> managers = project.members(is_manager=True) >>> supervisors = project.members(is_supervisor=True) >>> leadmembers = project.members(is_leadmember=True)
- add_member(member: str) None [source]¶
Add a single member to the scope.
You may only edit the list of members if the pykechain credentials allow this.
- Parameters:
member (basestring) – single username to be added to the scope list of members
- Raises:
APIError – when unable to update the scope member
- remove_member(member: str) None [source]¶
Remove a single member to the scope.
- Parameters:
member (basestring) – single username to be removed from the scope list of members
- Raises:
APIError – when unable to update the scope member
- add_manager(manager: str) None [source]¶
Add a single manager to the scope.
- Parameters:
manager (basestring) – single username to be added to the scope list of managers
- Raises:
APIError – when unable to update the scope manager
- remove_manager(manager: str) None [source]¶
Remove a single manager to the scope.
- Parameters:
manager (basestring) – single username to be added to the scope list of managers
- Raises:
APIError – when unable to update the scope manager
- add_leadmember(leadmember: str) None [source]¶
Add a single leadmember to the scope.
- Parameters:
leadmember (basestring) – single username to be added to the scope list of leadmembers
- Raises:
APIError – when unable to update the scope leadmember
- remove_leadmember(leadmember: str) None [source]¶
Remove a single leadmember to the scope.
- Parameters:
leadmember (basestring) – single username to be added to the scope list of leadmembers
- Raises:
APIError – when unable to update the scope leadmember
- add_supervisor(supervisor: str) None [source]¶
Add a single supervisor to the scope.
New in version 3.7: requires backend version 3.7 as well.
- Parameters:
supervisor (basestring) – single username to be added to the scope list of supervisors
- Raises:
APIError – when unable to update the scope supervisor
- remove_supervisor(supervisor: str) None [source]¶
Remove a single supervisor to the scope.
New in version 3.7: requires backend version 3.7 as well.
- Parameters:
supervisor (basestring) – single username to be added to the scope list of supervisors
- Raises:
APIError – when unable to update the scope supervisor
- context(*args, **kwargs) Context [source]¶
Retrieve a context object in this scope.
See
pykechain.Client.context
for available parameters.New in version 3.11.
- Returns:
a Context object
- contexts(*args, **kwargs) List[Context] [source]¶
Retrieve one or more contexts object in this scope.
See
pykechain.Client.contexts
for available parameters.New in version 3.11.
- Returns:
a list of Context objects
- create_context(*args, **kwargs) Context [source]¶
Create a new Context object of a ContextType in a scope.
See
pykechain.Client.create_context
for available parameters.New in version 3.11.
- Returns:
a Context object
- forms(**kwargs) List['Form'] [source]¶
Retrieve Form objects in a scope.
See
pykechain.Client.forms
for available parameters.- Returns:
a list of Form objects
- form(**kwargs) Form [source]¶
Retrieve a Form object in a scope.
See
pykechain.Client.form
for available parameters.- Returns:
a Form object
- create_form_model(*args, **kwargs) Form [source]¶
Create a new Form object in a scope.
See
Form.create_model()
for available parameters.- Returns:
a Form object
- instantiate_form(model, *args, **kwargs) Form [source]¶
Create a new Form instance based on a model.
See the Form.instantiate() method for available arguments.
- Returns:
a created Form Instance
- workflows(**kwargs) List[Workflow] [source]¶
Retrieve Workflow objects in a scope.
See
pykechain.Client.workflows
for available parameters.- Returns:
a list of Workflow objects
- workflow(**kwargs) Workflow [source]¶
Retrieve a Workflow object in a scope.
See
pykechain.Client.workflow
for available parameters.- Returns:
a Workflow object