Skip to content

Commit 7b802a2

Browse files
feat: ability to patch existing IdP
Fixture updates as well as `oauthIssuerId` is no longer an attripute of IdP JIRA: TRIVIAL risk: low
1 parent 0052c9e commit 7b802a2

9 files changed

Lines changed: 257 additions & 2230 deletions

File tree

gooddata-sdk/gooddata_sdk/catalog/organization/entity_model/identity_provider.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from gooddata_api_client.model.json_api_identity_provider_in import JsonApiIdentityProviderIn
88
from gooddata_api_client.model.json_api_identity_provider_in_attributes import JsonApiIdentityProviderInAttributes
99
from gooddata_api_client.model.json_api_identity_provider_in_document import JsonApiIdentityProviderInDocument
10+
from gooddata_api_client.model.json_api_identity_provider_patch import JsonApiIdentityProviderPatch
11+
from gooddata_api_client.model.json_api_identity_provider_patch_attributes import JsonApiIdentityProviderPatchAttributes
12+
from gooddata_api_client.model.json_api_identity_provider_patch_document import JsonApiIdentityProviderPatchDocument
1013

1114
from gooddata_sdk.catalog.base import Base
1215
from gooddata_sdk.utils import safeget
@@ -38,7 +41,6 @@ def init(
3841
identifiers: Optional[list[str]] = None,
3942
oauth_client_id: Optional[str] = None,
4043
oauth_client_secret: Optional[str] = None,
41-
oauth_issuer_id: Optional[str] = None,
4244
oauth_issuer_location: Optional[str] = None,
4345
saml_metadata: Optional[str] = None,
4446
) -> CatalogIdentityProvider:
@@ -49,7 +51,6 @@ def init(
4951
identifiers=identifiers,
5052
oauth_client_id=oauth_client_id,
5153
oauth_client_secret=oauth_client_secret,
52-
oauth_issuer_id=oauth_issuer_id,
5354
oauth_issuer_location=oauth_issuer_location,
5455
saml_metadata=saml_metadata,
5556
),
@@ -63,7 +64,6 @@ def from_api(cls, entity: dict[str, Any]) -> CatalogIdentityProvider:
6364
identifiers=safeget(ea, ["identifiers"]),
6465
oauth_client_id=safeget(ea, ["oauth_client_id"]),
6566
oauth_client_secret=safeget(ea, ["oauth_client_secret"]),
66-
oauth_issuer_id=safeget(ea, ["oauth_issuer_id"]),
6767
oauth_issuer_location=safeget(ea, ["oauth_issuer_location"]),
6868
saml_metadata=safeget(ea, ["saml_metadata"]),
6969
)
@@ -72,14 +72,21 @@ def from_api(cls, entity: dict[str, Any]) -> CatalogIdentityProvider:
7272
attributes=attr,
7373
)
7474

75+
@classmethod
76+
def to_api_patch(cls, identity_provider_id: str, attributes: dict) -> JsonApiIdentityProviderPatchDocument:
77+
return JsonApiIdentityProviderPatchDocument(
78+
data=JsonApiIdentityProviderPatch(
79+
id=identity_provider_id, attributes=JsonApiIdentityProviderPatchAttributes(**attributes)
80+
)
81+
)
82+
7583

7684
@attr.s(auto_attribs=True, kw_only=True)
7785
class CatalogIdentityProviderAttributes(Base):
7886
custom_claim_mapping: Optional[dict[str, str]] = None
7987
identifiers: Optional[list[str]] = None
8088
oauth_client_id: Optional[str] = None
8189
oauth_client_secret: Optional[str] = None
82-
oauth_issuer_id: Optional[str] = None
8390
oauth_issuer_location: Optional[str] = None
8491
saml_metadata: Optional[str] = None
8592

gooddata-sdk/gooddata_sdk/catalog/organization/layout/identity_provider.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class CatalogDeclarativeIdentityProvider(Base):
1515
identifiers: Optional[list[str]] = None
1616
oauth_client_id: Optional[str] = None
1717
oauth_client_secret: Optional[str] = None
18-
oauth_issuer_id: Optional[str] = None
1918
oauth_issuer_location: Optional[str] = None
2019
saml_metadata: Optional[str] = None
2120

gooddata-sdk/gooddata_sdk/catalog/organization/service.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,23 @@ def update_identity_provider(self, identity_provider: CatalogIdentityProvider) -
407407
f"Can not update {identity_provider.id} identity provider. This identity provider does not exist."
408408
)
409409

410+
def patch_identity_provider_attributes(self, identity_provider_id: str, attributes: dict) -> None:
411+
"""Applies changes to the specified identity provider.
412+
413+
Args:
414+
identity_provider_id (str):
415+
Identity Provider identification string. e.g. "auth0"
416+
attributes (dict):
417+
A dictionary containing attributes of the identity provider to be changed.
418+
419+
Returns:
420+
None
421+
"""
422+
423+
self._entities_api.patch_entity_identity_providers(
424+
identity_provider_id, CatalogIdentityProvider.to_api_patch(identity_provider_id, attributes)
425+
)
426+
410427
# Layout APIs
411428

412429
def get_declarative_notification_channels(self) -> list[CatalogDeclarativeNotificationChannel]:

0 commit comments

Comments
 (0)