@autorest/go
Version:
AutoRest Go Generator
191 lines • 7.28 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as type from './type.js';
export function isClientSideDefault(kind) {
return kind.defaultValue !== undefined;
}
export function isBodyParameter(param) {
return param.bodyFormat !== undefined;
}
export function isPartialBodyParameter(param) {
return param.serializedName !== undefined;
}
export function isFormBodyParameter(param) {
return param.formDataName !== undefined;
}
export function isFormBodyCollectionParameter(param) {
return param.formDataName !== undefined && param.collectionFormat !== undefined;
}
export function isMultipartFormBodyParameter(param) {
return param.multipartForm !== undefined;
}
export function isHeaderParameter(param) {
return param.headerName !== undefined;
}
export function isHeaderCollectionParameter(param) {
return param.headerName !== undefined && param.collectionFormat !== undefined;
}
export function isHeaderMapParameter(param) {
return param.headerName !== undefined && param.collectionPrefix !== undefined;
}
export function isPathParameter(param) {
return param.pathSegment !== undefined;
}
export function isPathCollectionParameter(param) {
return param.pathSegment !== undefined && param.collectionFormat !== undefined;
}
export function isQueryParameter(param) {
return param.queryParameter !== undefined;
}
export function isQueryCollectionParameter(param) {
return param.queryParameter !== undefined && param.collectionFormat !== undefined;
}
export function isURIParameter(param) {
return param.uriPathSegment !== undefined;
}
export function isResumeTokenParameter(param) {
return param.isResumeToken !== undefined;
}
export function isRequiredParameter(param) {
// parameters with a client-side default value are always optional
if (isClientSideDefault(param.kind)) {
return false;
}
return param.kind === 'required';
}
export function isLiteralParameter(param) {
if (isClientSideDefault(param.kind)) {
return false;
}
return param.kind === 'literal';
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// base types
///////////////////////////////////////////////////////////////////////////////////////////////////
export class Parameter {
constructor(name, type, kind, byValue, location) {
this.name = name;
this.type = type;
this.kind = kind;
this.byValue = byValue;
this.location = location;
this.docs = {};
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
export class BodyParameter extends Parameter {
constructor(name, bodyFormat, contentType, type, kind, byValue) {
super(name, type, kind, byValue, 'method');
this.bodyFormat = bodyFormat;
this.contentType = contentType;
}
}
export class PartialBodyParameter extends Parameter {
constructor(name, serializedName, format, type, kind, byValue) {
super(name, type, kind, byValue, 'method');
this.format = format;
this.serializedName = serializedName;
}
}
export class FormBodyParameter extends Parameter {
constructor(name, formDataName, type, kind, byValue) {
super(name, type, kind, byValue, 'method');
this.formDataName = formDataName;
}
}
export class FormBodyCollectionParameter extends Parameter {
constructor(name, formDataName, type, collectionFormat, kind, byValue) {
super(name, type, kind, byValue, 'method');
this.formDataName = formDataName;
this.collectionFormat = collectionFormat;
}
}
export class MultipartFormBodyParameter extends Parameter {
constructor(name, type, kind, byValue) {
super(name, type, kind, byValue, 'method');
this.multipartForm = true;
}
}
export class HeaderParameter extends Parameter {
constructor(name, headerName, type, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.headerName = headerName;
}
}
export class HeaderCollectionParameter extends Parameter {
constructor(name, headerName, type, collectionFormat, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.headerName = headerName;
this.collectionFormat = collectionFormat;
}
}
export class HeaderMapParameter extends Parameter {
constructor(name, headerName, type, collectionPrefix, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.headerName = headerName;
this.collectionPrefix = collectionPrefix;
}
}
export class PathParameter extends Parameter {
constructor(name, pathSegment, isEncoded, type, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.pathSegment = pathSegment;
this.isEncoded = isEncoded;
}
}
export class PathCollectionParameter extends Parameter {
constructor(name, pathSegment, isEncoded, type, collectionFormat, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.pathSegment = pathSegment;
this.isEncoded = isEncoded;
this.collectionFormat = collectionFormat;
}
}
export class QueryParameter extends Parameter {
constructor(name, queryParam, isEncoded, type, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.queryParameter = queryParam;
this.isEncoded = isEncoded;
}
}
export class QueryCollectionParameter extends Parameter {
constructor(name, queryParam, isEncoded, type, collectionFormat, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.queryParameter = queryParam;
this.isEncoded = isEncoded;
this.collectionFormat = collectionFormat;
}
}
export class URIParameter extends Parameter {
constructor(name, uriPathSegment, type, kind, byValue, location) {
super(name, type, kind, byValue, location);
this.uriPathSegment = uriPathSegment;
}
}
export class ResumeTokenParameter extends Parameter {
constructor() {
super('ResumeToken', new type.PrimitiveType('string'), 'optional', true, 'method');
this.isResumeToken = true;
this.docs.summary = 'Resumes the long-running operation from the provided token.';
}
}
export class ClientSideDefault {
constructor(defaultValue) {
this.defaultValue = defaultValue;
}
}
export class ParameterGroup {
constructor(name, groupName, required, location) {
this.groupName = groupName;
this.location = location;
this.name = name;
// params is required but must be populated post construction
this.params = new Array();
this.required = required;
this.docs = {};
}
}
//# sourceMappingURL=param.js.map