From 7f53ea0c190a64823400616a43525505075d5b8f Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 26 Jun 2024 16:09:42 +0530 Subject: [PATCH] Revert "feat: Support for token based authentication and no auth rest calls (#587)""" This reverts commit 4d002b8e2abf837213ab883e9b9911df1f14bda3. --- .../twilio/rest/api/v2010/AccountCreator.java | 7 +- .../twilio/rest/api/v2010/AccountDeleter.java | 7 +- .../twilio/rest/api/v2010/AccountFetcher.java | 9 +- .../twilio/rest/api/v2010/AccountReader.java | 11 +- .../twilio/rest/api/v2010/AccountUpdater.java | 9 +- .../rest/api/v2010/account/CallCreator.java | 7 +- .../rest/api/v2010/account/CallDeleter.java | 7 +- .../rest/api/v2010/account/CallFetcher.java | 9 +- .../call/FeedbackCallSummaryUpdater.java | 9 +- .../twilio/rest/flexapi/v1/CallUpdater.java | 9 +- .../flexapi/v1/credential/AwsDeleter.java | 7 +- .../flexapi/v1/credential/AwsFetcher.java | 9 +- .../rest/flexapi/v1/credential/AwsReader.java | 11 +- .../flexapi/v1/credential/AwsUpdater.java | 9 +- .../v1/credential/NewCredentialsCreator.java | 7 +- .../v1/credential/aws/HistoryFetcher.java | 9 +- .../deployedDevices/FleetCreator.java | 7 +- .../deployedDevices/FleetFetcher.java | 9 +- .../understand/AssistantReader.java | 11 +- examples/twilio_iam_organizations.yaml | 1390 ----------------- scripts/build_twilio_library.py | 36 +- scripts/generate.sh | 5 +- .../oai/api/JavaApiResourceBuilder.java | 25 - .../com/twilio/oai/api/JavaApiResources.java | 2 - .../resolver/java/JavaConventionResolver.java | 37 +- src/main/resources/twilio-java/api.mustache | 2 +- .../resources/twilio-java/creator.mustache | 32 +- .../resources/twilio-java/deleter.mustache | 32 +- .../resources/twilio-java/fetcher.mustache | 34 +- .../twilio-java/generate_uri.mustache | 6 +- .../twilio-java/headerParams.mustache | 2 +- .../resources/twilio-java/postParams.mustache | 2 +- .../twilio-java/postParams_body.mustache | 2 +- .../twilio-java/queryParamsFunc.mustache | 2 + .../resources/twilio-java/reader.mustache | 51 +- .../resources/twilio-java/updater.mustache | 34 +- 36 files changed, 179 insertions(+), 1678 deletions(-) delete mode 100644 examples/twilio_iam_organizations.yaml create mode 100644 src/main/resources/twilio-java/queryParamsFunc.mustache diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java index c4793a5e2..1c2fffd4c 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.math.BigDecimal; import java.util.List; @@ -49,10 +52,6 @@ import java.net.URI; -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AccountCreator extends Creator{ private Account.XTwilioWebhookEnabled xTwilioWebhookEnabled; private URI recordingStatusCallback; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java index d045c9e77..be577f3c8 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Deleter; import com.twilio.converter.Promoter; import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ import com.twilio.converter.Converter; 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; import java.time.LocalDate; import java.io.IOException; @@ -42,10 +45,6 @@ import lombok.ToString; -import com.twilio.base.Deleter; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AccountDeleter extends Deleter { private String pathSid; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java index 407e1aa20..7e197270a 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Fetcher; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.io.IOException; @@ -43,10 +46,6 @@ import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AccountFetcher extends Fetcher { private String pathSid; @@ -72,7 +71,7 @@ public Account fetch(final TwilioRestClient client) { Response response = client.request(request); if (response == null) { - throw new ApiConnectionException("Account fetch failed: Unable to connect to server"); + throw new ApiConnectionException("Account 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) { diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java index 24def5326..5b30577d5 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java @@ -15,7 +15,9 @@ package com.twilio.rest.api.v2010; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Reader; import com.twilio.constant.EnumConstants; +import com.twilio.base.ResourceSet; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; import com.twilio.converter.PrefixedCollapsibleMap; @@ -23,8 +25,11 @@ 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; +import com.twilio.base.Page; import java.time.LocalDate; import java.time.ZonedDateTime; import java.io.IOException; @@ -42,12 +47,6 @@ import lombok.ToString; -import com.twilio.base.Page; -import com.twilio.base.Reader; -import com.twilio.base.ResourceSet; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AccountReader extends Reader { private ZonedDateTime dateCreated; private LocalDate dateTest; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java index 01bc06773..79ed43156 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; @@ -43,11 +46,6 @@ import lombok.ToString; -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - - public class AccountUpdater extends Updater{ private Account.Status status; private String pathSid; @@ -98,7 +96,6 @@ public Account update(final TwilioRestClient client){ return Account.fromJson(response.getStream(), client.getObjectMapper()); } - private void addPostParams(final Request request) { if (pauseBehavior != null) { request.addPostParam("PauseBehavior", pauseBehavior); diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java index 6a6c70523..c789abbe4 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.account; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.math.BigDecimal; import java.util.List; @@ -49,10 +52,6 @@ import java.net.URI; -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class CallCreator extends Creator{ private String requiredStringProperty; private HttpMethod testMethod; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java index 21b843494..86f9b342d 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.account; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Deleter; import com.twilio.converter.Promoter; import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ import com.twilio.converter.Converter; 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; import java.time.LocalDate; import java.io.IOException; @@ -42,10 +45,6 @@ import lombok.ToString; -import com.twilio.base.Deleter; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class CallDeleter extends Deleter { private Integer pathTestInteger; private String pathAccountSid; diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java index 26b8c7398..7400150be 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.account; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Fetcher; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.io.IOException; @@ -43,10 +46,6 @@ import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class CallFetcher extends Fetcher { private Integer pathTestInteger; private String pathAccountSid; @@ -76,7 +75,7 @@ public Call fetch(final TwilioRestClient client) { Response response = client.request(request); if (response == null) { - throw new ApiConnectionException("Call fetch failed: Unable to connect to server"); + throw new ApiConnectionException("Call 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) { diff --git a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java index dd84baa09..63135eb7f 100644 --- a/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java @@ -15,6 +15,7 @@ package com.twilio.rest.api.v2010.account.call; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; @@ -43,11 +46,6 @@ import lombok.ToString; -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - - public class FeedbackCallSummaryUpdater extends Updater{ private String pathSid; private LocalDate endDate; @@ -110,7 +108,6 @@ public FeedbackCallSummary update(final TwilioRestClient client){ return FeedbackCallSummary.fromJson(response.getStream(), client.getObjectMapper()); } - private void addPostParams(final Request request) { if (accountSid != null) { request.addPostParam("AccountSid", accountSid); diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java index 05eb3ac0c..534608599 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java @@ -15,6 +15,7 @@ package com.twilio.rest.flexapi.v1; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; @@ -43,11 +46,6 @@ import lombok.ToString; -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - - public class CallUpdater extends Updater{ private String pathSid; @@ -80,5 +78,4 @@ public Call update(final TwilioRestClient client){ return Call.fromJson(response.getStream(), client.getObjectMapper()); } - } diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java index 194d7ec5e..388d07b24 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsDeleter.java @@ -15,6 +15,7 @@ package com.twilio.rest.flexapi.v1.credential; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Deleter; import com.twilio.converter.Promoter; import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ import com.twilio.converter.Converter; 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; import java.time.LocalDate; import java.io.IOException; @@ -42,10 +45,6 @@ import lombok.ToString; -import com.twilio.base.Deleter; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AwsDeleter extends Deleter { private String pathSid; diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java index 33079a2ce..cd699ccb9 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.flexapi.v1.credential; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Fetcher; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.io.IOException; @@ -43,10 +46,6 @@ import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AwsFetcher extends Fetcher { private String pathSid; @@ -69,7 +68,7 @@ public Aws fetch(final TwilioRestClient client) { Response response = client.request(request); if (response == null) { - throw new ApiConnectionException("Aws fetch failed: Unable to connect to server"); + throw new ApiConnectionException("Aws 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) { diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java index d08218939..e499204d5 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsReader.java @@ -15,7 +15,9 @@ package com.twilio.rest.flexapi.v1.credential; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Reader; import com.twilio.constant.EnumConstants; +import com.twilio.base.ResourceSet; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; import com.twilio.converter.PrefixedCollapsibleMap; @@ -23,8 +25,11 @@ 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; +import com.twilio.base.Page; import java.time.LocalDate; import java.time.ZonedDateTime; import java.io.IOException; @@ -42,12 +47,6 @@ import lombok.ToString; -import com.twilio.base.Page; -import com.twilio.base.Reader; -import com.twilio.base.ResourceSet; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AwsReader extends Reader { private Integer pageSize; diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java index 82c1dbc0d..da34966dc 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/AwsUpdater.java @@ -15,6 +15,7 @@ package com.twilio.rest.flexapi.v1.credential; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; @@ -43,11 +46,6 @@ import lombok.ToString; -import com.twilio.base.Updater; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - - public class AwsUpdater extends Updater{ private String pathSid; private String testString; @@ -92,7 +90,6 @@ public Aws update(final TwilioRestClient client){ return Aws.fromJson(response.getStream(), client.getObjectMapper()); } - private void addPostParams(final Request request) { if (testString != null) { request.addPostParam("TestString", testString); diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java index 2acabd640..ce96017a8 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/NewCredentialsCreator.java @@ -15,6 +15,7 @@ package com.twilio.rest.flexapi.v1.credential; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.math.BigDecimal; import java.util.List; @@ -49,10 +52,6 @@ import java.net.URI; -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class NewCredentialsCreator extends Creator{ private String testString; private Boolean testBoolean; diff --git a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java index 7ca88ac2e..b5fafe7fd 100644 --- a/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/flexapi/v1/credential/aws/HistoryFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.flexapi.v1.credential.aws; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Fetcher; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.io.IOException; @@ -43,10 +46,6 @@ import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class HistoryFetcher extends Fetcher { private String pathSid; private Map addOnsData; @@ -75,7 +74,7 @@ public History fetch(final TwilioRestClient client) { Response response = client.request(request); if (response == null) { - throw new ApiConnectionException("History fetch failed: Unable to connect to server"); + throw new ApiConnectionException("History 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) { diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java index 5bf8a973d..75f4badeb 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetCreator.java @@ -15,6 +15,7 @@ package com.twilio.rest.versionless.deployedDevices; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.math.BigDecimal; import java.util.List; @@ -49,10 +52,6 @@ import java.net.URI; -import com.twilio.base.Creator; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class FleetCreator extends Creator{ private String name; diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java index 0b1d72f92..9488721f6 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/deployedDevices/FleetFetcher.java @@ -15,6 +15,7 @@ package com.twilio.rest.versionless.deployedDevices; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Fetcher; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -23,7 +24,9 @@ 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; import java.io.IOException; @@ -43,10 +46,6 @@ import lombok.ToString; -import com.twilio.base.Fetcher; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class FleetFetcher extends Fetcher { private String pathSid; @@ -69,7 +68,7 @@ public Fleet fetch(final TwilioRestClient client) { Response response = client.request(request); if (response == null) { - throw new ApiConnectionException("Fleet fetch failed: Unable to connect to server"); + throw new ApiConnectionException("Fleet 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) { diff --git a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java index 5e9cac360..1cf88c107 100644 --- a/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java +++ b/examples/java/src/main/java/com/twilio/rest/versionless/understand/AssistantReader.java @@ -15,7 +15,9 @@ package com.twilio.rest.versionless.understand; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Reader; import com.twilio.constant.EnumConstants; +import com.twilio.base.ResourceSet; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; import com.twilio.converter.PrefixedCollapsibleMap; @@ -23,8 +25,11 @@ 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; +import com.twilio.base.Page; import java.time.LocalDate; import java.time.ZonedDateTime; import java.io.IOException; @@ -42,12 +47,6 @@ import lombok.ToString; -import com.twilio.base.Page; -import com.twilio.base.Reader; -import com.twilio.base.ResourceSet; -import com.twilio.http.Request; -import com.twilio.http.TwilioRestClient; - public class AssistantReader extends Reader { private Integer pageSize; diff --git a/examples/twilio_iam_organizations.yaml b/examples/twilio_iam_organizations.yaml deleted file mode 100644 index c99480be8..000000000 --- a/examples/twilio_iam_organizations.yaml +++ /dev/null @@ -1,1390 +0,0 @@ -openapi: 3.0.1 -security: - - oAuth2ClientCredentials: [] -info: - title: Organization Public API - contact: - name: Twilio Support - url: https://support.twilio.com - email: support@twilio.com - license: - name: Apache 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0.html - version: 1.0.0 -tags: - - name: SCIM - description: SCIM 2.0 User endpoints - - name: OrganizationAccount - description: Organization Account operations - - name: RoleAssignments - description: Role assignment operations - - name: OauthV1Authorize - - name: OauthV1Token -paths: - /Organizations/{organizationSid}/scim/Users: - servers: - - url: https://preview-iam.twilio.com - get: - tags: - - SCIM - summary: List SCIM Users - operationId: ListOrganizationUsers - parameters: - - name: organizationSid - in: path - required: true - schema: - pattern: OR[0-9a-f]{32} - type: string - format: OrganizationSid - example: OR33f4f3aa6fffe840d000f8ef22e883db - - name: filter - in: query - schema: - type: string - responses: - '200': - description: List of users - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimUserPage' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '400': - description: Bad request or business rules violation - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '401': - description: Unauthorized - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '403': - description: Forbidden - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '429': - description: Too many requests - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - post: - tags: - - SCIM - summary: Create SCIM User - operationId: CreateOrganizationUser - parameters: - - name: organizationSid - in: path - required: true - schema: - pattern: OR[0-9a-f]{32} - type: string - format: OrganizationSid - example: ORceef74a747c1ae8d837aafb5a31e475f - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScimUser' - application/scim+json: - schema: - $ref: '#/components/schemas/ScimUser' - required: true - responses: - '201': - description: Created User - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimUser' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '400': - description: Bad request or business rules violation - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '401': - description: Unauthorized - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '403': - description: Forbidden - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '404': - description: Not found - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '429': - description: Too many requests - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - /Organizations/{organizationSid}/scim/Users/{userSid}: - servers: - - url: https://preview-iam.twilio.com - get: - tags: - - SCIM - summary: Get SCIM User - operationId: FetchOrganizationUser - parameters: - - name: organizationSid - in: path - required: true - schema: - pattern: OR[0-9a-f]{32} - type: string - format: OrganizationSid - example: OR5f3baf01a0f8273e74266afb84341766 - - name: userSid - in: path - required: true - schema: - pattern: US[0-9a-f]{32} - type: string - format: UserSid - example: USb51dccce9ac8e67b938253c7bcaa4f45 - responses: - '200': - description: User - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimUser' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '400': - description: Bad request or business rules violation - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '401': - description: Unauthorized - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '403': - description: Forbidden - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '404': - description: Not found - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '429': - description: Too many requests - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - put: - tags: - - SCIM - summary: Update SCIM User - operationId: UpdateOrganizationUser - parameters: - - name: If-Match - in: header - schema: - type: string - - name: organizationSid - in: path - required: true - schema: - pattern: OR[0-9a-f]{32} - type: string - format: OrganizationSid - example: ORd3a1c06d4942d123cd8fa2a052fe110a - - name: userSid - in: path - required: true - schema: - pattern: US[0-9a-f]{32} - type: string - format: UserSid - example: US14def5586bc0799a5c7aab80247af278 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScimUser' - application/scim+json: - schema: - $ref: '#/components/schemas/ScimUser' - required: true - responses: - '200': - description: User object with updated attributes - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimUser' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '400': - description: Bad request or business rules violation - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '401': - description: Unauthorized - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '403': - description: Forbidden - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '404': - description: Not found - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '409': - description: Version conflict - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '429': - description: Too many requests - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - delete: - tags: - - SCIM - summary: Delete SCIM User - operationId: DeleteOrganizationUser - parameters: - - name: organizationSid - in: path - required: true - schema: - pattern: OR[0-9a-f]{32} - type: string - format: OrganizationSid - example: OR80b7392892f0a424d07c42f5b11dce2a - - name: userSid - in: path - required: true - schema: - pattern: US[0-9a-f]{32} - type: string - format: UserSid - example: US23c7d4510f1398849aaac5c543475b12 - responses: - '204': - description: No content - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '400': - description: Bad request or business rules violation - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '401': - description: Unauthorized - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '403': - description: Forbidden - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '404': - description: Not found - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - '429': - description: Too many requests - content: - application/scim+json: - schema: - $ref: '#/components/schemas/ScimError' - headers: - Access-Control-Allow-Origin: - description: Specify the origin(s) allowed to access the resource - schema: - type: string - example: '*' - Access-Control-Allow-Methods: - description: Specify the HTTP methods allowed when accessing the resource - schema: - type: string - example: POST, OPTIONS - Access-Control-Allow-Headers: - description: Specify the headers allowed when accessing the resource - schema: - type: string - example: Content-Type, Authorization - Access-Control-Allow-Credentials: - description: Indicates whether the browser should include credentials - schema: - type: boolean - Access-Control-Expose-Headers: - description: Headers exposed to the client - schema: - type: string - example: X-Custom-Header1, X-Custom-Header2 - /v1/token: - servers: - - url: https://preview-iam.twilio.com - x-twilio: - defaultOutputProperties: [] - pathType: list - post: - security: [] - tags: - - OauthV1Token - summary: Issues a new Access token (optionally identity_token & refresh_token) - in exchange of Oauth grant - operationId: CreateToken - responses: - '201': - content: - application/json: - schema: - $ref: '#/components/schemas/oauth.v1.token' - examples: - create: - value: - access_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c - refresh_token: ghjbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c - id_token: eyJhbdGciOiIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c - expires_in: 1438315200000 - token_type: bearer - description: Created - requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - title: CreateTokenRequest - properties: - grant_type: - type: string - description: Grant type is a credential representing resource owner's - authorization which can be used by client to obtain access token. - client_id: - type: string - description: A 34 character string that uniquely identifies this - OAuth App. - client_secret: - type: string - description: The credential for confidential OAuth App. - code: - type: string - description: JWT token related to the authorization code grant type. - redirect_uri: - type: string - description: The redirect uri - audience: - type: string - description: The targeted audience uri - refresh_token: - type: string - description: JWT token related to refresh access token. - scope: - type: string - description: The scope of token - required: - - grant_type - - client_id - examples: - create: - value: - client_id: OQ7cda1a615f05a95634e643aaaf7081d7 - client_secret: sUWblrQ4wx_aYkdAWjHXNvHinynkYOgBoiRyEQUeEntpgDEG47qnBFD98yoEzsTh - grant_type: client_credentials - redirect_uri: '' - audience: '' - code: '' - refresh_token: refresh_token - scope: scope - required: true -components: - securitySchemes: - oAuth2ClientCredentials: - type: oauth2 - flows: - clientCredentials: - tokenUrl: https://oauth.twilio.com/v1/token - scopes: {} - schemas: - ScimUser: - required: - - userName - type: object - properties: - id: - type: string - description: Unique Twilio user sid - externalId: - maxLength: 255 - minLength: 2 - type: string - description: External unique resource id defined by provisioning client - userName: - maxLength: 255 - minLength: 2 - type: string - description: Unique username, MUST be same as primary email address - displayName: - maxLength: 255 - minLength: 0 - type: string - description: User friendly display name - name: - $ref: '#/components/schemas/ScimName' - emails: - maxItems: 2147483647 - minItems: 1 - type: array - description: Email address list of the user. Primary email must be defined - if there are more than 1 email. Primary email must match the username. - items: - $ref: '#/components/schemas/ScimEmailAddress' - active: - type: boolean - description: Indicates whether the user is active - locale: - type: string - description: User's locale - timezone: - type: string - description: User's time zone - schemas: - type: array - description: An array of URIs that indicate the schemas supported for this - user resource - items: - type: string - description: An array of URIs that indicate the schemas supported for - this user resource - meta: - $ref: '#/components/schemas/ScimMeta' - ScimUserPage: - type: object - properties: - Resources: - type: array - items: - $ref: '#/components/schemas/ScimUser' - totalResults: - type: integer - format: int32 - schemas: - type: array - items: - type: string - description: Scim ListResponse schema - ScimEmailAddress: - type: object - properties: - primary: - type: boolean - description: Indicates if this email address is the primary one - value: - maxLength: 160 - minLength: 2 - type: string - description: The actual email address value - type: - maxLength: 64 - minLength: 0 - type: string - description: The type of email address (e.g., work, home, etc.) - description: Email address list of the user. Primary email must be defined if - there are more than 1 email. Primary email must match the username. - ScimMeta: - type: object - properties: - resourceType: - type: string - description: Indicates the type of the resource - created: - type: string - description: The date and time when the resource was created in the system - format: date-time - lastModified: - type: string - description: The date and time when the resource was last modified - format: date-time - version: - type: string - description: A version identifier for the resource. This can be used to - manage resource versioning and concurrency control. - description: Meta - ScimName: - type: object - properties: - givenName: - maxLength: 255 - minLength: 0 - type: string - description: The user's first or given name - familyName: - maxLength: 255 - minLength: 0 - type: string - description: The user's last or family name - description: User's name - ScimResourceTypes: - type: object - properties: - Resources: - type: array - items: - type: object - properties: - name: - type: string - description: Name of the resource type - description: - type: string - description: Description of the resource type - endpoint: - type: string - description: HTTP-addressable endpoint relative to the Base URL of - the service provider - schema: - type: string - description: Primary/base schema URI - JsonPatch: - type: object - properties: - op: - type: string - enum: - - add - - remove - - replace - path: - type: string - value: - type: string - TwilioServiceErrorResponse: - type: object - properties: - code: - description: Twilio-specific error code - type: integer - format: int32 - message: - description: Error message - type: string - moreInfo: - description: Link to Error Code References - type: string - status: - description: HTTP response status code - type: integer - format: int32 - ScimError: - type: object - properties: - schemas: - type: array - description: Schema URIs that define the contents of the error structure - items: - type: string - description: Schema URIs that define the contents of the error structure - detail: - type: string - description: A human-readable description of the error - scimType: - type: string - description: A scimType error code as defined in RFC7644 - enum: - - invalidFilter - - uniqueness - - mutability - - invalidValue - - invalidSyntax - status: - type: string - description: Http status code - code: - description: Twilio-specific error code - type: integer - format: int32 - moreInfo: - description: Link to Error Code References - type: string - oauth.v1.token: - type: object - properties: - access_token: - type: string - nullable: true - description: Token which carries the necessary information to access a Twilio - resource directly. - refresh_token: - type: string - nullable: true - description: Token which carries the information necessary to get a new - access token. - id_token: - type: string - nullable: true - description: Token which carries the information necessary of user profile. - token_type: - type: string - nullable: true - description: Token type - expires_in: - type: integer - format: int64 - nullable: true diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index 9880193b2..d4c73c6b0 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -17,9 +17,6 @@ 'csharp': 'Rest', 'php': 'Rest' } -generateForLanguages = { - 'twilio_iam_organizations.json' : ['java'] -} CLEANUP_IMPORT_LANGUAGES = ['java', 'php'] REMOVE_DUPLICATE_IMPORT_LANGUAGES = ['node'] CONFIG_FOLDER = 'tmp' @@ -46,25 +43,19 @@ def generate(spec_folder: str, spec_files: List[str], output_path: str, language Path(config_path).mkdir(parents=True, exist_ok=True) for spec_file in spec_files: - if spec_file in generateForLanguages: - if language in generateForLanguages.get(spec_file): - generate_domain_for_language(spec_file, config_path, spec_folder, output_path, language, parent_dir) - else: generate_domain_for_language(spec_file, config_path, spec_folder, output_path, language, parent_dir) - -def generate_domain_for_language(spec_file: str, config_path: str, spec_folder: str, output_path: str, language: str, parent_dir: str) -> None: - full_path = os.path.join(spec_folder, spec_file) - full_config_path = os.path.join(config_path, spec_file) - config = { - 'generatorName': 'terraform-provider-twilio' if language == 'terraform' else f'twilio-{language}', - 'inputSpec': full_path, - 'outputDir': output_path, - 'inlineSchemaNameDefaults': { - 'arrayItemSuffix': '' - }, - } - - with open(full_config_path, 'w') as f: - f.write(json.dumps(config)) + full_path = os.path.join(spec_folder, spec_file) + full_config_path = os.path.join(config_path, spec_file) + config = { + 'generatorName': 'terraform-provider-twilio' if language == 'terraform' else f'twilio-{language}', + 'inputSpec': full_path, + 'outputDir': output_path, + 'inlineSchemaNameDefaults': { + 'arrayItemSuffix': '' + }, + } + + with open(full_config_path, 'w') as f: + f.write(json.dumps(config)) print(f'Generating {output_path} from {spec_folder}') run_openapi_generator(parent_dir, language) @@ -75,6 +66,7 @@ def generate_domain_for_language(spec_file: str, config_path: str, spec_folder: if language in REMOVE_DUPLICATE_IMPORT_LANGUAGES: remove_duplicate_imports(output_path, language) + def run_openapi_generator(parent_dir: Path, language: str) -> None: properties = '-DapiTests=false' if language in {'node', 'python'}: diff --git a/scripts/generate.sh b/scripts/generate.sh index cc6444ae6..3e6186995 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -2,7 +2,7 @@ set -e function should-generate() { - [ "$LANGUAGES" == "" ] || [[ "$LANGUAGES" == *$1* ]] + [ "$LANGUAGES" = "" ] || [[ "$LANGUAGES" == *$1* ]] } function generate() { @@ -17,9 +17,6 @@ function generate() { rm -rf tmp mkdir -p tmp for api_spec in $files_regex; do - if [ "$1" != "twilio-java" ] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then - continue - fi echo "generatorName: $1 inputSpec: $api_spec outputDir: $OUT_DIR diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 3e95f1123..6386dde1c 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -15,7 +15,6 @@ import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; -import org.openapitools.codegen.CodegenSecurity; import org.openapitools.codegen.IJsonSchemaValidationProperties; import java.util.ArrayList; @@ -60,7 +59,6 @@ public class JavaApiResourceBuilder extends ApiResourceBuilder{ private Resolver codegenPropertyIResolver; public Set enums = new HashSet<>(); - public String authMethodPackage = ""; public ArrayList> modelParameters; @@ -76,7 +74,6 @@ public JavaApiResourceBuilder(IApiActionTemplate apiActionTemplate, List codegenPar } }); - co.vendorExtensions = conventionResolver.populateSecurityAttributes(co); - jsonRequestBodyResolver.setResourceName(resourceName); co.allParams.stream() .filter(item -> (item.getContent() != null && item.getContent().get("application/json") != null)) @@ -168,10 +163,6 @@ public ApiResourceBuilder updateOperations(Resolver codegenPar .collect(Collectors.toList()); co.hasParams = !co.allParams.isEmpty(); co.hasRequiredParams = !co.requiredParams.isEmpty(); - if(!co.formParams.isEmpty())co.vendorExtensions.put("x-has-form-params", true); - if(!co.headerParams.isEmpty())co.vendorExtensions.put("x-has-header-params", true); - if(!co.bodyParams.isEmpty())co.vendorExtensions.put("x-has-body-params", true); - if(!co.queryParams.isEmpty())co.vendorExtensions.put("x-has-query-params", true); requiredPathParams.addAll(co.pathParams); co.vendorExtensions = mapOperation(co); @@ -179,21 +170,6 @@ public ApiResourceBuilder updateOperations(Resolver codegenPar return this; } - - public void processAuthMethods(List opList) { - if(opList != null){ - List authMethods = opList.get(0).authMethods; - if(authMethods != null){ - for(CodegenSecurity c : authMethods){ - if(c.isOAuth == true){ - this.authMethodPackage = ".bearertoken"; - } - } - } - else this.authMethodPackage = ".noauth"; - } - } - @Override public void updateHttpMethod(CodegenOperation co) { switch (co.httpMethod) { @@ -209,7 +185,6 @@ public void updateHttpMethod(CodegenOperation co) { case "DELETE": co.vendorExtensions.put(HTTP_METHOD, JavaHttpMethod.DELETE.getValue()); break; - } } diff --git a/src/main/java/com/twilio/oai/api/JavaApiResources.java b/src/main/java/com/twilio/oai/api/JavaApiResources.java index ef9821c8c..59341c9f8 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResources.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResources.java @@ -17,7 +17,6 @@ public class JavaApiResources extends ApiResources{ public ArrayList> modelParameters; public boolean hasNestedRequestBody; - public String authMethodPackage = ""; public JavaApiResources(JavaApiResourceBuilder apiResourceBuilder) { super(apiResourceBuilder); @@ -27,7 +26,6 @@ public JavaApiResources(JavaApiResourceBuilder apiResourceBuilder) { // TODO: Need to improve, if there are requestBody in create and update operation. this.modelParameters = apiResourceBuilder.modelParameters; this.hasNestedRequestBody = apiResourceBuilder.hasNestedRequestBody; - this.authMethodPackage = apiResourceBuilder.authMethodPackage; } } diff --git a/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java b/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java index 2e0d06db6..c992164a3 100644 --- a/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java +++ b/src/main/java/com/twilio/oai/resolver/java/JavaConventionResolver.java @@ -3,20 +3,15 @@ import com.twilio.oai.CodegenUtils; import com.twilio.oai.StringHelper; -import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Stack; import com.twilio.oai.common.ApplicationConstants; import com.twilio.oai.common.EnumConstants; import com.twilio.oai.common.Utility; -import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; -import org.openapitools.codegen.CodegenSecurity; import static com.twilio.oai.common.ApplicationConstants.ENUM_VARS; import static com.twilio.oai.common.ApplicationConstants.LIST_END; @@ -25,14 +20,6 @@ public class JavaConventionResolver { private static final String VALUES = "values"; - public static final String AUTH_IMPORT_CLASS = "x-auth-import-class"; - public static final String HTTP_CLASS_PREFIX = "x-http-class-prefix"; - public static final String NOAUTH_IMPORT_CLASS = ".noauth"; - public static final String NOAUTH_HTTP_CLASS_PREFIX = "NoAuth"; - public static final String BEARER_AUTH_IMPORT_CLASS = ".bearertoken"; - public static final String BEARER_AUTH_HTTP_CLASS_PREFIX = "BearerToken"; - - public static final String EMPTY_STRING = ""; private ContainerResolver containerResolver = new ContainerResolver(Arrays.asList(EnumConstants.JavaDataTypes.values())); @@ -118,7 +105,7 @@ public CodegenProperty resolveEnumProperty(CodegenProperty property, String reso if (resourceName != null) { // It will restrict the data type to be ResourceName.ResourceName.EnumName. property.dataType = property.dataType != null && property.dataType.contains(resourceName + ApplicationConstants.DOT) - ? property.dataType : resourceName + ApplicationConstants.DOT + property.enumName; + ? property.dataType: resourceName + ApplicationConstants.DOT + property.dataType; } } @@ -126,26 +113,4 @@ public CodegenProperty resolveEnumProperty(CodegenProperty property, String reso } return property; } - - public Map populateSecurityAttributes(CodegenOperation co) { - ArrayList authMethods = (ArrayList) co.authMethods; - HashMap authAttributes = new HashMap<>(); - if(authMethods == null){ - authAttributes.put(AUTH_IMPORT_CLASS, NOAUTH_IMPORT_CLASS); - authAttributes.put(HTTP_CLASS_PREFIX, NOAUTH_HTTP_CLASS_PREFIX); - }else{ - for(CodegenSecurity c : authMethods){ - if(c.isOAuth == true){ - authAttributes.put(AUTH_IMPORT_CLASS, BEARER_AUTH_IMPORT_CLASS); - authAttributes.put(HTTP_CLASS_PREFIX, BEARER_AUTH_HTTP_CLASS_PREFIX); - } - else{ - authAttributes.put(AUTH_IMPORT_CLASS, EMPTY_STRING); - authAttributes.put(HTTP_CLASS_PREFIX, EMPTY_STRING); - } - } - } - co.vendorExtensions.put("x-auth-attributes", authAttributes); - return co.vendorExtensions; - } } diff --git a/src/main/resources/twilio-java/api.mustache b/src/main/resources/twilio-java/api.mustache index deaa723ed..7d127709f 100644 --- a/src/main/resources/twilio-java/api.mustache +++ b/src/main/resources/twilio-java/api.mustache @@ -10,7 +10,7 @@ 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{{authMethodPackage}}.Resource; +import com.twilio.base.Resource; import com.twilio.converter.Converter; import java.util.Currency; import com.twilio.converter.DateConverter; diff --git a/src/main/resources/twilio-java/creator.mustache b/src/main/resources/twilio-java/creator.mustache index 58d22a273..47dea36a7 100644 --- a/src/main/resources/twilio-java/creator.mustache +++ b/src/main/resources/twilio-java/creator.mustache @@ -3,6 +3,7 @@ package com.twilio.rest.{{domainPackage}}.{{apiVersion}}{{namespaceSubPart}}; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Creator; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -11,7 +12,9 @@ import com.twilio.converter.Converter; 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; import java.math.BigDecimal; import java.util.List; @@ -41,10 +44,6 @@ import java.net.URI; {{#apiOperations}} {{#vendorExtensions.x-is-create-operation}} -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.Creator; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient; - public class {{apiName}}Creator extends Creator<{{apiName}}>{ {{#allParams}} private {{{dataType}}} {{paramName}}; @@ -79,9 +78,9 @@ public class {{apiName}}Creator extends Creator<{{apiName}}>{ {{/vendorExtensions.x-non-path-params}} @Override - public {{apiName}} create(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client){ + public {{apiName}} create(final TwilioRestClient client){ {{>generate_uri}} - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + Request request = new Request( {{vendorExtensions.x-http-method}}, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), path @@ -103,7 +102,7 @@ public class {{apiName}}Creator extends Creator<{{apiName}}>{ Response response = client.request(request); if (response == null) { throw new ApiConnectionException("{{apiName}} creation failed: Unable to connect to server"); - } else if (!{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + } 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()); @@ -113,19 +112,18 @@ public class {{apiName}}Creator extends Creator<{{apiName}}>{ return {{apiName}}.fromJson(response.getStream(), client.getObjectMapper()); } -{{#vendorExtensions.x-has-form-params}} +{{#formParams.0}} {{>postParams}} -{{/vendorExtensions.x-has-form-params}} -{{#vendorExtensions.x-has-body-params}} +{{/formParams.0}} +{{#bodyParams.0}} {{>postParams_body}} -{{/vendorExtensions.x-has-body-params}} -{{#vendorExtensions.x-has-header-params}} +{{/bodyParams.0}} +{{#headerParams.0}} {{>headerParams}} -{{/vendorExtensions.x-has-header-params}} -{{#vendorExtensions.x-has-query-params}} - private void addQueryParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { -{{>queryParams}} } -{{/vendorExtensions.x-has-query-params}} +{{/headerParams.0}} +{{#queryParams.0}} +{{>queryParamsFunc}} +{{/queryParams.0}} } {{/vendorExtensions.x-is-create-operation}} {{/apiOperations}} diff --git a/src/main/resources/twilio-java/deleter.mustache b/src/main/resources/twilio-java/deleter.mustache index 3192a19ac..afddb9f8c 100644 --- a/src/main/resources/twilio-java/deleter.mustache +++ b/src/main/resources/twilio-java/deleter.mustache @@ -3,6 +3,7 @@ package com.twilio.rest.{{domainPackage}}.{{apiVersion}}{{namespaceSubPart}}; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Deleter; import com.twilio.converter.Promoter; import com.twilio.constant.EnumConstants; import com.twilio.exception.ApiConnectionException; @@ -11,7 +12,9 @@ import com.twilio.exception.ApiException; import com.twilio.converter.Converter; 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; import java.time.LocalDate; import java.io.IOException; @@ -34,10 +37,6 @@ import lombok.ToString; {{#apiOperations}} {{#vendorExtensions.x-is-delete-operation}} -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.Deleter; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient; - public class {{apiName}}Deleter extends Deleter<{{apiName}}> { {{#allParams}} private {{{dataType}}} {{paramName}}; @@ -72,9 +71,9 @@ public class {{apiName}}Deleter extends Deleter<{{apiName}}> { {{/vendorExtensions.x-non-path-params}} @Override - public boolean delete(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { + public boolean delete(final TwilioRestClient client) { {{>generate_uri}} - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + Request request = new Request( {{vendorExtensions.x-http-method}}, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), path @@ -97,7 +96,7 @@ public class {{apiName}}Deleter extends Deleter<{{apiName}}> { if (response == null) { throw new ApiConnectionException("{{apiName}} delete failed: Unable to connect to server"); - } else if (!{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + } 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()); @@ -106,19 +105,18 @@ public class {{apiName}}Deleter extends Deleter<{{apiName}}> { } return response.getStatusCode() == 204; } -{{#vendorExtensions.x-has-form-params}} +{{#formParams.0}} {{>postParams}} -{{/vendorExtensions.x-has-form-params}} -{{#vendorExtensions.x-has-body-params}} +{{/formParams.0}} +{{#bodyParams.0}} {{>postParams_body}} -{{/vendorExtensions.x-has-body-params}} -{{#vendorExtensions.x-has-header-params}} +{{/bodyParams.0}} +{{#headerParams.0}} {{>headerParams}} -{{/vendorExtensions.x-has-header-params}} -{{#vendorExtensions.x-has-query-params}} - private void addQueryParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { -{{>queryParams}} } -{{/vendorExtensions.x-has-query-params}} +{{/headerParams.0}} +{{#queryParams.0}} +{{>queryParamsFunc}} +{{/queryParams.0}} } {{/vendorExtensions.x-is-delete-operation}} {{/apiOperations}} diff --git a/src/main/resources/twilio-java/fetcher.mustache b/src/main/resources/twilio-java/fetcher.mustache index fd857de3d..fddeae2e3 100644 --- a/src/main/resources/twilio-java/fetcher.mustache +++ b/src/main/resources/twilio-java/fetcher.mustache @@ -3,6 +3,7 @@ package com.twilio.rest.{{domainPackage}}.{{apiVersion}}{{namespaceSubPart}}; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Fetcher; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -11,7 +12,9 @@ import com.twilio.converter.Converter; 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; import java.io.IOException; @@ -35,10 +38,6 @@ import lombok.ToString; {{#apiOperations}} {{#vendorExtensions.x-is-fetch-operation}} -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.Fetcher; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient; - public class {{apiName}}Fetcher extends Fetcher<{{apiName}}> { {{#allParams}} private {{{dataType}}} {{paramName}}; @@ -73,9 +72,9 @@ public class {{apiName}}Fetcher extends Fetcher<{{apiName}}> { {{/vendorExtensions.x-non-path-params}} @Override - public {{apiName}} fetch(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { + public {{apiName}} fetch(final TwilioRestClient client) { {{>generate_uri}} - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + Request request = new Request( {{vendorExtensions.x-http-method}}, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), path @@ -97,8 +96,8 @@ public class {{apiName}}Fetcher extends Fetcher<{{apiName}}> { Response response = client.request(request); if (response == null) { - throw new ApiConnectionException("{{apiName}} fetch failed: Unable to connect to server"); - } else if (!{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + throw new ApiConnectionException("{{apiName}} 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()); @@ -108,19 +107,18 @@ public class {{apiName}}Fetcher extends Fetcher<{{apiName}}> { return {{apiName}}.fromJson(response.getStream(), client.getObjectMapper()); } -{{#vendorExtensions.x-has-form-params}} +{{#formParams.0}} {{>postParams}} -{{/vendorExtensions.x-has-form-params}} -{{#vendorExtensions.x-has-body-params}} +{{/formParams.0}} +{{#bodyParams.0}} {{>postParams_body}} -{{/vendorExtensions.x-has-body-params}} -{{#vendorExtensions.x-has-header-params}} +{{/bodyParams.0}} +{{#headerParams.0}} {{>headerParams}} -{{/vendorExtensions.x-has-header-params}} -{{#vendorExtensions.x-has-query-params}} - private void addQueryParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { -{{>queryParams}} } -{{/vendorExtensions.x-has-query-params}} +{{/headerParams.0}} +{{#queryParams.0}} +{{>queryParamsFunc}} +{{/queryParams.0}} } {{/vendorExtensions.x-is-fetch-operation}} {{/apiOperations}} diff --git a/src/main/resources/twilio-java/generate_uri.mustache b/src/main/resources/twilio-java/generate_uri.mustache index 6ff4664d9..9fbfaa9d5 100644 --- a/src/main/resources/twilio-java/generate_uri.mustache +++ b/src/main/resources/twilio-java/generate_uri.mustache @@ -8,14 +8,14 @@ {{#allParams}} {{#vendorExtensions.x-is-account-sid}} this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; - path = path.replace("{"+"{{baseName}}"+"}", this.{{paramName}}.toString()); + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); {{/vendorExtensions.x-is-account-sid}} {{/allParams}} {{#requiredParams}} {{#vendorExtensions.x-is-phone-number-format}} - path = path.replace("{"+"{{baseName}}"+"}", this.{{paramName}}.encode("utf-8")); + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.encode("utf-8")); {{/vendorExtensions.x-is-phone-number-format}} {{^vendorExtensions.x-is-phone-number-format}} - path = path.replace("{"+"{{baseName}}"+"}", this.{{paramName}}.toString()); + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); {{/vendorExtensions.x-is-phone-number-format}} {{/requiredParams}} diff --git a/src/main/resources/twilio-java/headerParams.mustache b/src/main/resources/twilio-java/headerParams.mustache index 1f3828e30..bb423155a 100644 --- a/src/main/resources/twilio-java/headerParams.mustache +++ b/src/main/resources/twilio-java/headerParams.mustache @@ -1,4 +1,4 @@ - private void addHeaderParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { + private void addHeaderParams(final Request request) { {{#headerParams}} if ({{paramName}} != null) { {{#vendorExtensions.x-is-other-data-type}} diff --git a/src/main/resources/twilio-java/postParams.mustache b/src/main/resources/twilio-java/postParams.mustache index 9eeca1952..5dbfeb544 100644 --- a/src/main/resources/twilio-java/postParams.mustache +++ b/src/main/resources/twilio-java/postParams.mustache @@ -1,4 +1,4 @@ - private void addPostParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { + private void addPostParams(final Request request) { {{#formParams}} if ({{paramName}} != null) { {{#isFreeFormObject}} diff --git a/src/main/resources/twilio-java/postParams_body.mustache b/src/main/resources/twilio-java/postParams_body.mustache index e3b25ca06..f1b32323e 100644 --- a/src/main/resources/twilio-java/postParams_body.mustache +++ b/src/main/resources/twilio-java/postParams_body.mustache @@ -1,4 +1,4 @@ - private void addPostParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request, {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { + private void addPostParams(final Request request, TwilioRestClient client) { ObjectMapper objectMapper = client.getObjectMapper(); {{#bodyParams}} if ({{paramName}} != null) { diff --git a/src/main/resources/twilio-java/queryParamsFunc.mustache b/src/main/resources/twilio-java/queryParamsFunc.mustache new file mode 100644 index 000000000..c361ed26f --- /dev/null +++ b/src/main/resources/twilio-java/queryParamsFunc.mustache @@ -0,0 +1,2 @@ + private void addQueryParams(final Request request) { +{{>queryParams}} } \ No newline at end of file diff --git a/src/main/resources/twilio-java/reader.mustache b/src/main/resources/twilio-java/reader.mustache index 051683540..f82cd7b37 100644 --- a/src/main/resources/twilio-java/reader.mustache +++ b/src/main/resources/twilio-java/reader.mustache @@ -3,7 +3,9 @@ package com.twilio.rest.{{domainPackage}}.{{apiVersion}}{{namespaceSubPart}}; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Reader; import com.twilio.constant.EnumConstants; +import com.twilio.base.ResourceSet; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; import com.twilio.converter.PrefixedCollapsibleMap; @@ -11,8 +13,11 @@ import com.twilio.converter.Converter; 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; +import com.twilio.base.Page; import java.time.LocalDate; import java.time.ZonedDateTime; import java.io.IOException; @@ -34,12 +39,6 @@ import lombok.ToString; {{#apiOperations}} {{#vendorExtensions.x-is-read-operation}} -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.Page; -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.Reader; -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.ResourceSet; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient; - public class {{apiName}}Reader extends Reader<{{apiName}}> { {{#allParams}} private {{{dataType}}} {{paramName}}; @@ -74,23 +73,23 @@ public class {{apiName}}Reader extends Reader<{{apiName}}> { {{/vendorExtensions.x-non-path-params}} @Override - public ResourceSet<{{apiName}}> read(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { + public ResourceSet<{{apiName}}> read(final TwilioRestClient client) { return new ResourceSet<>(this, client, firstPage(client)); } - public Page<{{apiName}}> firstPage(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { + public Page<{{apiName}}> firstPage(final TwilioRestClient client) { String path = "{{{path}}}"; {{#allParams}} {{#vendorExtensions.x-is-account-sid}} this.{{paramName}} = this.{{paramName}} == null ? client.getAccountSid() : this.{{paramName}}; - path = path.replace("{"+"{{baseName}}"+"}", this.{{paramName}}.toString()); + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); {{/vendorExtensions.x-is-account-sid}} {{/allParams}} {{#requiredParams}} - path = path.replace("{"+"{{baseName}}"+"}", this.{{paramName}}.toString()); + path = path.replace("{"+"{{#lambda.titlecase}}{{baseName}}{{/lambda.titlecase}}"+"}", this.{{paramName}}.toString()); {{/requiredParams}} - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + Request request = new Request( {{vendorExtensions.x-http-method}}, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), path @@ -109,12 +108,12 @@ public class {{apiName}}Reader extends Reader<{{apiName}}> { return pageForRequest(client, request); } - private Page<{{apiName}}> pageForRequest(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client, final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { + private Page<{{apiName}}> pageForRequest(final TwilioRestClient client, final Request request) { Response response = client.request(request); if (response == null) { throw new ApiConnectionException("{{apiName}} read failed: Unable to connect to server"); - } else if (!{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + } 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()); @@ -131,8 +130,8 @@ public class {{apiName}}Reader extends Reader<{{apiName}}> { } @Override - public Page<{{apiName}}> previousPage(final Page<{{apiName}}> page, final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + public Page<{{apiName}}> previousPage(final Page<{{apiName}}> page, final TwilioRestClient client) { + Request request = new Request( {{vendorExtensions.x-http-method}}, page.getPreviousPageUrl(Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString()) ); @@ -141,8 +140,8 @@ public class {{apiName}}Reader extends Reader<{{apiName}}> { @Override - public Page<{{apiName}}> nextPage(final Page<{{apiName}}> page, final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + public Page<{{apiName}}> nextPage(final Page<{{apiName}}> page, final TwilioRestClient client) { + Request request = new Request( {{vendorExtensions.x-http-method}}, page.getNextPageUrl(Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString()) ); @@ -150,28 +149,28 @@ public class {{apiName}}Reader extends Reader<{{apiName}}> { } @Override - public Page<{{apiName}}> getPage(final String targetUrl, final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client) { - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + public Page<{{apiName}}> getPage(final String targetUrl, final TwilioRestClient client) { + Request request = new Request( HttpMethod.GET, targetUrl ); return pageForRequest(client, request); } -{{#vendorExtensions.x-has-form-params}} +{{#formParams.0}} {{>postParams}} -{{/vendorExtensions.x-has-form-params}} -{{#vendorExtensions.x-has-header-params}} +{{/formParams.0}} +{{#headerParams.0}} {{>headerParams}} -{{/vendorExtensions.x-has-header-params}} -{{#vendorExtensions.x-has-query-params}} - private void addQueryParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { +{{/headerParams.0}} +{{#queryParams.0}} + private void addQueryParams(final Request request) { {{>queryParams}} if(getPageSize() != null) { request.addQueryParam("PageSize", Integer.toString(getPageSize())); } } -{{/vendorExtensions.x-has-query-params}} +{{/queryParams.0}} } {{/vendorExtensions.x-is-read-operation}} {{/apiOperations}} diff --git a/src/main/resources/twilio-java/updater.mustache b/src/main/resources/twilio-java/updater.mustache index 2a3c42794..0aec5e177 100644 --- a/src/main/resources/twilio-java/updater.mustache +++ b/src/main/resources/twilio-java/updater.mustache @@ -3,6 +3,7 @@ package com.twilio.rest.{{domainPackage}}.{{apiVersion}}{{namespaceSubPart}}; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.base.Updater; import com.twilio.constant.EnumConstants; import com.twilio.converter.Promoter; import com.twilio.exception.ApiConnectionException; @@ -11,7 +12,9 @@ import com.twilio.converter.Converter; 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; import java.time.format.DateTimeFormatter; import com.twilio.converter.DateConverter; @@ -35,11 +38,6 @@ import lombok.ToString; {{#apiOperations}} {{#vendorExtensions.x-is-update-operation}} -import com.twilio.base{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.Updater; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request; -import com.twilio.http{{vendorExtensions.x-auth-attributes.x-auth-import-class}}.{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient; - - public class {{apiName}}Updater extends Updater<{{apiName}}>{ {{#allParams}} private {{{dataType}}} {{paramName}}; @@ -74,9 +72,9 @@ public class {{apiName}}Updater extends Updater<{{apiName}}>{ {{/vendorExtensions.x-non-path-params}} @Override - public {{apiName}} update(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient client){ + public {{apiName}} update(final TwilioRestClient client){ {{>generate_uri}} - {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request = new {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request( + Request request = new Request( {{vendorExtensions.x-http-method}}, Domains.{{#lambda.uppercase}}{{domainName}}{{/lambda.uppercase}}.toString(), path @@ -98,7 +96,7 @@ public class {{apiName}}Updater extends Updater<{{apiName}}>{ Response response = client.request(request); if (response == null) { throw new ApiConnectionException("{{apiName}} update failed: Unable to connect to server"); - } else if (!{{vendorExtensions.x-auth-attributes.x-http-class-prefix}}TwilioRestClient.SUCCESS.test(response.getStatusCode())) { + } 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()); @@ -108,20 +106,18 @@ public class {{apiName}}Updater extends Updater<{{apiName}}>{ return {{apiName}}.fromJson(response.getStream(), client.getObjectMapper()); } - -{{#vendorExtensions.x-has-form-params}} +{{#formParams.0}} {{>postParams}} -{{/vendorExtensions.x-has-form-params}} -{{#vendorExtensions.x-has-body-params}} +{{/formParams.0}} +{{#bodyParams.0}} {{>postParams_body}} -{{/vendorExtensions.x-has-body-params}} -{{#vendorExtensions.x-has-header-params}} +{{/bodyParams.0}} +{{#headerParams.0}} {{>headerParams}} -{{/vendorExtensions.x-has-header-params}} -{{#vendorExtensions.x-has-query-params}} - private void addQueryParams(final {{vendorExtensions.x-auth-attributes.x-http-class-prefix}}Request request) { -{{>queryParams}} } -{{/vendorExtensions.x-has-query-params}} +{{/headerParams.0}} +{{#queryParams.0}} +{{>queryParamsFunc}} +{{/queryParams.0}} } {{/vendorExtensions.x-is-update-operation}} {{/apiOperations}}