Skip to content

Commit c043797

Browse files
jens-kuertenJens Kürtenclaude
authored
Feat: Add Role object (Common Roles only) (#53)
* Add Role object (Common Roles only) Lets consumers represent a Common (global) Role, so services like functions-db-service can expose which roles a Person has. Organizational-Context roles are not represented by this object. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Rename Role to CommonRole Per review feedback: naming it Role/"role" now would make it awkward to add other role types (e.g. Org-Context roles) later without a breaking API change, since the discriminator value is part of the wire format. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Jens Kürten <jens.kuerten@contact-software.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e5da9e4 commit c043797

5 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎csfunctions/objects/__init__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .base import BaseObject
66
from .briefcase import Briefcase
77
from .classification import ObjectPropertyValue
8+
from .common_role import CommonRole
89
from .document import CADDocument, Document
910
from .engineering_change import Change, ChangeOrder, ChangeRequest, EngineeringChange
1011
from .file import File
@@ -26,7 +27,8 @@
2627
| Briefcase
2728
| Workflow
2829
| Person
29-
| MaturityLevel,
30+
| MaturityLevel
31+
| CommonRole,
3032
Field(discriminator="object_type"),
3133
]
3234

@@ -48,4 +50,5 @@
4850
"BaseObject",
4951
"Person",
5052
"MaturityLevel",
53+
"CommonRole",
5154
]

‎csfunctions/objects/base.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ObjectType(str, Enum):
2323
BRIEFCASE = "briefcase"
2424
PERSON = "person"
2525
MATURITY_LEVEL = "maturity_level"
26+
COMMON_ROLE = "common_role"
2627

2728

2829
class BaseObject(BaseModel):

‎csfunctions/objects/common_role.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Literal
2+
3+
from pydantic import Field
4+
5+
from csfunctions.objects.base import BaseObject, ObjectType
6+
7+
8+
class CommonRole(BaseObject):
9+
"""
10+
A Common (global) Role that can be assigned to a Person.
11+
"""
12+
13+
object_type: Literal[ObjectType.COMMON_ROLE] = ObjectType.COMMON_ROLE
14+
15+
role_id: str = Field(..., description="Role ID")
16+
name_de: str | None = Field(None, description="Name DE")
17+
name_en: str | None = Field(None, description="Name EN")
18+
name_ja: str | None = Field(None, description="Name JA")
19+
name_zh: str | None = Field(None, description="Name ZH")
20+
cdb_object_id: str | None = Field(None, description="Object ID")

‎docs/reference/objects.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,20 @@ A change request of the ECM module. Shares all attributes of its base class `csf
246246
|cdb_mpersno|str|Last Modified by|
247247
|cdb_mdate|datetime \| None|Last Modified on|
248248

249+
## CommonRole
250+
`csfunctions.objects.CommonRole`
251+
252+
A Common (global) Role that can be assigned to a Person.
253+
254+
|Attribute|Type|Description|
255+
|-|-|-|
256+
|role_id|str|Role ID|
257+
|name_de|str \| None|Name DE|
258+
|name_en|str \| None|Name EN|
259+
|name_ja|str \| None|Name JA|
260+
|name_zh|str \| None|Name ZH|
261+
|cdb_object_id|str \| None|Object ID|
262+
249263
## Document
250264
`csfunctions.objects.Document`
251265

‎docs/release_notes.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ hide:
33
- toc
44
---
55

6+
### Version next
7+
- Feat: Add CommonRole object
8+
69
### Version 0.27.0
710
- Feat: Add part_blocked and document_blocked events
811
- Feat: Add reviewers field to PartReleaseCheckEvent and DocumentReleaseCheckEvent, populated for express releases

0 commit comments

Comments
 (0)