Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/main/java/com/atlan/Atlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public abstract class Atlan {
public static final String API_VERSION = ApiVersion.CURRENT;
public static final String VERSION = "0.0.1";

public static volatile String apiKey;
public static volatile String clientId;
public static volatile boolean enableTelemetry = true;
public static volatile String partnerId;
Expand All @@ -26,21 +25,33 @@ public abstract class Atlan {

private static volatile int maxNetworkRetries = 0;

private static volatile String apiToken = null;
private static volatile String apiBase = null;
private static volatile Proxy connectionProxy = null;
private static volatile PasswordAuthentication proxyCredential = null;

private static volatile Map<String, String> appInfo = null;

/** Set the base URL for your tenant of Atlan. */
public static void setApiBase(final String baseURL) {
public static void setBaseUrl(final String baseURL) {
apiBase = baseURL;
}

public static String getApiBase() {
/** Retrieve the base URL for your tenant of Atlan. */
public static String getBaseUrl() {
return apiBase;
}

/** Set the API token to use for authenticating API calls. */
public static void setApiToken(final String token) {
apiToken = token;
}

/** Retrieve the API token to use for authenticating API calls. */
public static String getApiToken() {
return apiToken;
}

/**
* Set proxy to tunnel all Atlan connections.
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/atlan/api/EntityBulkEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static EntityMutationResponse upsert(
throws AtlanException {
String url = String.format(
"%s%s",
Atlan.getApiBase(),
Atlan.getBaseUrl(),
String.format(
"%s?replaceClassifications=%s&replaceBusinessAttributes=%s",
endpoint, replaceClassifications, replaceBusinessAttributes));
Expand All @@ -60,7 +60,7 @@ public static EntityMutationResponse delete(List<String> guids, AtlanDeleteType
guidList.setLength(guidList.length() - 1);
String url = String.format(
"%s%s",
Atlan.getApiBase(), String.format("%s?%s&deleteType=%s", endpoint, guidList, deleteType));
Atlan.getBaseUrl(), String.format("%s?%s&deleteType=%s", endpoint, guidList, deleteType));
return ApiResource.request(
ApiResource.RequestMethod.DELETE, url, "", EntityMutationResponse.class, null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/atlan/api/EntityGuidEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static EntityResponse retrieve(String guid, boolean ignoreRelationships,
throws AtlanException {
String url = String.format(
"%s%s",
Atlan.getApiBase(),
Atlan.getBaseUrl(),
String.format(
"%s%s?ignoreRelationships=%s&minExtInfo=%s",
endpoint, ApiResource.urlEncodeId(guid), ignoreRelationships, minExtInfo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static EntityResponse retrieve(
throws AtlanException {
String url = String.format(
"%s%s",
Atlan.getApiBase(),
Atlan.getBaseUrl(),
String.format(
"%s%s?attr:qualifiedName=%s&ignoreRelationships=%s&minExtInfo=%s",
endpoint,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/atlan/api/IndexSearchEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class IndexSearchEndpoint {
private static final String endpoint = "/api/meta/search/indexsearch";

public static IndexSearchResponse search(IndexSearchRequest request) throws AtlanException {
String url = String.format("%s%s", Atlan.getApiBase(), endpoint);
String url = String.format("%s%s", Atlan.getBaseUrl(), endpoint);
return ApiResource.request(ApiResource.RequestMethod.POST, url, request, IndexSearchResponse.class, null);
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/atlan/api/RolesEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static RoleResponse getRoles(String filter, String sort, boolean count, i
}
String url = String.format(
"%s%s?filter=%s&sort=%s&count=%s&offset=%s&limit=%s",
Atlan.getApiBase(),
Atlan.getBaseUrl(),
endpoint,
ApiResource.urlEncode(filter),
ApiResource.urlEncode(sort),
Expand All @@ -51,7 +51,7 @@ public static RoleResponse getRoles(String filter) throws AtlanException {
if (filter == null) {
filter = "";
}
String url = String.format("%s%s?filter=%s", Atlan.getApiBase(), endpoint, ApiResource.urlEncode(filter));
String url = String.format("%s%s?filter=%s", Atlan.getBaseUrl(), endpoint, ApiResource.urlEncode(filter));
return ApiResource.request(ApiResource.RequestMethod.GET, url, "", RoleResponse.class, null);
}

Expand All @@ -61,7 +61,7 @@ public static RoleResponse getRoles(String filter) throws AtlanException {
* @throws AtlanException on any API communication issue
*/
public static RoleResponse getAllRoles() throws AtlanException {
String url = String.format("%s%s", Atlan.getApiBase(), endpoint);
String url = String.format("%s%s", Atlan.getBaseUrl(), endpoint);
return ApiResource.request(ApiResource.RequestMethod.GET, url, "", RoleResponse.class, null);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/atlan/api/TypeDefsEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TypeDefsEndpoint {
* @param category of type definitions to retrieve
*/
public static TypeDefResponse getTypeDefs(String category) throws AtlanException {
String url = String.format("%s%s", Atlan.getApiBase(), String.format("%s?type=%s", endpoint, category));
String url = String.format("%s%s", Atlan.getBaseUrl(), String.format("%s?type=%s", endpoint, category));
return ApiResource.request(ApiResource.RequestMethod.GET, url, "", TypeDefResponse.class, null);
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/atlan/api/WorkflowsEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class WorkflowsEndpoint {
* @throws AtlanException on any API communication issue
*/
public static WorkflowResponse run(Workflow workflow) throws AtlanException {
String url = String.format("%s%s", Atlan.getApiBase(), String.format("%s?submit=true", workflows_endpoint));
String url = String.format("%s%s", Atlan.getBaseUrl(), String.format("%s?submit=true", workflows_endpoint));
return ApiResource.request(ApiResource.RequestMethod.POST, url, workflow, WorkflowResponse.class, null);
}

Expand All @@ -32,7 +32,7 @@ public static WorkflowResponse run(Workflow workflow) throws AtlanException {
*/
public static void archive(String workflowName) throws AtlanException {
String url = String.format(
"%s%s", Atlan.getApiBase(), String.format("%s/%s/archive", workflows_endpoint, workflowName));
"%s%s", Atlan.getBaseUrl(), String.format("%s/%s/archive", workflows_endpoint, workflowName));
ApiResource.request(ApiResource.RequestMethod.POST, url, "", ApiResource.class, null);
}

Expand All @@ -43,7 +43,7 @@ public static void archive(String workflowName) throws AtlanException {
* @throws AtlanException on any API communication issue
*/
public static WorkflowSearchResponse search(WorkflowSearchRequest request) throws AtlanException {
String url = String.format("%s%s", Atlan.getApiBase(), search_endpoint);
String url = String.format("%s%s", Atlan.getBaseUrl(), search_endpoint);
return ApiResource.request(ApiResource.RequestMethod.POST, url, request, WorkflowSearchResponse.class, null);
}
}
16 changes: 15 additions & 1 deletion src/main/java/com/atlan/model/relations/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class Reference extends AtlanObject {

/**
* Quickly create a new reference to another asset.
* Quickly create a new reference to another asset, by its GUID.
* @param typeName type of the asset to reference
* @param guid GUID of the asset to reference
* @return a reference to another asset
Expand All @@ -22,6 +22,20 @@ public static Reference to(String typeName, String guid) {
return Reference.builder().typeName(typeName).guid(guid).build();
}

/**
* Quickly create a new reference to another asset, by its qualifiedName.
* @param typeName type of the asset to reference
* @param qualifiedName of the asset to reference
* @return a reference to another asset
*/
public static Reference by(String typeName, String qualifiedName) {
return Reference.builder()
.typeName(typeName)
.uniqueAttributes(
UniqueAttributes.builder().qualifiedName(qualifiedName).build())
.build();
}

/**
* Unique identifier of the related entity. If the uniqueAttributes are not provided, this must be
* provided.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/atlan/net/AtlanRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public AtlanRequest(ApiResource.RequestMethod method, String url, String body, R
+ "Please check your internet connection and try again. If this problem persists,"
+ "you should check Atlan's availability via a browser,"
+ " or let us know at support@atlan.com.",
Atlan.getApiBase(), e.getMessage()),
Atlan.getBaseUrl(), e.getMessage()),
e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/atlan/net/HttpURLConnectionClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public AtlanResponseStream requestStream(AtlanRequest request) throws ApiConnect
+ "Please check your internet connection and try again. If this problem persists,"
+ "you should check Atlan's availability via a browser,"
+ " or let us know at support@atlan.com.",
Atlan.getApiBase(), e.getMessage()),
Atlan.getBaseUrl(), e.getMessage()),
e);
}
}
Expand All @@ -74,7 +74,7 @@ public AtlanResponse request(AtlanRequest request) throws ApiConnectionException
+ "Please check your internet connection and try again. If this problem persists,"
+ "you should check Atlan's availability via a browser,"
+ " or let us know at support@atlan.com.",
Atlan.getApiBase(), e.getMessage()),
Atlan.getBaseUrl(), e.getMessage()),
e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/atlan/net/RequestOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RequestOptions {

public static RequestOptions getDefault() {
return new RequestOptions(
Atlan.apiKey,
Atlan.getApiToken(),
Atlan.clientId,
null,
null,
Expand Down Expand Up @@ -139,7 +139,7 @@ public static final class RequestOptionsBuilder {
* default values.
*/
public RequestOptionsBuilder() {
this.apiKey = Atlan.apiKey;
this.apiKey = Atlan.getApiToken();
this.clientId = Atlan.clientId;
this.connectTimeout = Atlan.getConnectTimeout();
this.readTimeout = Atlan.getReadTimeout();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/atlan/functional/AtlanLiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class AtlanLiveTest {
public static final String ANNOUNCEMENT_MESSAGE = "Automated testing of the Java client.";

static {
Atlan.apiKey = System.getenv("ATLAN_API_KEY");
Atlan.setApiBase(System.getenv("ATLAN_BASE_URL"));
Atlan.setApiToken(System.getenv("ATLAN_API_KEY"));
Atlan.setBaseUrl(System.getenv("ATLAN_BASE_URL"));
}
}