API token connection admin package
The API token connection admin package allows you to assign an API token to a connection as a connection admin. This is a necessary step when:
- A connection is created through a workflow, run by a user
- You want to use an API token to programmatically administrate the connection or its assets (in particular, to manage policies in a persona)
Configuration
To set up the API token connection admin with the specified configuration.
- Java
- Python
- Kotlin
- Raw REST API
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.packages import APITokenConnectionAdmin
client = AtlanClient()
workflow = (
APITokenConnectionAdmin() # (1)
.config( # (2)
connection_qualified_name="default/snowflake/1234567890",
api_token_guid="92588c67-5ddf-4a45-8b5c-dd92f4b84e99",
)
.to_workflow() # (3)
)
response = client.workflow.run(workflow) # (4)
-
The API token connection admin package allows you to assign an API token to a connection as a connection admin.
-
Set up the API token connection admin with the specified configuration.
- connection_qualified_name: connection qualified name to which you want to add the API token as a connection admin
- api_token_guid: GUID of the API token
-
Convert the package into a
Workflowobject. -
Run the workflow by invoking the
run()method on the workflow client, passing the created object.Workflows run asynchronously
Remember that workflows run asynchronously. See the packages and workflows introduction for details on how to check the status and wait until the workflow has been completed. :::
We recommend creating the workflow only via the UI. To rerun an existing workflow, see the steps below.
Re-run existing workflow
To re-run an existing api token connection admin workflow:
- Java
- Python
- Kotlin
- Raw REST API
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.enums import WorkflowPackage
client = AtlanClient()
existing = client.workflow.find_by_type( # (1)
prefix=WorkflowPackage.API_TOKEN_CONNECTION_ADMIN, max_results=5
)
# Determine which api token connection admin workflow (n)
# from the list of results you want to re-run.
response = client.workflow.rerun(existing[n]) # (2)
-
You can find workflows by their type using the workflow client
find_by_type()method and providing the prefix for one of the packages. In this example, we do so for theAPITokenConnectionAdmin. (You can also specify the maximum number of resulting workflows you want to retrieve as results.) -
Once you've found the workflow you want to re-run, you can simply call the workflow client
rerun()method.- Optionally, you can use
rerun(idempotent=True)to avoid re-running a workflow that's already in running or in a pending state. This will return details of the already running workflow if found, and by default, it's set toFalse.
Workflows run asynchronously - Optionally, you can use
Remember that workflows run asynchronously. See the packages and workflows introduction for details on how you can check the status and wait until the workflow has been completed. :::
- Find the existing workflow.
- Send through the resulting re-run request.
{
"from": 0,
"size": 5,
"query": {
"bool": {
"filter": [
{
"nested": {
"path": "metadata",
"query": {
"prefix": {
"metadata.name.keyword": {
"value": "csa-api-token-connection-admin" // (1)
}
}
}
}
}
]
}
},
"sort": [
{
"metadata.creationTimestamp": {
"nested": {
"path": "metadata"
},
"order": "desc"
}
}
],
"track_total_hits": true
}
-
Searching by the
csa-api-token-connection-adminprefix will make sure you only find existing api token connection admin workflows.Name of the workflow
The name of the workflow will be nested within the _source.metadata.name property of the response object.
(Remember since this is a search, there could be multiple results, so you may want to use the other
details in each result to determine which workflow you really want.)
:::
{
"namespace": "default",
"resourceKind": "WorkflowTemplate",
"resourceName": "csa-api-token-connection-admin-1684500411" // (1)
}
- Send the name of the workflow as the
resourceNameto rerun it.