Find connections¶
Find a connection by name and type¶
You may have noticed that connections in Atlan have qualifiedName
s that include a timestamp. As a result, they are not trivial to directly construct.
However, you can search for them by name and type to resolve their qualifiedName
:
Find a connection by name and type | |
---|---|
1 2 3 |
|
- Use the
findByName
static method on theConnection
class to search for connections by name and type. If you name your connections uniquely (by type), this should only return a single-item list. - Provide the name of the connection (this will be exact-matched).
- Provide the type of the connection. You can also (optionally) provide a list of extra attributes you want to retrieve for the connection. Core attributes like
qualifiedName
and its GUID are already included.
Find a connection by name and type | |
---|---|
1 2 3 4 5 6 7 8 9 |
|
- Use the
asset.find_connections_by_name
method on theAtlanClient
class to search for connections by name and type. If you name your connections uniquely (by type), this should only return a single-item list. - Provide the name of the connection (this will be exact-matched).
- Provide the type of the connection.
- You can also (optionally) provide a list of extra attributes you want to retrieve for the connection. Core attributes like
qualifiedName
and its GUID are already included.
POST /api/meta/search/indexsearch | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
- Run a search to find the connections.
- To start building up a query with multiple conditions, you can use a
bool
query in Elasticsearch. - You can use the
filter
criteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result. - Searches by default will return all assets that are found — whether active or archived (soft-deleted). In most cases, you probably only want the active ones.
- Since there could be tables, views, materialized views, columns, databases, schemas, etc in this connection — but you only want the connection itself — you can use an exact match on the type to restrict results to only connections.
- Exact match search (case-sensitive) on the name of the connection.
- Exact match search on the type of the connector for the connection.
Find all connections¶
On the other hand, you may want to find all the connections that exist in the environment:
Find all connections | |
---|---|
1 2 3 4 5 6 7 |
|
- To start building up a query to include all connections, you can use the
select()
convenience method onConnection
itself. This will already limit results to only active (non-archived) connections. - (Optional) You can chain a
pageSize()
method to control the page sizes, to further limit API calls by retrieving more results per page. - The search will only run when you call the
stream()
method, which will then lazily-load each page of results into a stream. - (Optional) You can do any other operations you might do on a stream, such as filtering the results to ensure they are of a certain type.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
Find all connections | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
- Start with a client to run the search through. For the default client, you can always use
AtlanClient()
. - To search across all assets, you can use a
FluentSearch
object. - The
.where()
method allows you to limit to only certain assets. In this example, we are looking for connections, so use theCompoundQuery.asset_type()
helper to narrow to only connections. - You can chain additional
.where()
methods to add further conditions, like this example where we limit to only active (non-archived) assets. - (Optional) You can chain a
pageSize()
method to control the page sizes, to further limit API calls by retrieving more results per page. - You can then translate the fluent search into an index search request.
- This is the pattern for iterating through all results (across pages) covered in the Searching for assets portion of the SDK documentation.
- Use the
isinstance
method to ensure that the asset is of the desired type. This will also allow an IDE to provide specific type hints for this asset type.
POST /api/meta/search/indexsearch | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
-
Run a search to find the connections.
-
To start building up a query with multiple conditions, you can use a
bool
query in Elasticsearch. -
You can use the
filter
criteria to define all the conditions the search results must match in a binary way (either matches or doesn't). This avoids the need to calculate a score for each result. -
You can use an exact match on the type to restrict results to only connections.
-
Searches by default will return all assets that are found — whether active or archived (soft-deleted). In most cases, you probably only want the active ones.