Skip to content

Commit

Permalink
source-genesys: add discriminator to endpoint config's credentials
Browse files Browse the repository at this point in the history
Additionally, wrap the `ClientCredentialsOAuth2Credentials` class in a more user-friendly name since it shows up in the UI. There's likely a more elegant & correct solution to fix this, but I haven't found it yet.
  • Loading branch information
Alex-Bair committed Nov 13, 2024
1 parent df5aec7 commit c81dee6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 6 additions & 2 deletions source-genesys/source_genesys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
}
)

OAuth2Credentials = ClientCredentialsOAuth2Credentials
# The class name appears in the UI's Authentication section, so we wrap the non-user friendly name in a slighly better name.
# TODO(alex): figure out why the class name is appearing in the UI & determine if there's some property to set that overrides it.
class OAuth(ClientCredentialsOAuth2Credentials):
pass


def default_start_date():
Expand Down Expand Up @@ -55,8 +58,9 @@ class EndpointConfig(BaseModel):
] = Field(
title="Genesys Cloud Domain"
)
credentials: OAuth2Credentials = Field(
credentials: OAuth = Field(
title="Authentication",
discriminator="credentials_title"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"protocol": 3032023,
"configSchema": {
"$defs": {
"ClientCredentialsOAuth2Credentials": {
"OAuth": {
"properties": {
"credentials_title": {
"const": "OAuth Credentials",
Expand All @@ -29,7 +29,7 @@
"client_id",
"client_secret"
],
"title": "ClientCredentialsOAuth2Credentials",
"title": "OAuth",
"type": "object"
}
},
Expand Down Expand Up @@ -62,7 +62,17 @@
"type": "string"
},
"credentials": {
"$ref": "#/$defs/ClientCredentialsOAuth2Credentials",
"discriminator": {
"mapping": {
"OAuth Credentials": "#/$defs/OAuth"
},
"propertyName": "credentials_title"
},
"oneOf": [
{
"$ref": "#/$defs/OAuth"
}
],
"title": "Authentication"
}
},
Expand Down

0 comments on commit c81dee6

Please sign in to comment.