Skip to content

Commit d89c583

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 d89c583

File tree

8 files changed

+85
-53
lines changed

8 files changed

+85
-53
lines changed

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

Lines changed: 11 additions & 0 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
@@ -72,6 +75,14 @@ def from_api(cls, entity: dict[str, Any]) -> CatalogIdentityProvider:
7275
attributes=attr,
7376
)
7477

78+
@classmethod
79+
def to_api_patch(cls, identity_provider_id: str, attributes: dict) -> JsonApiIdentityProviderPatchDocument:
80+
return JsonApiIdentityProviderPatchDocument(
81+
data=JsonApiIdentityProviderPatch(
82+
id=identity_provider_id, attributes=JsonApiIdentityProviderPatchAttributes(**attributes)
83+
)
84+
)
85+
7586

7687
@attr.s(auto_attribs=True, kw_only=True)
7788
class CatalogIdentityProviderAttributes(Base):

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]:

gooddata-sdk/tests/catalog/fixtures/organization/create_identity_provider.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ interactions:
66
uri: http://localhost:3000/api/v1/entities/identityProviders
77
body:
88
data:
9-
id: test_identity_provider
10-
type: identityProvider
119
attributes:
12-
customClaimMapping:
13-
email: email
1410
identifiers:
1511
- goodtesting.com
12+
customClaimMapping:
13+
email: email
1614
oauthClientId: test_client_id
1715
oauthClientSecret: test_client_secret
18-
oauthIssuerId: test_issuer_id
1916
oauthIssuerLocation: https://issuer.goodtesting.com
17+
id: test_identity_provider
18+
type: identityProvider
2019
headers:
2120
Accept:
2221
- application/vnd.gooddata.api+json
@@ -88,16 +87,15 @@ interactions:
8887
body:
8988
string:
9089
data:
91-
id: test_identity_provider
92-
type: identityProvider
9390
attributes:
9491
identifiers:
9592
- goodtesting.com
9693
customClaimMapping:
9794
email: email
9895
oauthClientId: test_client_id
9996
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id
97+
id: test_identity_provider
98+
type: identityProvider
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
103101
- request:
@@ -172,16 +170,15 @@ interactions:
172170
body:
173171
string:
174172
data:
175-
id: test_identity_provider
176-
type: identityProvider
177173
attributes:
178174
identifiers:
179175
- goodtesting.com
180176
customClaimMapping:
181177
email: email
182178
oauthClientId: test_client_id
183179
oauthIssuerLocation: https://issuer.goodtesting.com
184-
oauthIssuerId: test_issuer_id
180+
id: test_identity_provider
181+
type: identityProvider
185182
links:
186183
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
187184
- request:

gooddata-sdk/tests/catalog/fixtures/organization/delete_identity_provider.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ interactions:
99
id: test_identity_provider
1010
type: identityProvider
1111
attributes:
12-
customClaimMapping:
13-
email: email
1412
identifiers:
1513
- goodtesting.com
14+
customClaimMapping:
15+
email: email
1616
oauthClientId: test_client_id
1717
oauthClientSecret: test_client_secret
18-
oauthIssuerId: test_issuer_id
1918
oauthIssuerLocation: https://issuer.goodtesting.com
2019
headers:
2120
Accept:
@@ -97,7 +96,6 @@ interactions:
9796
email: email
9897
oauthClientId: test_client_id
9998
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
103101
- request:

gooddata-sdk/tests/catalog/fixtures/organization/layout_identity_providers.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ interactions:
7878
uri: http://localhost:3000/api/v1/layout/identityProviders
7979
body:
8080
- id: test_identity_provider
81-
customClaimMapping:
82-
email: email
8381
identifiers:
8482
- goodtesting.com
83+
customClaimMapping:
84+
email: email
8585
oauthClientId: test_client_id
8686
oauthClientSecret: test_client_secret
87-
oauthIssuerId: test_issuer_id
8887
oauthIssuerLocation: https://issuer.goodtesting.com
8988
headers:
9089
Accept-Encoding:
@@ -228,7 +227,6 @@ interactions:
228227
identifiers:
229228
- goodtesting.com
230229
oauthClientId: test_client_id
231-
oauthIssuerId: test_issuer_id
232230
oauthIssuerLocation: https://issuer.goodtesting.com
233231
- request:
234232
method: PUT

gooddata-sdk/tests/catalog/fixtures/organization/list_identity_providers.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ interactions:
99
id: test_identity_provider_1
1010
type: identityProvider
1111
attributes:
12-
customClaimMapping:
13-
email: email
1412
identifiers:
1513
- goodtesting.com
14+
customClaimMapping:
15+
email: email
1616
oauthClientId: test_client_id_1
1717
oauthClientSecret: test_client_secret_1
18-
oauthIssuerId: test_issuer_id_1
1918
oauthIssuerLocation: https://issuer.goodtesting.com
2019
headers:
2120
Accept:
@@ -97,7 +96,6 @@ interactions:
9796
email: email
9897
oauthClientId: test_client_id_1
9998
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id_1
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_1
103101
- request:
@@ -108,13 +106,12 @@ interactions:
108106
id: test_identity_provider_2
109107
type: identityProvider
110108
attributes:
111-
customClaimMapping:
112-
email: email
113109
identifiers:
114110
- goodtesting.com
111+
customClaimMapping:
112+
email: email
115113
oauthClientId: test_client_id_2
116114
oauthClientSecret: test_client_secret_2
117-
oauthIssuerId: test_issuer_id_2
118115
oauthIssuerLocation: https://issuer.goodtesting.com
119116
headers:
120117
Accept:
@@ -195,7 +192,6 @@ interactions:
195192
email: email
196193
oauthClientId: test_client_id_2
197194
oauthIssuerLocation: https://issuer.goodtesting.com
198-
oauthIssuerId: test_issuer_id_2
199195
links:
200196
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_2
201197
- request:
@@ -279,7 +275,6 @@ interactions:
279275
email: email
280276
oauthClientId: test_client_id_1
281277
oauthIssuerLocation: https://issuer.goodtesting.com
282-
oauthIssuerId: test_issuer_id_1
283278
links:
284279
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_1
285280
- id: test_identity_provider_2
@@ -291,7 +286,6 @@ interactions:
291286
email: email
292287
oauthClientId: test_client_id_2
293288
oauthIssuerLocation: https://issuer.goodtesting.com
294-
oauthIssuerId: test_issuer_id_2
295289
links:
296290
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_2
297291
links:

gooddata-sdk/tests/catalog/fixtures/organization/update_identity_provider.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ interactions:
99
id: test_identity_provider
1010
type: identityProvider
1111
attributes:
12-
customClaimMapping:
13-
email: email
1412
identifiers:
1513
- goodtesting.com
14+
customClaimMapping:
15+
email: email
1616
oauthClientId: test_client_id
1717
oauthClientSecret: test_client_secret
18-
oauthIssuerId: test_issuer_id
1918
oauthIssuerLocation: https://issuer.goodtesting.com
2019
headers:
2120
Accept:
@@ -97,7 +96,6 @@ interactions:
9796
email: email
9897
oauthClientId: test_client_id
9998
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
103101
- request:
@@ -108,14 +106,13 @@ interactions:
108106
id: test_identity_provider
109107
type: identityProvider
110108
attributes:
111-
customClaimMapping:
112-
email: email
113109
identifiers:
114110
- goodtesting.com
115111
- anotheridentifier.com
112+
customClaimMapping:
113+
email: email
116114
oauthClientId: test_client_id
117115
oauthClientSecret: test_client_secret
118-
oauthIssuerId: test_issuer_id
119116
oauthIssuerLocation: https://issuer.goodtesting.com
120117
headers:
121118
Accept:
@@ -197,7 +194,6 @@ interactions:
197194
email: email
198195
oauthClientId: test_client_id
199196
oauthIssuerLocation: https://issuer.goodtesting.com
200-
oauthIssuerId: test_issuer_id
201197
links:
202198
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
203199
- request:
@@ -282,7 +278,6 @@ interactions:
282278
email: email
283279
oauthClientId: test_client_id
284280
oauthIssuerLocation: https://issuer.goodtesting.com
285-
oauthIssuerId: test_issuer_id
286281
links:
287282
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
288283
- request:

0 commit comments

Comments
 (0)