@autorest/go
Version:
AutoRest Go Generator
118 lines • 3.66 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';
/** returns the underlying type used for the specified result type */
export function getResultType(result) {
switch (result.kind) {
case 'anyResult':
return new type.Any();
case 'binaryResult':
return new type.QualifiedType('ReadCloser', 'io');
case 'headAsBooleanResult':
return new type.Scalar('bool', false);
case 'modelResult':
return result.modelType;
case 'monomorphicResult':
return result.monomorphicType;
case 'polymorphicResult':
return result.interface;
}
}
/** narrows type to a MonomorphicResultType within the conditional block */
export function isMonomorphicResultType(type) {
switch (type.kind) {
case 'any':
case 'constant':
case 'encodedBytes':
case 'map':
case 'rawJSON':
case 'scalar':
case 'slice':
case 'string':
case 'time':
return true;
default:
return false;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
export class AnyResult {
constructor(fieldName, format, resultTypes) {
this.kind = 'anyResult';
this.fieldName = fieldName;
this.format = format;
this.httpStatusCodeType = resultTypes;
this.docs = {};
}
}
export class BinaryResult {
constructor(fieldName) {
this.kind = 'binaryResult';
this.fieldName = fieldName;
this.docs = {};
}
}
export class HeadAsBooleanResult {
constructor(fieldName) {
this.kind = 'headAsBooleanResult';
this.fieldName = fieldName;
this.docs = {};
}
}
export class HeaderMapResponse {
constructor(fieldName, type, headerName) {
this.kind = 'headerMapResponse';
this.fieldName = fieldName;
this.type = type;
this.headerName = headerName;
this.docs = {};
}
}
export class HeaderScalarResponse {
constructor(fieldName, type, headerName, byValue) {
this.kind = 'headerScalarResponse';
this.fieldName = fieldName;
this.type = type;
this.byValue = byValue;
this.headerName = headerName;
this.docs = {};
}
}
export class ModelResult {
constructor(type, format) {
this.kind = 'modelResult';
this.modelType = type;
this.format = format;
this.docs = {};
}
}
export class MonomorphicResult {
constructor(fieldName, format, type, byValue) {
this.kind = 'monomorphicResult';
this.fieldName = fieldName;
this.format = format;
this.monomorphicType = type;
this.byValue = byValue;
this.docs = {};
}
}
export class PolymorphicResult {
constructor(type) {
this.kind = 'polymorphicResult';
this.interface = type;
this.format = 'JSON';
this.docs = {};
}
}
export class ResponseEnvelope {
constructor(name, docs, forMethod) {
this.docs = docs;
this.headers = new Array();
this.method = forMethod;
this.name = name;
}
}
//# sourceMappingURL=result.js.map