Import from internal git
This commit is contained in:
783
architecture/api/templates/7.3.0/csharp/api.mustache
Normal file
783
architecture/api/templates/7.3.0/csharp/api.mustache
Normal file
@@ -0,0 +1,783 @@
|
||||
{{>partial_header}}
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mime;
|
||||
using {{packageName}}.Client;
|
||||
{{#hasOAuthMethods}}using {{packageName}}.Client.Auth;
|
||||
{{/hasOAuthMethods}}
|
||||
{{#hasImport}}using {{packageName}}.{{modelPackage}};
|
||||
{{/hasImport}}
|
||||
{{#modelNamespaces}}
|
||||
using {{.}};
|
||||
{{/modelNamespaces}}
|
||||
|
||||
namespace {{packageName}}.{{apiPackage}}
|
||||
{
|
||||
{{#operations}}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
{{>visibility}} interface {{interfacePrefix}}{{classname}}Sync : IApiAccessor
|
||||
{
|
||||
#region Synchronous Operations
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}}
|
||||
/// </summary>
|
||||
{{#notes}}
|
||||
/// <remarks>
|
||||
/// {{.}}
|
||||
/// </remarks>
|
||||
{{/notes}}
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <returns>{{returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
{{{returnType}}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0);
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}}
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// {{notes}}
|
||||
/// </remarks>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <returns>ApiResponse of {{returnType}}{{^returnType}}Object(void){{/returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0);
|
||||
{{/operation}}
|
||||
#endregion Synchronous Operations
|
||||
}
|
||||
|
||||
{{#supportsAsync}}
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
{{>visibility}} interface {{interfacePrefix}}{{classname}}Async : IApiAccessor
|
||||
{
|
||||
#region Asynchronous Operations
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}}
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// {{notes}}
|
||||
/// </remarks>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task of {{returnType}}{{^returnType}}void{{/returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
{{#returnType}}System.Threading.Tasks.Task<{{{.}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}}
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// {{notes}}
|
||||
/// </remarks>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
System.Threading.Tasks.Task<ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||
{{/operation}}
|
||||
#endregion Asynchronous Operations
|
||||
}
|
||||
{{/supportsAsync}}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
{{>visibility}} interface {{interfacePrefix}}{{classname}} : {{interfacePrefix}}{{classname}}Sync{{#supportsAsync}}, {{interfacePrefix}}{{classname}}Async{{/supportsAsync}}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
{{>visibility}} partial class {{classname}} : {{interfacePrefix}}{{classname}}
|
||||
{
|
||||
private {{packageName}}.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public {{classname}}() : this((string)null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public {{classname}}(string basePath)
|
||||
{
|
||||
this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations(
|
||||
{{packageName}}.Client.GlobalConfiguration.Instance,
|
||||
new {{packageName}}.Client.Configuration { BasePath = basePath }
|
||||
);
|
||||
this.Client = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath);
|
||||
{{#supportsAsync}}
|
||||
this.AsynchronousClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath);
|
||||
{{/supportsAsync}}
|
||||
this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class
|
||||
/// using Configuration object
|
||||
/// </summary>
|
||||
/// <param name="configuration">An instance of Configuration</param>
|
||||
/// <returns></returns>
|
||||
public {{classname}}({{packageName}}.Client.Configuration configuration)
|
||||
{
|
||||
if (configuration == null) throw new ArgumentNullException("configuration");
|
||||
|
||||
this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations(
|
||||
{{packageName}}.Client.GlobalConfiguration.Instance,
|
||||
configuration
|
||||
);
|
||||
this.Client = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath);
|
||||
{{#supportsAsync}}
|
||||
this.AsynchronousClient = new {{packageName}}.Client.ApiClient(this.Configuration.BasePath);
|
||||
{{/supportsAsync}}
|
||||
ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class
|
||||
/// using a Configuration object and client instance.
|
||||
/// </summary>
|
||||
/// <param name="client">The client interface for synchronous API access.</param>{{#supportsAsync}}
|
||||
/// <param name="asyncClient">The client interface for asynchronous API access.</param>{{/supportsAsync}}
|
||||
/// <param name="configuration">The configuration object.</param>
|
||||
public {{classname}}({{packageName}}.Client.ISynchronousClient client, {{#supportsAsync}}{{packageName}}.Client.IAsynchronousClient asyncClient, {{/supportsAsync}}{{packageName}}.Client.IReadableConfiguration configuration)
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException("client");
|
||||
{{#supportsAsync}}
|
||||
if (asyncClient == null) throw new ArgumentNullException("asyncClient");
|
||||
{{/supportsAsync}}
|
||||
if (configuration == null) throw new ArgumentNullException("configuration");
|
||||
|
||||
this.Client = client;
|
||||
{{#supportsAsync}}
|
||||
this.AsynchronousClient = asyncClient;
|
||||
{{/supportsAsync}}
|
||||
this.Configuration = configuration;
|
||||
this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
|
||||
}
|
||||
|
||||
{{#supportsAsync}}
|
||||
/// <summary>
|
||||
/// The client for accessing this underlying API asynchronously.
|
||||
/// </summary>
|
||||
public {{packageName}}.Client.IAsynchronousClient AsynchronousClient { get; set; }
|
||||
{{/supportsAsync}}
|
||||
|
||||
/// <summary>
|
||||
/// The client for accessing this underlying API synchronously.
|
||||
/// </summary>
|
||||
public {{packageName}}.Client.ISynchronousClient Client { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public string GetBasePath()
|
||||
{
|
||||
return this.Configuration.BasePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration object
|
||||
/// </summary>
|
||||
/// <value>An instance of the Configuration</value>
|
||||
public {{packageName}}.Client.IReadableConfiguration Configuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides a factory method hook for the creation of exceptions.
|
||||
/// </summary>
|
||||
public {{packageName}}.Client.ExceptionFactory ExceptionFactory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1)
|
||||
{
|
||||
throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported.");
|
||||
}
|
||||
return _exceptionFactory;
|
||||
}
|
||||
set { _exceptionFactory = value; }
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <returns>{{returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
public {{{returnType}}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0)
|
||||
{
|
||||
{{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/returnType}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <returns>ApiResponse of {{returnType}}{{^returnType}}Object(void){{/returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
public {{packageName}}.Client.ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0)
|
||||
{
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
{{^vendorExtensions.x-csharp-value-type}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null)
|
||||
{
|
||||
throw new {{packageName}}.Client.ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
|
||||
}
|
||||
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
{{packageName}}.Client.RequestOptions localVarRequestOptions = new {{packageName}}.Client.RequestOptions();
|
||||
|
||||
string[] _contentTypes = new string[] {
|
||||
{{#consumes}}
|
||||
"{{{mediaType}}}"{{^-last}},{{/-last}}
|
||||
{{/consumes}}
|
||||
};
|
||||
|
||||
// to determine the Accept header
|
||||
string[] _accepts = new string[] {
|
||||
{{#produces}}
|
||||
"{{{mediaType}}}"{{^-last}},{{/-last}}
|
||||
{{/produces}}
|
||||
};
|
||||
|
||||
var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
|
||||
if (localVarContentType != null)
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
|
||||
}
|
||||
|
||||
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts);
|
||||
if (localVarAccept != null)
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||
}
|
||||
|
||||
{{#pathParams}}
|
||||
{{#required}}
|
||||
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
|
||||
}
|
||||
{{/required}}
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
{{#isDeepObject}}
|
||||
{{#items.vars}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}}.{{name}}));
|
||||
{{/items.vars}}
|
||||
{{^items}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("deepObject", "{{baseName}}", {{paramName}}));
|
||||
{{/items}}
|
||||
{{/isDeepObject}}
|
||||
{{^isDeepObject}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/isDeepObject}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
{{#isDeepObject}}
|
||||
{{#items.vars}}
|
||||
if ({{paramName}}.{{name}} != null)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{paramName}}[{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}]", {{paramName}}.{{name}}));
|
||||
}
|
||||
{{/items.vars}}
|
||||
{{^items}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("deepObject", "{{baseName}}", {{paramName}}));
|
||||
{{/items}}
|
||||
{{/isDeepObject}}
|
||||
{{^isDeepObject}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/isDeepObject}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
|
||||
}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
{{#formParams}}
|
||||
{{#required}}
|
||||
{{#isFile}}
|
||||
{{#isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
foreach (var file in {{paramName}})
|
||||
{
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", file);
|
||||
}
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.{{#isPrimitiveType}}ParameterToString{{/isPrimitiveType}}{{^isPrimitiveType}}Serialize{{/isPrimitiveType}}({{paramName}})); // form parameter
|
||||
{{/isFile}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
{{#isFile}}
|
||||
{{#isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
foreach (var file in {{paramName}})
|
||||
{
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", file);
|
||||
}
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.{{#isPrimitiveType}}ParameterToString{{/isPrimitiveType}}{{^isPrimitiveType}}Serialize{{/isPrimitiveType}}({{paramName}})); // form parameter
|
||||
{{/isFile}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
localVarRequestOptions.Data = {{paramName}};
|
||||
{{/bodyParam}}
|
||||
|
||||
localVarRequestOptions.Operation = "{{classname}}.{{operationId}}";
|
||||
localVarRequestOptions.OperationIndex = operationIndex;
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInCookie}}
|
||||
// cookie parameter support
|
||||
if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||
}
|
||||
{{/isKeyInCookie}}
|
||||
{{#isKeyInHeader}}
|
||||
if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"));
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasicBasic}}
|
||||
// http basic authentication required
|
||||
if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
|
||||
}
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
// bearer authentication required
|
||||
if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if (!localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.Configuration.AccessToken))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
|
||||
}
|
||||
{{#hasOAuthMethods}}
|
||||
else if (!string.IsNullOrEmpty(this.Configuration.OAuthTokenUrl) &&
|
||||
!string.IsNullOrEmpty(this.Configuration.OAuthClientId) &&
|
||||
!string.IsNullOrEmpty(this.Configuration.OAuthClientSecret) &&
|
||||
this.Configuration.OAuthFlow != null)
|
||||
{
|
||||
localVarRequestOptions.OAuth = true;
|
||||
}
|
||||
{{/hasOAuthMethods}}
|
||||
}
|
||||
{{/isOAuth}}
|
||||
{{#isHttpSignature}}
|
||||
if (this.Configuration.HttpSigningConfiguration != null)
|
||||
{
|
||||
var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "{{{httpMethod}}}", "{{{path}}}", localVarRequestOptions);
|
||||
foreach (var headerItem in HttpSigningHeaders)
|
||||
{
|
||||
if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters[headerItem.Key] = new List<string>() { headerItem.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/isHttpSignature}}
|
||||
{{/authMethods}}
|
||||
|
||||
// make the HTTP request
|
||||
var localVarResponse = this.Client.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}<{{{returnType}}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration);
|
||||
if (this.ExceptionFactory != null)
|
||||
{
|
||||
Exception _exception = this.ExceptionFactory("{{operationId}}", localVarResponse);
|
||||
if (_exception != null)
|
||||
{
|
||||
throw _exception;
|
||||
}
|
||||
}
|
||||
|
||||
return localVarResponse;
|
||||
}
|
||||
|
||||
{{#supportsAsync}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task of {{returnType}}{{^returnType}}void{{/returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{.}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||
{
|
||||
{{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}operationIndex, cancellationToken).ConfigureAwait(false);
|
||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}operationIndex, cancellationToken).ConfigureAwait(false);{{/returnType}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}}</returns>
|
||||
{{#isDeprecated}}
|
||||
[Obsolete]
|
||||
{{/isDeprecated}}
|
||||
public async System.Threading.Tasks.Task<{{packageName}}.Client.ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||
{
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
{{^vendorExtensions.x-csharp-value-type}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null)
|
||||
{
|
||||
throw new {{packageName}}.Client.ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
|
||||
}
|
||||
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
{{packageName}}.Client.RequestOptions localVarRequestOptions = new {{packageName}}.Client.RequestOptions();
|
||||
|
||||
string[] _contentTypes = new string[] {
|
||||
{{#consumes}}
|
||||
"{{{mediaType}}}"{{^-last}}, {{/-last}}
|
||||
{{/consumes}}
|
||||
};
|
||||
|
||||
// to determine the Accept header
|
||||
string[] _accepts = new string[] {
|
||||
{{#produces}}
|
||||
"{{{mediaType}}}"{{^-last}},{{/-last}}
|
||||
{{/produces}}
|
||||
};
|
||||
|
||||
var localVarContentType = {{packageName}}.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
|
||||
if (localVarContentType != null)
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
|
||||
}
|
||||
|
||||
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts);
|
||||
if (localVarAccept != null)
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||
}
|
||||
|
||||
{{#pathParams}}
|
||||
{{#required}}
|
||||
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter
|
||||
}
|
||||
{{/required}}
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
{{#isDeepObject}}
|
||||
{{#items.vars}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}}.{{name}}));
|
||||
{{/items.vars}}
|
||||
{{^items}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("deepObject", "{{baseName}}", {{paramName}}));
|
||||
{{/items}}
|
||||
{{/isDeepObject}}
|
||||
{{^isDeepObject}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/isDeepObject}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
{{#isDeepObject}}
|
||||
{{#items.vars}}
|
||||
if ({{paramName}}.{{name}} != null)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{paramName}}[{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}]", {{paramName}}.{{name}}));
|
||||
}
|
||||
{{/items.vars}}
|
||||
{{^items}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("deepObject", "{{baseName}}", {{paramName}}));
|
||||
{{/items}}
|
||||
{{/isDeepObject}}
|
||||
{{^isDeepObject}}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/isDeepObject}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // header parameter
|
||||
}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
{{#formParams}}
|
||||
{{#required}}
|
||||
{{#isFile}}
|
||||
{{#isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
foreach (var file in {{paramName}})
|
||||
{
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", file);
|
||||
}
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.{{#isPrimitiveType}}ParameterToString{{/isPrimitiveType}}{{^isPrimitiveType}}Serialize{{/isPrimitiveType}}({{paramName}})); // form parameter
|
||||
{{/isFile}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
{{#isFile}}
|
||||
{{#isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
foreach (var file in {{paramName}})
|
||||
{
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", file);
|
||||
}
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#supportsFileParameters}}
|
||||
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
||||
{{/supportsFileParameters}}
|
||||
{{/isArray}}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.{{#isPrimitiveType}}ParameterToString{{/isPrimitiveType}}{{^isPrimitiveType}}Serialize{{/isPrimitiveType}}({{paramName}})); // form parameter
|
||||
{{/isFile}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
localVarRequestOptions.Data = {{paramName}};
|
||||
{{/bodyParam}}
|
||||
|
||||
localVarRequestOptions.Operation = "{{classname}}.{{operationId}}";
|
||||
localVarRequestOptions.OperationIndex = operationIndex;
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInCookie}}
|
||||
// cookie parameter support
|
||||
if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
localVarRequestOptions.Cookies.Add(new Cookie("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||
}
|
||||
{{/isKeyInCookie}}
|
||||
{{#isKeyInHeader}}
|
||||
if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}"));
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
{{#isBasicBasic}}
|
||||
// http basic authentication required
|
||||
if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + {{packageName}}.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
|
||||
}
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
// bearer authentication required
|
||||
if (!string.IsNullOrEmpty(this.Configuration.AccessToken) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if (!localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.Configuration.AccessToken))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
|
||||
}
|
||||
{{#hasOAuthMethods}}
|
||||
else if (!string.IsNullOrEmpty(this.Configuration.OAuthTokenUrl) &&
|
||||
!string.IsNullOrEmpty(this.Configuration.OAuthClientId) &&
|
||||
!string.IsNullOrEmpty(this.Configuration.OAuthClientSecret) &&
|
||||
this.Configuration.OAuthFlow != null)
|
||||
{
|
||||
localVarRequestOptions.OAuth = true;
|
||||
}
|
||||
{{/hasOAuthMethods}}
|
||||
}
|
||||
{{/isOAuth}}
|
||||
{{#isHttpSignature}}
|
||||
if (this.Configuration.HttpSigningConfiguration != null)
|
||||
{
|
||||
var HttpSigningHeaders = this.Configuration.HttpSigningConfiguration.GetHttpSignedHeader(this.Configuration.BasePath, "{{{httpMethod}}}", "{{{path}}}", localVarRequestOptions);
|
||||
foreach (var headerItem in HttpSigningHeaders)
|
||||
{
|
||||
if (localVarRequestOptions.HeaderParameters.ContainsKey(headerItem.Key))
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters[headerItem.Key] = new List<string>() { headerItem.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
localVarRequestOptions.HeaderParameters.Add(headerItem.Key, headerItem.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/isHttpSignature}}
|
||||
{{/authMethods}}
|
||||
|
||||
// make the HTTP request
|
||||
var localVarResponse = await this.AsynchronousClient.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Async<{{{returnType}}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (this.ExceptionFactory != null)
|
||||
{
|
||||
Exception _exception = this.ExceptionFactory("{{operationId}}", localVarResponse);
|
||||
if (_exception != null)
|
||||
{
|
||||
throw _exception;
|
||||
}
|
||||
}
|
||||
|
||||
return localVarResponse;
|
||||
}
|
||||
|
||||
{{/supportsAsync}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
}
|
||||
Reference in New Issue
Block a user