From 35d27366a5b06d0bc8a1ae2a37af96b13e9b3b56 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:40:41 +0530 Subject: [PATCH 01/38] orgs api uptake for twilio csharp --- scripts/build_twilio_library.py | 2 +- scripts/generate.sh | 2 +- .../com/twilio/oai/TwilioCsharpGenerator.java | 37 +++++++++++++++++++ .../oai/api/CsharpApiResourceBuilder.java | 37 ++++++++++++++++++- .../twilio/oai/api/CsharpApiResources.java | 6 +++ .../oai/api/FluentApiResourceBuilder.java | 13 +++++++ .../twilio/oai/api/IApiResourceBuilder.java | 1 + .../oai/api/NodeApiResourceBuilder.java | 16 ++++++++ .../java/com/twilio/oai/common/Utility.java | 2 +- .../CsharpCodegenModelDataTypeResolver.java | 7 +++- .../twilio-csharp/Pagination.mustache | 14 +++---- .../twilio-csharp/ResourceUsings.mustache | 7 +++- .../resource/CreateResource.mustache | 17 ++++----- .../resource/DeleteResource.mustache | 16 ++++---- .../resource/FetchResource.mustache | 17 ++++----- .../resource/ReadResource.mustache | 25 ++++++------- .../resource/UpdateResource.mustache | 16 ++++---- 17 files changed, 173 insertions(+), 62 deletions(-) diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index 9880193b2..cff9c4005 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -18,7 +18,7 @@ 'php': 'Rest' } generateForLanguages = { - 'twilio_iam_organizations.json' : ['java'] + 'twilio_iam_organizations.json' : ['java', 'csharp'] } CLEANUP_IMPORT_LANGUAGES = ['java', 'php'] REMOVE_DUPLICATE_IMPORT_LANGUAGES = ['node'] diff --git a/scripts/generate.sh b/scripts/generate.sh index cc6444ae6..bcedb4714 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -17,7 +17,7 @@ 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 + if [ "$1" != "twilio-java" && "$1" != "twilio-csharp"] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then continue fi echo "generatorName: $1 diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 12724ab7b..fb0a21817 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -25,6 +25,7 @@ import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; +import org.openapitools.codegen.CodegenSecurity; import org.openapitools.codegen.languages.CSharpClientCodegen; import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelsMap; @@ -42,6 +43,9 @@ public class TwilioCsharpGenerator extends CSharpClientCodegen { private final TwilioCodegenAdapter twilioCodegen; + private final String BEARER_TOKEN_PREFIX = "BearerToken"; + private final String NO_AUTH_PREFIX = "NoAuth"; + private final String EMPTY_STRING = ""; private final DirectoryStructureService directoryStructureService = new DirectoryStructureService( additionalProperties, new ResourceMap(new Inflector()), @@ -125,10 +129,43 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L final OperationsMap results = super.postProcessOperationsWithModels(objs, allModels); final List opList = directoryStructureService.processOperations(results); CsharpApiResources apiResources = processCodegenOperations(opList); + apiResources.setAuthMethod(processAuthMethods(opList)); + apiResources.setRestClientPrefix(setRestClientPrefix(apiResources.getAuthMethod())); + apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); + apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); results.put("resources", apiResources); return results; } + private String fetchDomainClassPrefix(String authMethod) { + if(authMethod == BEARER_TOKEN_PREFIX) return "OrgsTokenAuth"; + else if(authMethod == NO_AUTH_PREFIX) return NO_AUTH_PREFIX; + return EMPTY_STRING; + } + + private String setResourceSetPrefix(String authMethod){ + return authMethod == BEARER_TOKEN_PREFIX ? authMethod : EMPTY_STRING; + } + + private String setRestClientPrefix(String authMethod){ + return authMethod == EMPTY_STRING ? "I" : EMPTY_STRING; + } + + private String processAuthMethods(List opList) { + if(opList != null){ + List authMethods = opList.get(0).authMethods; + if(authMethods != null){ + for(CodegenSecurity c : authMethods){ + if(c.isOAuth == true){ + return "BearerToken"; + } + } + } + else return "NoAuth"; + } + return ""; + } + @Override protected ImmutableMap.Builder addMustacheLambdas() { ImmutableMap.Builder lambdaBuilder = super.addMustacheLambdas(); diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 5163292bd..7824588c2 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -15,10 +15,12 @@ import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; +import org.openapitools.codegen.CodegenSecurity; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -34,9 +36,12 @@ public class CsharpApiResourceBuilder extends ApiResourceBuilder { + public String authMethod = ""; + public CsharpApiResourceBuilder(IApiActionTemplate template, List codegenOperations, List allModels) { super(template, codegenOperations, allModels); + processAuthMethods(codegenOperations); } public IApiResourceBuilder updateTemplate() { @@ -62,6 +67,13 @@ public IApiResourceBuilder setImports(DirectoryStructureService directoryStructu metaAPIProperties.put("array-exists-options", true); } }); + + if(this.authMethod == "BearerToken"){ + metaAPIProperties.put("auth_method-bearer-token", true); + } + else if(this.authMethod == "NoAuth"){ + metaAPIProperties.put("auth_method-no-auth", true); + } if (OperationStore.getInstance().isEnumPresentInOptions()) metaAPIProperties.put("enum-exists-options", true); @@ -78,14 +90,29 @@ public CsharpApiResources build() { @Override public ApiResourceBuilder updateOperations(Resolver codegenParameterIResolver) { // CsharpParameterResolver super.updateOperations(codegenParameterIResolver); + processAuthMethods(this.codegenOperationList); this.codegenOperationList.forEach(co -> { co.headerParams.forEach(e -> codegenParameterIResolver.resolve(e, this)); populateRequestBodyArgument(co); resolveIngressModel(co); }); - 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.authMethod = "BearerToken"; + } + } + } + else this.authMethod = "NoAuth"; + } + } + @Override public void updateHttpMethod(CodegenOperation co) { switch (co.httpMethod) { @@ -175,7 +202,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP modelName = response.baseType; } Optional responseModel = Utility.getModel(allModels, modelName, recordKey, codegenOperation); - if (responseModel.isEmpty()) { + if ((responseModel == null) || responseModel.isEmpty() || (Integer.parseInt(response.code) != 200)) { return; } codegenModelResolver.resolve(responseModel.get(), this); @@ -187,6 +214,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP } public Set getDistinctResponseModel(List responseModels) { + HashSet modelVars = new HashSet<>(); Set distinctResponseModels = new LinkedHashSet<>(); for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { @@ -199,6 +227,11 @@ public Set getDistinctResponseModel(List response distinctResponseModels.add(property); } } + for(CodegenProperty s : distinctResponseModels){ + if(modelVars.contains(s.name)){ + s.nameInCamelCase = "_" + s.nameInCamelCase; + }else modelVars.add(s.nameInCamelCase); + } return distinctResponseModels; } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index 64c8704cb..146bb029c 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -2,12 +2,18 @@ import com.twilio.oai.common.ApplicationConstants; import com.twilio.oai.resolver.csharp.OperationStore; +import lombok.Getter; +import lombok.Setter; import org.openapitools.codegen.IJsonSchemaValidationProperties; import java.util.ArrayList; import java.util.List; public class CsharpApiResources extends ApiResources { + @Getter @Setter private String authMethod; + @Getter @Setter private String restClientPrefix; + @Getter @Setter private String resourceSetPrefix; + @Getter @Setter private String domainClassPrefix; List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); public String resourceConstant = ApplicationConstants.RESOURCE; diff --git a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java index 492a0cb70..0183a7d08 100644 --- a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java @@ -54,6 +54,19 @@ public IApiResourceBuilder updateTemplate() { public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); + codegenOperationList.stream().filter(operation -> !operation.vendorExtensions.containsKey("x-ignore")).forEach(codegenOperation -> { + boolean isInstanceOperation = PathUtils.isInstanceOperation(codegenOperation); + if (!isInstanceOperation) { + listOperations.add(codegenOperation); + codegenOperation.vendorExtensions.put("listOperation", true); + metaAPIProperties.put("hasListOperation", true); + } else { + instanceOperations.add(codegenOperation); + codegenOperation.vendorExtensions.put("instanceOperation", true); + metaAPIProperties.put("hasInstanceOperation", true); + } + }); + for (final CodegenOperation co : codegenOperationList) { co.allParams.removeAll(co.pathParams); co.requiredParams.removeAll(co.pathParams); diff --git a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java index c0144caa2..95dc82a04 100644 --- a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java @@ -5,6 +5,7 @@ import com.twilio.oai.resolver.common.CodegenModelResolver; import com.twilio.oai.resolver.java.JavaPropertyResolver; import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 59ca136e8..0e0c771de 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -17,6 +17,7 @@ import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; +import static com.twilio.oai.DirectoryStructureService.VERSION_RESOURCES; import static com.twilio.oai.common.ApplicationConstants.HTTP_METHOD; import static com.twilio.oai.common.ApplicationConstants.STRING; @@ -37,9 +38,24 @@ public NodeApiResourceBuilder(final IApiActionTemplate template, this.toggleMap = toggleMap; } + private void updateVersionResources() { + var versionResources = (List) directoryStructureService.getAdditionalProperties().getOrDefault("versionResources", null); + if (versionResources != null) { + for (var versionResource : versionResources) { + //here "hasInstanceOperation" may be either null or false, so only set if it is true + if (versionResource.getResourceName().equals(getApiName()) && (boolean) metaAPIProperties.getOrDefault("hasInstanceOperation", false)) { + versionResource.setInstanceDependent(true); + } + } + var domain = (String) directoryStructureService.getAdditionalProperties().get("domainName"); + versionResources = versionResources.stream().filter(resource -> !(resource.getMountName().equals("account") && domain.equals("Api"))).collect(Collectors.toList()); + } + directoryStructureService.getAdditionalProperties().put(VERSION_RESOURCES, versionResources); + } @Override public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); + updateVersionResources(); final String apiName = getApiName(); final String resourceName = apiName + "Instance"; diff --git a/src/main/java/com/twilio/oai/common/Utility.java b/src/main/java/com/twilio/oai/common/Utility.java index acdb18c6b..9268f6a25 100644 --- a/src/main/java/com/twilio/oai/common/Utility.java +++ b/src/main/java/com/twilio/oai/common/Utility.java @@ -118,7 +118,7 @@ public Optional getModel(final List models, .map(CodegenProperty::getComplexType) .map(classname -> getModelByClassname(models, classname)) .findFirst() - .orElseThrow(); + .orElse(null); } return getModelByClassname(models, className); diff --git a/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java b/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java index 05974c4d4..e20bd9950 100644 --- a/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java +++ b/src/main/java/com/twilio/oai/resolver/csharp/CsharpCodegenModelDataTypeResolver.java @@ -73,9 +73,12 @@ private void resolveEnum(CodegenProperty property) { } String className = OperationStore.getInstance().getClassName(); property.isEnum = true; - property.enumName = property.complexType.contains("Enum") || property.complexType.contains("enum") - ? Utility.removeEnumName(property.complexType) + ApplicationConstants.ENUM + if(property.complexType != null){ + property.enumName = property.complexType.contains("Enum") || property.complexType.contains("enum") + ? Utility.removeEnumName(property.complexType) + ApplicationConstants.ENUM : Utility.removeEnumName(property.complexType); + } + // In case enum is an array if (property.items != null) { property.items.enumName = property.enumName; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index b168fa05a..c80f9015c 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -3,11 +3,11 @@ /// API-generated URL for the requested results page /// Client to make requests to Twilio /// The target page of records - public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, ITwilioRestClient client) + public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); - var request = new Request( + var request = new {{authMethod}}Request( HttpMethod.Get, targetUrl ); @@ -20,9 +20,9 @@ /// current page of records /// Client to make requests to Twilio /// The next page of records - public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, ITwilioRestClient client) + public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { - var request = new Request( + var request = new {{authMethod}}Request( HttpMethod.Get, page.GetNextPageUrl(Rest.Domain.Api) ); @@ -35,9 +35,9 @@ /// current page of records /// Client to make requests to Twilio /// The previous page of records - public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, ITwilioRestClient client) + public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { - var request = new Request( + var request = new {{authMethod}}Request( HttpMethod.Get, page.GetPreviousPageUrl(Rest.Domain.Api) ); diff --git a/src/main/resources/twilio-csharp/ResourceUsings.mustache b/src/main/resources/twilio-csharp/ResourceUsings.mustache index 62029cbac..5d8b87fed 100644 --- a/src/main/resources/twilio-csharp/ResourceUsings.mustache +++ b/src/main/resources/twilio-csharp/ResourceUsings.mustache @@ -7,4 +7,9 @@ using Twilio.Constant; using Twilio.Converters; using Twilio.Exceptions; using Twilio.Http; -{{#metaProperties}}{{#enum-exists-resource}}using Twilio.Types;{{/enum-exists-resource}}{{/metaProperties}} \ No newline at end of file +{{#metaProperties}}{{#enum-exists-resource}}using Twilio.Types;{{/enum-exists-resource}}{{/metaProperties}} +{{#metaProperties}}{{#auth_method-bearer-token}}using Twilio.Base.BearerToken; +using Twilio.Clients.BearerToken; +using Twilio.Http.BearerToken;{{/auth_method-bearer-token}}{{/metaProperties}} +{{#metaProperties}}{{#auth_method-no-auth}}using Twilio.Clients.NoAuth; +using Twilio.Http.NoAuth;{{/auth_method-no-auth}}{{/metaProperties}} \ No newline at end of file diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 711c90881..575d7d351 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildCreateRequest(Create{{apiName}}Options options, ITwilioRestClient client) + private static {{authMethod}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { {{>resource/GeneratePath}} - return new Request( + return new {{authMethod}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,9 +21,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, ITwilioRestClient client = null) + public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -33,10 +33,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -46,7 +45,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Create(options, client); @@ -57,7 +56,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await CreateAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index bb1e253a8..ffce5cb34 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,10 +3,10 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - private static Request BuildDeleteRequest(Delete{{apiName}}Options options, ITwilioRestClient client) + private static {{authMethod}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { {{>resource/GeneratePath}} - return new Request( + return new {{authMethod}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -19,9 +19,9 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static bool Delete(Delete{{apiName}}Options options, ITwilioRestClient client = null) + public static bool Delete(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -32,9 +32,9 @@ /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -42,7 +42,7 @@ {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} - public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}ITwilioRestClient client = null) + public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}} {{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}} {{/vendorExtensions.x-request-body-param}} ; return Delete(options, client); @@ -51,7 +51,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}}{{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}}{{/vendorExtensions.x-request-body-param}}; return await DeleteAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index a9dc6f78c..5790ce5ea 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildFetchRequest(Fetch{{apiName}}Options options, ITwilioRestClient client) + private static {{authMethod}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { {{>resource/GeneratePath}} - return new Request( + return new {{authMethod}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -15,9 +15,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, ITwilioRestClient client = null) + public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -27,10 +27,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -39,7 +38,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Fetch({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Fetch(options, client); @@ -48,7 +47,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await FetchAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index 0f07af260..a9dab17eb 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildReadRequest(Read{{apiName}}Options options, ITwilioRestClient client) + private static {{authMethod}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { {{>resource/GeneratePath}} - return new Request( + return new {{authMethod}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -14,12 +14,12 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, ITwilioRestClient client = null) + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); - return new ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); + return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); } #if !NET35 @@ -27,22 +27,21 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task> ReadAsync(Read{{apiName}}Options options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); - return new ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); + return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); } #endif {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} - public static ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return Read(options, client); @@ -51,10 +50,10 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task> ReadAsync({{#vendorExtensions.x-request-body-param}} + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return await ReadAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 7777b00a2..6f71210b2 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,8 +1,8 @@ - private static Request BuildUpdateRequest(Update{{apiName}}Options options, ITwilioRestClient client) + private static {{authMethod}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) { {{>resource/GeneratePath}} - return new Request( + return new {{authMethod}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,9 +21,9 @@ /// Update {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, ITwilioRestClient client = null) + public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -34,9 +34,9 @@ {{>resource/ReturnCommentsAsync}} #if !NET35 public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { - client = client ?? TwilioClient.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -46,7 +46,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Update(options, client); @@ -57,7 +57,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - ITwilioRestClient client = null) + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await UpdateAsync(options, client); From 29f595e79d7b047a29532db634f469e25a0a324b Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:45:13 +0530 Subject: [PATCH 02/38] orgs api uptake for twilio csharp --- src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 7824588c2..e2af57def 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -202,7 +202,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP modelName = response.baseType; } Optional responseModel = Utility.getModel(allModels, modelName, recordKey, codegenOperation); - if ((responseModel == null) || responseModel.isEmpty() || (Integer.parseInt(response.code) != 200)) { + if ((responseModel == null) || responseModel.isEmpty() || (Integer.parseInt(response.code) >= 400)) { return; } codegenModelResolver.resolve(responseModel.get(), this); From c6f0eea07fa657a790c14f3e37765493f802cc5d Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:46:12 +0530 Subject: [PATCH 03/38] orgs api uptake for twilio csharp --- .../java/com/twilio/oai/api/CsharpApiResourceBuilder.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index e2af57def..05c35740a 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -214,7 +214,6 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP } public Set getDistinctResponseModel(List responseModels) { - HashSet modelVars = new HashSet<>(); Set distinctResponseModels = new LinkedHashSet<>(); for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { @@ -227,11 +226,6 @@ public Set getDistinctResponseModel(List response distinctResponseModels.add(property); } } - for(CodegenProperty s : distinctResponseModels){ - if(modelVars.contains(s.name)){ - s.nameInCamelCase = "_" + s.nameInCamelCase; - }else modelVars.add(s.nameInCamelCase); - } return distinctResponseModels; } From 0541dc7f9bbcb1452e1e5d5bfd8ae7d481acc42c Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:52:13 +0530 Subject: [PATCH 04/38] orgs api uptake for twilio csharp --- .../twilio/oai/api/FluentApiResourceBuilder.java | 13 ------------- .../com/twilio/oai/api/IApiResourceBuilder.java | 1 - .../twilio/oai/api/NodeApiResourceBuilder.java | 16 ---------------- 3 files changed, 30 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java index 0183a7d08..492a0cb70 100644 --- a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java @@ -54,19 +54,6 @@ public IApiResourceBuilder updateTemplate() { public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); - codegenOperationList.stream().filter(operation -> !operation.vendorExtensions.containsKey("x-ignore")).forEach(codegenOperation -> { - boolean isInstanceOperation = PathUtils.isInstanceOperation(codegenOperation); - if (!isInstanceOperation) { - listOperations.add(codegenOperation); - codegenOperation.vendorExtensions.put("listOperation", true); - metaAPIProperties.put("hasListOperation", true); - } else { - instanceOperations.add(codegenOperation); - codegenOperation.vendorExtensions.put("instanceOperation", true); - metaAPIProperties.put("hasInstanceOperation", true); - } - }); - for (final CodegenOperation co : codegenOperationList) { co.allParams.removeAll(co.pathParams); co.requiredParams.removeAll(co.pathParams); diff --git a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java index 95dc82a04..c0144caa2 100644 --- a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java @@ -5,7 +5,6 @@ import com.twilio.oai.resolver.common.CodegenModelResolver; import com.twilio.oai.resolver.java.JavaPropertyResolver; import org.openapitools.codegen.CodegenModel; -import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 0e0c771de..59ca136e8 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -17,7 +17,6 @@ import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; -import static com.twilio.oai.DirectoryStructureService.VERSION_RESOURCES; import static com.twilio.oai.common.ApplicationConstants.HTTP_METHOD; import static com.twilio.oai.common.ApplicationConstants.STRING; @@ -38,24 +37,9 @@ public NodeApiResourceBuilder(final IApiActionTemplate template, this.toggleMap = toggleMap; } - private void updateVersionResources() { - var versionResources = (List) directoryStructureService.getAdditionalProperties().getOrDefault("versionResources", null); - if (versionResources != null) { - for (var versionResource : versionResources) { - //here "hasInstanceOperation" may be either null or false, so only set if it is true - if (versionResource.getResourceName().equals(getApiName()) && (boolean) metaAPIProperties.getOrDefault("hasInstanceOperation", false)) { - versionResource.setInstanceDependent(true); - } - } - var domain = (String) directoryStructureService.getAdditionalProperties().get("domainName"); - versionResources = versionResources.stream().filter(resource -> !(resource.getMountName().equals("account") && domain.equals("Api"))).collect(Collectors.toList()); - } - directoryStructureService.getAdditionalProperties().put(VERSION_RESOURCES, versionResources); - } @Override public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); - updateVersionResources(); final String apiName = getApiName(); final String resourceName = apiName + "Instance"; From c4eee198be1545adbb17dbfba0a5bfbc9f61d8f4 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:52:32 +0530 Subject: [PATCH 05/38] orgs api uptake for twilio csharp --- src/main/java/com/twilio/oai/common/Utility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/twilio/oai/common/Utility.java b/src/main/java/com/twilio/oai/common/Utility.java index 9268f6a25..acdb18c6b 100644 --- a/src/main/java/com/twilio/oai/common/Utility.java +++ b/src/main/java/com/twilio/oai/common/Utility.java @@ -118,7 +118,7 @@ public Optional getModel(final List models, .map(CodegenProperty::getComplexType) .map(classname -> getModelByClassname(models, classname)) .findFirst() - .orElse(null); + .orElseThrow(); } return getModelByClassname(models, className); From d4e70867add6460fd025857093227199bf0b2b95 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:53:14 +0530 Subject: [PATCH 06/38] orgs api uptake for twilio csharp --- src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 05c35740a..d81948e95 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; From d0e09333b487659f5c1888d766610c3e563655e4 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 4 Sep 2024 17:13:47 +0530 Subject: [PATCH 07/38] remove null pointer exceptions for error objects --- src/main/java/com/twilio/oai/common/Utility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/twilio/oai/common/Utility.java b/src/main/java/com/twilio/oai/common/Utility.java index acdb18c6b..9268f6a25 100644 --- a/src/main/java/com/twilio/oai/common/Utility.java +++ b/src/main/java/com/twilio/oai/common/Utility.java @@ -118,7 +118,7 @@ public Optional getModel(final List models, .map(CodegenProperty::getComplexType) .map(classname -> getModelByClassname(models, classname)) .findFirst() - .orElseThrow(); + .orElse(null); } return getModelByClassname(models, className); From 3bfe21dcdd5d0397883c598a23d444586ba82f76 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 4 Sep 2024 22:04:21 +0530 Subject: [PATCH 08/38] renaming TwilioBearerToken client to TwilioOrgsToken client --- .../com/twilio/oai/TwilioCsharpGenerator.java | 15 +++++++++++++-- .../twilio/oai/api/CsharpApiResourceBuilder.java | 4 +++- .../com/twilio/oai/api/CsharpApiResources.java | 2 ++ .../resources/twilio-csharp/Pagination.mustache | 8 ++++---- .../resource/CreateResource.mustache | 14 +++++++------- .../resource/DeleteResource.mustache | 14 +++++++------- .../twilio-csharp/resource/FetchResource.mustache | 14 +++++++------- .../twilio-csharp/resource/ReadResource.mustache | 14 +++++++------- .../resource/UpdateResource.mustache | 14 +++++++------- 9 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index fb0a21817..d20d68ea1 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -133,13 +133,14 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L apiResources.setRestClientPrefix(setRestClientPrefix(apiResources.getAuthMethod())); apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); + apiResources.setRestClientClassName(fetchRestClientClassName(apiResources.getAuthMethod())); + apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); results.put("resources", apiResources); return results; } private String fetchDomainClassPrefix(String authMethod) { - if(authMethod == BEARER_TOKEN_PREFIX) return "OrgsTokenAuth"; - else if(authMethod == NO_AUTH_PREFIX) return NO_AUTH_PREFIX; + if(authMethod == BEARER_TOKEN_PREFIX || authMethod == NO_AUTH_PREFIX) return "OrgsTokenAuth"; return EMPTY_STRING; } @@ -147,6 +148,16 @@ private String setResourceSetPrefix(String authMethod){ return authMethod == BEARER_TOKEN_PREFIX ? authMethod : EMPTY_STRING; } + private String fetchClientName(String authMethod){ + if(authMethod == BEARER_TOKEN_PREFIX) return "OrgsToken"; + if(authMethod == NO_AUTH_PREFIX) return "NoAuth"; + return EMPTY_STRING; + } + + private String fetchRestClientClassName(String authMethod){ + return authMethod == NO_AUTH_PREFIX ? "NoAuth" : EMPTY_STRING; + } + private String setRestClientPrefix(String authMethod){ return authMethod == EMPTY_STRING ? "I" : EMPTY_STRING; } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index d81948e95..24cbbef05 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -108,7 +108,9 @@ public void processAuthMethods(List opList) { } } } - else this.authMethod = "NoAuth"; + else{ + this.authMethod = "NoAuth"; + } } } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index 146bb029c..ad844aff3 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -14,6 +14,8 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String restClientPrefix; @Getter @Setter private String resourceSetPrefix; @Getter @Setter private String domainClassPrefix; + @Getter @Setter private String restClientClassName; + @Getter @Setter private String clientName; List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); public String resourceConstant = ApplicationConstants.RESOURCE; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index c80f9015c..8a99cb40e 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -3,9 +3,9 @@ /// API-generated URL for the requested results page /// Client to make requests to Twilio /// The target page of records - public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var request = new {{authMethod}}Request( HttpMethod.Get, @@ -20,7 +20,7 @@ /// current page of records /// Client to make requests to Twilio /// The next page of records - public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { var request = new {{authMethod}}Request( HttpMethod.Get, @@ -35,7 +35,7 @@ /// current page of records /// Client to make requests to Twilio /// The previous page of records - public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { var request = new {{authMethod}}Request( HttpMethod.Get, diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 575d7d351..c6bfb6b39 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,5 +1,5 @@ - private static {{authMethod}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + private static {{authMethod}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} return new {{authMethod}}Request( @@ -21,9 +21,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -33,9 +33,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -45,7 +45,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Create(options, client); @@ -56,7 +56,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await CreateAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index ffce5cb34..32bb6abe0 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,7 +3,7 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - private static {{authMethod}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + private static {{authMethod}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} return new {{authMethod}}Request( @@ -19,9 +19,9 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static bool Delete(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static bool Delete(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -32,9 +32,9 @@ /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -42,7 +42,7 @@ {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} - public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}} {{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}} {{/vendorExtensions.x-request-body-param}} ; return Delete(options, client); @@ -51,7 +51,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}}{{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}}{{/vendorExtensions.x-request-body-param}}; return await DeleteAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index 5790ce5ea..d0e878137 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,5 +1,5 @@ - private static {{authMethod}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + private static {{authMethod}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} return new {{authMethod}}Request( @@ -15,9 +15,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -27,9 +27,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -38,7 +38,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Fetch({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Fetch(options, client); @@ -47,7 +47,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await FetchAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index a9dab17eb..8248b8796 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,5 +1,5 @@ - private static {{authMethod}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + private static {{authMethod}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} return new {{authMethod}}Request( @@ -14,9 +14,9 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); @@ -27,9 +27,9 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); @@ -41,7 +41,7 @@ public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return Read(options, client); @@ -53,7 +53,7 @@ public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return await ReadAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 6f71210b2..99a1db04f 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,5 +1,5 @@ - private static {{authMethod}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + private static {{authMethod}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} return new {{authMethod}}Request( @@ -21,9 +21,9 @@ /// Update {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -34,9 +34,9 @@ {{>resource/ReturnCommentsAsync}} #if !NET35 public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -46,7 +46,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Update(options, client); @@ -57,7 +57,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await UpdateAsync(options, client); From b3eeb8759865865efc26fb7f6bf8e3782641c987 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 4 Sep 2024 23:05:25 +0530 Subject: [PATCH 09/38] renaming request classes --- src/main/java/com/twilio/oai/TwilioCsharpGenerator.java | 7 +++++++ src/main/java/com/twilio/oai/api/CsharpApiResources.java | 1 + src/main/resources/twilio-csharp/Pagination.mustache | 6 +++--- .../twilio-csharp/resource/CreateResource.mustache | 4 ++-- .../twilio-csharp/resource/DeleteResource.mustache | 4 ++-- .../twilio-csharp/resource/FetchResource.mustache | 4 ++-- .../resources/twilio-csharp/resource/ReadResource.mustache | 4 ++-- .../twilio-csharp/resource/UpdateResource.mustache | 4 ++-- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index d20d68ea1..5869e49a9 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -135,6 +135,7 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); apiResources.setRestClientClassName(fetchRestClientClassName(apiResources.getAuthMethod())); apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); + apiResources.setRequestName(fetchRequestName(apiResources.getAuthMethod())); results.put("resources", apiResources); return results; } @@ -154,6 +155,12 @@ private String fetchClientName(String authMethod){ return EMPTY_STRING; } + private String fetchRequestName(String authMethod){ + if(authMethod == BEARER_TOKEN_PREFIX) return "Token"; + if(authMethod == NO_AUTH_PREFIX) return "NoAuth"; + return EMPTY_STRING; + } + private String fetchRestClientClassName(String authMethod){ return authMethod == NO_AUTH_PREFIX ? "NoAuth" : EMPTY_STRING; } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index ad844aff3..badfb6986 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -16,6 +16,7 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String domainClassPrefix; @Getter @Setter private String restClientClassName; @Getter @Setter private String clientName; + @Getter @Setter private String requestName; List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); public String resourceConstant = ApplicationConstants.RESOURCE; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index 8a99cb40e..cbdc5070e 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -7,7 +7,7 @@ { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); - var request = new {{authMethod}}Request( + var request = new {{requestName}}Request( HttpMethod.Get, targetUrl ); @@ -22,7 +22,7 @@ /// The next page of records public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { - var request = new {{authMethod}}Request( + var request = new {{requestName}}Request( HttpMethod.Get, page.GetNextPageUrl(Rest.Domain.Api) ); @@ -37,7 +37,7 @@ /// The previous page of records public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { - var request = new {{authMethod}}Request( + var request = new {{requestName}}Request( HttpMethod.Get, page.GetPreviousPageUrl(Rest.Domain.Api) ); diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index c6bfb6b39..128a90347 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,8 +1,8 @@ - private static {{authMethod}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} - return new {{authMethod}}Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index 32bb6abe0..5adef106c 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,10 +3,10 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - private static {{authMethod}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} - return new {{authMethod}}Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index d0e878137..4ef69a462 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,8 +1,8 @@ - private static {{authMethod}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} - return new {{authMethod}}Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index 8248b8796..c5fce1949 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,8 +1,8 @@ - private static {{authMethod}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} - return new {{authMethod}}Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 99a1db04f..dd600afac 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,8 +1,8 @@ - private static {{authMethod}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) { {{>resource/GeneratePath}} - return new {{authMethod}}Request( + return new {{requestName}}Request( {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, From 55364db440a8e8875a9770bf95e0f9e4236a326b Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 4 Sep 2024 23:12:51 +0530 Subject: [PATCH 10/38] renaming resourcset --- src/main/java/com/twilio/oai/TwilioCsharpGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 5869e49a9..99eba9378 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -146,7 +146,7 @@ private String fetchDomainClassPrefix(String authMethod) { } private String setResourceSetPrefix(String authMethod){ - return authMethod == BEARER_TOKEN_PREFIX ? authMethod : EMPTY_STRING; + return authMethod == BEARER_TOKEN_PREFIX ? "Token" : EMPTY_STRING; } private String fetchClientName(String authMethod){ From 622f9318175804660e8601e98d1ffe432a48da8b Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Fri, 13 Sep 2024 15:56:44 +0530 Subject: [PATCH 11/38] Renaming rest clients in mustache files --- .../java/com/twilio/oai/TwilioCsharpGenerator.java | 10 +++------- .../java/com/twilio/oai/api/CsharpApiResources.java | 1 - src/main/resources/twilio-csharp/Pagination.mustache | 6 +++--- .../twilio-csharp/resource/CreateResource.mustache | 10 +++++----- .../twilio-csharp/resource/DeleteResource.mustache | 10 +++++----- .../twilio-csharp/resource/FetchResource.mustache | 10 +++++----- .../twilio-csharp/resource/ReadResource.mustache | 10 +++++----- .../twilio-csharp/resource/UpdateResource.mustache | 10 +++++----- 8 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 99eba9378..ce91900b8 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -130,7 +130,6 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L final List opList = directoryStructureService.processOperations(results); CsharpApiResources apiResources = processCodegenOperations(opList); apiResources.setAuthMethod(processAuthMethods(opList)); - apiResources.setRestClientPrefix(setRestClientPrefix(apiResources.getAuthMethod())); apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); apiResources.setRestClientClassName(fetchRestClientClassName(apiResources.getAuthMethod())); @@ -150,9 +149,9 @@ private String setResourceSetPrefix(String authMethod){ } private String fetchClientName(String authMethod){ - if(authMethod == BEARER_TOKEN_PREFIX) return "OrgsToken"; - if(authMethod == NO_AUTH_PREFIX) return "NoAuth"; - return EMPTY_STRING; + if(authMethod == BEARER_TOKEN_PREFIX) return "TwilioOrgsTokenRestClient"; + if(authMethod == NO_AUTH_PREFIX) return "TwilioNoAuthRestClient"; + return "ITwilioRestClient"; } private String fetchRequestName(String authMethod){ @@ -165,9 +164,6 @@ private String fetchRestClientClassName(String authMethod){ return authMethod == NO_AUTH_PREFIX ? "NoAuth" : EMPTY_STRING; } - private String setRestClientPrefix(String authMethod){ - return authMethod == EMPTY_STRING ? "I" : EMPTY_STRING; - } private String processAuthMethods(List opList) { if(opList != null){ diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index badfb6986..5846f2f49 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -11,7 +11,6 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String authMethod; - @Getter @Setter private String restClientPrefix; @Getter @Setter private String resourceSetPrefix; @Getter @Setter private String domainClassPrefix; @Getter @Setter private String restClientClassName; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index cbdc5070e..e65aaec46 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -3,7 +3,7 @@ /// API-generated URL for the requested results page /// Client to make requests to Twilio /// The target page of records - public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{clientName}} client) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); @@ -20,7 +20,7 @@ /// current page of records /// Client to make requests to Twilio /// The next page of records - public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { var request = new {{requestName}}Request( HttpMethod.Get, @@ -35,7 +35,7 @@ /// current page of records /// Client to make requests to Twilio /// The previous page of records - public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { var request = new {{requestName}}Request( HttpMethod.Get, diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 128a90347..959d5aa97 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,5 +1,5 @@ - private static {{requestName}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildCreateRequest(Create{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( @@ -21,7 +21,7 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildCreateRequest(options, client)); @@ -33,7 +33,7 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -45,7 +45,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Create(options, client); @@ -56,7 +56,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await CreateAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index 5adef106c..05f4d569c 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,7 +3,7 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - private static {{requestName}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( @@ -19,7 +19,7 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static bool Delete(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static bool Delete(Delete{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildDeleteRequest(options, client)); @@ -32,7 +32,7 @@ /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -42,7 +42,7 @@ {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} - public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}} {{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}} {{/vendorExtensions.x-request-body-param}} ; return Delete(options, client); @@ -51,7 +51,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}}{{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}}{{/vendorExtensions.x-request-body-param}}; return await DeleteAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index 4ef69a462..e31a4a362 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,5 +1,5 @@ - private static {{requestName}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( @@ -15,7 +15,7 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildFetchRequest(options, client)); @@ -27,7 +27,7 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -38,7 +38,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Fetch({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Fetch(options, client); @@ -47,7 +47,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await FetchAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index c5fce1949..916cc6822 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,5 +1,5 @@ - private static {{requestName}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildReadRequest(Read{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( @@ -14,7 +14,7 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildReadRequest(options, client)); @@ -27,7 +27,7 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} - public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -41,7 +41,7 @@ public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return Read(options, client); @@ -53,7 +53,7 @@ public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return await ReadAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index dd600afac..746046bc3 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,5 +1,5 @@ - private static {{requestName}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client) + private static {{requestName}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( @@ -21,7 +21,7 @@ /// Update {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} - public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildUpdateRequest(options, client)); @@ -34,7 +34,7 @@ {{>resource/ReturnCommentsAsync}} #if !NET35 public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -46,7 +46,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Update(options, client); @@ -57,7 +57,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} - {{restClientPrefix}}Twilio{{clientName}}RestClient client = null) + {{clientName}} client = null) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await UpdateAsync(options, client); From e3bc20b728c3a2aa60bbb2b9dd118db714c5455d Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 10:44:56 +0530 Subject: [PATCH 12/38] moving constant references to enum file --- .../com/twilio/oai/api/CsharpApiResourceBuilder.java | 8 ++++---- src/main/java/com/twilio/oai/common/EnumConstants.java | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 24cbbef05..aeb37c28f 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -67,10 +67,10 @@ public IApiResourceBuilder setImports(DirectoryStructureService directoryStructu } }); - if(this.authMethod == "BearerToken"){ + if(this.authMethod == EnumConstants.AuthType.BEARER_TOKEN.getValue()){ metaAPIProperties.put("auth_method-bearer-token", true); } - else if(this.authMethod == "NoAuth"){ + else if(this.authMethod == EnumConstants.AuthType.NOAUTH.getValue()){ metaAPIProperties.put("auth_method-no-auth", true); } if (OperationStore.getInstance().isEnumPresentInOptions()) @@ -104,12 +104,12 @@ public void processAuthMethods(List opList) { if(authMethods != null){ for(CodegenSecurity c : authMethods){ if(c.isOAuth == true){ - this.authMethod = "BearerToken"; + this.authMethod = EnumConstants.AuthType.BEARER_TOKEN.getValue(); } } } else{ - this.authMethod = "NoAuth"; + this.authMethod = EnumConstants.AuthType.NOAUTH.getValue(); } } } diff --git a/src/main/java/com/twilio/oai/common/EnumConstants.java b/src/main/java/com/twilio/oai/common/EnumConstants.java index 45e457ad1..e1cdb6ec1 100644 --- a/src/main/java/com/twilio/oai/common/EnumConstants.java +++ b/src/main/java/com/twilio/oai/common/EnumConstants.java @@ -43,6 +43,15 @@ public enum PathType { private final String value; } + @Getter + @RequiredArgsConstructor + public enum AuthType { + BEARER_TOKEN("BearerToken"), + NOAUTH("NoAuth"); + + private final String value; + } + @Getter @RequiredArgsConstructor public enum CsharpDataTypes implements LanguageDataType { From a53ecc6eb045cd33d8a5e5559ee728b1f33085d9 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 11:07:51 +0530 Subject: [PATCH 13/38] renamed mustache configurations for domain class name --- .../java/com/twilio/oai/TwilioCsharpGenerator.java | 10 ++++++---- .../java/com/twilio/oai/api/CsharpApiResources.java | 2 +- src/main/resources/twilio-csharp/Pagination.mustache | 2 +- .../twilio-csharp/resource/CreateResource.mustache | 4 ++-- .../twilio-csharp/resource/DeleteResource.mustache | 4 ++-- .../twilio-csharp/resource/FetchResource.mustache | 4 ++-- .../twilio-csharp/resource/ReadResource.mustache | 4 ++-- .../twilio-csharp/resource/UpdateResource.mustache | 4 ++-- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index ce91900b8..26bc69598 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -46,6 +46,8 @@ public class TwilioCsharpGenerator extends CSharpClientCodegen { private final String BEARER_TOKEN_PREFIX = "BearerToken"; private final String NO_AUTH_PREFIX = "NoAuth"; private final String EMPTY_STRING = ""; + private final String ORGS_TOKEN_CLIENT = "TwilioOrgsTokenAuthClient"; + private final String BASIC_CLIENT = "TwilioClient"; private final DirectoryStructureService directoryStructureService = new DirectoryStructureService( additionalProperties, new ResourceMap(new Inflector()), @@ -131,7 +133,7 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L CsharpApiResources apiResources = processCodegenOperations(opList); apiResources.setAuthMethod(processAuthMethods(opList)); apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); - apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); + apiResources.setDomainClass(fetchDomainClass(apiResources.getAuthMethod())); apiResources.setRestClientClassName(fetchRestClientClassName(apiResources.getAuthMethod())); apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); apiResources.setRequestName(fetchRequestName(apiResources.getAuthMethod())); @@ -139,9 +141,9 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L return results; } - private String fetchDomainClassPrefix(String authMethod) { - if(authMethod == BEARER_TOKEN_PREFIX || authMethod == NO_AUTH_PREFIX) return "OrgsTokenAuth"; - return EMPTY_STRING; + private String fetchDomainClass(String authMethod) { + if(authMethod == BEARER_TOKEN_PREFIX || authMethod == NO_AUTH_PREFIX) return ORGS_TOKEN_CLIENT; + return BASIC_CLIENT; } private String setResourceSetPrefix(String authMethod){ diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index 5846f2f49..7f211811c 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -12,7 +12,7 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String authMethod; @Getter @Setter private String resourceSetPrefix; - @Getter @Setter private String domainClassPrefix; + @Getter @Setter private String domainClass; @Getter @Setter private String restClientClassName; @Getter @Setter private String clientName; @Getter @Setter private String requestName; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index e65aaec46..6fa51f959 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -5,7 +5,7 @@ /// The target page of records public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{clientName}} client) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var request = new {{requestName}}Request( HttpMethod.Get, diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 959d5aa97..14854c469 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -23,7 +23,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -35,7 +35,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index 05f4d569c..8e44dbb8c 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -21,7 +21,7 @@ {{>resource/ReturnComments}} public static bool Delete(Delete{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -34,7 +34,7 @@ public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index e31a4a362..e67253b09 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -17,7 +17,7 @@ {{>resource/ReturnComments}} public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -29,7 +29,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index 916cc6822..66373e9e2 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -16,7 +16,7 @@ {{>resource/ReturnComments}} public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); @@ -29,7 +29,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 746046bc3..b567ec4c4 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -23,7 +23,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -36,7 +36,7 @@ public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? Twilio{{domainClassPrefix}}Client.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } From 0441b5c393d517713c4158c404072e9638cc638a Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 17 Sep 2024 11:16:42 +0530 Subject: [PATCH 14/38] Renaming rest client get method in mustache files --- src/main/java/com/twilio/oai/TwilioCsharpGenerator.java | 4 ++-- src/main/java/com/twilio/oai/api/CsharpApiResources.java | 2 +- src/main/resources/twilio-csharp/Pagination.mustache | 2 +- .../resources/twilio-csharp/resource/CreateResource.mustache | 4 ++-- .../resources/twilio-csharp/resource/DeleteResource.mustache | 4 ++-- .../resources/twilio-csharp/resource/FetchResource.mustache | 4 ++-- .../resources/twilio-csharp/resource/ReadResource.mustache | 4 ++-- .../resources/twilio-csharp/resource/UpdateResource.mustache | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 26bc69598..8146588e5 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -134,7 +134,7 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L apiResources.setAuthMethod(processAuthMethods(opList)); apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); apiResources.setDomainClass(fetchDomainClass(apiResources.getAuthMethod())); - apiResources.setRestClientClassName(fetchRestClientClassName(apiResources.getAuthMethod())); + apiResources.setRestClientMethodName(fetchRestClientClassName(apiResources.getAuthMethod())); apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); apiResources.setRequestName(fetchRequestName(apiResources.getAuthMethod())); results.put("resources", apiResources); @@ -163,7 +163,7 @@ private String fetchRequestName(String authMethod){ } private String fetchRestClientClassName(String authMethod){ - return authMethod == NO_AUTH_PREFIX ? "NoAuth" : EMPTY_STRING; + return authMethod == NO_AUTH_PREFIX ? "GetNoAuthRestClient" : "GetRestClient"; } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index 7f211811c..8920ac332 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -13,7 +13,7 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String authMethod; @Getter @Setter private String resourceSetPrefix; @Getter @Setter private String domainClass; - @Getter @Setter private String restClientClassName; + @Getter @Setter private String restClientMethodName; @Getter @Setter private String clientName; @Getter @Setter private String requestName; List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index 6fa51f959..9d556062c 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -5,7 +5,7 @@ /// The target page of records public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{clientName}} client) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var request = new {{requestName}}Request( HttpMethod.Get, diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 14854c469..14e5feed4 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -23,7 +23,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -35,7 +35,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index 8e44dbb8c..a21ca756b 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -21,7 +21,7 @@ {{>resource/ReturnComments}} public static bool Delete(Delete{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -34,7 +34,7 @@ public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index e67253b09..ede568d26 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -17,7 +17,7 @@ {{>resource/ReturnComments}} public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -29,7 +29,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index 66373e9e2..a5ead39b4 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -16,7 +16,7 @@ {{>resource/ReturnComments}} public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); @@ -29,7 +29,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index b567ec4c4..9ce79f3c3 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -23,7 +23,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -36,7 +36,7 @@ public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, {{clientName}} client = null) { - client = client ?? {{domainClass}}.Get{{restClientClassName}}RestClient(); + client = client ?? {{domainClass}}.{{restClientMethodName}}(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } From 21325de1cea1acd43914dcf617f6997de72f9403 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 12:32:02 +0530 Subject: [PATCH 15/38] Changes to auth method handler --- .../java/com/twilio/oai/TwilioCsharpGenerator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 8146588e5..f090cc404 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -168,18 +168,26 @@ private String fetchRestClientClassName(String authMethod){ private String processAuthMethods(List opList) { + boolean isBasicAuthPresent = false; + boolean isTokenAuthPresent = false; if(opList != null){ List authMethods = opList.get(0).authMethods; if(authMethods != null){ for(CodegenSecurity c : authMethods){ if(c.isOAuth == true){ - return "BearerToken"; + isTokenAuthPresent = true; + + } + if(c.isBasic == true){ + isBasicAuthPresent = true; } } } else return "NoAuth"; } - return ""; + if(isBasicAuthPresent) + return ""; + return "BearerToken"; } @Override From 436748eaa4487248258ea6239b10543b3482bf36 Mon Sep 17 00:00:00 2001 From: Shubham Date: Thu, 1 Aug 2024 16:42:34 +0530 Subject: [PATCH 16/38] fix: add support for required query params in node (#596) # Fixes # In twilio-node, read operation does not handle required query params correctly, see [here](https://github.com/twilio/twilio-oai-generator/blob/main/src/main/resources/twilio-node/api-single.mustache#L139). Till now, the existing APIs do not have such use case, but now some APIs are trying to pass required query params. This needs to be supported in twilio-node. ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository. --- .../resources/twilio-node/listInterfaceFunctions.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/twilio-node/listInterfaceFunctions.mustache b/src/main/resources/twilio-node/listInterfaceFunctions.mustache index 713062254..8c2adb6d6 100644 --- a/src/main/resources/twilio-node/listInterfaceFunctions.mustache +++ b/src/main/resources/twilio-node/listInterfaceFunctions.mustache @@ -13,7 +13,7 @@ * @param { {{vendorExtensions.x-resource-name}}EachOptions } [params] - Options for request * @param { function } [callback] - Function to process each record */ - each(callback?: (item: {{instanceName}}, done: (err?: Error) => void) => void): void; + {{^hasRequiredParams}}each(callback?: (item: {{instanceName}}, done: (err?: Error) => void) => void): void;{{/hasRequiredParams}} each(params: {{vendorExtensions.x-resource-name}}EachOptions, callback?: (item: {{instanceName}}, done: (err?: Error) => void) => void): void; /** * Retrieve a single target page of {{instanceName}} records from the API. @@ -33,7 +33,7 @@ * @param { {{vendorExtensions.x-resource-name}}Options } [params] - Options for request * @param { function } [callback] - Callback to handle list of records */ - list(callback?: (error: Error | null, items: {{instanceName}}[]) => any): Promise<{{instanceName}}[]>; + {{^hasRequiredParams}}list(callback?: (error: Error | null, items: {{instanceName}}[]) => any): Promise<{{instanceName}}[]>;{{/hasRequiredParams}} list(params: {{vendorExtensions.x-resource-name}}Options, callback?: (error: Error | null, items: {{instanceName}}[]) => any): Promise<{{instanceName}}[]>; /** * Retrieve a single page of {{instanceName}} records from the API. @@ -46,5 +46,5 @@ * @param { {{vendorExtensions.x-resource-name}}PageOptions } [params] - Options for request * @param { function } [callback] - Callback to handle list of records */ - page(callback?: (error: Error | null, items: {{returnType}}) => any): Promise<{{returnType}}>; + {{^hasRequiredParams}}page(callback?: (error: Error | null, items: {{returnType}}) => any): Promise<{{returnType}}>;{{/hasRequiredParams}} page(params: {{vendorExtensions.x-resource-name}}PageOptions, callback?: (error: Error | null, items: {{returnType}}) => any): Promise<{{returnType}}>; From 20af68b6bfb2b9f48d19371c2c83675cd2fdc37d Mon Sep 17 00:00:00 2001 From: Shubham Date: Fri, 2 Aug 2024 19:51:22 +0530 Subject: [PATCH 17/38] chore: removing unused params from python model constructor (#597) # Fixes # In python, the instancePathParams were not being used to initialize response models in constructors. So removing those unused params. --- src/main/resources/twilio-python/modelClasses.handlebars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/twilio-python/modelClasses.handlebars b/src/main/resources/twilio-python/modelClasses.handlebars index b4d34154a..210863b2a 100644 --- a/src/main/resources/twilio-python/modelClasses.handlebars +++ b/src/main/resources/twilio-python/modelClasses.handlebars @@ -4,7 +4,7 @@ :ivar {{name}}: {{{description}}}{{/vars}} """ - def __init__(self, payload: Dict[str, Any]{{#instancePathParams}}, {{paramName}}: {{#if vendorExtensions.x-is-parent-param}}{{{contentType}}}{{else}}Optional[{{{contentType}}}] = None{{/if}}{{/instancePathParams}}): + def __init__(self, payload: Dict[str, Any]): {{#vars}} self.{{name}}: Optional[{{{dataType}}}] = {{#if vendorExtensions.x-deserialize}}{{vendorExtensions.x-deserialize}}(payload.get("{{{name}}}")){{else}}payload.get("{{{name}}}"){{/if}}{{/vars}} From 1f7e230cd94ae97200ee782f71842c585e1ee5c5 Mon Sep 17 00:00:00 2001 From: Shubham Date: Mon, 5 Aug 2024 20:05:40 +0530 Subject: [PATCH 18/38] chore: remove local file paths (#598) # Fixes # Removing local file paths ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository. --- src/test/java/com/twilio/oai/TwilioGeneratorTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java index a68a61691..a06c24603 100644 --- a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java +++ b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java @@ -41,9 +41,6 @@ public static void setUp() { @Test public void launchGenerator() { final String pathname = "examples/spec/twilio_api_v2010.yaml"; -// final String pathname = "/Users/stiwari/di/github/twilio-oai/spec/json/twilio_accounts_v1.json"; -// final String pathname = "/Users/stiwari/di/codehq/open-api-transpiler/twilio_api_v2010.json"; -// final String pathname = "/Users/stiwari/di/codehq/open-api-transpiler/json/twilio_assistants_v1.json"; File filesList[] ; File directoryPath = new File(pathname); if (directoryPath.isDirectory()) { From b9f4793bbbf895880ee5e3f6bc56e4f2e8639e8f Mon Sep 17 00:00:00 2001 From: Manisha Singh Date: Mon, 12 Aug 2024 12:41:30 +0530 Subject: [PATCH 19/38] chore: librarian time check (#594) Removing run_openapi_generator from for loop which was causing too much delay with pipelines --- scripts/build_twilio_library.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index cff9c4005..12421568a 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -50,6 +50,18 @@ def generate(spec_folder: str, spec_files: List[str], output_path: str, language 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) + if spec_files[0] in generateForLanguages and language in generateForLanguages.get(spec_files[0]): + print(f'Generating {output_path} from {spec_folder}') + run_openapi_generator(parent_dir, language) + print(f'Code generation completed at {output_path}') + elif spec_files[0] not in generateForLanguages: + print(f'Generating {output_path} from {spec_folder}') + run_openapi_generator(parent_dir, language) + print(f'Code generation completed at {output_path}') + if language in CLEANUP_IMPORT_LANGUAGES: + remove_unused_imports(output_path, language) + if language in REMOVE_DUPLICATE_IMPORT_LANGUAGES: + remove_duplicate_imports(output_path, language) 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) @@ -62,18 +74,17 @@ def generate_domain_for_language(spec_file: str, config_path: str, spec_folder: 'arrayItemSuffix': '' }, } - + # print(config) 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) - print(f'Code generation completed at {output_path}') - - if language in CLEANUP_IMPORT_LANGUAGES: - remove_unused_imports(output_path, language) - if language in REMOVE_DUPLICATE_IMPORT_LANGUAGES: - remove_duplicate_imports(output_path, language) + # print(f'Generating {output_path} from {spec_folder}') + # run_openapi_generator(parent_dir, language) + # print(f'Code generation completed at {output_path}') + # if language in CLEANUP_IMPORT_LANGUAGES: + # remove_unused_imports(output_path, language) + # 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' From c1416ef05ddc22747d885e0f43e5a8aa797ef940 Mon Sep 17 00:00:00 2001 From: Manisha Singh Date: Mon, 19 Aug 2024 14:05:06 +0530 Subject: [PATCH 20/38] chore: fixing nullable attributes (#591) --- src/main/resources/twilio-node/responseModel.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/twilio-node/responseModel.mustache b/src/main/resources/twilio-node/responseModel.mustache index 2c52b0118..5eb3d0e53 100644 --- a/src/main/resources/twilio-node/responseModel.mustache +++ b/src/main/resources/twilio-node/responseModel.mustache @@ -27,7 +27,7 @@ export class {{instanceName}} { {{/vars}} {{#instancePath}} - this._solution = { {{#instancePathParams}}{{paramName}}{{^vendorExtensions.x-is-parent-param}}: {{paramName}} || this.{{paramName}}{{#vendorExtensions.x-stringify}}.toString(){{/vendorExtensions.x-stringify}}{{/vendorExtensions.x-is-parent-param}}, {{/instancePathParams}} }; + this._solution = { {{#instancePathParams}}{{paramName}}{{^vendorExtensions.x-is-parent-param}}: {{paramName}} || this.{{paramName}}{{#isNullable}}{{#vendorExtensions.x-stringify}}.toString(){{/vendorExtensions.x-stringify}}{{/isNullable}}{{/vendorExtensions.x-is-parent-param}}, {{/instancePathParams}} }; {{/instancePath}} } From ec82cc3a444718820146d62600ee4c5148f9b7f4 Mon Sep 17 00:00:00 2001 From: Manisha Singh Date: Mon, 19 Aug 2024 22:42:14 +0530 Subject: [PATCH 21/38] chore: revert changes (#603) --- src/main/resources/twilio-node/responseModel.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/twilio-node/responseModel.mustache b/src/main/resources/twilio-node/responseModel.mustache index 5eb3d0e53..2c52b0118 100644 --- a/src/main/resources/twilio-node/responseModel.mustache +++ b/src/main/resources/twilio-node/responseModel.mustache @@ -27,7 +27,7 @@ export class {{instanceName}} { {{/vars}} {{#instancePath}} - this._solution = { {{#instancePathParams}}{{paramName}}{{^vendorExtensions.x-is-parent-param}}: {{paramName}} || this.{{paramName}}{{#isNullable}}{{#vendorExtensions.x-stringify}}.toString(){{/vendorExtensions.x-stringify}}{{/isNullable}}{{/vendorExtensions.x-is-parent-param}}, {{/instancePathParams}} }; + this._solution = { {{#instancePathParams}}{{paramName}}{{^vendorExtensions.x-is-parent-param}}: {{paramName}} || this.{{paramName}}{{#vendorExtensions.x-stringify}}.toString(){{/vendorExtensions.x-stringify}}{{/vendorExtensions.x-is-parent-param}}, {{/instancePathParams}} }; {{/instancePath}} } From 6f7372b9b1114175c5b8351bfca128d504508f5d Mon Sep 17 00:00:00 2001 From: sbansla <104902068+sbansla@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:07:20 +0530 Subject: [PATCH 22/38] chore: ignore content_v1 spec for release and iam_organizations spec file as versionless (#606) --- .../rest/previewiam/{organizations => v1}/Token.java | 2 +- .../previewiam/{organizations => v1}/TokenCreator.java | 2 +- scripts/build_twilio_library.py | 2 +- src/main/java/com/twilio/oai/TwilioCodegenAdapter.java | 10 +++++----- .../com/twilio/oai/common/ApplicationConstants.java | 3 +++ src/test/java/com/twilio/oai/TwilioGeneratorTest.java | 9 ++++++++- 6 files changed, 19 insertions(+), 9 deletions(-) rename examples/java/src/main/java/com/twilio/rest/previewiam/{organizations => v1}/Token.java (99%) rename examples/java/src/main/java/com/twilio/rest/previewiam/{organizations => v1}/TokenCreator.java (99%) diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/Token.java b/examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java similarity index 99% rename from examples/java/src/main/java/com/twilio/rest/previewiam/organizations/Token.java rename to examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java index 1102d5c7e..17b8ef4d7 100644 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/Token.java +++ b/examples/java/src/main/java/com/twilio/rest/previewiam/v1/Token.java @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -package com.twilio.rest.previewiam.organizations; +package com.twilio.rest.previewiam.v1; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/TokenCreator.java b/examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java similarity index 99% rename from examples/java/src/main/java/com/twilio/rest/previewiam/organizations/TokenCreator.java rename to examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java index 134cd0f9c..39be29372 100644 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/TokenCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/previewiam/v1/TokenCreator.java @@ -12,7 +12,7 @@ * Do not edit the class manually. */ -package com.twilio.rest.previewiam.organizations; +package com.twilio.rest.previewiam.v1; import com.fasterxml.jackson.databind.ObjectMapper; import com.twilio.constant.EnumConstants; diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index 12421568a..99efcd30f 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -32,7 +32,7 @@ def build(openapi_spec_path: str, output_path: str, language: str) -> None: else: spec_folder = openapi_spec_path spec_files = sorted(os.listdir(spec_folder)) - + spec_files.remove('twilio_content_v1.json') generate(spec_folder, spec_files, output_path, language) diff --git a/src/main/java/com/twilio/oai/TwilioCodegenAdapter.java b/src/main/java/com/twilio/oai/TwilioCodegenAdapter.java index 72e2db227..c61226574 100644 --- a/src/main/java/com/twilio/oai/TwilioCodegenAdapter.java +++ b/src/main/java/com/twilio/oai/TwilioCodegenAdapter.java @@ -2,10 +2,6 @@ import java.io.File; import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Paths; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -13,6 +9,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.twilio.oai.common.ApplicationConstants; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.servers.Server; @@ -146,6 +143,9 @@ private String getInputSpecDomain() { } private String getInputSpecVersion() { - return codegen.getInputSpec().replaceAll(INPUT_SPEC_PATTERN, "${version}"); + String version = codegen.getInputSpec().replaceAll(INPUT_SPEC_PATTERN, "${version}"); + boolean textExists = Arrays.stream(ApplicationConstants.VERSION_LESS_SPECS) + .anyMatch(ignoredVersion -> ignoredVersion.equals(version)); + return textExists ? "" : version; } } diff --git a/src/main/java/com/twilio/oai/common/ApplicationConstants.java b/src/main/java/com/twilio/oai/common/ApplicationConstants.java index 953d2e03c..0694d76a9 100644 --- a/src/main/java/com/twilio/oai/common/ApplicationConstants.java +++ b/src/main/java/com/twilio/oai/common/ApplicationConstants.java @@ -55,4 +55,7 @@ public class ApplicationConstants { public static final String PHONE_NUMBER = "phone-number"; public static final Predicate SUCCESS = i -> i != null && i >= 200 && i < 400; + + public static final String[] VERSION_LESS_SPECS = {"organizations"}; + } diff --git a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java index a06c24603..12f8f1af5 100644 --- a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java +++ b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java @@ -28,7 +28,14 @@ public class TwilioGeneratorTest { @Parameterized.Parameters public static Collection generators() { - return Arrays.asList(Generator.TWILIO_PYTHON); + return Arrays.asList(Generator.TWILIO_CSHARP, + Generator.TWILIO_GO, + Generator.TWILIO_JAVA, + Generator.TWILIO_NODE, + Generator.TWILIO_PHP, + Generator.TWILIO_PYTHON, + Generator.TWILIO_RUBY, + Generator.TWILIO_TERRAFORM); } private final Generator generator; From 9c0ca40c46a1331f2a7a6d9ec6c67a3496f21710 Mon Sep 17 00:00:00 2001 From: sbansla <104902068+sbansla@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:38:16 +0530 Subject: [PATCH 23/38] chore: added a null check for content v1 spec file (#610) # Fixes # Added a null check for content_v1 file before removing it. ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository. --- scripts/build_twilio_library.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index 99efcd30f..14e3cd96a 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -32,7 +32,8 @@ def build(openapi_spec_path: str, output_path: str, language: str) -> None: else: spec_folder = openapi_spec_path spec_files = sorted(os.listdir(spec_folder)) - spec_files.remove('twilio_content_v1.json') + if 'twilio_content_v1.json' in spec_files: + spec_files.remove('twilio_content_v1.json') generate(spec_folder, spec_files, output_path, language) From 457304d2b31eba25c6e17d7803ab35e0a076b15d Mon Sep 17 00:00:00 2001 From: Shubham Date: Thu, 5 Sep 2024 15:32:24 +0530 Subject: [PATCH 24/38] chore: setting contentType correctly in java (#608) fixed contentType for twilio-java --- .../rest/previewiam/organizations/UserCreator.java | 2 +- .../rest/previewiam/organizations/UserUpdater.java | 2 +- .../com/twilio/oai/api/JavaApiResourceBuilder.java | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java index 6bdca6548..30ba8054f 100644 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java +++ b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserCreator.java @@ -79,7 +79,7 @@ public User create(final BearerTokenTwilioRestClient client){ Domains.PREVIEWIAM.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); Response response = client.request(request); if (response == null) { diff --git a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java index 5e5e82f58..f56013776 100644 --- a/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java +++ b/examples/java/src/main/java/com/twilio/rest/previewiam/organizations/UserUpdater.java @@ -82,7 +82,7 @@ public User update(final BearerTokenTwilioRestClient client){ Domains.PREVIEWIAM.toString(), path ); - request.setContentType(EnumConstants.ContentType.FORM_URLENCODED); + request.setContentType(EnumConstants.ContentType.JSON); addPostParams(request, client); addHeaderParams(request); Response response = client.request(request); diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 3e95f1123..7c71de2ca 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -96,16 +96,24 @@ public IApiResourceBuilder updateTemplate() { return this; } + private void populateContentType(CodegenOperation co) { + if(co.consumes != null && !co.consumes.isEmpty()) + co.consumes.forEach(consume -> { + if(consume.getOrDefault("mediaType", "").equals(CONTENT_TYPE_JSON)) + co.vendorExtensions.put("x-is-json", true); + }); + } + @Override public ApiResourceBuilder updateOperations(Resolver codegenParameterIResolver) { headerParamModelList = new HashSet<>(); JsonRequestBodyResolver jsonRequestBodyResolver = new JsonRequestBodyResolver(this, codegenPropertyIResolver); this.codegenOperationList.forEach(co -> { updateNestedContent(co); + populateContentType(co); updateHttpMethod(co); List filePathArray = new ArrayList<>(Arrays.asList(co.baseName.split(PATH_SEPARATOR_PLACEHOLDER))); String resourceName = filePathArray.remove(filePathArray.size()-1); - co.allParams.stream() .filter(item -> !(item.getContent() != null && item.getContent().get("application/json") != null)) @@ -631,7 +639,7 @@ public void addEnums(IJsonSchemaValidationProperties item) { } else { enumName = ((CodegenProperty) enumItem).enumName; } - + if (enumName.equals(newItemEnumName)) { isDuplicate = true; break; // No need to continue checking duplicates From bbe647304f0e963fee62c9c4a3af654bdc95d301 Mon Sep 17 00:00:00 2001 From: Shubham Date: Wed, 18 Sep 2024 12:27:17 +0530 Subject: [PATCH 25/38] chore: skipping isOverridden flag in distinctResponseModels (#611) --- examples/go/Dockerfile-goimports | 2 +- .../twilio/oai/api/ApiResourceBuilder.java | 9 +++++-- .../oai/api/CsharpApiResourceBuilder.java | 26 ++++++++++++------- .../oai/api/JavaApiResourceBuilder.java | 11 ++++++-- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/examples/go/Dockerfile-goimports b/examples/go/Dockerfile-goimports index 7747b9bfa..82ea98f65 100644 --- a/examples/go/Dockerfile-goimports +++ b/examples/go/Dockerfile-goimports @@ -1,6 +1,6 @@ FROM golang:1.18 ENV GOPATH /go -RUN go install golang.org/x/tools/cmd/goimports@latest +RUN go install golang.org/x/tools/cmd/goimports@v0.24.0 CMD goimports -w /local diff --git a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java index 36287c360..355268a87 100644 --- a/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/ApiResourceBuilder.java @@ -93,7 +93,7 @@ public ApiResourceBuilder updateOperations(Resolver codegenPar } public void updateHttpMethod(CodegenOperation co) { - + } protected void resolveParam(final Resolver codegenParameterIResolver, @@ -191,7 +191,7 @@ public CodegenModel getModel(String modelName ) { } return null; } - + public void addNestedModel(final CodegenModel codegenModel) { // TODO: Temporary fix, planning to use hashmap, set is inserting duplicate values. Iterator iterator = nestedModels.iterator(); @@ -290,12 +290,17 @@ protected Set getDistinctResponseModel(List respo for (CodegenModel codegenModel : responseModels) { for (CodegenProperty property : codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); + // When we have responseModel referencing a schema, isOverriden flag is set to false (which is null by default). This makes the property different. See assistants api ListAssistantResponse + Boolean isOverridden = property.isOverridden; + if(isOverridden != null && isOverridden == false) + property.isOverridden = null; if (Arrays .stream(Operation.values()) .anyMatch(value -> value.getValue().equals(property.nameInCamelCase))) { property.nameInCamelCase = "_" + property.nameInCamelCase; } distinctResponseModels.add(property); + property.isOverridden = isOverridden; } } return distinctResponseModels; diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index aeb37c28f..4a627a1ca 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -132,15 +132,19 @@ public void updateHttpMethod(CodegenOperation co) { } } + private void setDataType(CodegenParameter codegenParameter) { + for (CodegenModel codegenModel : getAllModels()) + if (codegenModel.classname.equals(codegenParameter.dataType)) + codegenParameter.dataType = getApiName() + "Resource" + ApplicationConstants.DOT + codegenParameter.dataType; + } + private void resolveIngressModel(CodegenOperation codegenOperation) { // Required params are used in parameters in C#, Check Params.mustache. - for (CodegenParameter codegenParameter: codegenOperation.requiredParams) { - for (CodegenModel codegenModel : getAllModels()) { - if (codegenModel.classname.equals(codegenParameter.paramName)) { - codegenParameter.dataType = getApiName() + "Resource" + ApplicationConstants.DOT + codegenParameter.dataType; - } - } - + for (CodegenParameter codegenParameter: codegenOperation.requiredParams) + setDataType(codegenParameter); + + for (CodegenParameter codegenParameter: codegenOperation.optionalParams) { + setDataType(codegenParameter); } } @@ -219,12 +223,16 @@ public Set getDistinctResponseModel(List response for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { property.nameInCamelCase = StringHelper.camelize(property.nameInSnakeCase); + Boolean isOverridden = property.isOverridden; + if(isOverridden != null && isOverridden == false) + property.isOverridden = null; if (Arrays.stream(EnumConstants.Operation.values()) - .anyMatch(value -> value.getValue().equals(property.nameInCamelCase)) + .anyMatch(value -> value.getValue().equals(property.nameInCamelCase)) || isNestedModelPresentWithPropertyName(property)) { property.nameInCamelCase = "_" + property.nameInCamelCase; } distinctResponseModels.add(property); + property.isOverridden = isOverridden; } } return distinctResponseModels; @@ -326,7 +334,7 @@ private void rearrangeBeforeAfter(final List parameters) { } public boolean isNestedModelPresentWithPropertyName(final CodegenProperty property) { - if (nestedModels == null || nestedModels.size() < 1) return false; + if (nestedModels == null || nestedModels.size() < 1) return false; Optional foundModel = nestedModels.stream() .filter(model -> model.classname.equals(property.name)) .findFirst(); diff --git a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java index 7c71de2ca..75b20d804 100644 --- a/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/JavaApiResourceBuilder.java @@ -610,8 +610,15 @@ private CodegenModel getConcatenatedResponseModel(List responseMod resModel.vendorExtensions.forEach( (key, value) -> codegenModel.vendorExtensions.merge(key, value, (oldValue, newValue) -> newValue)); } - - resModel.vars.stream().filter(Predicate.not(codegenProperties::contains)).forEach(codegenProperties::add); + resModel.vars.forEach(var -> { + Boolean isOverridden = var.isOverridden; + if(isOverridden != null && isOverridden == false) + var.isOverridden = null; + if(!codegenProperties.contains(var)) + codegenProperties.add(var); + var.isOverridden = isOverridden; + }); +// resModel.vars.stream().filter(Predicate.not(codegenProperties::contains)).forEach(codegenProperties::add); } codegenProperties.forEach(prop -> prop.baseName = StringHelper.camelize(prop.baseName, true)); From 6508649ed74cdbf71093aa79ca0688b066258b33 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 16:02:27 +0530 Subject: [PATCH 26/38] resolving merge conflicts --- .../com/twilio/oai/TwilioCsharpGenerator.java | 3 ++- .../twilio/oai/api/CsharpApiResourceBuilder.java | 9 ++++++++- .../twilio/oai/api/FluentApiResourceBuilder.java | 13 +++++++++++++ .../com/twilio/oai/api/IApiResourceBuilder.java | 1 + .../twilio/oai/api/NodeApiResourceBuilder.java | 16 ++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index f090cc404..9d6a81eca 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -48,6 +48,7 @@ public class TwilioCsharpGenerator extends CSharpClientCodegen { private final String EMPTY_STRING = ""; private final String ORGS_TOKEN_CLIENT = "TwilioOrgsTokenAuthClient"; private final String BASIC_CLIENT = "TwilioClient"; + private final DirectoryStructureService directoryStructureService = new DirectoryStructureService( additionalProperties, new ResourceMap(new Inflector()), @@ -170,13 +171,13 @@ private String fetchRestClientClassName(String authMethod){ private String processAuthMethods(List opList) { boolean isBasicAuthPresent = false; boolean isTokenAuthPresent = false; + if(opList != null){ List authMethods = opList.get(0).authMethods; if(authMethods != null){ for(CodegenSecurity c : authMethods){ if(c.isOAuth == true){ isTokenAuthPresent = true; - } if(c.isBasic == true){ isBasicAuthPresent = true; diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 4a627a1ca..5466bca82 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -110,7 +111,7 @@ public void processAuthMethods(List opList) { } else{ this.authMethod = EnumConstants.AuthType.NOAUTH.getValue(); - } + } } } @@ -219,6 +220,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP } public Set getDistinctResponseModel(List responseModels) { + HashSet modelVars = new HashSet<>(); Set distinctResponseModels = new LinkedHashSet<>(); for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { @@ -235,6 +237,11 @@ public Set getDistinctResponseModel(List response property.isOverridden = isOverridden; } } + for(CodegenProperty s : distinctResponseModels){ + if(modelVars.contains(s.name)){ + s.nameInCamelCase = "_" + s.nameInCamelCase; + }else modelVars.add(s.nameInCamelCase); + } return distinctResponseModels; } diff --git a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java index 492a0cb70..0183a7d08 100644 --- a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java @@ -54,6 +54,19 @@ public IApiResourceBuilder updateTemplate() { public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); + codegenOperationList.stream().filter(operation -> !operation.vendorExtensions.containsKey("x-ignore")).forEach(codegenOperation -> { + boolean isInstanceOperation = PathUtils.isInstanceOperation(codegenOperation); + if (!isInstanceOperation) { + listOperations.add(codegenOperation); + codegenOperation.vendorExtensions.put("listOperation", true); + metaAPIProperties.put("hasListOperation", true); + } else { + instanceOperations.add(codegenOperation); + codegenOperation.vendorExtensions.put("instanceOperation", true); + metaAPIProperties.put("hasInstanceOperation", true); + } + }); + for (final CodegenOperation co : codegenOperationList) { co.allParams.removeAll(co.pathParams); co.requiredParams.removeAll(co.pathParams); diff --git a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java index c0144caa2..95dc82a04 100644 --- a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java @@ -5,6 +5,7 @@ import com.twilio.oai.resolver.common.CodegenModelResolver; import com.twilio.oai.resolver.java.JavaPropertyResolver; import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 59ca136e8..0e0c771de 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -17,6 +17,7 @@ import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; +import static com.twilio.oai.DirectoryStructureService.VERSION_RESOURCES; import static com.twilio.oai.common.ApplicationConstants.HTTP_METHOD; import static com.twilio.oai.common.ApplicationConstants.STRING; @@ -37,9 +38,24 @@ public NodeApiResourceBuilder(final IApiActionTemplate template, this.toggleMap = toggleMap; } + private void updateVersionResources() { + var versionResources = (List) directoryStructureService.getAdditionalProperties().getOrDefault("versionResources", null); + if (versionResources != null) { + for (var versionResource : versionResources) { + //here "hasInstanceOperation" may be either null or false, so only set if it is true + if (versionResource.getResourceName().equals(getApiName()) && (boolean) metaAPIProperties.getOrDefault("hasInstanceOperation", false)) { + versionResource.setInstanceDependent(true); + } + } + var domain = (String) directoryStructureService.getAdditionalProperties().get("domainName"); + versionResources = versionResources.stream().filter(resource -> !(resource.getMountName().equals("account") && domain.equals("Api"))).collect(Collectors.toList()); + } + directoryStructureService.getAdditionalProperties().put(VERSION_RESOURCES, versionResources); + } @Override public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); + updateVersionResources(); final String apiName = getApiName(); final String resourceName = apiName + "Instance"; From b9176c36540acfe0f7221ea7a907524cc464c01a Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:46:12 +0530 Subject: [PATCH 27/38] orgs api uptake for twilio csharp --- .../java/com/twilio/oai/api/CsharpApiResourceBuilder.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 5466bca82..a5ba2434e 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -220,7 +220,6 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP } public Set getDistinctResponseModel(List responseModels) { - HashSet modelVars = new HashSet<>(); Set distinctResponseModels = new LinkedHashSet<>(); for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { @@ -237,11 +236,6 @@ public Set getDistinctResponseModel(List response property.isOverridden = isOverridden; } } - for(CodegenProperty s : distinctResponseModels){ - if(modelVars.contains(s.name)){ - s.nameInCamelCase = "_" + s.nameInCamelCase; - }else modelVars.add(s.nameInCamelCase); - } return distinctResponseModels; } From 80b24aabcc23ae4c5ad5ae083166d0e3d9aaf10e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:40:41 +0530 Subject: [PATCH 28/38] orgs api uptake for twilio csharp --- .../oai/api/CsharpApiResourceBuilder.java | 6 +++++ .../twilio/oai/api/CsharpApiResources.java | 6 +++++ .../twilio-csharp/Pagination.mustache | 20 ++++++++++++++ .../resource/CreateResource.mustache | 27 +++++++++++++++++++ .../resource/DeleteResource.mustache | 27 +++++++++++++++++++ .../resource/FetchResource.mustache | 27 +++++++++++++++++++ .../resource/ReadResource.mustache | 27 +++++++++++++++++++ .../resource/UpdateResource.mustache | 27 +++++++++++++++++++ 8 files changed, 167 insertions(+) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index a5ba2434e..5466bca82 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -220,6 +220,7 @@ public ApiResourceBuilder updateResponseModel(Resolver codegenP } public Set getDistinctResponseModel(List responseModels) { + HashSet modelVars = new HashSet<>(); Set distinctResponseModels = new LinkedHashSet<>(); for (CodegenModel codegenModel: responseModels) { for (CodegenProperty property: codegenModel.vars) { @@ -236,6 +237,11 @@ public Set getDistinctResponseModel(List response property.isOverridden = isOverridden; } } + for(CodegenProperty s : distinctResponseModels){ + if(modelVars.contains(s.name)){ + s.nameInCamelCase = "_" + s.nameInCamelCase; + }else modelVars.add(s.nameInCamelCase); + } return distinctResponseModels; } diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index 8920ac332..f25d137b0 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -11,11 +11,17 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String authMethod; +<<<<<<< HEAD @Getter @Setter private String resourceSetPrefix; @Getter @Setter private String domainClass; @Getter @Setter private String restClientMethodName; @Getter @Setter private String clientName; @Getter @Setter private String requestName; +======= + @Getter @Setter private String restClientPrefix; + @Getter @Setter private String resourceSetPrefix; + @Getter @Setter private String domainClassPrefix; +>>>>>>> a326080 (orgs api uptake for twilio csharp) List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); public String resourceConstant = ApplicationConstants.RESOURCE; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index 9d556062c..4a8108708 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -3,11 +3,19 @@ /// API-generated URL for the requested results page /// Client to make requests to Twilio /// The target page of records +<<<<<<< HEAD public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{clientName}} client) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); var request = new {{requestName}}Request( +======= + public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); + + var request = new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) HttpMethod.Get, targetUrl ); @@ -20,9 +28,15 @@ /// current page of records /// Client to make requests to Twilio /// The next page of records +<<<<<<< HEAD public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { var request = new {{requestName}}Request( +======= + public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + var request = new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) HttpMethod.Get, page.GetNextPageUrl(Rest.Domain.Api) ); @@ -35,9 +49,15 @@ /// current page of records /// Client to make requests to Twilio /// The previous page of records +<<<<<<< HEAD public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { var request = new {{requestName}}Request( +======= + public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + var request = new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) HttpMethod.Get, page.GetPreviousPageUrl(Rest.Domain.Api) ); diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index 14e5feed4..d9504cde0 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,8 +1,15 @@ +<<<<<<< HEAD private static {{requestName}}Request BuildCreateRequest(Create{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( +======= + private static {{authMethod}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + {{>resource/GeneratePath}} + return new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,9 +28,15 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} +<<<<<<< HEAD public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -33,9 +46,15 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} +<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -45,7 +64,11 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Create(options, client); @@ -56,7 +79,11 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await CreateAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index a21ca756b..e277c491a 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,10 +3,17 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} +<<<<<<< HEAD private static {{requestName}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( +======= + private static {{authMethod}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + {{>resource/GeneratePath}} + return new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -19,9 +26,15 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} +<<<<<<< HEAD public static bool Delete(Delete{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static bool Delete(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -32,9 +45,15 @@ /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, +<<<<<<< HEAD {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -42,7 +61,11 @@ {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} +<<<<<<< HEAD public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) +======= + public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}} {{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}} {{/vendorExtensions.x-request-body-param}} ; return Delete(options, client); @@ -51,7 +74,11 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} +<<<<<<< HEAD public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) +======= + public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}}{{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}}{{/vendorExtensions.x-request-body-param}}; return await DeleteAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index ede568d26..739cc7604 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,8 +1,15 @@ +<<<<<<< HEAD private static {{requestName}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( +======= + private static {{authMethod}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + {{>resource/GeneratePath}} + return new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -15,9 +22,15 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} +<<<<<<< HEAD public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -27,9 +40,15 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} +<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -38,7 +57,11 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Fetch({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}} +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Fetch(options, client); @@ -47,7 +70,11 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} +<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) +======= + public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await FetchAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index a5ead39b4..f93caef8b 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,8 +1,15 @@ +<<<<<<< HEAD private static {{requestName}}Request BuildReadRequest(Read{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( +======= + private static {{authMethod}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + {{>resource/GeneratePath}} + return new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -14,9 +21,15 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} +<<<<<<< HEAD public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); @@ -27,9 +40,15 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} +<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); @@ -41,7 +60,11 @@ public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return Read(options, client); @@ -53,7 +76,11 @@ public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return await ReadAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 9ce79f3c3..2d92c5849 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,8 +1,15 @@ +<<<<<<< HEAD private static {{requestName}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( +======= + private static {{authMethod}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) + { + {{>resource/GeneratePath}} + return new {{authMethod}}Request( +>>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,9 +28,15 @@ /// Update {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} +<<<<<<< HEAD public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -34,9 +47,15 @@ {{>resource/ReturnCommentsAsync}} #if !NET35 public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, +<<<<<<< HEAD {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) + { + client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); +>>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -46,7 +65,11 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Update(options, client); @@ -57,7 +80,11 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} +<<<<<<< HEAD {{clientName}} client = null) +======= + {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) +>>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await UpdateAsync(options, client); From 6ddab7635cd18981d6126b8cc7150a0f1f13b9ee Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Tue, 23 Jul 2024 08:40:41 +0530 Subject: [PATCH 29/38] orgs api uptake for twilio csharp --- .../com/twilio/oai/TwilioCsharpGenerator.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index 9d6a81eca..df5b0622a 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -46,9 +46,12 @@ public class TwilioCsharpGenerator extends CSharpClientCodegen { private final String BEARER_TOKEN_PREFIX = "BearerToken"; private final String NO_AUTH_PREFIX = "NoAuth"; private final String EMPTY_STRING = ""; +<<<<<<< HEAD private final String ORGS_TOKEN_CLIENT = "TwilioOrgsTokenAuthClient"; private final String BASIC_CLIENT = "TwilioClient"; +======= +>>>>>>> a93dd1b (orgs api uptake for twilio csharp) private final DirectoryStructureService directoryStructureService = new DirectoryStructureService( additionalProperties, new ResourceMap(new Inflector()), @@ -133,15 +136,22 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L final List opList = directoryStructureService.processOperations(results); CsharpApiResources apiResources = processCodegenOperations(opList); apiResources.setAuthMethod(processAuthMethods(opList)); +<<<<<<< HEAD apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); apiResources.setDomainClass(fetchDomainClass(apiResources.getAuthMethod())); apiResources.setRestClientMethodName(fetchRestClientClassName(apiResources.getAuthMethod())); apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); apiResources.setRequestName(fetchRequestName(apiResources.getAuthMethod())); +======= + apiResources.setRestClientPrefix(setRestClientPrefix(apiResources.getAuthMethod())); + apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); + apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); +>>>>>>> a93dd1b (orgs api uptake for twilio csharp) results.put("resources", apiResources); return results; } +<<<<<<< HEAD private String fetchDomainClass(String authMethod) { if(authMethod == BEARER_TOKEN_PREFIX || authMethod == NO_AUTH_PREFIX) return ORGS_TOKEN_CLIENT; return BASIC_CLIENT; @@ -172,23 +182,48 @@ private String processAuthMethods(List opList) { boolean isBasicAuthPresent = false; boolean isTokenAuthPresent = false; +======= + private String fetchDomainClassPrefix(String authMethod) { + if(authMethod == BEARER_TOKEN_PREFIX) return "OrgsTokenAuth"; + else if(authMethod == NO_AUTH_PREFIX) return NO_AUTH_PREFIX; + return EMPTY_STRING; + } + + private String setResourceSetPrefix(String authMethod){ + return authMethod == BEARER_TOKEN_PREFIX ? authMethod : EMPTY_STRING; + } + + private String setRestClientPrefix(String authMethod){ + return authMethod == EMPTY_STRING ? "I" : EMPTY_STRING; + } + + private String processAuthMethods(List opList) { +>>>>>>> a93dd1b (orgs api uptake for twilio csharp) if(opList != null){ List authMethods = opList.get(0).authMethods; if(authMethods != null){ for(CodegenSecurity c : authMethods){ if(c.isOAuth == true){ +<<<<<<< HEAD isTokenAuthPresent = true; } if(c.isBasic == true){ isBasicAuthPresent = true; +======= + return "BearerToken"; +>>>>>>> a93dd1b (orgs api uptake for twilio csharp) } } } else return "NoAuth"; } +<<<<<<< HEAD if(isBasicAuthPresent) return ""; return "BearerToken"; +======= + return ""; +>>>>>>> a93dd1b (orgs api uptake for twilio csharp) } @Override From 7bc8f1ec366664c1556d19c6715fbdf35d22e008 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 17:10:31 +0530 Subject: [PATCH 30/38] resolving conflicts --- .../com/twilio/oai/TwilioCsharpGenerator.java | 35 ------------------- .../twilio/oai/api/CsharpApiResources.java | 6 ---- .../twilio-csharp/Pagination.mustache | 20 ----------- .../resource/CreateResource.mustache | 27 -------------- .../resource/DeleteResource.mustache | 27 -------------- .../resource/FetchResource.mustache | 27 -------------- .../resource/ReadResource.mustache | 27 -------------- .../resource/UpdateResource.mustache | 27 -------------- 8 files changed, 196 deletions(-) diff --git a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java index df5b0622a..9d6a81eca 100644 --- a/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioCsharpGenerator.java @@ -46,12 +46,9 @@ public class TwilioCsharpGenerator extends CSharpClientCodegen { private final String BEARER_TOKEN_PREFIX = "BearerToken"; private final String NO_AUTH_PREFIX = "NoAuth"; private final String EMPTY_STRING = ""; -<<<<<<< HEAD private final String ORGS_TOKEN_CLIENT = "TwilioOrgsTokenAuthClient"; private final String BASIC_CLIENT = "TwilioClient"; -======= ->>>>>>> a93dd1b (orgs api uptake for twilio csharp) private final DirectoryStructureService directoryStructureService = new DirectoryStructureService( additionalProperties, new ResourceMap(new Inflector()), @@ -136,22 +133,15 @@ public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, L final List opList = directoryStructureService.processOperations(results); CsharpApiResources apiResources = processCodegenOperations(opList); apiResources.setAuthMethod(processAuthMethods(opList)); -<<<<<<< HEAD apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); apiResources.setDomainClass(fetchDomainClass(apiResources.getAuthMethod())); apiResources.setRestClientMethodName(fetchRestClientClassName(apiResources.getAuthMethod())); apiResources.setClientName(fetchClientName(apiResources.getAuthMethod())); apiResources.setRequestName(fetchRequestName(apiResources.getAuthMethod())); -======= - apiResources.setRestClientPrefix(setRestClientPrefix(apiResources.getAuthMethod())); - apiResources.setResourceSetPrefix(setResourceSetPrefix(apiResources.getAuthMethod())); - apiResources.setDomainClassPrefix(fetchDomainClassPrefix(apiResources.getAuthMethod())); ->>>>>>> a93dd1b (orgs api uptake for twilio csharp) results.put("resources", apiResources); return results; } -<<<<<<< HEAD private String fetchDomainClass(String authMethod) { if(authMethod == BEARER_TOKEN_PREFIX || authMethod == NO_AUTH_PREFIX) return ORGS_TOKEN_CLIENT; return BASIC_CLIENT; @@ -182,48 +172,23 @@ private String processAuthMethods(List opList) { boolean isBasicAuthPresent = false; boolean isTokenAuthPresent = false; -======= - private String fetchDomainClassPrefix(String authMethod) { - if(authMethod == BEARER_TOKEN_PREFIX) return "OrgsTokenAuth"; - else if(authMethod == NO_AUTH_PREFIX) return NO_AUTH_PREFIX; - return EMPTY_STRING; - } - - private String setResourceSetPrefix(String authMethod){ - return authMethod == BEARER_TOKEN_PREFIX ? authMethod : EMPTY_STRING; - } - - private String setRestClientPrefix(String authMethod){ - return authMethod == EMPTY_STRING ? "I" : EMPTY_STRING; - } - - private String processAuthMethods(List opList) { ->>>>>>> a93dd1b (orgs api uptake for twilio csharp) if(opList != null){ List authMethods = opList.get(0).authMethods; if(authMethods != null){ for(CodegenSecurity c : authMethods){ if(c.isOAuth == true){ -<<<<<<< HEAD isTokenAuthPresent = true; } if(c.isBasic == true){ isBasicAuthPresent = true; -======= - return "BearerToken"; ->>>>>>> a93dd1b (orgs api uptake for twilio csharp) } } } else return "NoAuth"; } -<<<<<<< HEAD if(isBasicAuthPresent) return ""; return "BearerToken"; -======= - return ""; ->>>>>>> a93dd1b (orgs api uptake for twilio csharp) } @Override diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResources.java b/src/main/java/com/twilio/oai/api/CsharpApiResources.java index f25d137b0..8920ac332 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResources.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResources.java @@ -11,17 +11,11 @@ public class CsharpApiResources extends ApiResources { @Getter @Setter private String authMethod; -<<<<<<< HEAD @Getter @Setter private String resourceSetPrefix; @Getter @Setter private String domainClass; @Getter @Setter private String restClientMethodName; @Getter @Setter private String clientName; @Getter @Setter private String requestName; -======= - @Getter @Setter private String restClientPrefix; - @Getter @Setter private String resourceSetPrefix; - @Getter @Setter private String domainClassPrefix; ->>>>>>> a326080 (orgs api uptake for twilio csharp) List enums = new ArrayList<>(OperationStore.getInstance().getEnums().values()); public String resourceConstant = ApplicationConstants.RESOURCE; diff --git a/src/main/resources/twilio-csharp/Pagination.mustache b/src/main/resources/twilio-csharp/Pagination.mustache index 4a8108708..9d556062c 100644 --- a/src/main/resources/twilio-csharp/Pagination.mustache +++ b/src/main/resources/twilio-csharp/Pagination.mustache @@ -3,19 +3,11 @@ /// API-generated URL for the requested results page /// Client to make requests to Twilio /// The target page of records -<<<<<<< HEAD public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{clientName}} client) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); var request = new {{requestName}}Request( -======= - public static Page<{{apiName}}{{resourceConstant}}> GetPage(string targetUrl, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); - - var request = new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) HttpMethod.Get, targetUrl ); @@ -28,15 +20,9 @@ /// current page of records /// Client to make requests to Twilio /// The next page of records -<<<<<<< HEAD public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { var request = new {{requestName}}Request( -======= - public static Page<{{apiName}}{{resourceConstant}}> NextPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - var request = new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) HttpMethod.Get, page.GetNextPageUrl(Rest.Domain.Api) ); @@ -49,15 +35,9 @@ /// current page of records /// Client to make requests to Twilio /// The previous page of records -<<<<<<< HEAD public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{clientName}} client) { var request = new {{requestName}}Request( -======= - public static Page<{{apiName}}{{resourceConstant}}> PreviousPage(Page<{{apiName}}{{resourceConstant}}> page, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - var request = new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) HttpMethod.Get, page.GetPreviousPageUrl(Rest.Domain.Api) ); diff --git a/src/main/resources/twilio-csharp/resource/CreateResource.mustache b/src/main/resources/twilio-csharp/resource/CreateResource.mustache index d9504cde0..14e5feed4 100644 --- a/src/main/resources/twilio-csharp/resource/CreateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/CreateResource.mustache @@ -1,15 +1,8 @@ -<<<<<<< HEAD private static {{requestName}}Request BuildCreateRequest(Create{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( -======= - private static {{authMethod}}Request BuildCreateRequest(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - {{>resource/GeneratePath}} - return new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -28,15 +21,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} -<<<<<<< HEAD public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static {{apiName}}{{resourceConstant}} Create(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -46,15 +33,9 @@ /// Create {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} -<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync(Create{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildCreateRequest(options, client)); return FromJson(response.Content); } @@ -64,11 +45,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Create({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Create(options, client); @@ -79,11 +56,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> CreateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Create{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}} {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await CreateAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache index e277c491a..a21ca756b 100644 --- a/src/main/resources/twilio-csharp/resource/DeleteResource.mustache +++ b/src/main/resources/twilio-csharp/resource/DeleteResource.mustache @@ -3,17 +3,10 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} -<<<<<<< HEAD private static {{requestName}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( -======= - private static {{authMethod}}Request BuildDeleteRequest(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - {{>resource/GeneratePath}} - return new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -26,15 +19,9 @@ /// Delete {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} -<<<<<<< HEAD public static bool Delete(Delete{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static bool Delete(Delete{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -45,15 +32,9 @@ /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task DeleteAsync(Delete{{apiName}}Options options, -<<<<<<< HEAD {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildDeleteRequest(options, client)); return response.StatusCode == System.Net.HttpStatusCode.NoContent; } @@ -61,11 +42,7 @@ {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnComments}} -<<<<<<< HEAD public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) -======= - public static bool Delete({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}} {{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}} {{/vendorExtensions.x-request-body-param}} ; return Delete(options, client); @@ -74,11 +51,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} -<<<<<<< HEAD public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) -======= - public static async System.Threading.Tasks.Task DeleteAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Delete{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}) {{#vendorExtensions.x-request-body-param}}{{^required}} { {{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}} }{{/required}}{{/vendorExtensions.x-request-body-param}}; return await DeleteAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/FetchResource.mustache b/src/main/resources/twilio-csharp/resource/FetchResource.mustache index 739cc7604..ede568d26 100644 --- a/src/main/resources/twilio-csharp/resource/FetchResource.mustache +++ b/src/main/resources/twilio-csharp/resource/FetchResource.mustache @@ -1,15 +1,8 @@ -<<<<<<< HEAD private static {{requestName}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( -======= - private static {{authMethod}}Request BuildFetchRequest(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - {{>resource/GeneratePath}} - return new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -22,15 +15,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} -<<<<<<< HEAD public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static {{apiName}}Resource Fetch(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -40,15 +27,9 @@ /// Fetch {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} -<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static async System.Threading.Tasks.Task<{{apiName}}Resource> FetchAsync(Fetch{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } @@ -57,11 +38,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Fetch({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}} -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Fetch(options, client); @@ -70,11 +47,7 @@ #if !NET35 {{>Summary}}{{>resource/MethodsComments}} {{>resource/ReturnCommentsAsync}} -<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{clientName}} client = null) -======= - public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> FetchAsync({{#vendorExtensions.x-request-body-param}}{{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}}, {{/vendorExtensions.x-request-body-param}}{{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Fetch{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await FetchAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/ReadResource.mustache b/src/main/resources/twilio-csharp/resource/ReadResource.mustache index f93caef8b..a5ead39b4 100644 --- a/src/main/resources/twilio-csharp/resource/ReadResource.mustache +++ b/src/main/resources/twilio-csharp/resource/ReadResource.mustache @@ -1,15 +1,8 @@ -<<<<<<< HEAD private static {{requestName}}Request BuildReadRequest(Read{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( -======= - private static {{authMethod}}Request BuildReadRequest(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - {{>resource/GeneratePath}} - return new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -21,15 +14,9 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} -<<<<<<< HEAD public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); return new {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>(page, options, client); @@ -40,15 +27,9 @@ /// Read {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnCommentsAsync}} -<<<<<<< HEAD public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync(Read{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildReadRequest(options, client)); var page = Page<{{apiName}}{{resourceConstant}}>.FromJson("{{recordKey}}", response.Content); @@ -60,11 +41,7 @@ public static {{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}> Read({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return Read(options, client); @@ -76,11 +53,7 @@ public static async System.Threading.Tasks.Task<{{resourceSetPrefix}}ResourceSet<{{apiName}}{{resourceConstant}}>> ReadAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} long? limit = null, -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Read{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/required}}{{/vendorExtensions.x-request-body-param}}Limit = limit}; return await ReadAsync(options, client); diff --git a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache index 2d92c5849..9ce79f3c3 100644 --- a/src/main/resources/twilio-csharp/resource/UpdateResource.mustache +++ b/src/main/resources/twilio-csharp/resource/UpdateResource.mustache @@ -1,15 +1,8 @@ -<<<<<<< HEAD private static {{requestName}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{clientName}} client) { {{>resource/GeneratePath}} return new {{requestName}}Request( -======= - private static {{authMethod}}Request BuildUpdateRequest(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client) - { - {{>resource/GeneratePath}} - return new {{authMethod}}Request( ->>>>>>> a326080 (orgs api uptake for twilio csharp) {{vendorExtensions.x-http-method}}, Rest.Domain.{{domainPackage}}, path, @@ -28,15 +21,9 @@ /// Update {{apiName}} parameters /// Client to make requests to Twilio {{>resource/ReturnComments}} -<<<<<<< HEAD public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - public static {{apiName}}{{resourceConstant}} Update(Update{{apiName}}Options options, {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = client.Request(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -47,15 +34,9 @@ {{>resource/ReturnCommentsAsync}} #if !NET35 public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync(Update{{apiName}}Options options, -<<<<<<< HEAD {{clientName}} client = null) { client = client ?? {{domainClass}}.{{restClientMethodName}}(); -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) - { - client = client ?? Twilio{{domainClassPrefix}}Client.GetRestClient(); ->>>>>>> a326080 (orgs api uptake for twilio csharp) var response = await client.RequestAsync(BuildUpdateRequest(options, client)); return FromJson(response.Content); } @@ -65,11 +46,7 @@ {{>resource/ReturnComments}} public static {{apiName}}{{resourceConstant}} Update({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return Update(options, client); @@ -80,11 +57,7 @@ {{>resource/ReturnCommentsAsync}} public static async System.Threading.Tasks.Task<{{apiName}}{{resourceConstant}}> UpdateAsync({{#vendorExtensions.x-request-body-param}} {{{dataType}}} {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^required}} = null{{/required}},{{/vendorExtensions.x-request-body-param}} -<<<<<<< HEAD {{clientName}} client = null) -======= - {{restClientPrefix}}Twilio{{authMethod}}RestClient client = null) ->>>>>>> a326080 (orgs api uptake for twilio csharp) { var options = new Update{{apiName}}Options({{#requiredParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/requiredParams}}){ {{#vendorExtensions.x-request-body-param}}{{^required}}{{paramName}} = {{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/required}}{{/vendorExtensions.x-request-body-param}} }; return await UpdateAsync(options, client); From b3929d2e67de634c8a3833a6338345ef8ccd5b66 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 17:18:19 +0530 Subject: [PATCH 31/38] auth method processing changes --- .../com/twilio/oai/api/CsharpApiResourceBuilder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java index 5466bca82..464781f7f 100644 --- a/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/CsharpApiResourceBuilder.java @@ -100,13 +100,21 @@ public ApiResourceBuilder updateOperations(Resolver codegenPar } public void processAuthMethods(List opList) { + boolean isBasicAuthPresent = false; + boolean isTokenAuthPresent = false; if(opList != null){ List authMethods = opList.get(0).authMethods; if(authMethods != null){ for(CodegenSecurity c : authMethods){ if(c.isOAuth == true){ - this.authMethod = EnumConstants.AuthType.BEARER_TOKEN.getValue(); + isTokenAuthPresent = true; } + if(c.isBasic == true){ + isBasicAuthPresent = true; + } + } + if(isBasicAuthPresent != true && isTokenAuthPresent){ + this.authMethod = EnumConstants.AuthType.BEARER_TOKEN.getValue(); } } else{ From 98b9f195093f83123d9e739b108da3c949c3272e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 17:21:28 +0530 Subject: [PATCH 32/38] removing unwanted changes --- .../twilio/oai/api/FluentApiResourceBuilder.java | 13 ------------- .../com/twilio/oai/api/IApiResourceBuilder.java | 1 - .../twilio/oai/api/NodeApiResourceBuilder.java | 16 ---------------- 3 files changed, 30 deletions(-) diff --git a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java index 0183a7d08..492a0cb70 100644 --- a/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/FluentApiResourceBuilder.java @@ -54,19 +54,6 @@ public IApiResourceBuilder updateTemplate() { public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); - codegenOperationList.stream().filter(operation -> !operation.vendorExtensions.containsKey("x-ignore")).forEach(codegenOperation -> { - boolean isInstanceOperation = PathUtils.isInstanceOperation(codegenOperation); - if (!isInstanceOperation) { - listOperations.add(codegenOperation); - codegenOperation.vendorExtensions.put("listOperation", true); - metaAPIProperties.put("hasListOperation", true); - } else { - instanceOperations.add(codegenOperation); - codegenOperation.vendorExtensions.put("instanceOperation", true); - metaAPIProperties.put("hasInstanceOperation", true); - } - }); - for (final CodegenOperation co : codegenOperationList) { co.allParams.removeAll(co.pathParams); co.requiredParams.removeAll(co.pathParams); diff --git a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java index 95dc82a04..c0144caa2 100644 --- a/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/IApiResourceBuilder.java @@ -5,7 +5,6 @@ import com.twilio.oai.resolver.common.CodegenModelResolver; import com.twilio.oai.resolver.java.JavaPropertyResolver; import org.openapitools.codegen.CodegenModel; -import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; diff --git a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java index 0e0c771de..59ca136e8 100644 --- a/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java +++ b/src/main/java/com/twilio/oai/api/NodeApiResourceBuilder.java @@ -17,7 +17,6 @@ import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenProperty; -import static com.twilio.oai.DirectoryStructureService.VERSION_RESOURCES; import static com.twilio.oai.common.ApplicationConstants.HTTP_METHOD; import static com.twilio.oai.common.ApplicationConstants.STRING; @@ -38,24 +37,9 @@ public NodeApiResourceBuilder(final IApiActionTemplate template, this.toggleMap = toggleMap; } - private void updateVersionResources() { - var versionResources = (List) directoryStructureService.getAdditionalProperties().getOrDefault("versionResources", null); - if (versionResources != null) { - for (var versionResource : versionResources) { - //here "hasInstanceOperation" may be either null or false, so only set if it is true - if (versionResource.getResourceName().equals(getApiName()) && (boolean) metaAPIProperties.getOrDefault("hasInstanceOperation", false)) { - versionResource.setInstanceDependent(true); - } - } - var domain = (String) directoryStructureService.getAdditionalProperties().get("domainName"); - versionResources = versionResources.stream().filter(resource -> !(resource.getMountName().equals("account") && domain.equals("Api"))).collect(Collectors.toList()); - } - directoryStructureService.getAdditionalProperties().put(VERSION_RESOURCES, versionResources); - } @Override public ApiResourceBuilder updateOperations(final Resolver codegenParameterIResolver) { super.updateOperations(codegenParameterIResolver); - updateVersionResources(); final String apiName = getApiName(); final String resourceName = apiName + "Instance"; From a9dbbd4d52e92cd1e47b0288273174d6bed9f90e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 17:24:54 +0530 Subject: [PATCH 33/38] excluding other languages from generation --- scripts/generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.sh b/scripts/generate.sh index bcedb4714..31ee69b4d 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -17,7 +17,7 @@ function generate() { rm -rf tmp mkdir -p tmp for api_spec in $files_regex; do - if [ "$1" != "twilio-java" && "$1" != "twilio-csharp"] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then + if [ "$1" != "twilio-java" || "$1" != "twilio-csharp"] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then continue fi echo "generatorName: $1 From 918725d508f29f5c1986f33d6c5a17bf54e90d5b Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 18:09:33 +0530 Subject: [PATCH 34/38] test files --- .../Call/FeedbackCallSummaryResource.cs | 8 +- .../Rest/Api/V2010/Account/CallResource.cs | 16 +- .../Twilio/Rest/Api/V2010/AccountResource.cs | 29 +- examples/csharp/src/Twilio/Rest/Domain.cs | 1 + .../Twilio/Rest/FlexApi/V1/CallResource.cs | 8 +- .../V1/Credential/Aws/HistoryResource.cs | 7 +- .../Rest/FlexApi/V1/Credential/AwsResource.cs | 22 +- .../V1/Credential/NewCredentialsResource.cs | 9 +- .../PreviewIam/Organizations/UserOptions.cs | 225 ++++++ .../PreviewIam/Organizations/UserResource.cs | 749 ++++++++++++++++++ .../Twilio/Rest/PreviewIam/V1/TokenOptions.cs | 110 +++ .../Rest/PreviewIam/V1/TokenResource.cs | 195 +++++ .../DeployedDevices/FleetResource.cs | 14 +- .../Understand/AssistantResource.cs | 9 +- examples/prism/docker-compose.yml | 1 - scripts/generate.sh | 2 +- 16 files changed, 1345 insertions(+), 60 deletions(-) create mode 100644 examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs create mode 100644 examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs create mode 100644 examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs create mode 100644 examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs diff --git a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs index 1081d3a76..91e2b7351 100644 --- a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs +++ b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/Call/FeedbackCallSummaryResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.Api.V2010.Account.Call { public class FeedbackCallSummaryResource : Resource @@ -88,7 +90,7 @@ public static FeedbackCallSummaryResource Update(UpdateFeedbackCallSummaryOption /// Task that resolves to A single instance of FeedbackCallSummary #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateFeedbackCallSummaryOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -110,7 +112,7 @@ public static FeedbackCallSummaryResource Update( DateTime? startDate, string pathAccountSid = null, string accountSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateFeedbackCallSummaryOptions(pathSid, endDate, startDate){ PathAccountSid = pathAccountSid, AccountSid = accountSid }; return Update(options, client); @@ -131,7 +133,7 @@ public static async System.Threading.Tasks.Task Upd DateTime? startDate, string pathAccountSid = null, string accountSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateFeedbackCallSummaryOptions(pathSid, endDate, startDate){ PathAccountSid = pathAccountSid, AccountSid = accountSid }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs index 92b48c64b..7f0c78496 100644 --- a/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs +++ b/examples/csharp/src/Twilio/Rest/Api/V2010/Account/CallResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.Api.V2010.Account { public class CallResource : Resource @@ -85,8 +87,7 @@ public static CallResource Create(CreateCallOptions options, ITwilioRestClient c /// Create Call parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task CreateAsync(CreateCallOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateCallOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -108,7 +109,7 @@ public static CallResource Create( string pathAccountSid = null, List testArrayOfStrings = null, List testArrayOfUri = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateCallOptions(requiredStringProperty, testMethod){ PathAccountSid = pathAccountSid, TestArrayOfStrings = testArrayOfStrings, TestArrayOfUri = testArrayOfUri }; return Create(options, client); @@ -129,7 +130,7 @@ public static async System.Threading.Tasks.Task CreateAsync( string pathAccountSid = null, List testArrayOfStrings = null, List testArrayOfUri = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateCallOptions(requiredStringProperty, testMethod){ PathAccountSid = pathAccountSid, TestArrayOfStrings = testArrayOfStrings, TestArrayOfUri = testArrayOfUri }; return await CreateAsync(options, client); @@ -176,7 +177,7 @@ public static bool Delete(DeleteCallOptions options, ITwilioRestClient client = /// Client to make requests to Twilio /// Task that resolves to A single instance of Call public static async System.Threading.Tasks.Task DeleteAsync(DeleteCallOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -243,8 +244,7 @@ public static CallResource Fetch(FetchCallOptions options, ITwilioRestClient cli /// Fetch Call parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Call - public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchCallOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -259,7 +259,7 @@ public static async System.Threading.Tasks.Task FetchAsync(FetchCa public static CallResource Fetch( int? pathTestInteger, string pathAccountSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchCallOptions(pathTestInteger){ PathAccountSid = pathAccountSid }; return Fetch(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs b/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs index 7043f5a2a..77545c99d 100644 --- a/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs +++ b/examples/csharp/src/Twilio/Rest/Api/V2010/AccountResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.Api.V2010 { public class AccountResource : Resource @@ -95,8 +97,7 @@ public static AccountResource Create(CreateAccountOptions options, ITwilioRestCl /// Create Account parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task CreateAsync(CreateAccountOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateAccountOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -116,7 +117,7 @@ public static AccountResource Create( List recordingStatusCallbackEvent = null, Types.Twiml twiml = null, AccountResource.XTwilioWebhookEnabledEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateAccountOptions(){ RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Twiml = twiml, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; return Create(options, client); @@ -135,7 +136,7 @@ public static async System.Threading.Tasks.Task CreateAsync( List recordingStatusCallbackEvent = null, Types.Twiml twiml = null, AccountResource.XTwilioWebhookEnabledEnum xTwilioWebhookEnabled = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateAccountOptions(){ RecordingStatusCallback = recordingStatusCallback, RecordingStatusCallbackEvent = recordingStatusCallbackEvent, Twiml = twiml, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; return await CreateAsync(options, client); @@ -180,7 +181,7 @@ public static bool Delete(DeleteAccountOptions options, ITwilioRestClient client /// Client to make requests to Twilio /// Task that resolves to A single instance of Account public static async System.Threading.Tasks.Task DeleteAsync(DeleteAccountOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -243,8 +244,7 @@ public static AccountResource Fetch(FetchAccountOptions options, ITwilioRestClie /// Fetch Account parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task FetchAsync(FetchAccountOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchAccountOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -257,7 +257,7 @@ public static async System.Threading.Tasks.Task FetchAsync(Fetc /// A single instance of Account public static AccountResource Fetch( string pathSid = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchAccountOptions(){ PathSid = pathSid }; return Fetch(options, client); @@ -306,8 +306,7 @@ public static ResourceSet Read(ReadAccountOptions options, ITwi /// Read Account parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Account - public static async System.Threading.Tasks.Task> ReadAsync(ReadAccountOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAccountOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -332,7 +331,7 @@ public static ResourceSet Read( DateTime? dateCreatedAfter = null, int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAccountOptions(){ DateCreated = dateCreated, DateTest = dateTest, DateCreatedBefore = dateCreatedBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; return Read(options, client); @@ -355,7 +354,7 @@ public static async System.Threading.Tasks.Task> Re DateTime? dateCreatedAfter = null, int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAccountOptions(){ DateCreated = dateCreated, DateTest = dateTest, DateCreatedBefore = dateCreatedBefore, DateCreatedAfter = dateCreatedAfter, PageSize = pageSize, Limit = limit}; return await ReadAsync(options, client); @@ -446,7 +445,7 @@ public static AccountResource Update(UpdateAccountOptions options, ITwilioRestCl /// Task that resolves to A single instance of Account #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateAccountOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -464,7 +463,7 @@ public static AccountResource Update( AccountResource.StatusEnum status, string pathSid = null, string pauseBehavior = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAccountOptions(status){ PathSid = pathSid, PauseBehavior = pauseBehavior }; return Update(options, client); @@ -481,7 +480,7 @@ public static async System.Threading.Tasks.Task UpdateAsync( AccountResource.StatusEnum status, string pathSid = null, string pauseBehavior = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAccountOptions(status){ PathSid = pathSid, PauseBehavior = pauseBehavior }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Domain.cs b/examples/csharp/src/Twilio/Rest/Domain.cs index 1e97dbdb2..0440f1f2d 100644 --- a/examples/csharp/src/Twilio/Rest/Domain.cs +++ b/examples/csharp/src/Twilio/Rest/Domain.cs @@ -14,5 +14,6 @@ public static implicit operator Domain(string value) public static readonly Domain Api = new Domain("api"); public static readonly Domain FlexApi = new Domain("flex-api"); public static readonly Domain Versionless = new Domain("versionless"); + public static readonly Domain PreviewIam = new Domain("preview-iam"); } } diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs index e09f5cbed..17d61aa0a 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/CallResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.FlexApi.V1 { public class CallResource : Resource @@ -69,7 +71,7 @@ public static CallResource Update(UpdateCallOptions options, ITwilioRestClient c /// Task that resolves to A single instance of Call #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateCallOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -83,7 +85,7 @@ public static async System.Threading.Tasks.Task UpdateAsync(Update /// A single instance of Call public static CallResource Update( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateCallOptions(pathSid){ }; return Update(options, client); @@ -96,7 +98,7 @@ public static CallResource Update( /// Task that resolves to A single instance of Call public static async System.Threading.Tasks.Task UpdateAsync( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateCallOptions(pathSid){ }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs index edb7bb8f2..52d16c36f 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/Aws/HistoryResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.FlexApi.V1.Credential.Aws { public class HistoryResource : Resource @@ -67,8 +69,7 @@ public static HistoryResource Fetch(FetchHistoryOptions options, ITwilioRestClie /// Fetch History parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of History - public static async System.Threading.Tasks.Task FetchAsync(FetchHistoryOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchHistoryOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -83,7 +84,7 @@ public static async System.Threading.Tasks.Task FetchAsync(Fetc public static HistoryResource Fetch( string pathSid, Dictionary addOnsData = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchHistoryOptions(pathSid){ AddOnsData = addOnsData }; return Fetch(options, client); diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs index 20abf0368..8b9f121fb 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/AwsResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.FlexApi.V1.Credential { public class AwsResource : Resource @@ -72,7 +74,7 @@ public static bool Delete(DeleteAwsOptions options, ITwilioRestClient client = n /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws public static async System.Threading.Tasks.Task DeleteAsync(DeleteAwsOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildDeleteRequest(options, client)); @@ -135,8 +137,7 @@ public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient clien /// Fetch Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -149,7 +150,7 @@ public static async System.Threading.Tasks.Task FetchAsync(FetchAws /// A single instance of Aws public static AwsResource Fetch( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchAwsOptions(pathSid){ }; return Fetch(options, client); @@ -198,8 +199,7 @@ public static ResourceSet Read(ReadAwsOptions options, ITwilioRestC /// Read Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -216,7 +216,7 @@ public static async System.Threading.Tasks.Task> ReadAs public static ResourceSet Read( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAwsOptions(){ PageSize = pageSize, Limit = limit}; return Read(options, client); @@ -231,7 +231,7 @@ public static ResourceSet Read( public static async System.Threading.Tasks.Task> ReadAsync( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAwsOptions(){ PageSize = pageSize, Limit = limit}; return await ReadAsync(options, client); @@ -322,7 +322,7 @@ public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient cli /// Task that resolves to A single instance of Aws #if !NET35 public static async System.Threading.Tasks.Task UpdateAsync(UpdateAwsOptions options, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); @@ -340,7 +340,7 @@ public static AwsResource Update( string pathSid, string testString = null, bool? testBoolean = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAwsOptions(pathSid){ TestString = testString, TestBoolean = testBoolean }; return Update(options, client); @@ -357,7 +357,7 @@ public static async System.Threading.Tasks.Task UpdateAsync( string pathSid, string testString = null, bool? testBoolean = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new UpdateAwsOptions(pathSid){ TestString = testString, TestBoolean = testBoolean }; return await UpdateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs index 29ab953c6..8b9293561 100644 --- a/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs +++ b/examples/csharp/src/Twilio/Rest/FlexApi/V1/Credential/NewCredentialsResource.cs @@ -25,6 +25,8 @@ using Twilio.Types; + + namespace Twilio.Rest.FlexApi.V1.Credential { public class NewCredentialsResource : Resource @@ -94,8 +96,7 @@ public static NewCredentialsResource Create(CreateNewCredentialsOptions options, /// Create NewCredentials parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of NewCredentials - public static async System.Threading.Tasks.Task CreateAsync(CreateNewCredentialsOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateNewCredentialsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -141,7 +142,7 @@ public static NewCredentialsResource Create( List testAnyArray = null, List permissions = null, string someA2PThing = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateNewCredentialsOptions(testString){ TestInteger = testInteger, TestDate = testDate, TestNumberFloat = testNumberFloat, TestObject = testObject, TestBoolean = testBoolean, TestNumber = testNumber, TestNumberDouble = testNumberDouble, TestNumberInt32 = testNumberInt32, TestNumberInt64 = testNumberInt64, TestDateTime = testDateTime, TestEnum = testEnum, TestObjectArray = testObjectArray, TestAnyType = testAnyType, TestAnyArray = testAnyArray, Permissions = permissions, SomeA2PThing = someA2PThing }; return Create(options, client); @@ -186,7 +187,7 @@ public static async System.Threading.Tasks.Task CreateAs List testAnyArray = null, List permissions = null, string someA2PThing = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateNewCredentialsOptions(testString){ TestInteger = testInteger, TestDate = testDate, TestNumberFloat = testNumberFloat, TestObject = testObject, TestBoolean = testBoolean, TestNumber = testNumber, TestNumberDouble = testNumberDouble, TestNumberInt32 = testNumberInt32, TestNumberInt64 = testNumberInt64, TestDateTime = testDateTime, TestEnum = testEnum, TestObjectArray = testObjectArray, TestAnyType = testAnyType, TestAnyArray = testAnyArray, Permissions = permissions, SomeA2PThing = someA2PThing }; return await CreateAsync(options, client); diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs new file mode 100644 index 000000000..e0e20bc05 --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserOptions.cs @@ -0,0 +1,225 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Organization Public API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Converters; + + + + +namespace Twilio.Rest.PreviewIam.Organizations +{ + + /// create + public class CreateUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public UserResource.ScimUser ScimUser { get; } + + + /// Construct a new CreateOrganizationUserOptions + /// + /// + public CreateUserOptions(string pathOrganizationSid, UserResource.ScimUser scimUser) + { + PathOrganizationSid = pathOrganizationSid; + ScimUser = scimUser; + } + + + /// Generate the request body + public string GetBody() + { + string body = ""; + + if (ScimUser != null) + { + body = UserResource.ToJson(ScimUser); + } + return body; + } + + + } + /// delete + public class DeleteUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public string PathUserSid { get; } + + + + /// Construct a new DeleteOrganizationUserOptions + /// + /// + public DeleteUserOptions(string pathOrganizationSid, string pathUserSid) + { + PathOrganizationSid = pathOrganizationSid; + PathUserSid = pathUserSid; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + return p; + } + + + + } + + + /// fetch + public class FetchUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public string PathUserSid { get; } + + + + /// Construct a new FetchOrganizationUserOptions + /// + /// + public FetchUserOptions(string pathOrganizationSid, string pathUserSid) + { + PathOrganizationSid = pathOrganizationSid; + PathUserSid = pathUserSid; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + return p; + } + + + + } + + + /// read + public class ReadUserOptions : ReadOptions + { + + + public string PathOrganizationSid { get; } + + + public string Filter { get; set; } + + + + /// Construct a new ListOrganizationUsersOptions + /// + public ReadUserOptions(string pathOrganizationSid) + { + PathOrganizationSid = pathOrganizationSid; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + if (Filter != null) + { + p.Add(new KeyValuePair("filter", Filter)); + } + return p; + } + + + + } + + /// update + public class UpdateUserOptions : IOptions + { + + + public string PathOrganizationSid { get; } + + + public string PathUserSid { get; } + + + public UserResource.ScimUser ScimUser { get; } + + + public string IfMatch { get; set; } + + + + /// Construct a new UpdateOrganizationUserOptions + /// + /// + /// + public UpdateUserOptions(string pathOrganizationSid, string pathUserSid, UserResource.ScimUser scimUser) + { + PathOrganizationSid = pathOrganizationSid; + PathUserSid = pathUserSid; + ScimUser = scimUser; + } + + + /// Generate the request body + public string GetBody() + { + string body = ""; + + if (ScimUser != null) + { + body = UserResource.ToJson(ScimUser); + } + return body; + } + + /// Generate the necessary header parameters + public List> GetHeaderParams() + { + var p = new List>(); + if (IfMatch != null) + { + p.Add(new KeyValuePair("If-Match", IfMatch)); + } + return p; + } + + } + + +} + diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs new file mode 100644 index 000000000..0d8660353 --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs @@ -0,0 +1,749 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Organization Public API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Clients; +using Twilio.Constant; +using Twilio.Converters; +using Twilio.Exceptions; +using Twilio.Http; + +using Twilio.Base.BearerToken; +using Twilio.Clients.BearerToken; +using Twilio.Http.BearerToken; + + + +namespace Twilio.Rest.PreviewIam.Organizations +{ + public class UserResource : Resource + { + + public class ScimName + { + [JsonProperty("givenName")] + private string GivenName {get; set;} + [JsonProperty("familyName")] + private string FamilyName {get; set;} + public ScimName() { } + public class Builder + { + private ScimName _scimName = new ScimName(); + public Builder() + { + } + public Builder WithGivenName(string givenName) + { + _scimName.GivenName= givenName; + return this; + } + public Builder WithFamilyName(string familyName) + { + _scimName.FamilyName= familyName; + return this; + } + public ScimName Build() + { + return _scimName; + } + } + } + public class ScimEmailAddress + { + [JsonProperty("primary")] + private bool? Primary {get; set;} + [JsonProperty("value")] + private string Value {get; set;} + [JsonProperty("type")] + private string Type {get; set;} + public ScimEmailAddress() { } + public class Builder + { + private ScimEmailAddress _scimEmailAddress = new ScimEmailAddress(); + public Builder() + { + } + public Builder WithPrimary(bool? primary) + { + _scimEmailAddress.Primary= primary; + return this; + } + public Builder WithValue(string value) + { + _scimEmailAddress.Value= value; + return this; + } + public Builder WithType(string type) + { + _scimEmailAddress.Type= type; + return this; + } + public ScimEmailAddress Build() + { + return _scimEmailAddress; + } + } + } + public class ScimMeta + { + [JsonProperty("resourceType")] + private string ResourceType {get; set;} + [JsonProperty("created")] + private DateTime? Created {get; set;} + [JsonProperty("lastModified")] + private DateTime? LastModified {get; set;} + [JsonProperty("version")] + private string Version {get; set;} + public ScimMeta() { } + public class Builder + { + private ScimMeta _scimMeta = new ScimMeta(); + public Builder() + { + } + public Builder WithResourceType(string resourceType) + { + _scimMeta.ResourceType= resourceType; + return this; + } + public Builder WithCreated(DateTime? created) + { + _scimMeta.Created= created; + return this; + } + public Builder WithLastModified(DateTime? lastModified) + { + _scimMeta.LastModified= lastModified; + return this; + } + public Builder WithVersion(string version) + { + _scimMeta.Version= version; + return this; + } + public ScimMeta Build() + { + return _scimMeta; + } + } + } + public class ScimUser + { + [JsonProperty("id")] + private string Id {get; set;} + [JsonProperty("externalId")] + private string ExternalId {get; set;} + [JsonProperty("userName")] + private string UserName {get; set;} + [JsonProperty("displayName")] + private string DisplayName {get; set;} + [JsonProperty("name")] + private ScimName Name {get; set;} + [JsonProperty("emails")] + private List Emails {get; set;} + [JsonProperty("active")] + private bool? Active {get; set;} + [JsonProperty("locale")] + private string Locale {get; set;} + [JsonProperty("timezone")] + private string Timezone {get; set;} + [JsonProperty("schemas")] + private List Schemas {get; set;} + [JsonProperty("meta")] + private ScimMeta Meta {get; set;} + public ScimUser() { } + public class Builder + { + private ScimUser _scimUser = new ScimUser(); + public Builder() + { + } + public Builder WithId(string id) + { + _scimUser.Id= id; + return this; + } + public Builder WithExternalId(string externalId) + { + _scimUser.ExternalId= externalId; + return this; + } + public Builder WithUserName(string userName) + { + _scimUser.UserName= userName; + return this; + } + public Builder WithDisplayName(string displayName) + { + _scimUser.DisplayName= displayName; + return this; + } + public Builder WithName(ScimName name) + { + _scimUser.Name= name; + return this; + } + public Builder WithEmails(List emails) + { + _scimUser.Emails= emails; + return this; + } + public Builder WithActive(bool? active) + { + _scimUser.Active= active; + return this; + } + public Builder WithLocale(string locale) + { + _scimUser.Locale= locale; + return this; + } + public Builder WithTimezone(string timezone) + { + _scimUser.Timezone= timezone; + return this; + } + public Builder WithSchemas(List schemas) + { + _scimUser.Schemas= schemas; + return this; + } + public Builder WithMeta(ScimMeta meta) + { + _scimUser.Meta= meta; + return this; + } + public ScimUser Build() + { + return _scimUser; + } + } + } + + + + + private static TokenRequest BuildCreateRequest(CreateUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + + return new TokenRequest( + HttpMethod.Post, + Rest.Domain.PreviewIam, + path, + + contentType: EnumConstants.ContentTypeEnum.JSON, + body: options.GetBody(), + headerParams: null + ); + } + + /// create + /// Create User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create(CreateUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + + #if !NET35 + /// create + /// Create User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync(CreateUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + #endif + + /// create + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Create( + string pathOrganizationSid, + UserResource.ScimUser scimUser, + TwilioOrgsTokenRestClient client = null) + { + var options = new CreateUserOptions(pathOrganizationSid, scimUser){ }; + return Create(options, client); + } + + #if !NET35 + /// create + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task CreateAsync( + string pathOrganizationSid, + UserResource.ScimUser scimUser, + TwilioOrgsTokenRestClient client = null) + { + var options = new CreateUserOptions(pathOrganizationSid, scimUser){ }; + return await CreateAsync(options, client); + } + #endif + + /// delete + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + private static TokenRequest BuildDeleteRequest(DeleteUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + string PathUserSid = options.PathUserSid.ToString(); + path = path.Replace("{"+"UserSid"+"}", PathUserSid); + + return new TokenRequest( + HttpMethod.Delete, + Rest.Domain.PreviewIam, + path, + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// delete + /// Delete User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(DeleteUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + + #if !NET35 + /// delete + /// Delete User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(DeleteUserOptions options, + TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildDeleteRequest(options, client)); + return response.StatusCode == System.Net.HttpStatusCode.NoContent; + } + #endif + + /// delete + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static bool Delete(string pathOrganizationSid, string pathUserSid, TwilioOrgsTokenRestClient client = null) + { + var options = new DeleteUserOptions(pathOrganizationSid, pathUserSid) ; + return Delete(options, client); + } + + #if !NET35 + /// delete + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task DeleteAsync(string pathOrganizationSid, string pathUserSid, TwilioOrgsTokenRestClient client = null) + { + var options = new DeleteUserOptions(pathOrganizationSid, pathUserSid) ; + return await DeleteAsync(options, client); + } + #endif + + private static TokenRequest BuildFetchRequest(FetchUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + string PathUserSid = options.PathUserSid.ToString(); + path = path.Replace("{"+"UserSid"+"}", PathUserSid); + + return new TokenRequest( + HttpMethod.Get, + Rest.Domain.PreviewIam, + path, + queryParams: options.GetParams(), + headerParams: null + ); + } + + /// fetch + /// Fetch User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch(FetchUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + + #if !NET35 + /// fetch + /// Fetch User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(FetchUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildFetchRequest(options, client)); + return FromJson(response.Content); + } + #endif + /// fetch + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Fetch( + string pathOrganizationSid, + string pathUserSid, + TwilioOrgsTokenRestClient client = null) + { + var options = new FetchUserOptions(pathOrganizationSid, pathUserSid){ }; + return Fetch(options, client); + } + + #if !NET35 + /// fetch + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task FetchAsync(string pathOrganizationSid, string pathUserSid, TwilioOrgsTokenRestClient client = null) + { + var options = new FetchUserOptions(pathOrganizationSid, pathUserSid){ }; + return await FetchAsync(options, client); + } + #endif + + private static TokenRequest BuildReadRequest(ReadUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + + return new TokenRequest( + HttpMethod.Get, + Rest.Domain.PreviewIam, + path, + queryParams: options.GetParams(), + headerParams: null + ); + } + /// read + /// Read User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static TokenResourceSet Read(ReadUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildReadRequest(options, client)); + var page = Page.FromJson("Resources", response.Content); + return new TokenResourceSet(page, options, client); + } + + #if !NET35 + /// read + /// Read User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync(ReadUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildReadRequest(options, client)); + + var page = Page.FromJson("Resources", response.Content); + return new TokenResourceSet(page, options, client); + } + #endif + /// read + /// + /// + /// Record limit + /// Client to make requests to Twilio + /// A single instance of User + public static TokenResourceSet Read( + string pathOrganizationSid, + string filter = null, + long? limit = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new ReadUserOptions(pathOrganizationSid){ Filter = filter, Limit = limit}; + return Read(options, client); + } + + #if !NET35 + /// read + /// + /// + /// Record limit + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task> ReadAsync( + string pathOrganizationSid, + string filter = null, + long? limit = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new ReadUserOptions(pathOrganizationSid){ Filter = filter, Limit = limit}; + return await ReadAsync(options, client); + } + #endif + + + /// Fetch the target page of records + /// API-generated URL for the requested results page + /// Client to make requests to Twilio + /// The target page of records + public static Page GetPage(string targetUrl, TwilioOrgsTokenRestClient client) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + + var request = new TokenRequest( + HttpMethod.Get, + targetUrl + ); + + var response = client.Request(request); + return Page.FromJson("Resources", response.Content); + } + + /// Fetch the next page of records + /// current page of records + /// Client to make requests to Twilio + /// The next page of records + public static Page NextPage(Page page, TwilioOrgsTokenRestClient client) + { + var request = new TokenRequest( + HttpMethod.Get, + page.GetNextPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("Resources", response.Content); + } + + /// Fetch the previous page of records + /// current page of records + /// Client to make requests to Twilio + /// The previous page of records + public static Page PreviousPage(Page page, TwilioOrgsTokenRestClient client) + { + var request = new TokenRequest( + HttpMethod.Get, + page.GetPreviousPageUrl(Rest.Domain.Api) + ); + + var response = client.Request(request); + return Page.FromJson("Resources", response.Content); + } + + + private static TokenRequest BuildUpdateRequest(UpdateUserOptions options, TwilioOrgsTokenRestClient client) + { + + string path = "/Organizations/{organizationSid}/scim/Users/{userSid}"; + + string PathOrganizationSid = options.PathOrganizationSid.ToString(); + path = path.Replace("{"+"OrganizationSid"+"}", PathOrganizationSid); + string PathUserSid = options.PathUserSid.ToString(); + path = path.Replace("{"+"UserSid"+"}", PathUserSid); + + return new TokenRequest( + HttpMethod.Put, + Rest.Domain.PreviewIam, + path, + + contentType: EnumConstants.ContentTypeEnum.JSON, + body: options.GetBody(), + headerParams: options.GetHeaderParams() + ); + } + + /// update + /// Update User parameters + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update(UpdateUserOptions options, TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = client.Request(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + + /// update + /// Update User parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + #if !NET35 + public static async System.Threading.Tasks.Task UpdateAsync(UpdateUserOptions options, + TwilioOrgsTokenRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetRestClient(); + var response = await client.RequestAsync(BuildUpdateRequest(options, client)); + return FromJson(response.Content); + } + #endif + + /// update + /// + /// + /// + /// + /// Client to make requests to Twilio + /// A single instance of User + public static UserResource Update( + string pathOrganizationSid, + string pathUserSid, + UserResource.ScimUser scimUser, + string ifMatch = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new UpdateUserOptions(pathOrganizationSid, pathUserSid, scimUser){ IfMatch = ifMatch }; + return Update(options, client); + } + + #if !NET35 + /// update + /// + /// + /// + /// + /// Client to make requests to Twilio + /// Task that resolves to A single instance of User + public static async System.Threading.Tasks.Task UpdateAsync( + string pathOrganizationSid, + string pathUserSid, + UserResource.ScimUser scimUser, + string ifMatch = null, + TwilioOrgsTokenRestClient client = null) + { + var options = new UpdateUserOptions(pathOrganizationSid, pathUserSid, scimUser){ IfMatch = ifMatch }; + return await UpdateAsync(options, client); + } + #endif + + /// + /// Converts a JSON string into a UserResource object + /// + /// Raw JSON string + /// UserResource object represented by the provided JSON + public static UserResource FromJson(string json) + { + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + /// + /// Converts an object into a json string + /// + /// C# model + /// JSON string + public static string ToJson(object model) + { + try + { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + + /// Unique Twilio user sid + [JsonProperty("id")] + public string Id { get; private set; } + + /// External unique resource id defined by provisioning client + [JsonProperty("externalId")] + public string ExternalId { get; private set; } + + /// Unique username, MUST be same as primary email address + [JsonProperty("userName")] + public string UserName { get; } + + /// User friendly display name + [JsonProperty("displayName")] + public string DisplayName { get; private set; } + + /// The name + [JsonProperty("name")] + public ScimName Name { get; private set; } + + /// Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + [JsonProperty("emails")] + public List Emails { get; private set; } + + /// Indicates whether the user is active + [JsonProperty("active")] + public bool? Active { get; private set; } + + /// User's locale + [JsonProperty("locale")] + public string Locale { get; private set; } + + /// User's time zone + [JsonProperty("timezone")] + public string Timezone { get; private set; } + + /// An array of URIs that indicate the schemas supported for this user resource + [JsonProperty("schemas")] + public List Schemas { get; private set; } + + /// The meta + [JsonProperty("meta")] + public ScimMeta Meta { get; private set; } + + + + private UserResource() { + + } + } +} + diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs new file mode 100644 index 000000000..95adbbe9f --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenOptions.cs @@ -0,0 +1,110 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Organization Public API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Converters; + + + + +namespace Twilio.Rest.PreviewIam.V1 +{ + + /// create + public class CreateTokenOptions : IOptions + { + + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + public string GrantType { get; } + + /// A 34 character string that uniquely identifies this OAuth App. + public string ClientId { get; } + + /// The credential for confidential OAuth App. + public string ClientSecret { get; set; } + + /// JWT token related to the authorization code grant type. + public string Code { get; set; } + + /// The redirect uri + public string RedirectUri { get; set; } + + /// The targeted audience uri + public string Audience { get; set; } + + /// JWT token related to refresh access token. + public string RefreshToken { get; set; } + + /// The scope of token + public string Scope { get; set; } + + + /// Construct a new CreateTokenOptions + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + /// A 34 character string that uniquely identifies this OAuth App. + public CreateTokenOptions(string grantType, string clientId) + { + GrantType = grantType; + ClientId = clientId; + } + + + /// Generate the necessary parameters + public List> GetParams() + { + var p = new List>(); + + if (GrantType != null) + { + p.Add(new KeyValuePair("grant_type", GrantType)); + } + if (ClientId != null) + { + p.Add(new KeyValuePair("client_id", ClientId)); + } + if (ClientSecret != null) + { + p.Add(new KeyValuePair("client_secret", ClientSecret)); + } + if (Code != null) + { + p.Add(new KeyValuePair("code", Code)); + } + if (RedirectUri != null) + { + p.Add(new KeyValuePair("redirect_uri", RedirectUri)); + } + if (Audience != null) + { + p.Add(new KeyValuePair("audience", Audience)); + } + if (RefreshToken != null) + { + p.Add(new KeyValuePair("refresh_token", RefreshToken)); + } + if (Scope != null) + { + p.Add(new KeyValuePair("scope", Scope)); + } + return p; + } + + + + } +} + diff --git a/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs new file mode 100644 index 000000000..9f79ada3c --- /dev/null +++ b/examples/csharp/src/Twilio/Rest/PreviewIam/V1/TokenResource.cs @@ -0,0 +1,195 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Organization Public API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using Twilio.Base; +using Twilio.Clients; +using Twilio.Constant; +using Twilio.Converters; +using Twilio.Exceptions; +using Twilio.Http; + + +using Twilio.Clients.NoAuth; +using Twilio.Http.NoAuth; + + +namespace Twilio.Rest.PreviewIam.V1 +{ + public class TokenResource : Resource + { + + + + + + private static NoAuthRequest BuildCreateRequest(CreateTokenOptions options, TwilioNoAuthRestClient client) + { + + string path = "/v1/token"; + + + return new NoAuthRequest( + HttpMethod.Post, + Rest.Domain.PreviewIam, + path, + contentType: EnumConstants.ContentTypeEnum.FORM_URLENCODED, + postParams: options.GetParams(), + headerParams: null + ); + } + + /// create + /// Create Token parameters + /// Client to make requests to Twilio + /// A single instance of Token + public static TokenResource Create(CreateTokenOptions options, TwilioNoAuthRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetNoAuthRestClient(); + var response = client.Request(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + + #if !NET35 + /// create + /// Create Token parameters + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Token + public static async System.Threading.Tasks.Task CreateAsync(CreateTokenOptions options, TwilioNoAuthRestClient client = null) + { + client = client ?? TwilioOrgsTokenAuthClient.GetNoAuthRestClient(); + var response = await client.RequestAsync(BuildCreateRequest(options, client)); + return FromJson(response.Content); + } + #endif + + /// create + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + /// A 34 character string that uniquely identifies this OAuth App. + /// The credential for confidential OAuth App. + /// JWT token related to the authorization code grant type. + /// The redirect uri + /// The targeted audience uri + /// JWT token related to refresh access token. + /// The scope of token + /// Client to make requests to Twilio + /// A single instance of Token + public static TokenResource Create( + string grantType, + string clientId, + string clientSecret = null, + string code = null, + string redirectUri = null, + string audience = null, + string refreshToken = null, + string scope = null, + TwilioNoAuthRestClient client = null) + { + var options = new CreateTokenOptions(grantType, clientId){ ClientSecret = clientSecret, Code = code, RedirectUri = redirectUri, Audience = audience, RefreshToken = refreshToken, Scope = scope }; + return Create(options, client); + } + + #if !NET35 + /// create + /// Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + /// A 34 character string that uniquely identifies this OAuth App. + /// The credential for confidential OAuth App. + /// JWT token related to the authorization code grant type. + /// The redirect uri + /// The targeted audience uri + /// JWT token related to refresh access token. + /// The scope of token + /// Client to make requests to Twilio + /// Task that resolves to A single instance of Token + public static async System.Threading.Tasks.Task CreateAsync( + string grantType, + string clientId, + string clientSecret = null, + string code = null, + string redirectUri = null, + string audience = null, + string refreshToken = null, + string scope = null, + TwilioNoAuthRestClient client = null) + { + var options = new CreateTokenOptions(grantType, clientId){ ClientSecret = clientSecret, Code = code, RedirectUri = redirectUri, Audience = audience, RefreshToken = refreshToken, Scope = scope }; + return await CreateAsync(options, client); + } + #endif + + /// + /// Converts a JSON string into a TokenResource object + /// + /// Raw JSON string + /// TokenResource object represented by the provided JSON + public static TokenResource FromJson(string json) + { + try + { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + /// + /// Converts an object into a json string + /// + /// C# model + /// JSON string + public static string ToJson(object model) + { + try + { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) + { + throw new ApiException(e.Message, e); + } + } + + + /// Token which carries the necessary information to access a Twilio resource directly. + [JsonProperty("access_token")] + public string AccessToken { get; private set; } + + /// Token which carries the information necessary to get a new access token. + [JsonProperty("refresh_token")] + public string RefreshToken { get; private set; } + + /// Token which carries the information necessary of user profile. + [JsonProperty("id_token")] + public string IdToken { get; private set; } + + /// Token type + [JsonProperty("token_type")] + public string TokenType { get; private set; } + + /// The expires_in + [JsonProperty("expires_in")] + public long? ExpiresIn { get; private set; } + + + + private TokenResource() { + + } + } +} + diff --git a/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs b/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs index 01deb6ea8..3e418d40d 100644 --- a/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs +++ b/examples/csharp/src/Twilio/Rest/Versionless/DeployedDevices/FleetResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.Versionless.DeployedDevices { public class FleetResource : Resource @@ -66,8 +68,7 @@ public static FleetResource Create(CreateFleetOptions options, ITwilioRestClient /// Create Fleet parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateFleetOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); @@ -81,7 +82,7 @@ public static async System.Threading.Tasks.Task CreateAsync(Creat /// A single instance of Fleet public static FleetResource Create( string name = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateFleetOptions(){ Name = name }; return Create(options, client); @@ -94,7 +95,7 @@ public static FleetResource Create( /// Task that resolves to A single instance of Fleet public static async System.Threading.Tasks.Task CreateAsync( string name = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new CreateFleetOptions(){ Name = name }; return await CreateAsync(options, client); @@ -134,8 +135,7 @@ public static FleetResource Fetch(FetchFleetOptions options, ITwilioRestClient c /// Fetch Fleet parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Fleet - public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchFleetOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); @@ -148,7 +148,7 @@ public static async System.Threading.Tasks.Task FetchAsync(FetchF /// A single instance of Fleet public static FleetResource Fetch( string pathSid, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new FetchFleetOptions(pathSid){ }; return Fetch(options, client); diff --git a/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs b/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs index 324cc8e77..be48d22c3 100644 --- a/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs +++ b/examples/csharp/src/Twilio/Rest/Versionless/Understand/AssistantResource.cs @@ -25,6 +25,8 @@ + + namespace Twilio.Rest.Versionless.Understand { public class AssistantResource : Resource @@ -65,8 +67,7 @@ public static ResourceSet Read(ReadAssistantOptions options, /// Read Assistant parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Assistant - public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, - ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAssistantOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); @@ -83,7 +84,7 @@ public static async System.Threading.Tasks.Task> public static ResourceSet Read( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAssistantOptions(){ PageSize = pageSize, Limit = limit}; return Read(options, client); @@ -98,7 +99,7 @@ public static ResourceSet Read( public static async System.Threading.Tasks.Task> ReadAsync( int? pageSize = null, long? limit = null, - ITwilioRestClient client = null) + ITwilioRestClient client = null) { var options = new ReadAssistantOptions(){ PageSize = pageSize, Limit = limit}; return await ReadAsync(options, client); diff --git a/examples/prism/docker-compose.yml b/examples/prism/docker-compose.yml index e4e307ab1..aad0b0d97 100644 --- a/examples/prism/docker-compose.yml +++ b/examples/prism/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3' services: go-test: build: diff --git a/scripts/generate.sh b/scripts/generate.sh index 31ee69b4d..cc6444ae6 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -17,7 +17,7 @@ function generate() { rm -rf tmp mkdir -p tmp for api_spec in $files_regex; do - if [ "$1" != "twilio-java" || "$1" != "twilio-csharp"] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then + if [ "$1" != "twilio-java" ] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then continue fi echo "generatorName: $1 From 4e2c9e11661088aa5a90f7dbf9a007bc47dcb1c0 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 18:15:19 +0530 Subject: [PATCH 35/38] test files --- scripts/generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.sh b/scripts/generate.sh index cc6444ae6..260cac2a0 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -17,7 +17,7 @@ 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 + if [ "$1" != "twilio-java" && "$1" != "twilio-csharp"] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then continue fi echo "generatorName: $1 From 11af9e54f215d956e9f951625f23ed808344db41 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 18:18:50 +0530 Subject: [PATCH 36/38] test files --- scripts/generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.sh b/scripts/generate.sh index 260cac2a0..2e883968a 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -10,7 +10,7 @@ function generate() { files_regex=("examples/spec/*.yaml") # shellcheck disable=SC2161 - if [ "$1" = "twilio-java" ]; then + if [ "$1" = "twilio-java" || "$1" = "twilio-csharp" ]; then files_regex=("examples/spec/*") fi From f97bec66fa72f1ce4676127d052e389701423246 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 18:21:41 +0530 Subject: [PATCH 37/38] test files --- scripts/generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.sh b/scripts/generate.sh index 2e883968a..7ade6558b 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -17,7 +17,7 @@ function generate() { rm -rf tmp mkdir -p tmp for api_spec in $files_regex; do - if [ "$1" != "twilio-java" && "$1" != "twilio-csharp"] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then + if [ "$1" != "twilio-java" ] && [ "$1" != "twilio-csharp" ] && [[ $api_spec == "examples/spec/twilio_iam_organizations.yaml" ]]; then continue fi echo "generatorName: $1 From 6147a3881ecd64130f85313c9b55304afbc4791f Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Mon, 23 Sep 2024 18:28:20 +0530 Subject: [PATCH 38/38] test files --- scripts/generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate.sh b/scripts/generate.sh index 7ade6558b..fcf9017ad 100644 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -10,7 +10,7 @@ function generate() { files_regex=("examples/spec/*.yaml") # shellcheck disable=SC2161 - if [ "$1" = "twilio-java" || "$1" = "twilio-csharp" ]; then + if [ "$1" = "twilio-java" ]; then files_regex=("examples/spec/*") fi