-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add optional audience parameter to credential exchange related methods #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9d8c088
c10b9ea
80fe4db
274f1d6
7ec16c6
22d43c0
83dec3b
ef3d299
8b12a43
0c298d8
dfbd8a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
from __future__ import annotations | ||
|
||
import os | ||
import posixpath | ||
import time | ||
|
||
|
@@ -1000,3 +1001,16 @@ def get(self, guid: str) -> ContentItem: | |
|
||
response = self._ctx.client.get(f"v1/content/{guid}", params=params) | ||
return ContentItem(self._ctx, **response.json()) | ||
|
||
@property | ||
def current(self) -> ContentItem: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Did you consider making this the default behavior for |
||
"""Get the content item for the current context. | ||
|
||
Returns | ||
------- | ||
ContentItem | ||
""" | ||
guid = os.getenv("CONNECT_CONTENT_GUID") | ||
if not guid: | ||
raise RuntimeError("CONNECT_CONTENT_GUID environment variable is not set.") | ||
return self.get(guid) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
"""OAuth association resources.""" | ||
|
||
from typing_extensions import List | ||
from __future__ import annotations | ||
|
||
from ..context import Context | ||
import re | ||
|
||
from typing_extensions import TYPE_CHECKING, List, Optional | ||
|
||
# from ..context import requires | ||
from ..resources import BaseResource, Resources | ||
|
||
if TYPE_CHECKING: | ||
from ..context import Context | ||
from ..oauth import types | ||
|
||
|
||
class Association(BaseResource): | ||
pass | ||
|
@@ -59,16 +67,78 @@ def find(self) -> List[Association]: | |
for result in response.json() | ||
] | ||
|
||
# TODO turn this on before merging | ||
# @requires("2025.07.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can do |
||
def find_by( | ||
self, | ||
integration_type: Optional[types.OAuthIntegrationType | str] = None, | ||
auth_type: Optional[types.OAuthIntegrationAuthType | str] = None, | ||
name: Optional[str] = None, | ||
description: Optional[str] = None, | ||
guid: Optional[str] = None, | ||
) -> Association | None: | ||
"""Find an OAuth integration associated with content by various criteria. | ||
|
||
Parameters | ||
---------- | ||
integration_type : Optional[types.OAuthIntegrationType | str] | ||
The type of the integration (e.g., "aws", "azure"). | ||
auth_type : Optional[types.OAuthIntegrationAuthType | str] | ||
The authentication type of the integration (e.g., "Viewer", "Service Account"). | ||
name : Optional[str] | ||
A regex pattern to match the integration name. For exact matches, use `^` and `$`. For example, | ||
`^My Integration$` will match only "My Integration". | ||
description : Optional[str] | ||
A regex pattern to match the integration description. For exact matches, use `^` and `$`. For example, | ||
`^My Integration Description$` will match only "My Integration Description". | ||
guid : Optional[str] | ||
The unique identifier of the integration. | ||
|
||
Returns | ||
------- | ||
Association | None | ||
The first matching association, or None if no match is found. | ||
""" | ||
for integration in self.find(): | ||
if ( | ||
integration_type is not None | ||
and integration.get("oauth_integration_template") != integration_type | ||
): | ||
continue | ||
|
||
if ( | ||
auth_type is not None | ||
and integration.get("oauth_integration_auth_type") != auth_type | ||
): | ||
continue | ||
|
||
if name is not None: | ||
integration_name = integration.get("oauth_integration_name", "") | ||
if not re.search(name, integration_name): | ||
continue | ||
|
||
if description is not None: | ||
integration_description = integration.get("oauth_integration_description", "") | ||
if not re.search(description, integration_description): | ||
continue | ||
|
||
if guid is not None and integration.get("oauth_integration_guid") != guid: | ||
continue | ||
|
||
return integration | ||
|
||
return None | ||
|
||
def delete(self) -> None: | ||
"""Delete integration associations.""" | ||
data = [] | ||
|
||
path = f"v1/content/{self.content_guid}/oauth/integrations/associations" | ||
self._ctx.client.put(path, json=data) | ||
|
||
def update(self, integration_guid: str) -> None: | ||
def update(self, integration_guids: list[str]) -> None: | ||
"""Set integration associations.""" | ||
data = [{"oauth_integration_guid": integration_guid}] | ||
data = [{"oauth_integration_guid": guid} for guid in integration_guids] | ||
|
||
path = f"v1/content/{self.content_guid}/oauth/integrations/associations" | ||
self._ctx.client.put(path, json=data) |
Uh oh!
There was an error while loading. Please reload this page.