-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
2,454 additions
and
6 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
gooddata-sdk/gooddata_sdk/catalog/organization/entity_model/identity_provider.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# (C) 2024 GoodData Corporation | ||
from __future__ import annotations | ||
|
||
from typing import Any, Optional | ||
|
||
import attr | ||
from gooddata_api_client.model.json_api_identity_provider_in import JsonApiIdentityProviderIn | ||
from gooddata_api_client.model.json_api_identity_provider_in_attributes import JsonApiIdentityProviderInAttributes | ||
from gooddata_api_client.model.json_api_identity_provider_in_document import JsonApiIdentityProviderInDocument | ||
|
||
from gooddata_sdk.catalog.base import Base | ||
from gooddata_sdk.utils import safeget | ||
|
||
|
||
@attr.s(auto_attribs=True, kw_only=True) | ||
class CatalogIdentityProviderDocument(Base): | ||
data: CatalogIdentityProvider | ||
|
||
@staticmethod | ||
def client_class() -> type[JsonApiIdentityProviderInDocument]: | ||
return JsonApiIdentityProviderInDocument | ||
|
||
|
||
@attr.s(auto_attribs=True, kw_only=True) | ||
class CatalogIdentityProvider(Base): | ||
id: str | ||
attributes: Optional[CatalogIdentityProviderAttributes] = None | ||
|
||
@staticmethod | ||
def client_class() -> type[JsonApiIdentityProviderIn]: | ||
return JsonApiIdentityProviderIn | ||
|
||
@classmethod | ||
def init( | ||
cls, | ||
identity_provider_id: str, | ||
custom_claim_mapping: Optional[dict[str, str]] = None, | ||
identifiers: Optional[list[str]] = None, | ||
oauth_client_id: Optional[str] = None, | ||
oauth_client_secret: Optional[str] = None, | ||
oauth_issuer_id: Optional[str] = None, | ||
oauth_issuer_location: Optional[str] = None, | ||
saml_metadata: Optional[str] = None, | ||
) -> CatalogIdentityProvider: | ||
return cls( | ||
id=identity_provider_id, | ||
attributes=CatalogIdentityProviderAttributes( | ||
custom_claim_mapping=custom_claim_mapping, | ||
identifiers=identifiers, | ||
oauth_client_id=oauth_client_id, | ||
oauth_client_secret=oauth_client_secret, | ||
oauth_issuer_id=oauth_issuer_id, | ||
oauth_issuer_location=oauth_issuer_location, | ||
saml_metadata=saml_metadata, | ||
), | ||
) | ||
|
||
@classmethod | ||
def from_api(cls, entity: dict[str, Any]) -> CatalogIdentityProvider: | ||
ea = entity["attributes"] | ||
attr = CatalogIdentityProviderAttributes( | ||
custom_claim_mapping=safeget(ea, ["custom_claim_mapping"]), | ||
identifiers=safeget(ea, ["identifiers"]), | ||
oauth_client_id=safeget(ea, ["oauth_client_id"]), | ||
oauth_client_secret=safeget(ea, ["oauth_client_secret"]), | ||
oauth_issuer_id=safeget(ea, ["oauth_issuer_id"]), | ||
oauth_issuer_location=safeget(ea, ["oauth_issuer_location"]), | ||
saml_metadata=safeget(ea, ["saml_metadata"]), | ||
) | ||
return cls( | ||
id=entity["id"], | ||
attributes=attr, | ||
) | ||
|
||
|
||
@attr.s(auto_attribs=True, kw_only=True) | ||
class CatalogIdentityProviderAttributes(Base): | ||
custom_claim_mapping: Optional[dict[str, str]] = None | ||
identifiers: Optional[list[str]] = None | ||
oauth_client_id: Optional[str] = None | ||
oauth_client_secret: Optional[str] = None | ||
oauth_issuer_id: Optional[str] = None | ||
oauth_issuer_location: Optional[str] = None | ||
saml_metadata: Optional[str] = None | ||
|
||
@staticmethod | ||
def client_class() -> type[JsonApiIdentityProviderInAttributes]: | ||
return JsonApiIdentityProviderInAttributes |
24 changes: 24 additions & 0 deletions
24
gooddata-sdk/gooddata_sdk/catalog/organization/layout/identity_provider.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# (C) 2024 GoodData Corporation | ||
import builtins | ||
from typing import Optional | ||
|
||
import attr | ||
from gooddata_api_client.model.declarative_identity_provider import DeclarativeIdentityProvider | ||
|
||
from gooddata_sdk.catalog.base import Base | ||
|
||
|
||
@attr.s(auto_attribs=True, kw_only=True) | ||
class CatalogDeclarativeIdentityProvider(Base): | ||
id: str | ||
custom_claim_mapping: Optional[dict[str, str]] = None | ||
identifiers: Optional[list[str]] = None | ||
oauth_client_id: Optional[str] = None | ||
oauth_client_secret: Optional[str] = None | ||
oauth_issuer_id: Optional[str] = None | ||
oauth_issuer_location: Optional[str] = None | ||
saml_metadata: Optional[str] = None | ||
|
||
@staticmethod | ||
def client_class() -> builtins.type[DeclarativeIdentityProvider]: | ||
return DeclarativeIdentityProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.