Skip to content

Commit

Permalink
Merge pull request #420 from atlanhq/DVX-777
Browse files Browse the repository at this point in the history
DVX-777: Added `username` and extra `fields` to the `CredentialResponse`
  • Loading branch information
Aryamanz29 authored Nov 20, 2024
2 parents 340fa21 + c611b8e commit 49931ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pyatlan/model/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ class CredentialResponse(AtlanObject):
metadata: Optional[Dict[str, Any]]
level: Optional[Dict[str, Any]]
connection: Optional[Dict[str, Any]]
username: Optional[str]
extras: Optional[Dict[str, Any]] = Field(default=None, alias="extra")

def to_credential(self) -> Credential:
"""
Convert this response into a credential instance.
Note: the username, password, and extras fields
must still all be populated, as they will never be
returned by a credential lookup (for security reasons).
Note: The password field must still be populated manually,
as it will never be returned by a credential lookup for security reasons.
"""
return Credential(
id=self.id,
Expand All @@ -88,6 +89,8 @@ def to_credential(self) -> Credential:
auth_type=self.auth_type,
connector_type=self.connector_type,
connector_config_name=self.connector_config_name,
username=self.username,
extras=self.extras, # type: ignore[call-arg]
)


Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_credential_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def client(mock_api_caller) -> CredentialClient:

@pytest.fixture()
def credential_response() -> CredentialResponse:
return CredentialResponse(
return CredentialResponse( # type: ignore[call-arg]
id="test-id",
version="1.2.3",
is_active=True,
Expand All @@ -67,6 +67,8 @@ def credential_response() -> CredentialResponse:
metadata=None,
level=None,
connection=None,
username="test-username",
extras={"some": "value"},
)


Expand All @@ -77,6 +79,8 @@ def _assert_cred_response(cred: Credential, cred_response: CredentialResponse):
assert cred.auth_type == cred_response.auth_type
assert cred.connector_type == cred_response.connector_type
assert cred.connector_config_name == cred_response.connector_config_name
assert cred.username == cred_response.username
assert cred.extras == cred_response.extras


@pytest.mark.parametrize("test_api_caller", ["abc", None])
Expand Down

0 comments on commit 49931ab

Please sign in to comment.