diff --git a/changelog.d/20250425_135326_salome.voltz.md b/changelog.d/20250425_135326_salome.voltz.md new file mode 100644 index 00000000..c686ae0f --- /dev/null +++ b/changelog.d/20250425_135326_salome.voltz.md @@ -0,0 +1,41 @@ + + + + + + + +### Fixed + +- Added missing scopes to the TokenScope Enum. + + diff --git a/pygitguardian/models.py b/pygitguardian/models.py index d3af5581..8647532c 100644 --- a/pygitguardian/models.py +++ b/pygitguardian/models.py @@ -749,7 +749,11 @@ class TokenScope(str, Enum): IP_ALLOWLIST_WRITE = "ip_allowlist:write" SOURCES_READ = "sources:read" SOURCES_WRITE = "sources:write" - NHI_WRITE = "nhi:write" + NHI_WRITE_VAULT = "nhi:write-vault" + NHI_SEND_INVENTORY = "nhi:send-inventory" + CUSTOM_TAGS_READ = "custom_tags:read" + CUSTOM_TAGS_WRITE = "custom_tags:write" + SECRET_READ = "secrets:read" class APITokensResponseSchema(BaseSchema): @@ -764,7 +768,7 @@ class APITokensResponseSchema(BaseSchema): revoked_at = fields.AwareDateTime(allow_none=True) member_id = fields.Int(allow_none=True) creator_id = fields.Int(allow_none=True) - scopes = fields.List(fields.Enum(TokenScope, by_value=True), required=False) + scopes = fields.List(fields.String, required=False) @post_load def make_api_tokens_response( @@ -789,7 +793,7 @@ def __init__( revoked_at: Optional[datetime] = None, member_id: Optional[int] = None, creator_id: Optional[int] = None, - scopes: Optional[List[TokenScope]] = None, + scopes: Optional[List[str]] = None, ): self.id = id self.name = name diff --git a/tests/test_models.py b/tests/test_models.py index 2d501499..2322d499 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -80,7 +80,7 @@ def test_document_handle_surrogates(self): "revoked_at": "2023-05-27T12:40:55.662949Z", "member_id": 22015, "creator_id": 22015, - "scopes": ["incidents:read", "scan"], + "scopes": ["incidents:read", "scan", "unplanned:scope"], }, ), (MatchSchema, Match, {"match": "hello", "type": "hello"}),