@autorest/go
Version:
AutoRest Go Generator
293 lines • 13 kB
TypeScript
import { MethodExample } from './examples.js';
import * as pkg from './codeModel.js';
import * as method from './method.js';
import * as module from './module.js';
import * as param from './param.js';
import * as result from './result.js';
import * as type from './type.js';
/** an SDK client */
export interface Client {
kind: 'client';
/** the name of the client */
name: string;
/** any docs for the client */
docs: type.Docs;
/** contains info for client instances */
instance?: Constructable | TemplatedHost;
/** constructor params that are persisted as fields on the client, can be empty */
parameters: Array<ClientParameter>;
/** contains client methods. can be empty */
methods: Array<MethodType>;
/** contains any client accessor methods. can be empty */
clientAccessors: Array<ClientAccessor>;
/** the package to which this client belongs */
pkg: module.PackageContent;
/**
* for versioned clients, the API versions used to generate the
* content as well as the default API version used in requests.
* while most versioned clients will have a single API version,
* some may use distinct API versions for different methods.
*/
apiVersions: Array<type.ConstantDef>;
/** the parent client in a hierarchical client */
parent?: Client;
}
/** contains client endpoint configuration */
export interface ClientEndpoint {
/** the parameter that contains the service endpoint */
parameter: param.URIParameter;
/**
* indicates that the endpoint requires additional host configuration. i.e. the
* endpoint passed by the caller will be augmented with supplemental path info.
*/
supplemental?: SupplementalEndpoint;
}
/** contains data for instantiable clients. */
export interface Constructable {
kind: 'constructable';
/** the client options type used in the constructors */
options: ClientOptionsType;
/** the constructor functions for a client */
constructors: Array<Constructor>;
/** the client endpoint configuration */
endpoint?: ClientEndpoint;
}
/** the possible types used for the client options type */
export type ClientOptionsType = type.ArmClientOptions | ClientOptions;
/** the possible client parameter types */
export type ClientParameter = ClientCredentialParameter | param.MethodParameter;
/** a client method that returns a sub-client instance */
export interface ClientAccessor extends method.Method<Client, Client> {
kind: 'clientAccessor';
/** the name of the client accessor method */
name: string;
/** the method's return type */
returns: Client;
}
/** a credential constructor parameter */
export interface ClientCredentialParameter extends method.Parameter {
kind: 'credentialParam';
/** the parameter's type */
type: type.TokenCredential;
style: 'required';
group: never;
}
/** the client options parameter type */
export interface ClientOptions {
kind: 'clientOptions';
/** the name of the type */
name: string;
/** any docs for the type */
docs: type.Docs;
/** the parameters that belong to this options */
parameters: Array<param.MethodParameter>;
/** the package to which this type belongs */
pkg: module.PackageContent;
}
/** a client constructor function */
export interface Constructor {
/** the name of the constructor function */
name: string;
/** the modeled parameters. can be empty */
parameters: Array<ClientParameter>;
/** the package to which this constructor belongs */
pkg: module.PackageContent;
}
/** contains data on how to supplement a client endpoint */
export interface SupplementalEndpoint {
/** the supplemental path used to construct the complete endpoint */
path: string;
/** the parameters used to replace segments in the path */
parameters: Array<param.URIParameter>;
}
/**
* NOTE: this is for compat with Autorest, tsp MUST NOT use this!
* templatedHost indicates that there's one or more URIParameters
* required to construct the complete host. the parameters can
* be solely on the client or span client and method params.
*/
export interface TemplatedHost {
kind: 'templatedHost';
/** the templated host path */
path: string;
}
/**
* returns true if the provided parameter is for the service API version
*
* @param param the parameter to inspect
* @returns true if the parameter is for the API version
*/
export declare function isAPIVersionParameter(param: ClientParameter): boolean;
/** the possible values defining the "final state via" behavior for LROs */
export type FinalStateVia = 'azure-async-operation' | 'location' | 'operation-location' | 'original-uri';
/** the supported HTTP verbs */
export type HTTPMethod = 'delete' | 'get' | 'head' | 'patch' | 'post' | 'put';
/** the possible method types */
export type MethodType = LROMethod | LROPageableMethod | SyncMethod | PageableMethod;
/** a long-running operation method */
export interface LROMethod extends LROMethodBase {
kind: 'lroMethod';
}
/** a long-running operation method that returns pages of responses */
export interface LROPageableMethod extends LROMethodBase, PageableMethodBase {
kind: 'lroPageableMethod';
}
/** a synchronous method */
export interface SyncMethod extends HttpMethodBase {
kind: 'method';
}
/** contains the names of the helper methods used to create a complete method implementation */
export interface MethodNaming {
/** the name of the internal method for consumption by LROs/paging methods */
internalMethod: string;
/** the name of the internal method that creates the HTTP request */
requestMethod: string;
/** the name of the internal method that handles the HTTP response */
responseMethod: string;
}
/**
* the internal method used for fetching the next page for a PageableMethod.
* It's unique from a regular Method as it's not exported and has no optional params/response envelope.
* thus, it's not included in the array of methods for a client.
*/
export interface NextPageMethod {
kind: 'nextPageMethod';
/** the name of the next page method */
name: string;
/** the HTTP path used when creating the request */
httpPath: string;
/** the HTTP verb used when creating the request */
httpMethod: HTTPMethod;
/** any modeled parameters */
parameters: Array<param.MethodParameter>;
/** the complete list of successful HTTP status codes */
httpStatusCodes: Array<number>;
/** the method's receiver parameter */
receiver: method.Receiver<Client>;
}
/** a synchronous method that returns pages of responses */
export interface PageableMethod extends PageableMethodBase {
kind: 'pageableMethod';
}
/** the different strategies for fetching subsequent pages */
export type PageableStrategyKind = PageableStrategyContinuationToken | PageableStrategyNextLink;
/** indicates a pageable method uses the continuation token strategy */
export interface PageableStrategyContinuationToken {
kind: 'continuationToken';
/** the parameter that contains the continuation token */
requestToken: param.HeaderScalarParameter | param.QueryScalarParameter;
/**
* the location in the response that contains the continuation token.
* can be a response header or a field in response model.
*/
responseToken: result.HeaderScalarResponse | PageableStrategyNextLink;
}
/** indicates a pageable method uses the nextLink strategy */
export interface PageableStrategyNextLink {
kind: 'nextLink';
/**
* the field path in the response that contains the next link URL.
* one entry at minimum. when the next link is nested in the response
* type, the array will contain the "path" to the next link.
*/
nextLinkPath: Array<type.ModelField>;
/** the custom method used to fetch the next link */
method?: NextPageMethod;
}
/** narrows method to a LRO method type within the conditional block */
export declare function isLROMethod(method: MethodType): method is LROMethod | LROPageableMethod;
/** narrows method to a pageable method type within the conditional block */
export declare function isPageableMethod(method: MethodType): method is LROPageableMethod | PageableMethod;
/** creates the ClientOptions type from the specified input */
export declare function newClientOptions(pkg: module.PackageContent, modelType: pkg.CodeModelType, clientName: string): ClientOptionsType;
interface LROMethodBase extends HttpMethodBase {
finalStateVia?: FinalStateVia;
operationLocationResultPath?: string;
}
interface HttpMethodBase extends method.Method<Client, result.ResponseEnvelope> {
/** the HTTP path used when creating the request */
httpPath: string;
/** the HTTP verb used when creating the request */
httpMethod: HTTPMethod;
/** any modeled parameters. the ones we add to the generated code (context.Context etc) aren't included here */
parameters: Array<param.MethodParameter>;
/** the method options type for this method */
optionalParamsGroup: param.ParameterGroup;
/** the method's return type */
returns: result.ResponseEnvelope;
/** the complete list of successful HTTP status codes */
httpStatusCodes: Array<number>;
/** naming info for the internal hepler methods for which this method depends */
naming: MethodNaming;
/** any examples for this method */
examples: Array<MethodExample>;
}
interface PageableMethodBase extends HttpMethodBase {
/**
* the HTTP verb when fetching from the next link URL.
* the default is get
*/
nextLinkVerb: 'get' | 'post';
/**
* the strategy used to fetch the next page.
* no strategy indicates the method is modeled as pageable
* but doesn't (yet) support fetching subsequent pages.
*/
strategy?: PageableStrategyKind;
}
declare class HttpMethodBase extends method.Method<Client, result.ResponseEnvelope> implements HttpMethodBase {
constructor(name: string, client: Client, httpPath: string, httpMethod: HTTPMethod, statusCodes: Array<number>, naming: MethodNaming);
}
export declare class Client implements Client {
constructor(pkg: module.PackageContent, name: string, docs: type.Docs);
}
export declare class ClientEndpoint implements ClientEndpoint {
constructor(parameter: param.URIParameter);
}
export declare class ClientAccessor extends method.Method<Client, Client> implements ClientAccessor {
constructor(name: string, client: Client, returns: Client);
}
export declare class Constructable implements Constructable {
constructor(options: ClientOptionsType);
}
export declare class ClientCredentialParameter extends method.Parameter implements ClientCredentialParameter {
constructor(name: string, type: type.TokenCredential);
}
export declare class ClientOptions implements ClientOptions {
constructor(pkg: module.PackageContent, name: string);
}
export declare class Constructor implements Constructor {
constructor(pkg: module.PackageContent, name: string);
}
export declare class LROMethod extends HttpMethodBase implements LROMethod {
constructor(name: string, client: Client, httpPath: string, httpMethod: HTTPMethod, statusCodes: Array<number>, naming: MethodNaming);
}
export declare class LROPageableMethod extends HttpMethodBase implements LROPageableMethod {
constructor(name: string, client: Client, httpPath: string, httpMethod: HTTPMethod, statusCodes: Array<number>, naming: MethodNaming);
}
export declare class SyncMethod extends HttpMethodBase implements SyncMethod {
constructor(name: string, client: Client, httpPath: string, httpMethod: HTTPMethod, statusCodes: Array<number>, naming: MethodNaming);
}
export declare class MethodNaming implements MethodNaming {
constructor(internalMethod: string, requestMethod: string, responseMethod: string);
}
export declare class NextPageMethod implements NextPageMethod {
constructor(name: string, client: Client, httpPath: string, httpMethod: HTTPMethod, statusCodes: Array<number>);
}
export declare class PageableMethod extends HttpMethodBase implements PageableMethod {
constructor(name: string, client: Client, httpPath: string, httpMethod: HTTPMethod, statusCodes: Array<number>, naming: MethodNaming);
}
export declare class PageableStrategyContinuationToken implements PageableStrategyContinuationToken {
constructor(requestToken: param.HeaderScalarParameter | param.QueryScalarParameter, responseToken: result.HeaderScalarResponse | PageableStrategyNextLink);
}
export declare class PageableStrategyNextLink implements PageableStrategyNextLink {
constructor(nextLinkPath: Array<type.ModelField>);
}
export declare class SupplementalEndpoint implements SupplementalEndpoint {
constructor(path: string);
}
export declare class TemplatedHost implements TemplatedHost {
constructor(path: string);
}
export {};
//# sourceMappingURL=client.d.ts.map