Skip to content

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
polytomic-sdk-bot committed May 15, 2024
1 parent 4703d9b commit e48088e
Show file tree
Hide file tree
Showing 15 changed files with 969 additions and 81 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.polytomic'
artifactId = 'polytomic-java'
version = '1.0.0'
version = '1.2.0'
from components.java
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/polytomic/api/Polytomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public class Polytomic {

protected final Supplier<SchemasClient> schemasClient;

protected final Supplier<ModelsClient> modelsClient;

protected final Supplier<EventsClient> eventsClient;

protected final Supplier<JobsClient> jobsClient;

protected final Supplier<IdentityClient> identityClient;

protected final Supplier<ModelsClient> modelsClient;

protected final Supplier<OrganizationClient> organizationClient;

protected final Supplier<UsersClient> usersClient;
Expand All @@ -52,10 +52,10 @@ public Polytomic(ClientOptions clientOptions) {
this.connectionsClient = Suppliers.memoize(() -> new ConnectionsClient(clientOptions));
this.modelSyncClient = Suppliers.memoize(() -> new ModelSyncClient(clientOptions));
this.schemasClient = Suppliers.memoize(() -> new SchemasClient(clientOptions));
this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions));
this.eventsClient = Suppliers.memoize(() -> new EventsClient(clientOptions));
this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions));
this.identityClient = Suppliers.memoize(() -> new IdentityClient(clientOptions));
this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions));
this.organizationClient = Suppliers.memoize(() -> new OrganizationClient(clientOptions));
this.usersClient = Suppliers.memoize(() -> new UsersClient(clientOptions));
this.permissionsClient = Suppliers.memoize(() -> new PermissionsClient(clientOptions));
Expand All @@ -78,6 +78,10 @@ public SchemasClient schemas() {
return this.schemasClient.get();
}

public ModelsClient models() {
return this.modelsClient.get();
}

public EventsClient events() {
return this.eventsClient.get();
}
Expand All @@ -90,10 +94,6 @@ public IdentityClient identity() {
return this.identityClient.get();
}

public ModelsClient models() {
return this.modelsClient.get();
}

public OrganizationClient organization() {
return this.organizationClient.get();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/polytomic/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private ClientOptions(
"X-Fern-SDK-Name",
"com.polytomic.fern:api-sdk",
"X-Fern-SDK-Version",
"1.0.0",
"1.2.0",
"X-Fern-Language",
"JAVA"));
this.headerSuppliers = headerSuppliers;
Expand Down
136 changes: 102 additions & 34 deletions src/main/java/com/polytomic/api/resources/models/ModelsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import com.polytomic.api.core.MediaTypes;
import com.polytomic.api.core.ObjectMappers;
import com.polytomic.api.core.RequestOptions;
import com.polytomic.api.resources.models.requests.CreateModelRequest;
import com.polytomic.api.resources.models.requests.GetEnrichmentInputFieldsRequest;
import com.polytomic.api.resources.models.requests.ModelsCreateRequest;
import com.polytomic.api.resources.models.requests.ModelsPreviewRequest;
import com.polytomic.api.resources.models.requests.UpdateModelRequest;
import com.polytomic.api.types.ModelListResponseEnvelope;
import com.polytomic.api.types.ModelResponseEnvelope;
import com.polytomic.api.types.V2GetEnrichmentInputFieldsResponseEnvelope;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -28,6 +31,98 @@ public ModelsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}

/**
* For a given connection and enrichment configuration, provides the valid sets of input fields.
*/
public V2GetEnrichmentInputFieldsResponseEnvelope post(String connectionId) {
return post(connectionId, GetEnrichmentInputFieldsRequest.builder().build());
}

/**
* For a given connection and enrichment configuration, provides the valid sets of input fields.
*/
public V2GetEnrichmentInputFieldsResponseEnvelope post(
String connectionId, GetEnrichmentInputFieldsRequest request) {
return post(connectionId, request, null);
}

/**
* For a given connection and enrichment configuration, provides the valid sets of input fields.
*/
public V2GetEnrichmentInputFieldsResponseEnvelope post(
String connectionId, GetEnrichmentInputFieldsRequest request, RequestOptions requestOptions) {
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("api/enrichment")
.addPathSegment(connectionId)
.addPathSegments("inputfields")
.build();
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (Exception e) {
throw new RuntimeException(e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl)
.method("POST", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.build();
try {
Response response =
clientOptions.httpClient().newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(
response.body().string(), V2GetEnrichmentInputFieldsResponseEnvelope.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public ModelResponseEnvelope preview(ModelsPreviewRequest request) {
return preview(request, null);
}

public ModelResponseEnvelope preview(ModelsPreviewRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("api/model-preview");
if (request.getAsync().isPresent()) {
httpUrl.addQueryParameter("async", request.getAsync().get().toString());
}
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON);
} catch (Exception e) {
throw new RuntimeException(e);
}
Request.Builder _requestBuilder = new Request.Builder()
.url(httpUrl.build())
.method("POST", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json");
Request okhttpRequest = _requestBuilder.build();
try {
Response response =
clientOptions.httpClient().newCall(okhttpRequest).execute();
if (response.isSuccessful()) {
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), ModelResponseEnvelope.class);
}
throw new ApiError(
response.code(),
ObjectMappers.JSON_MAPPER.readValue(response.body().string(), Object.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public ModelListResponseEnvelope list() {
return list(null);
}
Expand Down Expand Up @@ -57,51 +152,21 @@ public ModelListResponseEnvelope list(RequestOptions requestOptions) {
}
}

public ModelResponseEnvelope create(CreateModelRequest request) {
public ModelResponseEnvelope create(ModelsCreateRequest request) {
return create(request, null);
}

public ModelResponseEnvelope create(CreateModelRequest request, RequestOptions requestOptions) {
public ModelResponseEnvelope create(ModelsCreateRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("api/models");
if (request.getAsync().isPresent()) {
httpUrl.addQueryParameter("async", request.getAsync().get().toString());
}
Map<String, Object> properties = new HashMap<>();
if (request.getAdditionalFields().isPresent()) {
properties.put("additional_fields", request.getAdditionalFields());
}
if (request.getConfiguration().isPresent()) {
properties.put("configuration", request.getConfiguration());
}
properties.put("connection_id", request.getConnectionId());
if (request.getFields().isPresent()) {
properties.put("fields", request.getFields());
}
if (request.getIdentifier().isPresent()) {
properties.put("identifier", request.getIdentifier());
}
if (request.getLabels().isPresent()) {
properties.put("labels", request.getLabels());
}
properties.put("name", request.getName());
if (request.getOrganizationId().isPresent()) {
properties.put("organization_id", request.getOrganizationId());
}
if (request.getPolicies().isPresent()) {
properties.put("policies", request.getPolicies());
}
if (request.getRelations().isPresent()) {
properties.put("relations", request.getRelations());
}
if (request.getTrackingColumns().isPresent()) {
properties.put("tracking_columns", request.getTrackingColumns());
}
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON);
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -175,6 +240,9 @@ public ModelResponseEnvelope update(String id, UpdateModelRequest request, Reque
properties.put("configuration", request.getConfiguration());
}
properties.put("connection_id", request.getConnectionId());
if (request.getEnricher().isPresent()) {
properties.put("enricher", request.getEnricher());
}
if (request.getFields().isPresent()) {
properties.put("fields", request.getFields());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.polytomic.api.resources.models.requests;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.polytomic.api.core.ObjectMappers;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonDeserialize(builder = GetEnrichmentInputFieldsRequest.Builder.class)
public final class GetEnrichmentInputFieldsRequest {
private final Optional<Map<String, Object>> configuration;

private final Map<String, Object> additionalProperties;

private GetEnrichmentInputFieldsRequest(
Optional<Map<String, Object>> configuration, Map<String, Object> additionalProperties) {
this.configuration = configuration;
this.additionalProperties = additionalProperties;
}

@JsonProperty("configuration")
public Optional<Map<String, Object>> getConfiguration() {
return configuration;
}

@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
return other instanceof GetEnrichmentInputFieldsRequest && equalTo((GetEnrichmentInputFieldsRequest) other);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

private boolean equalTo(GetEnrichmentInputFieldsRequest other) {
return configuration.equals(other.configuration);
}

@java.lang.Override
public int hashCode() {
return Objects.hash(this.configuration);
}

@java.lang.Override
public String toString() {
return ObjectMappers.stringify(this);
}

public static Builder builder() {
return new Builder();
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Optional<Map<String, Object>> configuration = Optional.empty();

@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();

private Builder() {}

public Builder from(GetEnrichmentInputFieldsRequest other) {
configuration(other.getConfiguration());
return this;
}

@JsonSetter(value = "configuration", nulls = Nulls.SKIP)
public Builder configuration(Optional<Map<String, Object>> configuration) {
this.configuration = configuration;
return this;
}

public Builder configuration(Map<String, Object> configuration) {
this.configuration = Optional.of(configuration);
return this;
}

public GetEnrichmentInputFieldsRequest build() {
return new GetEnrichmentInputFieldsRequest(configuration, additionalProperties);
}
}
}
Loading

0 comments on commit e48088e

Please sign in to comment.