Skip to content

API Manage API assets

Operations on API assets (specs, paths).

Example OpenAPI crawler

For a jump-start, read more about an example for crawling OpenAPI specifications, or grab the code from: atlanhq/atlan-java-samples

In general, these should be:

erDiagram
  Connection ||--o{ APISpec : contains
  APISpec ||--o{ APIPath : contains

Asset structure

Connection

1.4.0 1.0.0

An API connection requires a name and qualifiedName. For creation, specific settings are also required to distinguish it as an API connection rather than another type of connection. In addition, at least one of adminRoles, adminGroups, or adminUsers must be provided.

Create an API connection
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
String adminRoleGuid = RoleCache.getIdForName("$admin"); // (1)
Connection connection = Connection.creator( // (2)
        "api-connection", // (3)
        AtlanConnectorType.API, // (4)
        List.of(adminRoleGuid), // (5)
        List.of("group2"), // (6)
        List.of("jsmith")) // (7)
    .build();
AssetMutationResponse response = connection.save(); // (8)
String connectionQualifiedName = response.getCreatedAssets().get(0).getQualifiedName(); // (9)
  1. Retrieve the GUID for the admin role, to use later for defining the roles that can administer the connection.
  2. Build up the minimum request to create a connection.
  3. Provide a human-readable name for your connection, such as production or development.
  4. Set the type of connection to API.
  5. List the workspace roles that should be able to administer the connection (or null if none). All users with that workspace role (current and future) will be administrators of the connection. Note that the values here need to be the GUID(s) of the workspace role(s). At least one of adminRoles, adminGroups, or adminUsers must be provided.
  6. List the group names that can administer this connection (or null if none). All users within that group (current and future) will be administrators of the connection. Note that the values here are the name(s) of the group(s). At least one of adminRoles, adminGroups, or adminUsers must be provided.
  7. List the user names that can administer this connection (or null if none). Note that the values here are the username(s) of the user(s). At least one of adminRoles, adminGroups, or adminUsers must be provided.
  8. Actually call Atlan to create the connection.
  9. Retrieve the qualifiedName for use in subsequent creation calls. (You'd probably want to do some null checking first.)
Create an API connection
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from pyatlan.cache.role_cache import RoleCache
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Connection, APISpec, APIPath
from pyatlan.model.enums import AtlanConnectorType

admin_role_guid = RoleCache.get_id_for_name("$admin") # (1)
connection = Connection.create( # (2)
    name = "api-connection", # (3)
    connector_type = AtlanConnectorType.API, # (4)
    admin_roles = [admin_role_guid], # (5)
    admin_groups = ["group2"], # (6)
    admin_users = ["jsmith"]) # (7)
) 

response = client.asset.save(connection) # (8)
connection_qualified_name = response.assets_created(asset_type=Connection)[0].qualified_name # (9)
  1. Retrieve the GUID for the admin role, to use later for defining the roles that can administer the connection.
  2. Build up the minimum request to create a connection.
  3. Provide a human-readable name for your connection, such as production or development.
  4. Set the type of connection to API.
  5. List the workspace roles that should be able to administer the connection (or None if none). All users with that workspace role (current and future) will be administrators of the connection. Note that the values here need to be the GUID(s) of the workspace role(s). At least one of admin_roles, admin_groups, or admin_users must be provided.
  6. List the group names that can administer this connection (or None if none). All users within that group (current and future) will be administrators of the connection. Note that the values here are the name(s) of the group(s). At least one of admin_roles, admin_groups, or admin_users must be provided.
  7. List the user names that can administer this connection (or None if none). Note that the values here are the username(s) of the user(s). At least one of admin_roles, admin_groups, or admin_users must be provided.
  8. Actually call Atlan to create the connection.
  9. Retrieve the qualified_name for use in subsequent creation calls. (You'd probably want to do some null checking first.)
POST /api/meta/entity/bulk
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "entities": [
    {
      "typeName": "Connection", // (1)
      "attributes": {
        "name": "api-connection", // (2)
        "connectorName": "api", // (3)
        "qualifiedName": "default/api/123456789", // (4)
        "category": "API", // (5)
        "adminRoles": [ // (6)
          "e7ae0295-c60a-469a-bd2c-fb903943aa02"
        ],
        "adminGroups": [ // (7)
          "group2"
        ],
        "adminUsers": [ // (8)
          "jsmith"
        ]
      }
    }
  ]
}
  1. The typeName must be exactly Connection.
  2. Human-readable name for your connection, such as production or development.
  3. The connectorName must be exactly api.
  4. The qualifiedName should follow the pattern: default/api/<epoch>, where <epoch> is the time in milliseconds at which the connection is being created.
  5. The category must be API.
  6. List any workspace roles that can administer this connection. All users with that workspace role (current and future) will be administrators of the connection. Note that the values here need to be the GUID(s) of the workspace role(s). At least one of adminRoles, adminGroups, or adminUsers must be provided.
  7. List any groups that can administer this connection. All users within that group (current and future) will be administrators of the connection. Note that the values here are the name(s) of the group(s). At least one of adminRoles, adminGroups, or adminUsers must be provided.
  8. List any users that can administer this connection. Note that the values here are the username(s) of the user(s). At least one of adminRoles, adminGroups, or adminUsers must be provided.

Access policies

Atlan creates the policies that grant access to a connection, including the ability to retrieve the connection and to create assets within it, asynchronously. It can take several seconds (even up to approximately 30 seconds) before these are in place after creating the connection.

You may therefore need to wait before you'll be able to create the assets below within the connection.

To confirm access, retrieve the connection after it has been created. The SDKs' retry loops will automatically retry until the connection can be successfully retrieved. At that point, your API token has permission to create the other assets.

Note: if you are reusing an existing connection rather than creating one via your API token, you must give your API token a persona that has access to that connection. Otherwise all attempts to create, read, update, or delete assets within that connection will fail due to a lack of permissions.

APISpec

1.4.0 1.0.0

An API spec requires a name and a qualifiedName. For creation, you also need to specify the connectionQualifiedName of the connection for the spec.

Create an API spec
11
12
13
14
15
16
APISpec apiSpec = APISpec.creator( // (1)
        "api-spec", // (2)
        connectionQualifiedName) // (3)
    .build();
AssetMutationResponse response = apiSpec.save(); // (4)
apiSpec = response.getResult(apiSpec); // (5)
  1. Build up the minimum request to create a spec.
  2. Provide a human-readable name for your spec.
  3. Provide the qualifiedName of the connection for this spec.
  4. Actually call Atlan to create the spec.
  5. Retrieve the created spec for use in subsequent creation calls. (You'd probably want to do some null checking first.)
Create an API spec
17
18
19
20
21
22
apiSpec = APISpec.create( # (1)
    name = "api-spec", # (2)
    connection_qualified_name = connection_qualified_name # (3)
)
response = client.asset.save(apiSpec) # (4)
spec_qualified_name = response.assets_created(asset_type=APISpec)[0].qualified_name # (5)
  1. Build up the minimum request to create an spec.
  2. Provide a human-readable name for your spec.
  3. Provide the qualified_name of the connection for this spec.
  4. Actually call Atlan to create the spec.
  5. Retrieve the created spec for use in subsequent creation calls. (You'd probably want to do some null checking first.)
POST /api/meta/entity/bulk
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "entities": [
    {
      "typeName": "APISpec", // (1)
      "attributes": {
        "name": "api-spec", // (2)
        "qualifiedName": "default/api/123456789/api-spec", // (3)
        "connectionQualifiedName": "default/api/123456789", // (4)
        "connectorName": "api" // (5)
      }
    }
  ]
}
  1. The typeName must be exactly APISpec.
  2. Human-readable name for your spec.
  3. The qualifiedName should follow the pattern: default/api/<epoch>/<specName>, where default/api/<epoch> is the qualifiedName of the connection for this spec and <specName> is the name of this spec.
  4. The connectionQualifiedName must be the exact qualifiedName of the connection for this spec.
  5. The connectorName must be exactly api.

APIPath

1.4.0 1.0.0

An API path requires a name and a qualifiedName. For creation, you also need to specify the connectionQualifiedName of the connection for the path and the apiSpec the path is in. If the name of your path does no give the URI of the endpoint it represents, be sure to also specify the apiPathRawURI.

Create an API path
18
19
20
21
22
APIPath apiPath = APIPath.creator( // (1)
        "/api/path", // (2)
        apiSpec) // (3)
    .build();
AssetMutationResponse response = apiPath.save(); // (4)
  1. Build up the minimum request to create a path.
  2. Provide the unique endpoint URI for this path. (The SDK will also use this by default as the name for the path. If you want a different name, simply add a .name() call onto the builder with your preferred name.)
  3. Provide the spec for this path. If you did not already have the object, you could also use APISpec.refByGuid() with the GUID of the spec, or APISpec.refByQualifiedName() with the qualifiedName of the spec.
  4. Actually call Atlan to create the path.
Create an API path
23
24
25
26
27
apiPath = APIPath.create( # (1)
    path_raw_uri = "/api/path", # (2)
    spec_qualified_name = spec_qualified_name # (3)
)
response = client.asset.save(apiPath) # (4)
  1. Build up the minimum request to create an path.
  2. Provide the unique endpoint URI for this path.
  3. Provide the qualified_name of the API path.
  4. Actually call Atlan to create the path.
POST /api/meta/entity/bulk
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
  "entities": [
    {
      "typeName": "APIPath", // (1)
      "attributes": {
        "name": "/api/path", // (2)
        "apiPathRawURI": "/api/path", // (3)
        "qualifiedName": "default/api/123456789/api-spec/api/path", // (4)
        "connectionQualifiedName": "default/api/123456789", // (5)
        "connectorName": "api", // (6)
        "apiSpec": { // (7)
          "typeName": "APISpec", // (8)
          "uniqueAttributes": { // (9)
            "qualifiedName": "default/api/123456789/api-spec"
          }
        }
      }
    }
  ]
}
  1. The typeName must be exactly APIPath.
  2. Human-readable name for your path.
  3. The apiPathRawURI should be the unique endpoint URI this path represents.
  4. The qualifiedName should follow the pattern: default/api/<epoch>/<specName>/<apiPathRawURI>, where default/api/<epoch>/<specName> is the qualifiedName of the spec for this path and <apiPathRawURI> is the unique endpoint URI the path represents.
  5. The connectionQualifiedName must be the exact qualifiedName of the connection for this path.
  6. The connectorName must be exactly api.
  7. The spec in which this path exists is embedded in the apiSpec attribute.
  8. The typeName for this embedded reference must be APISpec.
  9. To complete the reference, you must include a uniqueAttributes object with the qualifiedName of the spec. Note: the spec must already exist in Atlan before creating the path.

Available relationships

Every level of the API structure is an Asset, and can therefore be related to the following other assets.


title: Asset management overview description: Overview of asset-related entities and their relationships, including glossary terms, links, READMEs, and processes.


erDiagram
  Asset }o--o{ AtlasGlossaryTerm : meanings
  Asset ||--o{ Link : links
  Asset ||--o| Readme : readme
  Asset }o--o{ Process : inputToProcesses
  Asset }o--o{ Process : outputFromProcesses

AtlasGlossaryTerm

A glossary term provides meaning to an asset. The link terms to assets snippet provides more detail on setting this relationship.

A link provides additional context to an asset, by providing a URL to additional information.

Readme

A README provides rich documentation for an asset. The add asset READMEs snippet provides more detail on setting this relationship.

Process

A process provides lineage information for an asset. An asset can be both an input and an output for one or more processes. The lineage snippets provide more detail on creating and working with lineage.


  1. Although if you want to delete everything in a connection, your better avenue is the packaged connection delete utility in the UI.