From 1d1ce36673da388661b09df0c08b284be8d2248f Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 18 Sep 2024 13:19:05 +0000 Subject: [PATCH] [Librarian] Regenerated @ 1b6718f23da76f150eac392860c66a26de9af713 ceb130295f80bc623f22496076e3dd57e27da2fb --- CHANGES.md | 10 + src/main/java/com/twilio/Domains.java | 1 + .../twilio/rest/assistants/v1/Assistant.java | 566 ++++++++++++++++++ .../rest/assistants/v1/AssistantCreator.java | 101 ++++ .../rest/assistants/v1/AssistantDeleter.java | 69 +++ .../rest/assistants/v1/AssistantFetcher.java | 73 +++ .../rest/assistants/v1/AssistantReader.java | 135 +++++ .../rest/assistants/v1/AssistantUpdater.java | 95 +++ .../twilio/rest/assistants/v1/Knowledge.java | 392 ++++++++++++ .../rest/assistants/v1/KnowledgeCreator.java | 101 ++++ .../rest/assistants/v1/KnowledgeDeleter.java | 69 +++ .../rest/assistants/v1/KnowledgeFetcher.java | 73 +++ .../rest/assistants/v1/KnowledgeReader.java | 144 +++++ .../rest/assistants/v1/KnowledgeUpdater.java | 95 +++ .../com/twilio/rest/assistants/v1/Policy.java | 197 ++++++ .../rest/assistants/v1/PolicyReader.java | 153 +++++ .../twilio/rest/assistants/v1/Session.java | 181 ++++++ .../rest/assistants/v1/SessionFetcher.java | 70 +++ .../rest/assistants/v1/SessionReader.java | 135 +++++ .../com/twilio/rest/assistants/v1/Tool.java | 409 +++++++++++++ .../rest/assistants/v1/ToolCreator.java | 95 +++ .../rest/assistants/v1/ToolDeleter.java | 69 +++ .../twilio/rest/assistants/v1/ToolReader.java | 144 +++++ .../rest/assistants/v1/ToolUpdater.java | 89 +++ .../assistants/v1/assistant/Feedback.java | 274 +++++++++ .../v1/assistant/FeedbackCreator.java | 105 ++++ .../v1/assistant/FeedbackReader.java | 139 +++++ .../rest/assistants/v1/knowledge/Chunk.java | 161 +++++ .../assistants/v1/knowledge/ChunkReader.java | 139 +++++ .../rest/assistants/v1/session/Message.java | 206 +++++++ .../assistants/v1/session/MessageReader.java | 143 +++++ .../content/v1/content/ApprovalFetch.java | 4 +- .../v1/content/ApprovalFetchFetcher.java | 14 +- .../rest/intelligence/v2/OperatorType.java | 45 +- .../marketplace/v1/ModuleDataManagement.java | 17 +- .../v1/ModuleDataManagementUpdater.java | 9 + .../installedaddon/InstalledAddOnUsage.java | 76 +-- 37 files changed, 4713 insertions(+), 85 deletions(-) create mode 100644 src/main/java/com/twilio/rest/assistants/v1/Assistant.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/AssistantCreator.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/AssistantDeleter.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/AssistantFetcher.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/AssistantReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/AssistantUpdater.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/Knowledge.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/KnowledgeCreator.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/KnowledgeDeleter.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/KnowledgeFetcher.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/KnowledgeReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/KnowledgeUpdater.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/Policy.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/PolicyReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/Session.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/SessionFetcher.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/SessionReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/Tool.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/ToolCreator.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/ToolDeleter.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/ToolReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/ToolUpdater.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/assistant/Feedback.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackCreator.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/knowledge/Chunk.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/knowledge/ChunkReader.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/session/Message.java create mode 100644 src/main/java/com/twilio/rest/assistants/v1/session/MessageReader.java diff --git a/CHANGES.md b/CHANGES.md index 6010252a3e..c71ed13e07 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,16 @@ twilio-java changelog ===================== +[2024-09-18] Version 10.5.1 +--------------------------- +**Intelligence** +- Remove public from operator_type +- Update operator_type to include general-availablity and deprecated + +**Numbers** +- Remove beta flag for bundle clone API + + [2024-09-05] Version 10.5.0 --------------------------- **Iam** diff --git a/src/main/java/com/twilio/Domains.java b/src/main/java/com/twilio/Domains.java index 1a805dc447..4cea2a4672 100644 --- a/src/main/java/com/twilio/Domains.java +++ b/src/main/java/com/twilio/Domains.java @@ -13,6 +13,7 @@ public enum Domains { ACCOUNTS("accounts"), API("api"), + ASSISTANTS("assistants"), BULKEXPORTS("bulkexports"), CHAT("chat"), CONTENT("content"), diff --git a/src/main/java/com/twilio/rest/assistants/v1/Assistant.java b/src/main/java/com/twilio/rest/assistants/v1/Assistant.java new file mode 100644 index 0000000000..fb4182bab7 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/Assistant.java @@ -0,0 +1,566 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.Converter; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.List; +import java.util.Map; +import java.util.Map; +import java.util.Objects; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Assistant extends Resource { + + private static final long serialVersionUID = 83480490674350L; + + @ToString + public static class AssistantsV1ServiceCustomerAi { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("perception_engine_enabled") + @Getter + @Setter + private Boolean perceptionEngineEnabled; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("personalization_engine_enabled") + @Getter + @Setter + private Boolean personalizationEngineEnabled; + + public static AssistantsV1ServiceCustomerAi fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCustomerAi.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceSegmentCredential { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("profile_api_key") + @Getter + @Setter + private String profileApiKey; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("space_id") + @Getter + @Setter + private String spaceId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("write_key") + @Getter + @Setter + private String writeKey; + + public static AssistantsV1ServiceSegmentCredential fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceSegmentCredential.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceCreateAssistantRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("customer_ai") + @Getter + @Setter + private AssistantsV1ServiceCustomerAi customerAi; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("owner") + @Getter + @Setter + private String owner; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("personality_prompt") + @Getter + @Setter + private String personalityPrompt; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("segment_credential") + @Getter + @Setter + private AssistantsV1ServiceSegmentCredential segmentCredential; + + public AssistantsV1ServiceCreateAssistantRequest() {} + + public static AssistantsV1ServiceCreateAssistantRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCreateAssistantRequest.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceUpdateAssistantRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("customer_ai") + @Getter + @Setter + private AssistantsV1ServiceCustomerAi customerAi; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("owner") + @Getter + @Setter + private String owner; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("personality_prompt") + @Getter + @Setter + private String personalityPrompt; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("segment_credential") + @Getter + @Setter + private AssistantsV1ServiceSegmentCredential segmentCredential; + + public AssistantsV1ServiceUpdateAssistantRequest() {} + + public static AssistantsV1ServiceUpdateAssistantRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceUpdateAssistantRequest.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceKnowledge { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("id") + @Getter + @Setter + private String id; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("account_sid") + @Getter + @Setter + private String accountSid; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("knowledge_source_details") + @Getter + @Setter + private Map knowledgeSourceDetails; + + public String getKnowledgeSourceDetails() { + return Converter.mapToJson(knowledgeSourceDetails); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("status") + @Getter + @Setter + private String status; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("date_created") + @Getter + @Setter + private ZonedDateTime dateCreated; + + public String getDateCreated() { + return dateCreated.toInstant().toString(); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("date_updated") + @Getter + @Setter + private ZonedDateTime dateUpdated; + + public String getDateUpdated() { + return dateUpdated.toInstant().toString(); + } + + public static AssistantsV1ServiceKnowledge fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceKnowledge.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceTool { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("account_sid") + @Getter + @Setter + private String accountSid; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("enabled") + @Getter + @Setter + private Boolean enabled; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("id") + @Getter + @Setter + private String id; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("meta") + @Getter + @Setter + private Map meta; + + public String getMeta() { + return Converter.mapToJson(meta); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("requires_auth") + @Getter + @Setter + private Boolean requiresAuth; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("date_created") + @Getter + @Setter + private ZonedDateTime dateCreated; + + public String getDateCreated() { + return dateCreated.toInstant().toString(); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("date_updated") + @Getter + @Setter + private ZonedDateTime dateUpdated; + + public String getDateUpdated() { + return dateUpdated.toInstant().toString(); + } + + public static AssistantsV1ServiceTool fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue(jsonString, AssistantsV1ServiceTool.class); + } + } + + public static AssistantCreator creator( + final Assistant.AssistantsV1ServiceCreateAssistantRequest assistantsV1ServiceCreateAssistantRequest + ) { + return new AssistantCreator(assistantsV1ServiceCreateAssistantRequest); + } + + public static AssistantDeleter deleter(final String pathId) { + return new AssistantDeleter(pathId); + } + + public static AssistantFetcher fetcher(final String pathId) { + return new AssistantFetcher(pathId); + } + + public static AssistantReader reader() { + return new AssistantReader(); + } + + public static AssistantUpdater updater(final String pathId) { + return new AssistantUpdater(pathId); + } + + /** + * Converts a JSON String into a Assistant object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Assistant object represented by the provided JSON + */ + public static Assistant fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Assistant.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Assistant object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Assistant object represented by the provided JSON + */ + public static Assistant fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Assistant.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String accountSid; + private final Map customerAi; + private final String id; + private final String model; + private final String name; + private final String owner; + private final String personalityPrompt; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + private final List knowledge; + private final List tools; + + @JsonCreator + private Assistant( + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("customer_ai") final Map customerAi, + @JsonProperty("id") final String id, + @JsonProperty("model") final String model, + @JsonProperty("name") final String name, + @JsonProperty("owner") final String owner, + @JsonProperty("personality_prompt") final String personalityPrompt, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated, + @JsonProperty("knowledge") final List< + AssistantsV1ServiceKnowledge + > knowledge, + @JsonProperty("tools") final List tools + ) { + this.accountSid = accountSid; + this.customerAi = customerAi; + this.id = id; + this.model = model; + this.name = name; + this.owner = owner; + this.personalityPrompt = personalityPrompt; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + this.knowledge = knowledge; + this.tools = tools; + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final Map getCustomerAi() { + return this.customerAi; + } + + public final String getId() { + return this.id; + } + + public final String getModel() { + return this.model; + } + + public final String getName() { + return this.name; + } + + public final String getOwner() { + return this.owner; + } + + public final String getPersonalityPrompt() { + return this.personalityPrompt; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + public final List getKnowledge() { + return this.knowledge; + } + + public final List getTools() { + return this.tools; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Assistant other = (Assistant) o; + + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(customerAi, other.customerAi) && + Objects.equals(id, other.id) && + Objects.equals(model, other.model) && + Objects.equals(name, other.name) && + Objects.equals(owner, other.owner) && + Objects.equals(personalityPrompt, other.personalityPrompt) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) && + Objects.equals(knowledge, other.knowledge) && + Objects.equals(tools, other.tools) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + accountSid, + customerAi, + id, + model, + name, + owner, + personalityPrompt, + dateCreated, + dateUpdated, + knowledge, + tools + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/AssistantCreator.java b/src/main/java/com/twilio/rest/assistants/v1/AssistantCreator.java new file mode 100644 index 0000000000..255b68ce0a --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/AssistantCreator.java @@ -0,0 +1,101 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class AssistantCreator extends Creator { + + private Assistant.AssistantsV1ServiceCreateAssistantRequest assistantsV1ServiceCreateAssistantRequest; + + public AssistantCreator( + final Assistant.AssistantsV1ServiceCreateAssistantRequest assistantsV1ServiceCreateAssistantRequest + ) { + this.assistantsV1ServiceCreateAssistantRequest = + assistantsV1ServiceCreateAssistantRequest; + } + + public AssistantCreator setAssistantsV1ServiceCreateAssistantRequest( + final Assistant.AssistantsV1ServiceCreateAssistantRequest assistantsV1ServiceCreateAssistantRequest + ) { + this.assistantsV1ServiceCreateAssistantRequest = + assistantsV1ServiceCreateAssistantRequest; + return this; + } + + @Override + public Assistant create(final TwilioRestClient client) { + String path = "/v1/Assistants"; + + path = + path.replace( + "{" + "AssistantsV1ServiceCreateAssistantRequest" + "}", + this.assistantsV1ServiceCreateAssistantRequest.toString() + ); + + Request request = new Request( + HttpMethod.POST, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Assistant creation failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Assistant.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceCreateAssistantRequest != null) { + request.setBody( + Assistant.toJson( + assistantsV1ServiceCreateAssistantRequest, + objectMapper + ) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/AssistantDeleter.java b/src/main/java/com/twilio/rest/assistants/v1/AssistantDeleter.java new file mode 100644 index 0000000000..fdac762673 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/AssistantDeleter.java @@ -0,0 +1,69 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Deleter; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class AssistantDeleter extends Deleter { + + private String pathId; + + public AssistantDeleter(final String pathId) { + this.pathId = pathId; + } + + @Override + public boolean delete(final TwilioRestClient client) { + String path = "/v1/Assistants/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.DELETE, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Assistant delete failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + return response.getStatusCode() == 204; + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/AssistantFetcher.java b/src/main/java/com/twilio/rest/assistants/v1/AssistantFetcher.java new file mode 100644 index 0000000000..f05d4ed235 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/AssistantFetcher.java @@ -0,0 +1,73 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Fetcher; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class AssistantFetcher extends Fetcher { + + private String pathId; + + public AssistantFetcher(final String pathId) { + this.pathId = pathId; + } + + @Override + public Assistant fetch(final TwilioRestClient client) { + String path = "/v1/Assistants/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Assistant fetch failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Assistant.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/AssistantReader.java b/src/main/java/com/twilio/rest/assistants/v1/AssistantReader.java new file mode 100644 index 0000000000..3ab3635317 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/AssistantReader.java @@ -0,0 +1,135 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class AssistantReader extends Reader { + + private Integer pageSize; + + public AssistantReader() {} + + public AssistantReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Assistants"; + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Assistant read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "assistants", + response.getContent(), + Assistant.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/AssistantUpdater.java b/src/main/java/com/twilio/rest/assistants/v1/AssistantUpdater.java new file mode 100644 index 0000000000..dd27f7c127 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/AssistantUpdater.java @@ -0,0 +1,95 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class AssistantUpdater extends Updater { + + private String pathId; + private Assistant.AssistantsV1ServiceUpdateAssistantRequest assistantsV1ServiceUpdateAssistantRequest; + + public AssistantUpdater(final String pathId) { + this.pathId = pathId; + } + + public AssistantUpdater setAssistantsV1ServiceUpdateAssistantRequest( + final Assistant.AssistantsV1ServiceUpdateAssistantRequest assistantsV1ServiceUpdateAssistantRequest + ) { + this.assistantsV1ServiceUpdateAssistantRequest = + assistantsV1ServiceUpdateAssistantRequest; + return this; + } + + @Override + public Assistant update(final TwilioRestClient client) { + String path = "/v1/Assistants/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.PUT, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Assistant update failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Assistant.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceUpdateAssistantRequest != null) { + request.setBody( + Assistant.toJson( + assistantsV1ServiceUpdateAssistantRequest, + objectMapper + ) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/Knowledge.java b/src/main/java/com/twilio/rest/assistants/v1/Knowledge.java new file mode 100644 index 0000000000..ed482235c5 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/Knowledge.java @@ -0,0 +1,392 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.Converter; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Map; +import java.util.Objects; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Knowledge extends Resource { + + private static final long serialVersionUID = 228486068645709L; + + @ToString + public static class AssistantsV1ServiceCreatePolicyRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("id") + @Getter + @Setter + private String id; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("policy_details") + @Getter + @Setter + private Map policyDetails; + + public String getPolicyDetails() { + return Converter.mapToJson(policyDetails); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + public static AssistantsV1ServiceCreatePolicyRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCreatePolicyRequest.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceCreateKnowledgeRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("assistant_id") + @Getter + @Setter + private String assistantId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("knowledge_source_details") + @Getter + @Setter + private Map knowledgeSourceDetails; + + public String getKnowledgeSourceDetails() { + return Converter.mapToJson(knowledgeSourceDetails); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("policy") + @Getter + @Setter + private AssistantsV1ServiceCreatePolicyRequest policy; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + public AssistantsV1ServiceCreateKnowledgeRequest() {} + + public static AssistantsV1ServiceCreateKnowledgeRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCreateKnowledgeRequest.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceUpdateKnowledgeRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("knowledge_source_details") + @Getter + @Setter + private Map knowledgeSourceDetails; + + public String getKnowledgeSourceDetails() { + return Converter.mapToJson(knowledgeSourceDetails); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("policy") + @Getter + @Setter + private AssistantsV1ServiceCreatePolicyRequest policy; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + public AssistantsV1ServiceUpdateKnowledgeRequest() {} + + public static AssistantsV1ServiceUpdateKnowledgeRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceUpdateKnowledgeRequest.class + ); + } + } + + public static KnowledgeCreator creator( + final Knowledge.AssistantsV1ServiceCreateKnowledgeRequest assistantsV1ServiceCreateKnowledgeRequest + ) { + return new KnowledgeCreator(assistantsV1ServiceCreateKnowledgeRequest); + } + + public static KnowledgeDeleter deleter(final String pathId) { + return new KnowledgeDeleter(pathId); + } + + public static KnowledgeFetcher fetcher(final String pathId) { + return new KnowledgeFetcher(pathId); + } + + public static KnowledgeReader reader() { + return new KnowledgeReader(); + } + + public static KnowledgeUpdater updater(final String pathId) { + return new KnowledgeUpdater(pathId); + } + + /** + * Converts a JSON String into a Knowledge object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Knowledge object represented by the provided JSON + */ + public static Knowledge fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Knowledge.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Knowledge object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Knowledge object represented by the provided JSON + */ + public static Knowledge fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Knowledge.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String description; + private final String id; + private final String accountSid; + private final Map knowledgeSourceDetails; + private final String name; + private final String status; + private final String type; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Knowledge( + @JsonProperty("description") final String description, + @JsonProperty("id") final String id, + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("knowledge_source_details") final Map< + String, + Object + > knowledgeSourceDetails, + @JsonProperty("name") final String name, + @JsonProperty("status") final String status, + @JsonProperty("type") final String type, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.description = description; + this.id = id; + this.accountSid = accountSid; + this.knowledgeSourceDetails = knowledgeSourceDetails; + this.name = name; + this.status = status; + this.type = type; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getDescription() { + return this.description; + } + + public final String getId() { + return this.id; + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final Map getKnowledgeSourceDetails() { + return this.knowledgeSourceDetails; + } + + public final String getName() { + return this.name; + } + + public final String getStatus() { + return this.status; + } + + public final String getType() { + return this.type; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Knowledge other = (Knowledge) o; + + return ( + Objects.equals(description, other.description) && + Objects.equals(id, other.id) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals( + knowledgeSourceDetails, + other.knowledgeSourceDetails + ) && + Objects.equals(name, other.name) && + Objects.equals(status, other.status) && + Objects.equals(type, other.type) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + description, + id, + accountSid, + knowledgeSourceDetails, + name, + status, + type, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/KnowledgeCreator.java b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeCreator.java new file mode 100644 index 0000000000..73da89e2fa --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeCreator.java @@ -0,0 +1,101 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class KnowledgeCreator extends Creator { + + private Knowledge.AssistantsV1ServiceCreateKnowledgeRequest assistantsV1ServiceCreateKnowledgeRequest; + + public KnowledgeCreator( + final Knowledge.AssistantsV1ServiceCreateKnowledgeRequest assistantsV1ServiceCreateKnowledgeRequest + ) { + this.assistantsV1ServiceCreateKnowledgeRequest = + assistantsV1ServiceCreateKnowledgeRequest; + } + + public KnowledgeCreator setAssistantsV1ServiceCreateKnowledgeRequest( + final Knowledge.AssistantsV1ServiceCreateKnowledgeRequest assistantsV1ServiceCreateKnowledgeRequest + ) { + this.assistantsV1ServiceCreateKnowledgeRequest = + assistantsV1ServiceCreateKnowledgeRequest; + return this; + } + + @Override + public Knowledge create(final TwilioRestClient client) { + String path = "/v1/Knowledge"; + + path = + path.replace( + "{" + "AssistantsV1ServiceCreateKnowledgeRequest" + "}", + this.assistantsV1ServiceCreateKnowledgeRequest.toString() + ); + + Request request = new Request( + HttpMethod.POST, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Knowledge creation failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Knowledge.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceCreateKnowledgeRequest != null) { + request.setBody( + Knowledge.toJson( + assistantsV1ServiceCreateKnowledgeRequest, + objectMapper + ) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/KnowledgeDeleter.java b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeDeleter.java new file mode 100644 index 0000000000..99a0057c51 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeDeleter.java @@ -0,0 +1,69 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Deleter; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class KnowledgeDeleter extends Deleter { + + private String pathId; + + public KnowledgeDeleter(final String pathId) { + this.pathId = pathId; + } + + @Override + public boolean delete(final TwilioRestClient client) { + String path = "/v1/Knowledge/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.DELETE, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Knowledge delete failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + return response.getStatusCode() == 204; + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/KnowledgeFetcher.java b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeFetcher.java new file mode 100644 index 0000000000..16a9d19745 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeFetcher.java @@ -0,0 +1,73 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Fetcher; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class KnowledgeFetcher extends Fetcher { + + private String pathId; + + public KnowledgeFetcher(final String pathId) { + this.pathId = pathId; + } + + @Override + public Knowledge fetch(final TwilioRestClient client) { + String path = "/v1/Knowledge/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Knowledge fetch failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Knowledge.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/KnowledgeReader.java b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeReader.java new file mode 100644 index 0000000000..aa784ccf77 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeReader.java @@ -0,0 +1,144 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class KnowledgeReader extends Reader { + + private String assistantId; + private Integer pageSize; + + public KnowledgeReader() {} + + public KnowledgeReader setAssistantId(final String assistantId) { + this.assistantId = assistantId; + return this; + } + + public KnowledgeReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Knowledge"; + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Knowledge read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "knowledge", + response.getContent(), + Knowledge.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (assistantId != null) { + request.addQueryParam("AssistantId", assistantId); + } + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/KnowledgeUpdater.java b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeUpdater.java new file mode 100644 index 0000000000..773dbf4099 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/KnowledgeUpdater.java @@ -0,0 +1,95 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class KnowledgeUpdater extends Updater { + + private String pathId; + private Knowledge.AssistantsV1ServiceUpdateKnowledgeRequest assistantsV1ServiceUpdateKnowledgeRequest; + + public KnowledgeUpdater(final String pathId) { + this.pathId = pathId; + } + + public KnowledgeUpdater setAssistantsV1ServiceUpdateKnowledgeRequest( + final Knowledge.AssistantsV1ServiceUpdateKnowledgeRequest assistantsV1ServiceUpdateKnowledgeRequest + ) { + this.assistantsV1ServiceUpdateKnowledgeRequest = + assistantsV1ServiceUpdateKnowledgeRequest; + return this; + } + + @Override + public Knowledge update(final TwilioRestClient client) { + String path = "/v1/Knowledge/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.PUT, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Knowledge update failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Knowledge.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceUpdateKnowledgeRequest != null) { + request.setBody( + Knowledge.toJson( + assistantsV1ServiceUpdateKnowledgeRequest, + objectMapper + ) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/Policy.java b/src/main/java/com/twilio/rest/assistants/v1/Policy.java new file mode 100644 index 0000000000..aad952fdda --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/Policy.java @@ -0,0 +1,197 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Map; +import java.util.Objects; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Policy extends Resource { + + private static final long serialVersionUID = 15658572271109L; + + public static PolicyReader reader() { + return new PolicyReader(); + } + + /** + * Converts a JSON String into a Policy object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Policy object represented by the provided JSON + */ + public static Policy fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Policy.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Policy object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Policy object represented by the provided JSON + */ + public static Policy fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Policy.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String id; + private final String name; + private final String description; + private final String accountSid; + private final String userSid; + private final String type; + private final Map policyDetails; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Policy( + @JsonProperty("id") final String id, + @JsonProperty("name") final String name, + @JsonProperty("description") final String description, + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("user_sid") final String userSid, + @JsonProperty("type") final String type, + @JsonProperty("policy_details") final Map policyDetails, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.id = id; + this.name = name; + this.description = description; + this.accountSid = accountSid; + this.userSid = userSid; + this.type = type; + this.policyDetails = policyDetails; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getId() { + return this.id; + } + + public final String getName() { + return this.name; + } + + public final String getDescription() { + return this.description; + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final String getUserSid() { + return this.userSid; + } + + public final String getType() { + return this.type; + } + + public final Map getPolicyDetails() { + return this.policyDetails; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Policy other = (Policy) o; + + return ( + Objects.equals(id, other.id) && + Objects.equals(name, other.name) && + Objects.equals(description, other.description) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(userSid, other.userSid) && + Objects.equals(type, other.type) && + Objects.equals(policyDetails, other.policyDetails) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + name, + description, + accountSid, + userSid, + type, + policyDetails, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/PolicyReader.java b/src/main/java/com/twilio/rest/assistants/v1/PolicyReader.java new file mode 100644 index 0000000000..c216cafe42 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/PolicyReader.java @@ -0,0 +1,153 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class PolicyReader extends Reader { + + private String toolId; + private String knowledgeId; + private Integer pageSize; + + public PolicyReader() {} + + public PolicyReader setToolId(final String toolId) { + this.toolId = toolId; + return this; + } + + public PolicyReader setKnowledgeId(final String knowledgeId) { + this.knowledgeId = knowledgeId; + return this; + } + + public PolicyReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Policies"; + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Policy read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "policies", + response.getContent(), + Policy.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (toolId != null) { + request.addQueryParam("ToolId", toolId); + } + if (knowledgeId != null) { + request.addQueryParam("KnowledgeId", knowledgeId); + } + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/Session.java b/src/main/java/com/twilio/rest/assistants/v1/Session.java new file mode 100644 index 0000000000..c42f56ba6e --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/Session.java @@ -0,0 +1,181 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Objects; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Session extends Resource { + + private static final long serialVersionUID = 32443356464816L; + + public static SessionFetcher fetcher(final String pathId) { + return new SessionFetcher(pathId); + } + + public static SessionReader reader() { + return new SessionReader(); + } + + /** + * Converts a JSON String into a Session object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Session object represented by the provided JSON + */ + public static Session fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Session.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Session object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Session object represented by the provided JSON + */ + public static Session fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Session.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String id; + private final String accountSid; + private final String assistantId; + private final Boolean verified; + private final String identity; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Session( + @JsonProperty("id") final String id, + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("assistant_id") final String assistantId, + @JsonProperty("verified") final Boolean verified, + @JsonProperty("identity") final String identity, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.id = id; + this.accountSid = accountSid; + this.assistantId = assistantId; + this.verified = verified; + this.identity = identity; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getId() { + return this.id; + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final String getAssistantId() { + return this.assistantId; + } + + public final Boolean getVerified() { + return this.verified; + } + + public final String getIdentity() { + return this.identity; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Session other = (Session) o; + + return ( + Objects.equals(id, other.id) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(assistantId, other.assistantId) && + Objects.equals(verified, other.verified) && + Objects.equals(identity, other.identity) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + accountSid, + assistantId, + verified, + identity, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/SessionFetcher.java b/src/main/java/com/twilio/rest/assistants/v1/SessionFetcher.java new file mode 100644 index 0000000000..92eaa1f146 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/SessionFetcher.java @@ -0,0 +1,70 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Fetcher; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class SessionFetcher extends Fetcher { + + private String pathId; + + public SessionFetcher(final String pathId) { + this.pathId = pathId; + } + + @Override + public Session fetch(final TwilioRestClient client) { + String path = "/v1/Sessions/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Session fetch failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Session.fromJson(response.getStream(), client.getObjectMapper()); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/SessionReader.java b/src/main/java/com/twilio/rest/assistants/v1/SessionReader.java new file mode 100644 index 0000000000..05a8c72660 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/SessionReader.java @@ -0,0 +1,135 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class SessionReader extends Reader { + + private Integer pageSize; + + public SessionReader() {} + + public SessionReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Sessions"; + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Session read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "sessions", + response.getContent(), + Session.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/Tool.java b/src/main/java/com/twilio/rest/assistants/v1/Tool.java new file mode 100644 index 0000000000..6347579d67 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/Tool.java @@ -0,0 +1,409 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.Converter; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Map; +import java.util.Objects; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Tool extends Resource { + + private static final long serialVersionUID = 250744757874592L; + + @ToString + public static class AssistantsV1ServiceCreatePolicyRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("id") + @Getter + @Setter + private String id; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("policy_details") + @Getter + @Setter + private Map policyDetails; + + public String getPolicyDetails() { + return Converter.mapToJson(policyDetails); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + public static AssistantsV1ServiceCreatePolicyRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCreatePolicyRequest.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceCreateToolRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("assistant_id") + @Getter + @Setter + private String assistantId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("enabled") + @Getter + @Setter + private Boolean enabled; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("meta") + @Getter + @Setter + private Map meta; + + public String getMeta() { + return Converter.mapToJson(meta); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("policy") + @Getter + @Setter + private AssistantsV1ServiceCreatePolicyRequest policy; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + public AssistantsV1ServiceCreateToolRequest() {} + + public static AssistantsV1ServiceCreateToolRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCreateToolRequest.class + ); + } + } + + @ToString + public static class AssistantsV1ServiceUpdateToolRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("assistant_id") + @Getter + @Setter + private String assistantId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("description") + @Getter + @Setter + private String description; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("enabled") + @Getter + @Setter + private Boolean enabled; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("meta") + @Getter + @Setter + private Map meta; + + public String getMeta() { + return Converter.mapToJson(meta); + } + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("name") + @Getter + @Setter + private String name; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("policy") + @Getter + @Setter + private AssistantsV1ServiceCreatePolicyRequest policy; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("type") + @Getter + @Setter + private String type; + + public AssistantsV1ServiceUpdateToolRequest() {} + + public static AssistantsV1ServiceUpdateToolRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceUpdateToolRequest.class + ); + } + } + + public static ToolCreator creator( + final Tool.AssistantsV1ServiceCreateToolRequest assistantsV1ServiceCreateToolRequest + ) { + return new ToolCreator(assistantsV1ServiceCreateToolRequest); + } + + public static ToolDeleter deleter(final String pathId) { + return new ToolDeleter(pathId); + } + + public static ToolReader reader() { + return new ToolReader(); + } + + public static ToolUpdater updater(final String pathId) { + return new ToolUpdater(pathId); + } + + /** + * Converts a JSON String into a Tool object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Tool object represented by the provided JSON + */ + public static Tool fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Tool.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Tool object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Tool object represented by the provided JSON + */ + public static Tool fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Tool.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String accountSid; + private final String description; + private final Boolean enabled; + private final String id; + private final Map meta; + private final String name; + private final Boolean requiresAuth; + private final String type; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Tool( + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("description") final String description, + @JsonProperty("enabled") final Boolean enabled, + @JsonProperty("id") final String id, + @JsonProperty("meta") final Map meta, + @JsonProperty("name") final String name, + @JsonProperty("requires_auth") final Boolean requiresAuth, + @JsonProperty("type") final String type, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.accountSid = accountSid; + this.description = description; + this.enabled = enabled; + this.id = id; + this.meta = meta; + this.name = name; + this.requiresAuth = requiresAuth; + this.type = type; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final String getDescription() { + return this.description; + } + + public final Boolean getEnabled() { + return this.enabled; + } + + public final String getId() { + return this.id; + } + + public final Map getMeta() { + return this.meta; + } + + public final String getName() { + return this.name; + } + + public final Boolean getRequiresAuth() { + return this.requiresAuth; + } + + public final String getType() { + return this.type; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Tool other = (Tool) o; + + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(description, other.description) && + Objects.equals(enabled, other.enabled) && + Objects.equals(id, other.id) && + Objects.equals(meta, other.meta) && + Objects.equals(name, other.name) && + Objects.equals(requiresAuth, other.requiresAuth) && + Objects.equals(type, other.type) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + accountSid, + description, + enabled, + id, + meta, + name, + requiresAuth, + type, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/ToolCreator.java b/src/main/java/com/twilio/rest/assistants/v1/ToolCreator.java new file mode 100644 index 0000000000..0b841a7264 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/ToolCreator.java @@ -0,0 +1,95 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class ToolCreator extends Creator { + + private Tool.AssistantsV1ServiceCreateToolRequest assistantsV1ServiceCreateToolRequest; + + public ToolCreator( + final Tool.AssistantsV1ServiceCreateToolRequest assistantsV1ServiceCreateToolRequest + ) { + this.assistantsV1ServiceCreateToolRequest = + assistantsV1ServiceCreateToolRequest; + } + + public ToolCreator setAssistantsV1ServiceCreateToolRequest( + final Tool.AssistantsV1ServiceCreateToolRequest assistantsV1ServiceCreateToolRequest + ) { + this.assistantsV1ServiceCreateToolRequest = + assistantsV1ServiceCreateToolRequest; + return this; + } + + @Override + public Tool create(final TwilioRestClient client) { + String path = "/v1/Tools"; + + path = + path.replace( + "{" + "AssistantsV1ServiceCreateToolRequest" + "}", + this.assistantsV1ServiceCreateToolRequest.toString() + ); + + Request request = new Request( + HttpMethod.POST, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Tool creation failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Tool.fromJson(response.getStream(), client.getObjectMapper()); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceCreateToolRequest != null) { + request.setBody( + Tool.toJson(assistantsV1ServiceCreateToolRequest, objectMapper) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/ToolDeleter.java b/src/main/java/com/twilio/rest/assistants/v1/ToolDeleter.java new file mode 100644 index 0000000000..7ef83721f7 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/ToolDeleter.java @@ -0,0 +1,69 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Deleter; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class ToolDeleter extends Deleter { + + private String pathId; + + public ToolDeleter(final String pathId) { + this.pathId = pathId; + } + + @Override + public boolean delete(final TwilioRestClient client) { + String path = "/v1/Tools/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.DELETE, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Tool delete failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + return response.getStatusCode() == 204; + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/ToolReader.java b/src/main/java/com/twilio/rest/assistants/v1/ToolReader.java new file mode 100644 index 0000000000..7b8e49a7d8 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/ToolReader.java @@ -0,0 +1,144 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class ToolReader extends Reader { + + private String assistantId; + private Integer pageSize; + + public ToolReader() {} + + public ToolReader setAssistantId(final String assistantId) { + this.assistantId = assistantId; + return this; + } + + public ToolReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Tools"; + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Tool read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "tools", + response.getContent(), + Tool.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (assistantId != null) { + request.addQueryParam("AssistantId", assistantId); + } + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/ToolUpdater.java b/src/main/java/com/twilio/rest/assistants/v1/ToolUpdater.java new file mode 100644 index 0000000000..eb5293917b --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/ToolUpdater.java @@ -0,0 +1,89 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class ToolUpdater extends Updater { + + private String pathId; + private Tool.AssistantsV1ServiceUpdateToolRequest assistantsV1ServiceUpdateToolRequest; + + public ToolUpdater(final String pathId) { + this.pathId = pathId; + } + + public ToolUpdater setAssistantsV1ServiceUpdateToolRequest( + final Tool.AssistantsV1ServiceUpdateToolRequest assistantsV1ServiceUpdateToolRequest + ) { + this.assistantsV1ServiceUpdateToolRequest = + assistantsV1ServiceUpdateToolRequest; + return this; + } + + @Override + public Tool update(final TwilioRestClient client) { + String path = "/v1/Tools/{id}"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.PUT, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Tool update failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Tool.fromJson(response.getStream(), client.getObjectMapper()); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceUpdateToolRequest != null) { + request.setBody( + Tool.toJson(assistantsV1ServiceUpdateToolRequest, objectMapper) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/assistant/Feedback.java b/src/main/java/com/twilio/rest/assistants/v1/assistant/Feedback.java new file mode 100644 index 0000000000..c607c9c472 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/assistant/Feedback.java @@ -0,0 +1,274 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.assistant; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Objects; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Feedback extends Resource { + + private static final long serialVersionUID = 81835402394387L; + + @ToString + public static class AssistantsV1ServiceCreateFeedbackRequest { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("message_id") + @Getter + @Setter + private String messageId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("score") + @Getter + @Setter + private Float score; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("session_id") + @Getter + @Setter + private String sessionId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("text") + @Getter + @Setter + private String text; + + public AssistantsV1ServiceCreateFeedbackRequest( + final String sessionId + ) { + this.sessionId = sessionId; + } + + public static AssistantsV1ServiceCreateFeedbackRequest fromJson( + String jsonString, + ObjectMapper mapper + ) throws IOException { + return mapper.readValue( + jsonString, + AssistantsV1ServiceCreateFeedbackRequest.class + ); + } + } + + public static FeedbackCreator creator( + final String pathId, + final Feedback.AssistantsV1ServiceCreateFeedbackRequest assistantsV1ServiceCreateFeedbackRequest + ) { + return new FeedbackCreator( + pathId, + assistantsV1ServiceCreateFeedbackRequest + ); + } + + public static FeedbackReader reader(final String pathId) { + return new FeedbackReader(pathId); + } + + /** + * Converts a JSON String into a Feedback object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Feedback object represented by the provided JSON + */ + public static Feedback fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Feedback.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Feedback object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Feedback object represented by the provided JSON + */ + public static Feedback fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Feedback.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + public static String toJson(Object object, ObjectMapper mapper) { + try { + return mapper.writeValueAsString(object); + } catch (final JsonMappingException e) { + throw new ApiException(e.getMessage(), e); + } catch (JsonProcessingException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String assistantId; + private final String id; + private final String accountSid; + private final String userSid; + private final String messageId; + private final Float score; + private final String sessionId; + private final String text; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Feedback( + @JsonProperty("assistant_id") final String assistantId, + @JsonProperty("id") final String id, + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("user_sid") final String userSid, + @JsonProperty("message_id") final String messageId, + @JsonProperty("score") final Float score, + @JsonProperty("session_id") final String sessionId, + @JsonProperty("text") final String text, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.assistantId = assistantId; + this.id = id; + this.accountSid = accountSid; + this.userSid = userSid; + this.messageId = messageId; + this.score = score; + this.sessionId = sessionId; + this.text = text; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getAssistantId() { + return this.assistantId; + } + + public final String getId() { + return this.id; + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final String getUserSid() { + return this.userSid; + } + + public final String getMessageId() { + return this.messageId; + } + + public final Float getScore() { + return this.score; + } + + public final String getSessionId() { + return this.sessionId; + } + + public final String getText() { + return this.text; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Feedback other = (Feedback) o; + + return ( + Objects.equals(assistantId, other.assistantId) && + Objects.equals(id, other.id) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(userSid, other.userSid) && + Objects.equals(messageId, other.messageId) && + Objects.equals(score, other.score) && + Objects.equals(sessionId, other.sessionId) && + Objects.equals(text, other.text) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + assistantId, + id, + accountSid, + userSid, + messageId, + score, + sessionId, + text, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackCreator.java b/src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackCreator.java new file mode 100644 index 0000000000..86a729120d --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackCreator.java @@ -0,0 +1,105 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.assistant; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class FeedbackCreator extends Creator { + + private String pathId; + private Feedback.AssistantsV1ServiceCreateFeedbackRequest assistantsV1ServiceCreateFeedbackRequest; + + public FeedbackCreator( + final String pathId, + final Feedback.AssistantsV1ServiceCreateFeedbackRequest assistantsV1ServiceCreateFeedbackRequest + ) { + this.pathId = pathId; + this.assistantsV1ServiceCreateFeedbackRequest = + assistantsV1ServiceCreateFeedbackRequest; + } + + public FeedbackCreator setAssistantsV1ServiceCreateFeedbackRequest( + final Feedback.AssistantsV1ServiceCreateFeedbackRequest assistantsV1ServiceCreateFeedbackRequest + ) { + this.assistantsV1ServiceCreateFeedbackRequest = + assistantsV1ServiceCreateFeedbackRequest; + return this; + } + + @Override + public Feedback create(final TwilioRestClient client) { + String path = "/v1/Assistants/{id}/Feedbacks"; + + path = path.replace("{" + "id" + "}", this.pathId.toString()); + path = + path.replace( + "{" + "AssistantsV1ServiceCreateFeedbackRequest" + "}", + this.assistantsV1ServiceCreateFeedbackRequest.toString() + ); + + Request request = new Request( + HttpMethod.POST, + Domains.ASSISTANTS.toString(), + path + ); + request.setContentType(EnumConstants.ContentType.JSON); + addPostParams(request, client); + Response response = client.request(request); + if (response == null) { + throw new ApiConnectionException( + "Feedback creation failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Feedback.fromJson( + response.getStream(), + client.getObjectMapper() + ); + } + + private void addPostParams(final Request request, TwilioRestClient client) { + ObjectMapper objectMapper = client.getObjectMapper(); + if (assistantsV1ServiceCreateFeedbackRequest != null) { + request.setBody( + Feedback.toJson( + assistantsV1ServiceCreateFeedbackRequest, + objectMapper + ) + ); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackReader.java b/src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackReader.java new file mode 100644 index 0000000000..4dee076a8b --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/assistant/FeedbackReader.java @@ -0,0 +1,139 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.assistant; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class FeedbackReader extends Reader { + + private String pathId; + private Integer pageSize; + + public FeedbackReader(final String pathId) { + this.pathId = pathId; + } + + public FeedbackReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Assistants/{id}/Feedbacks"; + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Feedback read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "feedbacks", + response.getContent(), + Feedback.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/knowledge/Chunk.java b/src/main/java/com/twilio/rest/assistants/v1/knowledge/Chunk.java new file mode 100644 index 0000000000..85668dd2c2 --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/knowledge/Chunk.java @@ -0,0 +1,161 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.knowledge; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Map; +import java.util.Objects; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Chunk extends Resource { + + private static final long serialVersionUID = 152804488582909L; + + public static ChunkReader reader(final String pathId) { + return new ChunkReader(pathId); + } + + /** + * Converts a JSON String into a Chunk object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Chunk object represented by the provided JSON + */ + public static Chunk fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Chunk.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Chunk object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Chunk object represented by the provided JSON + */ + public static Chunk fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Chunk.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String accountSid; + private final String content; + private final Map metadata; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Chunk( + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("content") final String content, + @JsonProperty("metadata") final Map metadata, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.accountSid = accountSid; + this.content = content; + this.metadata = metadata; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final String getContent() { + return this.content; + } + + public final Map getMetadata() { + return this.metadata; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Chunk other = (Chunk) o; + + return ( + Objects.equals(accountSid, other.accountSid) && + Objects.equals(content, other.content) && + Objects.equals(metadata, other.metadata) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + accountSid, + content, + metadata, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/knowledge/ChunkReader.java b/src/main/java/com/twilio/rest/assistants/v1/knowledge/ChunkReader.java new file mode 100644 index 0000000000..ed0d3a7b2d --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/knowledge/ChunkReader.java @@ -0,0 +1,139 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.knowledge; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class ChunkReader extends Reader { + + private String pathId; + private Integer pageSize; + + public ChunkReader(final String pathId) { + this.pathId = pathId; + } + + public ChunkReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Knowledge/{id}/Chunks"; + path = path.replace("{" + "id" + "}", this.pathId.toString()); + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Chunk read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "chunks", + response.getContent(), + Chunk.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/session/Message.java b/src/main/java/com/twilio/rest/assistants/v1/session/Message.java new file mode 100644 index 0000000000..8f5ade962d --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/session/Message.java @@ -0,0 +1,206 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.session; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Resource; +import com.twilio.converter.DateConverter; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import java.io.IOException; +import java.io.InputStream; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Map; +import java.util.Objects; +import lombok.ToString; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Message extends Resource { + + private static final long serialVersionUID = 88120971522058L; + + public static MessageReader reader(final String pathSessionId) { + return new MessageReader(pathSessionId); + } + + /** + * Converts a JSON String into a Message object using the provided ObjectMapper. + * + * @param json Raw JSON String + * @param objectMapper Jackson ObjectMapper + * @return Message object represented by the provided JSON + */ + public static Message fromJson( + final String json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Message.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + /** + * Converts a JSON InputStream into a Message object using the provided + * ObjectMapper. + * + * @param json Raw JSON InputStream + * @param objectMapper Jackson ObjectMapper + * @return Message object represented by the provided JSON + */ + public static Message fromJson( + final InputStream json, + final ObjectMapper objectMapper + ) { + // Convert all checked exceptions to Runtime + try { + return objectMapper.readValue(json, Message.class); + } catch (final JsonMappingException | JsonParseException e) { + throw new ApiException(e.getMessage(), e); + } catch (final IOException e) { + throw new ApiConnectionException(e.getMessage(), e); + } + } + + private final String id; + private final String accountSid; + private final String assistantId; + private final String sessionId; + private final String identity; + private final String role; + private final Map content; + private final Map meta; + private final ZonedDateTime dateCreated; + private final ZonedDateTime dateUpdated; + + @JsonCreator + private Message( + @JsonProperty("id") final String id, + @JsonProperty("account_sid") final String accountSid, + @JsonProperty("assistant_id") final String assistantId, + @JsonProperty("session_id") final String sessionId, + @JsonProperty("identity") final String identity, + @JsonProperty("role") final String role, + @JsonProperty("content") final Map content, + @JsonProperty("meta") final Map meta, + @JsonProperty("date_created") final String dateCreated, + @JsonProperty("date_updated") final String dateUpdated + ) { + this.id = id; + this.accountSid = accountSid; + this.assistantId = assistantId; + this.sessionId = sessionId; + this.identity = identity; + this.role = role; + this.content = content; + this.meta = meta; + this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated); + this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated); + } + + public final String getId() { + return this.id; + } + + public final String getAccountSid() { + return this.accountSid; + } + + public final String getAssistantId() { + return this.assistantId; + } + + public final String getSessionId() { + return this.sessionId; + } + + public final String getIdentity() { + return this.identity; + } + + public final String getRole() { + return this.role; + } + + public final Map getContent() { + return this.content; + } + + public final Map getMeta() { + return this.meta; + } + + public final ZonedDateTime getDateCreated() { + return this.dateCreated; + } + + public final ZonedDateTime getDateUpdated() { + return this.dateUpdated; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + Message other = (Message) o; + + return ( + Objects.equals(id, other.id) && + Objects.equals(accountSid, other.accountSid) && + Objects.equals(assistantId, other.assistantId) && + Objects.equals(sessionId, other.sessionId) && + Objects.equals(identity, other.identity) && + Objects.equals(role, other.role) && + Objects.equals(content, other.content) && + Objects.equals(meta, other.meta) && + Objects.equals(dateCreated, other.dateCreated) && + Objects.equals(dateUpdated, other.dateUpdated) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + accountSid, + assistantId, + sessionId, + identity, + role, + content, + meta, + dateCreated, + dateUpdated + ); + } +} diff --git a/src/main/java/com/twilio/rest/assistants/v1/session/MessageReader.java b/src/main/java/com/twilio/rest/assistants/v1/session/MessageReader.java new file mode 100644 index 0000000000..a4efe9d8ac --- /dev/null +++ b/src/main/java/com/twilio/rest/assistants/v1/session/MessageReader.java @@ -0,0 +1,143 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Assistants + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.twilio.rest.assistants.v1.session; + +import com.twilio.base.Page; +import com.twilio.base.Reader; +import com.twilio.base.ResourceSet; +import com.twilio.constant.EnumConstants; +import com.twilio.exception.ApiConnectionException; +import com.twilio.exception.ApiException; +import com.twilio.exception.RestException; +import com.twilio.http.HttpMethod; +import com.twilio.http.Request; +import com.twilio.http.Response; +import com.twilio.http.TwilioRestClient; +import com.twilio.rest.Domains; + +public class MessageReader extends Reader { + + private String pathSessionId; + private Integer pageSize; + + public MessageReader(final String pathSessionId) { + this.pathSessionId = pathSessionId; + } + + public MessageReader setPageSize(final Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + @Override + public ResourceSet read(final TwilioRestClient client) { + return new ResourceSet<>(this, client, firstPage(client)); + } + + public Page firstPage(final TwilioRestClient client) { + String path = "/v1/Sessions/{sessionId}/Messages"; + path = + path.replace( + "{" + "sessionId" + "}", + this.pathSessionId.toString() + ); + + Request request = new Request( + HttpMethod.GET, + Domains.ASSISTANTS.toString(), + path + ); + + addQueryParams(request); + request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + return pageForRequest(client, request); + } + + private Page pageForRequest( + final TwilioRestClient client, + final Request request + ) { + Response response = client.request(request); + + if (response == null) { + throw new ApiConnectionException( + "Message read failed: Unable to connect to server" + ); + } else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + RestException restException = RestException.fromJson( + response.getStream(), + client.getObjectMapper() + ); + if (restException == null) { + throw new ApiException( + "Server Error, no content", + response.getStatusCode() + ); + } + throw new ApiException(restException); + } + + return Page.fromJson( + "messages", + response.getContent(), + Message.class, + client.getObjectMapper() + ); + } + + @Override + public Page previousPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getPreviousPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page nextPage( + final Page page, + final TwilioRestClient client + ) { + Request request = new Request( + HttpMethod.GET, + page.getNextPageUrl(Domains.ASSISTANTS.toString()) + ); + return pageForRequest(client, request); + } + + @Override + public Page getPage( + final String targetUrl, + final TwilioRestClient client + ) { + Request request = new Request(HttpMethod.GET, targetUrl); + + return pageForRequest(client, request); + } + + private void addQueryParams(final Request request) { + if (pageSize != null) { + request.addQueryParam("PageSize", pageSize.toString()); + } + + if (getPageSize() != null) { + request.addQueryParam("PageSize", Integer.toString(getPageSize())); + } + } +} diff --git a/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetch.java b/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetch.java index 983eb5308d..6893d223b7 100644 --- a/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetch.java +++ b/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetch.java @@ -38,8 +38,8 @@ public class ApprovalFetch extends Resource { private static final long serialVersionUID = 266557741388539L; - public static ApprovalFetchFetcher fetcher(final String pathContentSid) { - return new ApprovalFetchFetcher(pathContentSid); + public static ApprovalFetchFetcher fetcher(final String pathSid) { + return new ApprovalFetchFetcher(pathSid); } /** diff --git a/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetchFetcher.java b/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetchFetcher.java index 317508063a..656e2d6ee1 100644 --- a/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetchFetcher.java +++ b/src/main/java/com/twilio/rest/content/v1/content/ApprovalFetchFetcher.java @@ -27,21 +27,17 @@ public class ApprovalFetchFetcher extends Fetcher { - private String pathContentSid; + private String pathSid; - public ApprovalFetchFetcher(final String pathContentSid) { - this.pathContentSid = pathContentSid; + public ApprovalFetchFetcher(final String pathSid) { + this.pathSid = pathSid; } @Override public ApprovalFetch fetch(final TwilioRestClient client) { - String path = "/v1/Content/{ContentSid}/ApprovalRequests"; + String path = "/v1/Content/{Sid}/ApprovalRequests"; - path = - path.replace( - "{" + "ContentSid" + "}", - this.pathContentSid.toString() - ); + path = path.replace("{" + "Sid" + "}", this.pathSid.toString()); Request request = new Request( HttpMethod.GET, diff --git a/src/main/java/com/twilio/rest/intelligence/v2/OperatorType.java b/src/main/java/com/twilio/rest/intelligence/v2/OperatorType.java index 1adf6058e1..2142f4f135 100644 --- a/src/main/java/com/twilio/rest/intelligence/v2/OperatorType.java +++ b/src/main/java/com/twilio/rest/intelligence/v2/OperatorType.java @@ -251,28 +251,6 @@ public int hashCode() { ); } - public enum Availability { - INTERNAL("internal"), - BETA("beta"), - PUBLIC("public"), - RETIRED("retired"); - - private final String value; - - private Availability(final String value) { - this.value = value; - } - - public String toString() { - return value; - } - - @JsonCreator - public static Availability forValue(final String value) { - return Promoter.enumFromString(value, Availability.values()); - } - } - public enum Provider { TWILIO("twilio"), AMAZON("amazon"), @@ -315,4 +293,27 @@ public static OutputType forValue(final String value) { return Promoter.enumFromString(value, OutputType.values()); } } + + public enum Availability { + INTERNAL("internal"), + BETA("beta"), + GENERAL_AVAILABILITY("general-availability"), + RETIRED("retired"), + DEPRECATED("deprecated"); + + private final String value; + + private Availability(final String value) { + this.value = value; + } + + public String toString() { + return value; + } + + @JsonCreator + public static Availability forValue(final String value) { + return Promoter.enumFromString(value, Availability.values()); + } + } } diff --git a/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagement.java b/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagement.java index a23d2a6d47..4030edb955 100644 --- a/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagement.java +++ b/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagement.java @@ -36,7 +36,7 @@ @ToString public class ModuleDataManagement extends Resource { - private static final long serialVersionUID = 187208983422591L; + private static final long serialVersionUID = 28686366019019L; public static ModuleDataManagementFetcher fetcher(final String pathSid) { return new ModuleDataManagementFetcher(pathSid); @@ -97,6 +97,7 @@ public static ModuleDataManagement fromJson( private final Map moduleInfo; private final Map documentation; private final Map configuration; + private final Map pricing; @JsonCreator private ModuleDataManagement( @@ -107,7 +108,8 @@ private ModuleDataManagement( @JsonProperty("policies") final Map policies, @JsonProperty("module_info") final Map moduleInfo, @JsonProperty("documentation") final Map documentation, - @JsonProperty("configuration") final Map configuration + @JsonProperty("configuration") final Map configuration, + @JsonProperty("pricing") final Map pricing ) { this.url = url; this.sid = sid; @@ -117,6 +119,7 @@ private ModuleDataManagement( this.moduleInfo = moduleInfo; this.documentation = documentation; this.configuration = configuration; + this.pricing = pricing; } public final URI getUrl() { @@ -151,6 +154,10 @@ public final Map getConfiguration() { return this.configuration; } + public final Map getPricing() { + return this.pricing; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -171,7 +178,8 @@ public boolean equals(final Object o) { Objects.equals(policies, other.policies) && Objects.equals(moduleInfo, other.moduleInfo) && Objects.equals(documentation, other.documentation) && - Objects.equals(configuration, other.configuration) + Objects.equals(configuration, other.configuration) && + Objects.equals(pricing, other.pricing) ); } @@ -185,7 +193,8 @@ public int hashCode() { policies, moduleInfo, documentation, - configuration + configuration, + pricing ); } } diff --git a/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagementUpdater.java b/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagementUpdater.java index 3236bc2ec8..98a678bc01 100644 --- a/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagementUpdater.java +++ b/src/main/java/com/twilio/rest/marketplace/v1/ModuleDataManagementUpdater.java @@ -34,6 +34,7 @@ public class ModuleDataManagementUpdater extends Updater { private String policies; private String support; private String configuration; + private String pricing; public ModuleDataManagementUpdater(final String pathSid) { this.pathSid = pathSid; @@ -75,6 +76,11 @@ public ModuleDataManagementUpdater setConfiguration( return this; } + public ModuleDataManagementUpdater setPricing(final String pricing) { + this.pricing = pricing; + return this; + } + @Override public ModuleDataManagement update(final TwilioRestClient client) { String path = "/v1/Listing/{Sid}"; @@ -132,5 +138,8 @@ private void addPostParams(final Request request) { if (configuration != null) { request.addPostParam("Configuration", configuration); } + if (pricing != null) { + request.addPostParam("Pricing", pricing); + } } } diff --git a/src/main/java/com/twilio/rest/marketplace/v1/installedaddon/InstalledAddOnUsage.java b/src/main/java/com/twilio/rest/marketplace/v1/installedaddon/InstalledAddOnUsage.java index ceb98d272e..26949939ae 100644 --- a/src/main/java/com/twilio/rest/marketplace/v1/installedaddon/InstalledAddOnUsage.java +++ b/src/main/java/com/twilio/rest/marketplace/v1/installedaddon/InstalledAddOnUsage.java @@ -39,7 +39,7 @@ @ToString public class InstalledAddOnUsage extends Resource { - private static final long serialVersionUID = 244026319744874L; + private static final long serialVersionUID = 201246203121312L; @ToString public static class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems { @@ -56,6 +56,12 @@ public static class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems @Setter private String sid; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("submitted") + @Getter + @Setter + private Boolean submitted; + public static MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems fromJson( String jsonString, ObjectMapper mapper @@ -71,7 +77,13 @@ public static MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems fromJs public static class MarketplaceV1InstalledAddOnInstalledAddOnUsage { @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("billable_items") + @JsonProperty("totalSubmitted") + @Getter + @Setter + private BigDecimal totalSubmitted; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("billableItems") @Getter @Setter private List< @@ -97,38 +109,6 @@ public static MarketplaceV1InstalledAddOnInstalledAddOnUsage fromJson( } } - @ToString - public static class MarketplaceV1InstalledAddOnBillingUsageResponseBillableItems { - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("quantity") - @Getter - @Setter - private BigDecimal quantity; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("sid") - @Getter - @Setter - private String sid; - - @JsonInclude(JsonInclude.Include.NON_EMPTY) - @JsonProperty("submitted") - @Getter - @Setter - private Boolean submitted; - - public static MarketplaceV1InstalledAddOnBillingUsageResponseBillableItems fromJson( - String jsonString, - ObjectMapper mapper - ) throws IOException { - return mapper.readValue( - jsonString, - MarketplaceV1InstalledAddOnBillingUsageResponseBillableItems.class - ); - } - } - public static InstalledAddOnUsageCreator creator( final String pathInstalledAddOnSid, final InstalledAddOnUsage.MarketplaceV1InstalledAddOnInstalledAddOnUsage marketplaceV1InstalledAddOnInstalledAddOnUsage @@ -194,32 +174,32 @@ public static String toJson(Object object, ObjectMapper mapper) { } } + private final BigDecimal totalSubmitted; private final List< - MarketplaceV1InstalledAddOnBillingUsageResponseBillableItems + MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems > billableItems; - private final BigDecimal totalSubmitted; @JsonCreator private InstalledAddOnUsage( + @JsonProperty("total_submitted") final BigDecimal totalSubmitted, @JsonProperty("billable_items") final List< - MarketplaceV1InstalledAddOnBillingUsageResponseBillableItems - > billableItems, - @JsonProperty("total_submitted") final BigDecimal totalSubmitted + MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems + > billableItems ) { - this.billableItems = billableItems; this.totalSubmitted = totalSubmitted; + this.billableItems = billableItems; + } + + public final BigDecimal getTotalSubmitted() { + return this.totalSubmitted; } public final List< - MarketplaceV1InstalledAddOnBillingUsageResponseBillableItems + MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems > getBillableItems() { return this.billableItems; } - public final BigDecimal getTotalSubmitted() { - return this.totalSubmitted; - } - @Override public boolean equals(final Object o) { if (this == o) { @@ -233,13 +213,13 @@ public boolean equals(final Object o) { InstalledAddOnUsage other = (InstalledAddOnUsage) o; return ( - Objects.equals(billableItems, other.billableItems) && - Objects.equals(totalSubmitted, other.totalSubmitted) + Objects.equals(totalSubmitted, other.totalSubmitted) && + Objects.equals(billableItems, other.billableItems) ); } @Override public int hashCode() { - return Objects.hash(billableItems, totalSubmitted); + return Objects.hash(totalSubmitted, billableItems); } }