diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..36b356317b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "trailingComma": "none" +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 7406d6dd65..87c23424e8 100755 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -51,6 +51,23 @@ "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "IntegrationTests - Current File", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-r", + "ts-node/register", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/${relativeFile}" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "protocol": "inspector" } ] } diff --git a/package-lock.json b/package-lock.json index c769da6386..61fe00dbff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,24 +113,24 @@ "integrity": "sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg==" }, "@azure/core-auth": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.0.2.tgz", - "integrity": "sha512-zhPJObdrhz2ymIqGL1x8i3meEuaLz0UPjH9mOq9RGOlJB2Pb6K6xPtkHbRsfElgoO9USR4hH2XU5pLa4/JHHIw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.1.1.tgz", + "integrity": "sha512-9Sgl5tFu9s1UKghJUx1VK72CiShSeHbubaaE1xkK/xRc6CU11nU3aEFZBJxWNqBQoR1KmOk53mOQEz4haVLo6w==", "requires": { "@azure/abort-controller": "^1.0.0", "@azure/core-tracing": "1.0.0-preview.7", "@opentelemetry/types": "^0.2.0", - "tslib": "^1.9.3" + "tslib": "^1.10.0" } }, "@azure/core-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.0.4.tgz", - "integrity": "sha512-UhQ4Tpgv6a/7fmvleXEpyQAg8FWcemqzAPY2F75QBygEDD4Hsz2fFujTAEUBQ1an+eNQjzk7EC7TTbqXOmiwAw==", + "version": "1.1.1-dev.20200410.1", + "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.1.1-dev.20200410.1.tgz", + "integrity": "sha512-9pGlmGXB+nJowcwOPGy5q9jNvmCS0sBIlNeahfNH3SXrK32Uq9KeIE5f6WorqHOR0KXc26hM9Od/gmr8YFoUfA==", "requires": { "@azure/abort-controller": "^1.0.0", - "@azure/core-auth": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.7", + "@azure/core-auth": "^1.1.0", + "@azure/core-tracing": "^1.0.0-dev", "@azure/logger": "^1.0.0", "@opentelemetry/types": "^0.2.0", "@types/node-fetch": "^2.5.0", @@ -178,6 +178,51 @@ "@opentelemetry/types": "^0.2.0", "events": "^3.0.0", "tslib": "^1.10.0" + }, + "dependencies": { + "@azure/core-http": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.1.0.tgz", + "integrity": "sha512-2H9AU5PxOSpRggWvOwDOSjJ6+Vym7r8nkdm0PQVGXPiyHjhrR/pvYqi5fHKPYDQQL4hm0eQy7LsT0dRIfdeztw==", + "requires": { + "@azure/abort-controller": "^1.0.0", + "@azure/core-auth": "^1.1.0", + "@azure/core-tracing": "1.0.0-preview.7", + "@azure/logger": "^1.0.0", + "@opentelemetry/types": "^0.2.0", + "@types/node-fetch": "^2.5.0", + "@types/tunnel": "^0.0.1", + "cross-env": "^6.0.3", + "form-data": "^3.0.0", + "node-fetch": "^2.6.0", + "process": "^0.11.10", + "tough-cookie": "^3.0.1", + "tslib": "^1.10.0", + "tunnel": "^0.0.6", + "uuid": "^3.3.2", + "xml2js": "^0.4.19" + } + }, + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "tough-cookie": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", + "integrity": "sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg==", + "requires": { + "ip-regex": "^2.1.0", + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + } } }, "@azure/core-paging": { @@ -1353,9 +1398,9 @@ }, "dependencies": { "cross-spawn": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", - "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz", + "integrity": "sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==", "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", diff --git a/package.json b/package.json index 46717e1241..4db5f11ff3 100755 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@azure-tools/codemodel": "4.13.317", "@azure-tools/linq": "3.1.206", "@azure-tools/openapi": "3.0.209", - "@azure/core-http": "^1.0.4", + "@azure/core-http": "^1.1.1-dev.20200410.1", "@azure/core-lro": "^1.0.1", "@azure/core-paging": "^1.0.0", "@azure/logger": "^1.0.0", diff --git a/src/generators/LROGenerator.ts b/src/generators/LROGenerator.ts index e0a55a985d..381d53c681 100644 --- a/src/generators/LROGenerator.ts +++ b/src/generators/LROGenerator.ts @@ -2,6 +2,7 @@ import { ClientDetails } from "../models/clientDetails"; import { Project } from "ts-morph"; import { OperationGroupDetails } from "../models/operationDetails"; import { promises } from "fs"; +import { join as joinPath } from "path"; export async function generateLROFiles( clientDetails: ClientDetails, @@ -11,19 +12,16 @@ export async function generateLROFiles( return; } - const lroFiles = [ - { name: "bodyPollingStrategy", file: "./src/lro/bodyPollingStrategy.ts" }, - { name: "lroPoller", file: "./src/lro/lroPoller.ts" }, - { name: "models", file: "./src/lro/models.ts" }, - { name: "operation", file: "./src/lro/operation.ts" } - ]; + const lroDir = joinPath(__dirname, "..", "..", "..", "src", "lro"); + const lroFiles = await promises.readdir(lroDir); for (let i = 0; i < lroFiles.length; i++) { - const { name, file } = lroFiles[i]; - const fileContent = await promises.readFile(file, "utf-8"); + const file = lroFiles[i]; + const filePath = joinPath(lroDir, file); + const fileContent = await promises.readFile(filePath, "utf-8"); project.createSourceFile( - `${clientDetails.srcPath}/lro/${name}.ts`, + joinPath(clientDetails.srcPath || "", "lro", file), fileContent, { overwrite: true } ); diff --git a/src/generators/clientContextFileGenerator.ts b/src/generators/clientContextFileGenerator.ts index be39f19c95..a432f29126 100644 --- a/src/generators/clientContextFileGenerator.ts +++ b/src/generators/clientContextFileGenerator.ts @@ -25,6 +25,11 @@ export function generateClientContext( const clientParams = clientDetails.parameters.filter( param => param.implementationLocation === ImplementationLocation.Client ); + + const hasLRO = clientDetails.operationGroups.some(og => + og.operations.some(o => o.isLRO) + ); + const clientContextClassName = `${clientDetails.className}Context`; const clientContextFileName = normalizeName( clientContextClassName, @@ -39,7 +44,7 @@ export function generateClientContext( } ); - writeImports(sourceFile); + writeImports(sourceFile, hasLRO); writePackageInfo(sourceFile, packageDetails); const contextClass = buildClass(sourceFile, clientContextClassName); @@ -51,10 +56,14 @@ export function generateClientContext( clientParams }); - writeConstructorBody(classConstructor, { - clientParams, - clientDetails - }); + writeConstructorBody( + classConstructor, + { + clientParams, + clientDetails + }, + hasLRO + ); } interface WriteConstructorBodyParameters { @@ -62,7 +71,7 @@ interface WriteConstructorBodyParameters { clientDetails: ClientDetails; } -function writeImports(sourceFile: SourceFile) { +function writeImports(sourceFile: SourceFile, hasLRO: boolean) { sourceFile.addImportDeclaration({ namespaceImport: "coreHttp", moduleSpecifier: "@azure/core-http" @@ -72,6 +81,13 @@ function writeImports(sourceFile: SourceFile) { namespaceImport: "Models", moduleSpecifier: "./models" }); + + if (hasLRO) { + sourceFile.addImportDeclaration({ + namedImports: ["lroPolicy"], + moduleSpecifier: "./lro" + }); + } } function writePackageInfo( @@ -104,7 +120,8 @@ function writeClassProperties( function writeConstructorBody( classConstructor: ConstructorDeclaration, - { clientParams, clientDetails }: WriteConstructorBodyParameters + { clientParams, clientDetails }: WriteConstructorBodyParameters, + hasLRO: boolean ) { const requiredParams = getRequiredParameters(clientParams); const addBlankLine = true; @@ -113,7 +130,10 @@ function writeConstructorBody( classConstructor.addStatements([ writeStatements(getRequiredParamChecks(requiredParams), addBlankLine), writeStatement( - writeDefaultOptions(clientParams.some(p => p.name === "credentials")) + writeDefaultOptions( + clientParams.some(p => p.name === "credentials"), + hasLRO + ) ), writeStatement(getEndpointStatement(clientDetails.endpoint), addBlankLine), requiredParameters.length ? "// Parameter assignments" : "", @@ -141,7 +161,16 @@ const writeStatements = (lines: string[], shouldAddBlankLine = false) => ( shouldAddBlankLine && writer.blankLine(); }; -function writeDefaultOptions(hasCredentials: boolean) { +function writeDefaultOptions(hasCredentials: boolean, hasLRO: boolean) { + const policies = ` + const defaultPipelines = coreHttp.createPipelineFromOptions(options) + .requestPolicyFactories as coreHttp.RequestPolicyFactory[]; + + options = { + ...options, + requestPolicyFactories: [lroPolicy(), ...defaultPipelines] + };`; + return `// Initializing default values for options if (!options) { options = {}; @@ -152,6 +181,8 @@ function writeDefaultOptions(hasCredentials: boolean) { options.userAgent = \`\${packageName}/\${packageVersion} \${defaultUserAgent}\`; } + ${hasLRO ? policies : ""} + super(${hasCredentials ? "credentials" : `undefined`}, options); this.requestContentType = "application/json; charset=utf-8"; diff --git a/src/generators/operationGenerator.ts b/src/generators/operationGenerator.ts index b8fab19424..59566e336f 100644 --- a/src/generators/operationGenerator.ts +++ b/src/generators/operationGenerator.ts @@ -109,6 +109,26 @@ function generateOperation( ); } +function writeGetOperationOptions(operationGroupClass: ClassDeclaration) { + operationGroupClass.addMethod({ + scope: Scope.Private, + name: "getOperationOptions", + parameters: [ + { name: "options", type: "TOptions | undefined" }, + { name: "finalStateVia", type: "string", hasQuestionToken: true } + ], + returnType: `coreHttp.RequestOptionsBase`, + statements: ` + const operationOptions: coreHttp.OperationOptions = options || {}; + operationOptions.requestOptions = { + ...operationOptions.requestOptions, + shouldDeserialize: shouldDeserializeLRO(finalStateVia), + }; + return coreHttp.operationOptionsToRequestOptionsBase(operationOptions); + ` + }); +} + /** * Generates a string representation of an Operation spec * the output is to be inserted in the Operation group file @@ -341,6 +361,10 @@ function addClass( clientDetails.parameters ); + if (hasLROOperation(operationGroupDetails)) { + writeGetOperationOptions(operationGroupClass); + } + // Use named import from Models if (importedModels.size) { // Add alias to any model that collides with the class name @@ -593,14 +617,29 @@ function writeNoOverloadsOperationBody( parameterDeclarations: ParameterWithDescription[], isInline: boolean ): void { - const sendParams = parameterDeclarations.map(p => p.name).join(","); + const sendParams = parameterDeclarations + .map(p => (p.name === "options" ? "options: operationOptions" : p.name)) + .join(","); + + const finalStateVia = + operation.lroOptions && operation.lroOptions["final-state-via"]; + const operationSpecName = `${operation.name}OperationSpec`; + + const operationOptions = operation.isLRO + ? `const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions(options, + ${finalStateVia ? `"${finalStateVia}"` : ""});` + : `const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(options || {});`; + + operationMethod.addStatements(operationOptions); + if (operation.isLRO) { writeLROOperationBody( sendParams, responseName, operationSpecName, - operationMethod + operationMethod, + finalStateVia ); } else { operationMethod.addStatements( @@ -617,10 +656,15 @@ function writeLROOperationBody( sendParams: string, responseName: string, operationSpecName: string, - methodDeclaration: MethodDeclaration + methodDeclaration: MethodDeclaration, + finalStateVia?: string ) { + const finalStateStr = finalStateVia + ? `finalStateVia: "${finalStateVia.toLowerCase()}"` + : ""; + const operationBody = ` - const args = {${sendParams}}; + const args: coreHttp.OperationArguments = {${sendParams}}; const sendOperation = (args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec) => this.client.sendOperationRequest(args, spec) as Promise<${responseName}>; const initialOperationResult = await sendOperation(args, ${operationSpecName}); @@ -628,7 +672,8 @@ function writeLROOperationBody( initialOperationArguments: args, initialOperationSpec: ${operationSpecName}, initialOperationResult, - sendOperation + sendOperation, + ${finalStateStr} }); `; @@ -711,7 +756,14 @@ function writeMultiMediaTypeOperationBody( isInline ? "" : ".client" }.sendOperationRequest(operationArguments, operationSpec) as Promise<${responseName}>`; } else { - ` + const finalStateVia = + operation.lroOptions && operation.lroOptions["final-state-via"]; + + const finalStateStr = finalStateVia + ? `finalStateVia: "${finalStateVia.toLowerCase()}"` + : ""; + + statements += ` const sendOperation = (args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec) => this.client.sendOperationRequest(args, spec) as Promise<${responseName}>; const initialOperationResult = await sendOperation(operationArguments, operationSpec); @@ -719,7 +771,8 @@ function writeMultiMediaTypeOperationBody( initialOperationArguments: operationArguments, initialOperationSpec: operationSpec initialOperationResult, - sendOperation + sendOperation, + ${finalStateStr} }); `; } @@ -880,8 +933,8 @@ function addImports( if (hasLROOperation(operationGroupDetails)) { operationGroupFile.addImportDeclaration({ - namedImports: ["LROPoller"], - moduleSpecifier: `../lro/lroPoller` + namedImports: ["LROPoller", "shouldDeserializeLRO"], + moduleSpecifier: `../lro` }); } } diff --git a/src/lro/azureAsyncOperationStrategy.ts b/src/lro/azureAsyncOperationStrategy.ts new file mode 100644 index 0000000000..e2d93f584a --- /dev/null +++ b/src/lro/azureAsyncOperationStrategy.ts @@ -0,0 +1,189 @@ +import { + LROStrategy, + BaseResult, + LROOperationStep, + LROResponseInfo, + FinalStateVia +} from "./models"; +import { OperationSpec, OperationArguments } from "@azure/core-http"; +import { terminalStates } from "./constants"; +import { SendOperationFn } from "."; + +export function createAzureAsyncOperationStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + finalStateVia?: FinalStateVia +): LROStrategy { + const lroData = initialOperation.result._lroData; + if (!lroData) { + throw new Error( + "Expected lroData to be defined for Azure-AsyncOperation strategy" + ); + } + + let currentOperation = initialOperation; + let lastKnownPollingUrl = + lroData.azureAsyncOperation || lroData.operationLocation; + + return { + isTerminal: () => { + const currentResult = currentOperation.result._lroData; + + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (currentOperation === initialOperation) { + // Azure-AsyncOperations don't need to check for terminal state + // on originalOperation result, always need to poll + return false; + } + + const { status = "succeeded" } = currentResult; + return terminalStates.includes(status.toLowerCase()); + }, + sendFinalRequest: async () => { + if (!initialOperation.result._lroData) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (!currentOperation.result._lroData) { + throw new Error("Expected lroData to determine terminal status"); + } + + const initialOperationResult = initialOperation.result._lroData; + const currentOperationResult = currentOperation.result._lroData; + + if ( + !shouldPerformFinalGet(initialOperationResult, currentOperationResult) + ) { + return currentOperation; + } + + if (initialOperationResult.requestMethod === "PUT") { + currentOperation = await sendFinalGet( + initialOperation, + sendOperationFn + ); + + return currentOperation; + } + + if (initialOperationResult.location) { + switch (finalStateVia) { + case "original-uri": + currentOperation = await sendFinalGet( + initialOperation, + sendOperationFn + ); + return currentOperation; + + case "azure-async-operation": + return currentOperation; + case "location": + default: + const location = + initialOperationResult.location || + currentOperationResult.location; + + if (!location) { + throw new Error("Couldn't determine final GET URL from location"); + } + + return await sendFinalGet( + initialOperation, + sendOperationFn, + location + ); + } + } + + // All other cases return the last operation + return currentOperation; + }, + poll: async () => { + if (!lastKnownPollingUrl) { + throw new Error("Unable to determine polling url"); + } + + const pollingArgs = currentOperation.args; + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = currentOperation.spec; + const pollingSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET", + path: lastKnownPollingUrl + }; + + const result = await sendOperationFn(pollingArgs, pollingSpec); + + // Update latest polling url + lastKnownPollingUrl = + result._lroData?.azureAsyncOperation || + result._lroData?.operationLocation || + lastKnownPollingUrl; + + // Update lastOperation result + currentOperation = { + args: pollingArgs, + spec: pollingSpec, + result + }; + + return currentOperation; + } + }; +} + +function shouldPerformFinalGet( + initialResult: LROResponseInfo, + currentResult: LROResponseInfo +) { + const { status } = currentResult; + const { requestMethod: initialRequestMethod, location } = initialResult; + if (status && status.toLowerCase() !== "succeeded") { + return false; + } + + if (initialRequestMethod === "DELETE") { + return false; + } + + if (initialRequestMethod !== "PUT" && !location) { + return false; + } + + return true; +} + +async function sendFinalGet( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + path?: string +): Promise> { + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = initialOperation.spec; + const finalGetSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET" + }; + + // Send final GET request to the Original URL + const spec = { + ...finalGetSpec, + ...(path && { path }) + }; + + let operationArgs: OperationArguments = initialOperation.args; + if (operationArgs.options) { + operationArgs.options.shouldDeserialize = true; + } + + const finalResult = await sendOperationFn(initialOperation.args, spec); + + return { + args: initialOperation.args, + spec, + result: finalResult + }; +} diff --git a/src/lro/bodyPollingStrategy.ts b/src/lro/bodyPollingStrategy.ts index 566495635d..1a4212c0e2 100644 --- a/src/lro/bodyPollingStrategy.ts +++ b/src/lro/bodyPollingStrategy.ts @@ -1,46 +1,59 @@ -import { LROStrategy, BaseResult, LROOperationState } from "./models"; +import { + LROStrategy, + BaseResult, + LROOperationStep, + LROResponseInfo +} from "./models"; import { OperationSpec } from "@azure/core-http"; - -const terminalStates = ["succeeded", "failed", "canceled", "cancelled"]; +import { terminalStates } from "./constants"; +import { SendOperationFn } from "./lroPoller"; /** * Creates a polling strategy based on BodyPolling which uses the provisioning state * from the result to determine the current operation state */ -export function createBodyPollingStrategy({ - lastOperation: operation, - sendOperation -}: LROOperationState): LROStrategy { - let lastOperation = { ...operation }; +export function createBodyPollingStrategy( + initialOperation: LROOperationStep, + sendOperation: SendOperationFn +): LROStrategy { + if (!initialOperation.result._lroData) { + throw new Error("Expected lroData to be defined for BodyPolling strategy"); + } + + let currentOperation = initialOperation; + return { isTerminal: () => { + const currentResult = currentOperation.result._lroData; + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + const { provisioningState = "succeeded" } = currentResult; // If provisioning state is missing, default to Success - const provisioningState = ( - lastOperation.result.provisioningState || - lastOperation.result.properties?.provisioningState || - "succeeded" - ).toLowerCase(); - return terminalStates.includes(provisioningState); + return terminalStates.includes(provisioningState.toLowerCase()); }, sendFinalRequest: () => { // BodyPolling doesn't require a final get so return the lastOperation - return Promise.resolve(lastOperation); + return Promise.resolve(currentOperation); }, poll: async () => { // When doing BodyPolling, we need to poll to the original url with a // GET http method + const { requestBody, ...restSpec } = initialOperation.spec; const pollingSpec: OperationSpec = { - ...lastOperation.spec, + // Make sure we don't send any body to the get request + ...restSpec, httpMethod: "GET" }; // Execute the polling operation - const result = await sendOperation(lastOperation.args, pollingSpec); - - // Update lastOperation result - lastOperation.result = result; - return lastOperation; + initialOperation.result = await sendOperation( + initialOperation.args, + pollingSpec + ); + return initialOperation; } }; } diff --git a/src/lro/constants.ts b/src/lro/constants.ts new file mode 100644 index 0000000000..b0a9acd375 --- /dev/null +++ b/src/lro/constants.ts @@ -0,0 +1 @@ +export const terminalStates = ["succeeded", "failed", "canceled", "cancelled"]; diff --git a/src/lro/index.ts b/src/lro/index.ts new file mode 100644 index 0000000000..a2a8e9c0e3 --- /dev/null +++ b/src/lro/index.ts @@ -0,0 +1,15 @@ +export { shouldDeserializeLRO } from "./requestUtils"; +export { createBodyPollingStrategy } from "./bodyPollingStrategy"; +export { terminalStates } from "./constants"; +export { lroPolicy } from "./lroPolicy"; +export { LROPoller, LROPollerOptions, SendOperationFn } from "./lroPoller"; +export { + LROResponseInfo, + BaseResult, + LROOperationStep, + LROOperationState, + LROStrategy, + LROOperation +} from "./models"; +export { makeOperation } from "./operation"; +export * from "./locationStrategy"; diff --git a/src/lro/locationStrategy.ts b/src/lro/locationStrategy.ts new file mode 100644 index 0000000000..7349765644 --- /dev/null +++ b/src/lro/locationStrategy.ts @@ -0,0 +1,66 @@ +import { BaseResult, LROOperationStep, LROStrategy } from "./models"; +import { SendOperationFn } from "./lroPoller"; +import { OperationSpec } from "@azure/core-http"; + +export function createLocationStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn +): LROStrategy { + const lroData = initialOperation.result._lroData; + if (!lroData) { + throw new Error( + "Expected lroData to be defined for Azure-AsyncOperation strategy" + ); + } + + let currentOperation = initialOperation; + let lastKnownPollingUrl = lroData.location; + + return { + isTerminal: () => { + const currentResult = currentOperation.result._lroData; + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (currentOperation === initialOperation) { + return false; + } + + if (currentResult.statusCode === 202) { + return false; + } + + return true; + }, + sendFinalRequest: () => Promise.resolve(currentOperation), + poll: async () => { + if (!lastKnownPollingUrl) { + throw new Error("Unable to determine polling url"); + } + + const pollingArgs = currentOperation.args; + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = currentOperation.spec; + const pollingSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET", + path: lastKnownPollingUrl + }; + + const result = await sendOperationFn(pollingArgs, pollingSpec); + + // Update latest polling url + lastKnownPollingUrl = result._lroData?.location || lastKnownPollingUrl; + + // Update lastOperation result + currentOperation = { + args: pollingArgs, + spec: pollingSpec, + result + }; + + return currentOperation; + } + }; +} diff --git a/src/lro/lroPolicy.ts b/src/lro/lroPolicy.ts new file mode 100644 index 0000000000..4010a82630 --- /dev/null +++ b/src/lro/lroPolicy.ts @@ -0,0 +1,36 @@ +import { + RequestPolicy, + RequestPolicyOptions, + BaseRequestPolicy, + HttpOperationResponse, + WebResource +} from "@azure/core-http"; +import { getLROData } from "./requestUtils"; +import { isEmpty } from "lodash"; + +export function lroPolicy() { + return { + create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => { + return new LROPolicy(nextPolicy, options); + } + }; +} + +class LROPolicy extends BaseRequestPolicy { + constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) { + super(nextPolicy, options); + } + + public async sendRequest( + webResource: WebResource + ): Promise { + let result = await this._nextPolicy.sendRequest(webResource); + + if (webResource.shouldDeserialize !== undefined) { + const _lroData = getLROData(result); + result.parsedBody = { ...result.parsedBody, _lroData }; + } + + return result; + } +} diff --git a/src/lro/lroPoller.ts b/src/lro/lroPoller.ts index 678db61058..34d6d5ffa4 100644 --- a/src/lro/lroPoller.ts +++ b/src/lro/lroPoller.ts @@ -1,7 +1,21 @@ -import { Poller } from "@azure/core-lro"; -import { OperationSpec, OperationArguments, delay } from "@azure/core-http"; -import { BaseResult, LROOperationState } from "./models"; +import { Poller, PollOperationState } from "@azure/core-lro"; +import { + OperationSpec, + OperationArguments, + delay, + RestError +} from "@azure/core-http"; +import { + BaseResult, + LROOperationState, + LROOperationStep, + FinalStateVia +} from "./models"; import { makeOperation } from "./operation"; +import { createBodyPollingStrategy } from "./bodyPollingStrategy"; +import { createAzureAsyncOperationStrategy } from "./azureAsyncOperationStrategy"; +import { createLocationStrategy } from "./locationStrategy"; +import { createPassthroughStrategy } from "./passthroughStrategy"; export type SendOperationFn = ( args: OperationArguments, @@ -29,6 +43,10 @@ export interface LROPollerOptions { * Function to execute an operation based on an operation spec and arguments */ sendOperation: SendOperationFn; + /** + * Optional information on where to poll. When not defined it defaults to "Location" + */ + finalStateVia?: FinalStateVia; } export class LROPoller extends Poller< @@ -42,17 +60,27 @@ export class LROPoller extends Poller< initialOperationResult, initialOperationSpec, sendOperation, + finalStateVia, intervalInMs = 2000 }: LROPollerOptions) { + const initialOperation = { + args: initialOperationArguments, + spec: initialOperationSpec, + result: initialOperationResult + }; + + const pollingStrategy = getPollingStrategy( + initialOperation, + sendOperation, + finalStateVia + ); + const state: LROOperationState = { // Initial operation will become the last operation - lastOperation: { - args: initialOperationArguments, - spec: initialOperationSpec, - result: initialOperationResult - }, - sendOperation, - result: initialOperationResult + initialOperation, + lastOperation: initialOperation, + pollingStrategy, + finalStateVia }; const operation = makeOperation(state); @@ -68,3 +96,51 @@ export class LROPoller extends Poller< return delay(this.intervalInMs); } } + +/** + * This function determines which strategy to use based on the response from + * the last operation executed, this last operation can be an initial operation + * or a polling operation. The 3 possible strategies are described below: + * + * A) Azure-AsyncOperation or Operation-Location + * B) Location + * C) BodyPolling (provisioningState) + * - This strategy is used when: + * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location + * - Last operation method is PUT + */ +function getPollingStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + finalStateVia?: FinalStateVia +) { + const lroData = initialOperation.result._lroData; + + if (!lroData) { + const error = new RestError( + "Service response doesn't include the required LRO data to continue polling" + ); + error.statusCode = initialOperation.result._response.status; + error.response = initialOperation.result._response; + throw error; + } + + if (lroData.azureAsyncOperation || lroData.operationLocation) { + return createAzureAsyncOperationStrategy( + initialOperation, + sendOperationFn, + finalStateVia + ); + } + + if (lroData.location) { + return createLocationStrategy(initialOperation, sendOperationFn); + } + + if (["PUT", "PATCH"].includes(lroData.requestMethod || "")) { + return createBodyPollingStrategy(initialOperation, sendOperationFn); + } + + // Default strategy is just a passthrough returning the initial operation + return createPassthroughStrategy(initialOperation); +} diff --git a/src/lro/models.ts b/src/lro/models.ts index 467ad0f6e0..7caebbe059 100644 --- a/src/lro/models.ts +++ b/src/lro/models.ts @@ -1,21 +1,32 @@ import { OperationArguments, OperationSpec, - RestResponse + RestResponse, + HttpMethods } from "@azure/core-http"; import { PollOperationState, PollOperation } from "@azure/core-lro"; -export interface BaseResult extends RestResponse { - location?: string; - operationLocation?: string; +export type FinalStateVia = + | "azure-async-operation" + | "location" + | "original-uri"; + +export interface LROResponseInfo { + requestMethod: HttpMethods; + statusCode: number; + isInitialRequest?: boolean; azureAsyncOperation?: string; + operationLocation?: string; + location?: string; provisioningState?: string; - properties?: { - provisioningState?: string; - }; + status?: string; +} + +export interface BaseResult extends RestResponse { + _lroData?: LROResponseInfo; } -export interface LastOperation { +export interface LROOperationStep { args: OperationArguments; spec: OperationSpec; result: TResult; @@ -23,17 +34,16 @@ export interface LastOperation { export interface LROOperationState extends PollOperationState { - lastOperation: LastOperation; - sendOperation: ( - args: OperationArguments, - spec: OperationSpec - ) => Promise; + lastOperation: LROOperationStep; + initialOperation: LROOperationStep; + pollingStrategy: LROStrategy; + finalStateVia?: FinalStateVia; } export interface LROStrategy { isTerminal: () => boolean; - sendFinalRequest: () => Promise>; - poll: () => Promise>; + sendFinalRequest: () => Promise>; + poll: () => Promise>; } export type LROOperation = PollOperation< diff --git a/src/lro/operation.ts b/src/lro/operation.ts index 53ae5b6629..0448ab5d1d 100644 --- a/src/lro/operation.ts +++ b/src/lro/operation.ts @@ -1,9 +1,4 @@ -import { - BaseResult, - LROOperationState, - LROOperation, - LROStrategy -} from "./models"; +import { BaseResult, LROOperationState, LROOperation } from "./models"; import { createBodyPollingStrategy } from "./bodyPollingStrategy"; /** @@ -42,19 +37,27 @@ async function update( ): Promise> { const state = { ...this.state }; - // Get strategy from last operation - const lroStrategy: LROStrategy = getStrategyFromResult(state); + const { sendFinalRequest, poll, isTerminal } = state.pollingStrategy; + const currentResponse = state.lastOperation; + const currentLroData = currentResponse.result._lroData; + + if (!currentLroData) { + throw new Error( + "Expected lroData to be defined for updating LRO operation" + ); + } + + if (state.result) { + state.isCompleted = true; + return makeOperation(state); + } // Check if last result is terminal - if (lroStrategy.isTerminal()) { - const result = await lroStrategy.sendFinalRequest(); - state.lastOperation = result; + if (isTerminal()) { + state.lastOperation = await sendFinalRequest(); state.result = state.lastOperation.result; - state.isCompleted = true; } else { - const result = await lroStrategy.poll(); - state.lastOperation = result; - state.result = state.lastOperation.result; + state.lastOperation = await poll(); } // Return operation @@ -70,37 +73,3 @@ async function cancel( ): Promise> { return makeOperation({ ...this.state, isCancelled: true }); } - -/** - * This function determines which strategy to use based on the response from - * the last operation executed, this last operation can be an initial operation - * or a polling operation. The 3 possible strategies are described below: - * - * A) Azure-AsyncOperation or Operation-Location - * B) Location - * C) BodyPolling (provisioningState) - * - This strategy is used when: - * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location - * - Last operation method is PUT - */ -function getStrategyFromResult( - state: LROOperationState -): LROStrategy { - const { - lastOperation: { spec, result } - } = state; - - if (result.azureAsyncOperation) { - throw new Error("Azure-AsyncOperation strategy is not yet implemented"); - } - - if (result.location) { - throw new Error("Location strategy is not yet implemented"); - } - - if (["PUT", "PATCH"].includes(spec.httpMethod)) { - return createBodyPollingStrategy(state); - } - - throw new Error("Unknown Long Running Operation strategy"); -} diff --git a/src/lro/passthroughStrategy.ts b/src/lro/passthroughStrategy.ts new file mode 100644 index 0000000000..d49e3d6234 --- /dev/null +++ b/src/lro/passthroughStrategy.ts @@ -0,0 +1,23 @@ +import { LROStrategy, BaseResult, LROOperationStep } from "./models"; +import { SendOperationFn } from "./lroPoller"; + +/** + * Creates a polling strategy based on BodyPolling which uses the provisioning state + * from the result to determine the current operation state + */ +export function createPassthroughStrategy( + initialOperation: LROOperationStep +): LROStrategy { + return { + isTerminal: () => { + return true; + }, + sendFinalRequest: () => { + // BodyPolling doesn't require a final get so return the lastOperation + return Promise.resolve(initialOperation); + }, + poll: async () => { + throw new Error("Passthrough strategy should never poll"); + } + }; +} diff --git a/src/lro/requestUtils.ts b/src/lro/requestUtils.ts new file mode 100644 index 0000000000..e3289b9590 --- /dev/null +++ b/src/lro/requestUtils.ts @@ -0,0 +1,109 @@ +import { HttpOperationResponse } from "@azure/core-http"; +import { terminalStates } from "./constants"; +import { LROResponseInfo } from "./models"; + +/** + * We need to selectively deserialize our responses, only deserializing if we + * are in a final LRO response, not deserializing any polling non-terminal responses + */ +export function shouldDeserializeLRO(finalStateVia?: string) { + let initialOperationInfo: LROResponseInfo | undefined; + let isInitialRequest = true; + + return (response: HttpOperationResponse) => { + if (response.status < 200 || response.status >= 300) { + return true; + } + + if (!initialOperationInfo) { + initialOperationInfo = getLROData(response); + } else { + isInitialRequest = false; + } + + if ( + initialOperationInfo.azureAsyncOperation || + initialOperationInfo.operationLocation + ) { + return ( + !isInitialRequest && + isAsyncOperationFinalResponse( + response, + initialOperationInfo, + finalStateVia + ) + ); + } + + if (initialOperationInfo.location) { + return isLocationFinalResponse(response); + } + + if (initialOperationInfo.requestMethod === "PUT") { + return isBodyPollingFinalResponse(response); + } + + return true; + }; +} + +function isAsyncOperationFinalResponse( + response: HttpOperationResponse, + initialOperationInfo: LROResponseInfo, + finalStateVia?: string +): boolean { + const status: string = response.parsedBody?.status || "Succeeded"; + if (!terminalStates.includes(status.toLowerCase())) { + return false; + } + + if (initialOperationInfo.requestMethod === "DELETE") { + return true; + } + + if ( + initialOperationInfo.requestMethod === "PUT" && + finalStateVia && + finalStateVia.toLowerCase() === "azure-asyncoperation" + ) { + return true; + } + + if ( + initialOperationInfo.requestMethod !== "PUT" && + !initialOperationInfo.location + ) { + return true; + } + + return false; +} + +function isLocationFinalResponse(response: HttpOperationResponse): boolean { + return response.status !== 202; +} + +function isBodyPollingFinalResponse(response: HttpOperationResponse): boolean { + const provisioningState: string = + response.parsedBody?.properties?.provisioningState || "Succeeded"; + + if (terminalStates.includes(provisioningState.toLowerCase())) { + return true; + } + + return false; +} + +export function getLROData(result: HttpOperationResponse): LROResponseInfo { + const statusCode = result.status; + const { status, properties } = result.parsedBody || {}; + return { + statusCode, + azureAsyncOperation: result.headers.get("azure-asyncoperation"), + operationLocation: result.headers.get("operation-location"), + location: result.headers.get("location"), + requestMethod: result.request.method, + status, + provisioningState: properties?.provisioningState + }; +} diff --git a/src/models/operationDetails.ts b/src/models/operationDetails.ts index 48fc45e98a..ea312b9afc 100644 --- a/src/models/operationDetails.ts +++ b/src/models/operationDetails.ts @@ -62,6 +62,7 @@ export interface OperationDetails { mediaTypes: Set; pagination?: PaginationDetails; isLRO: boolean; + lroOptions: { "final-state-via": string }; } /** diff --git a/src/transforms/operationTransforms.ts b/src/transforms/operationTransforms.ts index 28e85c0cf3..cbe7d01385 100644 --- a/src/transforms/operationTransforms.ts +++ b/src/transforms/operationTransforms.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { HttpMethods, Mapper } from "@azure/core-http"; +import { HttpMethods, Mapper, OperationSpec } from "@azure/core-http"; import { Operation, Request, @@ -34,6 +34,53 @@ import { PropertyKind, TypeDetails } from "../models/modelDetails"; import { KnownMediaType } from "@azure-tools/codegen"; import { headersToSchema } from "../utils/headersToSchema"; import { extractPaginationDetails } from "../utils/extractPaginationDetails"; +import { isEmpty, isEqual } from "lodash"; + +/** + * SWAGGER doesn't require to define all possible response codes + * for the polling operations, since we need to send operation specs + * to coreHttp we'll inject possible response codes. The stub responses + * will be a clone of the first success response defined + */ +function injectMissingResponses( + responses: OperationResponseDetails[] +): OperationResponseDetails[] { + const acceptedResponses = ["200", "201", "202", "204"]; + + // Use an already defined accepted response as base; + const baseResponse = acceptedResponses.reduce((acc, status) => { + if (!isEmpty(acc)) { + return acc; + } + + const response = responses.find(r => r.statusCodes.includes(status)); + if (response) { + acc = response; + } + + return acc; + }, {} as OperationResponseDetails); + + // Clone the bas response with the accepted response codes + const enhancedResponses = acceptedResponses.reduce< + OperationResponseDetails[] + >((acc, status) => { + let current = responses.find(r => r.statusCodes.includes(status)); + + if (!current) { + current = { ...baseResponse, statusCodes: [status] }; + } + + return [...acc, current]; + }, []); + + // Keep the non success responses originally defined + const otherResponses = responses.filter( + r => !acceptedResponses.some(ar => isEqual([ar], r.statusCodes)) + ); + + return [...enhancedResponses, ...otherResponses]; +} export function transformOperationSpec( operationDetails: OperationDetails, @@ -85,13 +132,20 @@ export function extractHttpDetails({ path, method }: OperationRequestDetails) { export function extractSpecResponses({ name, - responses + responses, + isLRO }: OperationDetails): OperationSpecResponses { if (!responses || !responses.length) { throw new Error(`The operation ${name} contains no responses`); } - return extractSchemaResponses(responses); + let enhancedResponses = responses; + + if (isLRO) { + enhancedResponses = injectMissingResponses(responses); + } + + return extractSchemaResponses(enhancedResponses); } export interface SpecType { @@ -260,6 +314,9 @@ export async function transformOperation( const isLRO: boolean = Boolean( operation.extensions && operation.extensions["x-ms-long-running-operation"] ); + const lroOptions = + operation.extensions && + operation.extensions["x-ms-long-running-operation-options"]; const codeModelRequests = operation.requests; if (codeModelRequests === undefined || !codeModelRequests.length) { @@ -299,7 +356,8 @@ export async function transformOperation( responses, mediaTypes, pagination, - isLRO + isLRO, + lroOptions }; } diff --git a/test/integration/generated/additionalProperties/src/operations/pets.ts b/test/integration/generated/additionalProperties/src/operations/pets.ts index 5a5475b163..d25f146d07 100644 --- a/test/integration/generated/additionalProperties/src/operations/pets.ts +++ b/test/integration/generated/additionalProperties/src/operations/pets.ts @@ -48,8 +48,11 @@ export class Pets { createParameters: PetAPTrue, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { createParameters, options }, + { createParameters, options: operationOptions }, createAPTrueOperationSpec ) as Promise; } @@ -63,8 +66,11 @@ export class Pets { createParameters: CatAPTrue, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { createParameters, options }, + { createParameters, options: operationOptions }, createCatAPTrueOperationSpec ) as Promise; } @@ -78,8 +84,11 @@ export class Pets { createParameters: PetAPObject, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { createParameters, options }, + { createParameters, options: operationOptions }, createAPObjectOperationSpec ) as Promise; } @@ -93,8 +102,11 @@ export class Pets { createParameters: PetAPString, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { createParameters, options }, + { createParameters, options: operationOptions }, createAPStringOperationSpec ) as Promise; } @@ -108,8 +120,11 @@ export class Pets { createParameters: PetAPInProperties, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { createParameters, options }, + { createParameters, options: operationOptions }, createAPInPropertiesOperationSpec ) as Promise; } @@ -123,8 +138,11 @@ export class Pets { createParameters: PetAPInPropertiesWithAPString, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { createParameters, options }, + { createParameters, options: operationOptions }, createAPInPropertiesWithAPStringOperationSpec ) as Promise; } diff --git a/test/integration/generated/azureParameterGrouping/src/operations/parameterGrouping.ts b/test/integration/generated/azureParameterGrouping/src/operations/parameterGrouping.ts index 70b3317962..d7be536f9c 100644 --- a/test/integration/generated/azureParameterGrouping/src/operations/parameterGrouping.ts +++ b/test/integration/generated/azureParameterGrouping/src/operations/parameterGrouping.ts @@ -40,8 +40,11 @@ export class ParameterGrouping { parameterGroupingPostRequiredParameters: ParameterGroupingPostRequiredParameters, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { parameterGroupingPostRequiredParameters, options }, + { parameterGroupingPostRequiredParameters, options: operationOptions }, postRequiredOperationSpec ) as Promise; } @@ -53,8 +56,11 @@ export class ParameterGrouping { postOptional( options?: ParameterGroupingPostOptionalOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, postOptionalOperationSpec ) as Promise; } @@ -66,8 +72,11 @@ export class ParameterGrouping { postMultiParamGroups( options?: ParameterGroupingPostMultiParamGroupsOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, postMultiParamGroupsOperationSpec ) as Promise; } @@ -79,8 +88,11 @@ export class ParameterGrouping { postSharedParameterGroupObject( options?: ParameterGroupingPostSharedParameterGroupObjectOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, postSharedParameterGroupObjectOperationSpec ) as Promise; } diff --git a/test/integration/generated/azureReport/src/reportClient.ts b/test/integration/generated/azureReport/src/reportClient.ts index 91dd024ae5..3d54862279 100644 --- a/test/integration/generated/azureReport/src/reportClient.ts +++ b/test/integration/generated/azureReport/src/reportClient.ts @@ -32,8 +32,11 @@ class ReportClient extends ReportClientContext { getReport( options?: ReportClientGetReportOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getReportOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyArray/src/operations/array.ts b/test/integration/generated/bodyArray/src/operations/array.ts index 9ab629c975..0d6b034ec1 100644 --- a/test/integration/generated/bodyArray/src/operations/array.ts +++ b/test/integration/generated/bodyArray/src/operations/array.ts @@ -86,8 +86,11 @@ export class Array { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -99,8 +102,11 @@ export class Array { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } @@ -112,8 +118,11 @@ export class Array { getEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -127,8 +136,11 @@ export class Array { arrayBody: string[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putEmptyOperationSpec ) as Promise; } @@ -140,8 +152,11 @@ export class Array { getBooleanTfft( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanTfftOperationSpec ) as Promise; } @@ -155,8 +170,11 @@ export class Array { arrayBody: boolean[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putBooleanTfftOperationSpec ) as Promise; } @@ -168,8 +186,11 @@ export class Array { getBooleanInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanInvalidNullOperationSpec ) as Promise; } @@ -181,8 +202,11 @@ export class Array { getBooleanInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanInvalidStringOperationSpec ) as Promise; } @@ -194,8 +218,11 @@ export class Array { getIntegerValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntegerValidOperationSpec ) as Promise; } @@ -209,8 +236,11 @@ export class Array { arrayBody: number[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putIntegerValidOperationSpec ) as Promise; } @@ -222,8 +252,11 @@ export class Array { getIntInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntInvalidNullOperationSpec ) as Promise; } @@ -235,8 +268,11 @@ export class Array { getIntInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntInvalidStringOperationSpec ) as Promise; } @@ -248,8 +284,11 @@ export class Array { getLongValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongValidOperationSpec ) as Promise; } @@ -263,8 +302,11 @@ export class Array { arrayBody: number[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putLongValidOperationSpec ) as Promise; } @@ -276,8 +318,11 @@ export class Array { getLongInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongInvalidNullOperationSpec ) as Promise; } @@ -289,8 +334,11 @@ export class Array { getLongInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongInvalidStringOperationSpec ) as Promise; } @@ -302,8 +350,11 @@ export class Array { getFloatValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatValidOperationSpec ) as Promise; } @@ -317,8 +368,11 @@ export class Array { arrayBody: number[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putFloatValidOperationSpec ) as Promise; } @@ -330,8 +384,11 @@ export class Array { getFloatInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatInvalidNullOperationSpec ) as Promise; } @@ -343,8 +400,11 @@ export class Array { getFloatInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatInvalidStringOperationSpec ) as Promise; } @@ -356,8 +416,11 @@ export class Array { getDoubleValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleValidOperationSpec ) as Promise; } @@ -371,8 +434,11 @@ export class Array { arrayBody: number[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDoubleValidOperationSpec ) as Promise; } @@ -384,8 +450,11 @@ export class Array { getDoubleInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleInvalidNullOperationSpec ) as Promise; } @@ -397,8 +466,11 @@ export class Array { getDoubleInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleInvalidStringOperationSpec ) as Promise; } @@ -410,8 +482,11 @@ export class Array { getStringValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringValidOperationSpec ) as Promise; } @@ -425,8 +500,11 @@ export class Array { arrayBody: string[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putStringValidOperationSpec ) as Promise; } @@ -438,8 +516,11 @@ export class Array { getEnumValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEnumValidOperationSpec ) as Promise; } @@ -453,8 +534,11 @@ export class Array { arrayBody: FooEnum[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putEnumValidOperationSpec ) as Promise; } @@ -466,8 +550,11 @@ export class Array { getStringEnumValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringEnumValidOperationSpec ) as Promise; } @@ -481,8 +568,11 @@ export class Array { arrayBody: Enum1[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putStringEnumValidOperationSpec ) as Promise; } @@ -494,8 +584,11 @@ export class Array { getStringWithNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringWithNullOperationSpec ) as Promise; } @@ -507,8 +600,11 @@ export class Array { getStringWithInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringWithInvalidOperationSpec ) as Promise; } @@ -521,8 +617,11 @@ export class Array { getUuidValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUuidValidOperationSpec ) as Promise; } @@ -538,8 +637,11 @@ export class Array { arrayBody: string[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putUuidValidOperationSpec ) as Promise; } @@ -551,8 +653,11 @@ export class Array { getUuidInvalidChars( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUuidInvalidCharsOperationSpec ) as Promise; } @@ -564,8 +669,11 @@ export class Array { getDateValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateValidOperationSpec ) as Promise; } @@ -579,8 +687,11 @@ export class Array { arrayBody: Date[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDateValidOperationSpec ) as Promise; } @@ -592,8 +703,11 @@ export class Array { getDateInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateInvalidNullOperationSpec ) as Promise; } @@ -605,8 +719,11 @@ export class Array { getDateInvalidChars( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateInvalidCharsOperationSpec ) as Promise; } @@ -619,8 +736,11 @@ export class Array { getDateTimeValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeValidOperationSpec ) as Promise; } @@ -635,8 +755,11 @@ export class Array { arrayBody: Date[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDateTimeValidOperationSpec ) as Promise; } @@ -648,8 +771,11 @@ export class Array { getDateTimeInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeInvalidNullOperationSpec ) as Promise; } @@ -661,8 +787,11 @@ export class Array { getDateTimeInvalidChars( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeInvalidCharsOperationSpec ) as Promise; } @@ -675,8 +804,11 @@ export class Array { getDateTimeRfc1123Valid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeRfc1123ValidOperationSpec ) as Promise; } @@ -692,8 +824,11 @@ export class Array { arrayBody: Date[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDateTimeRfc1123ValidOperationSpec ) as Promise; } @@ -705,8 +840,11 @@ export class Array { getDurationValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDurationValidOperationSpec ) as Promise; } @@ -720,8 +858,11 @@ export class Array { arrayBody: string[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDurationValidOperationSpec ) as Promise; } @@ -734,8 +875,11 @@ export class Array { getByteValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getByteValidOperationSpec ) as Promise; } @@ -751,8 +895,11 @@ export class Array { arrayBody: Uint8Array[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putByteValidOperationSpec ) as Promise; } @@ -764,8 +911,11 @@ export class Array { getByteInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getByteInvalidNullOperationSpec ) as Promise; } @@ -778,8 +928,11 @@ export class Array { getBase64Url( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBase64UrlOperationSpec ) as Promise; } @@ -791,8 +944,11 @@ export class Array { getComplexNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexNullOperationSpec ) as Promise; } @@ -804,8 +960,11 @@ export class Array { getComplexEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexEmptyOperationSpec ) as Promise; } @@ -818,8 +977,11 @@ export class Array { getComplexItemNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexItemNullOperationSpec ) as Promise; } @@ -832,8 +994,11 @@ export class Array { getComplexItemEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexItemEmptyOperationSpec ) as Promise; } @@ -846,8 +1011,11 @@ export class Array { getComplexValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexValidOperationSpec ) as Promise; } @@ -863,8 +1031,11 @@ export class Array { arrayBody: Product[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putComplexValidOperationSpec ) as Promise; } @@ -876,8 +1047,11 @@ export class Array { getArrayNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayNullOperationSpec ) as Promise; } @@ -889,8 +1063,11 @@ export class Array { getArrayEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayEmptyOperationSpec ) as Promise; } @@ -902,8 +1079,11 @@ export class Array { getArrayItemNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayItemNullOperationSpec ) as Promise; } @@ -915,8 +1095,11 @@ export class Array { getArrayItemEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayItemEmptyOperationSpec ) as Promise; } @@ -928,8 +1111,11 @@ export class Array { getArrayValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayValidOperationSpec ) as Promise; } @@ -943,8 +1129,11 @@ export class Array { arrayBody: string[][], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putArrayValidOperationSpec ) as Promise; } @@ -956,8 +1145,11 @@ export class Array { getDictionaryNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryNullOperationSpec ) as Promise; } @@ -969,8 +1161,11 @@ export class Array { getDictionaryEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryEmptyOperationSpec ) as Promise; } @@ -983,8 +1178,11 @@ export class Array { getDictionaryItemNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryItemNullOperationSpec ) as Promise; } @@ -997,8 +1195,11 @@ export class Array { getDictionaryItemEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryItemEmptyOperationSpec ) as Promise; } @@ -1011,8 +1212,11 @@ export class Array { getDictionaryValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryValidOperationSpec ) as Promise; } @@ -1029,8 +1233,11 @@ export class Array { arrayBody: { [propertyName: string]: string }[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDictionaryValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyBoolean/src/operations/bool.ts b/test/integration/generated/bodyBoolean/src/operations/bool.ts index 3e20815ac1..96caf86da0 100644 --- a/test/integration/generated/bodyBoolean/src/operations/bool.ts +++ b/test/integration/generated/bodyBoolean/src/operations/bool.ts @@ -36,8 +36,11 @@ export class Bool { * @param options The options parameters. */ getTrue(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getTrueOperationSpec ) as Promise; } @@ -47,8 +50,11 @@ export class Bool { * @param options The options parameters. */ putTrue(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putTrueOperationSpec ) as Promise; } @@ -58,8 +64,11 @@ export class Bool { * @param options The options parameters. */ getFalse(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFalseOperationSpec ) as Promise; } @@ -71,8 +80,11 @@ export class Bool { putFalse( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putFalseOperationSpec ) as Promise; } @@ -82,8 +94,11 @@ export class Bool { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -95,8 +110,11 @@ export class Bool { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts b/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts index e1dd0f68aa..d036697bb9 100644 --- a/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts +++ b/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts @@ -36,8 +36,11 @@ export class Bool { * @param options The options parameters. */ getTrue(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getTrueOperationSpec ) as Promise; } @@ -51,8 +54,11 @@ export class Bool { boolBody: boolean, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { boolBody, options }, + { boolBody, options: operationOptions }, putTrueOperationSpec ) as Promise; } @@ -62,8 +68,11 @@ export class Bool { * @param options The options parameters. */ getFalse(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFalseOperationSpec ) as Promise; } @@ -77,8 +86,11 @@ export class Bool { boolBody: boolean, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { boolBody, options }, + { boolBody, options: operationOptions }, putFalseOperationSpec ) as Promise; } @@ -88,8 +100,11 @@ export class Bool { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -101,8 +116,11 @@ export class Bool { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyByte/src/operations/byte.ts b/test/integration/generated/bodyByte/src/operations/byte.ts index 6a3ddb6e38..0ae979d7af 100644 --- a/test/integration/generated/bodyByte/src/operations/byte.ts +++ b/test/integration/generated/bodyByte/src/operations/byte.ts @@ -36,8 +36,11 @@ export class Byte { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -47,8 +50,11 @@ export class Byte { * @param options The options parameters. */ getEmpty(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -60,8 +66,11 @@ export class Byte { getNonAscii( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNonAsciiOperationSpec ) as Promise; } @@ -75,8 +84,11 @@ export class Byte { byteBody: Uint8Array, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { byteBody, options }, + { byteBody, options: operationOptions }, putNonAsciiOperationSpec ) as Promise; } @@ -88,8 +100,11 @@ export class Byte { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/array.ts b/test/integration/generated/bodyComplex/src/operations/array.ts index 3960b1b65b..05585b2fc4 100644 --- a/test/integration/generated/bodyComplex/src/operations/array.ts +++ b/test/integration/generated/bodyComplex/src/operations/array.ts @@ -38,8 +38,11 @@ export class Array { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -54,8 +57,11 @@ export class Array { complexBody: ArrayWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } @@ -67,8 +73,11 @@ export class Array { getEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -82,8 +91,11 @@ export class Array { complexBody: ArrayWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putEmptyOperationSpec ) as Promise; } @@ -95,8 +107,11 @@ export class Array { getNotProvided( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNotProvidedOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/basic.ts b/test/integration/generated/bodyComplex/src/operations/basic.ts index f809b9bf41..866093a960 100644 --- a/test/integration/generated/bodyComplex/src/operations/basic.ts +++ b/test/integration/generated/bodyComplex/src/operations/basic.ts @@ -40,8 +40,11 @@ export class Basic { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -55,8 +58,11 @@ export class Basic { complexBody: BasicModel, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } @@ -68,8 +74,11 @@ export class Basic { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } @@ -81,8 +90,11 @@ export class Basic { getEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -92,8 +104,11 @@ export class Basic { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -105,8 +120,11 @@ export class Basic { getNotProvided( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNotProvidedOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/dictionary.ts b/test/integration/generated/bodyComplex/src/operations/dictionary.ts index 8b12be5b75..d75bd9016a 100644 --- a/test/integration/generated/bodyComplex/src/operations/dictionary.ts +++ b/test/integration/generated/bodyComplex/src/operations/dictionary.ts @@ -39,8 +39,11 @@ export class Dictionary { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -55,8 +58,11 @@ export class Dictionary { complexBody: DictionaryWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } @@ -68,8 +74,11 @@ export class Dictionary { getEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -83,8 +92,11 @@ export class Dictionary { complexBody: DictionaryWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putEmptyOperationSpec ) as Promise; } @@ -96,8 +108,11 @@ export class Dictionary { getNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -109,8 +124,11 @@ export class Dictionary { getNotProvided( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNotProvidedOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/flattencomplex.ts b/test/integration/generated/bodyComplex/src/operations/flattencomplex.ts index 289a5d22a6..d70ed45074 100644 --- a/test/integration/generated/bodyComplex/src/operations/flattencomplex.ts +++ b/test/integration/generated/bodyComplex/src/operations/flattencomplex.ts @@ -32,8 +32,11 @@ export class Flattencomplex { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/inheritance.ts b/test/integration/generated/bodyComplex/src/operations/inheritance.ts index 75efe76dfa..9673be94b6 100644 --- a/test/integration/generated/bodyComplex/src/operations/inheritance.ts +++ b/test/integration/generated/bodyComplex/src/operations/inheritance.ts @@ -33,8 +33,11 @@ export class Inheritance { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -50,8 +53,11 @@ export class Inheritance { complexBody: Siamese, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts b/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts index 6f21f1b221..05998f21bd 100644 --- a/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts +++ b/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts @@ -33,8 +33,11 @@ export class Polymorphicrecursive { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -100,8 +103,11 @@ export class Polymorphicrecursive { complexBody: FishUnion, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/polymorphism.ts b/test/integration/generated/bodyComplex/src/operations/polymorphism.ts index 83ed4eeb9d..e6c9821b1e 100644 --- a/test/integration/generated/bodyComplex/src/operations/polymorphism.ts +++ b/test/integration/generated/bodyComplex/src/operations/polymorphism.ts @@ -42,8 +42,11 @@ export class Polymorphism { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -89,8 +92,11 @@ export class Polymorphism { complexBody: FishUnion, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } @@ -102,8 +108,11 @@ export class Polymorphism { getDotSyntax( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDotSyntaxOperationSpec ) as Promise; } @@ -117,8 +126,11 @@ export class Polymorphism { getComposedWithDiscriminator( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComposedWithDiscriminatorOperationSpec ) as Promise; } @@ -132,8 +144,11 @@ export class Polymorphism { getComposedWithoutDiscriminator( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComposedWithoutDiscriminatorOperationSpec ) as Promise; } @@ -146,8 +161,11 @@ export class Polymorphism { getComplicated( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplicatedOperationSpec ) as Promise; } @@ -162,8 +180,11 @@ export class Polymorphism { complexBody: SalmonUnion, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putComplicatedOperationSpec ) as Promise; } @@ -177,8 +198,11 @@ export class Polymorphism { complexBody: SalmonUnion, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putMissingDiscriminatorOperationSpec ) as Promise; } @@ -219,8 +243,11 @@ export class Polymorphism { complexBody: FishUnion, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidMissingRequiredOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/primitive.ts b/test/integration/generated/bodyComplex/src/operations/primitive.ts index 7c241d7746..fcb5a3a71c 100644 --- a/test/integration/generated/bodyComplex/src/operations/primitive.ts +++ b/test/integration/generated/bodyComplex/src/operations/primitive.ts @@ -56,8 +56,11 @@ export class Primitive { getInt( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntOperationSpec ) as Promise; } @@ -71,8 +74,11 @@ export class Primitive { complexBody: IntWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putIntOperationSpec ) as Promise; } @@ -84,8 +90,11 @@ export class Primitive { getLong( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongOperationSpec ) as Promise; } @@ -99,8 +108,11 @@ export class Primitive { complexBody: LongWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putLongOperationSpec ) as Promise; } @@ -112,8 +124,11 @@ export class Primitive { getFloat( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatOperationSpec ) as Promise; } @@ -127,8 +142,11 @@ export class Primitive { complexBody: FloatWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putFloatOperationSpec ) as Promise; } @@ -140,8 +158,11 @@ export class Primitive { getDouble( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleOperationSpec ) as Promise; } @@ -156,8 +177,11 @@ export class Primitive { complexBody: DoubleWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putDoubleOperationSpec ) as Promise; } @@ -169,8 +193,11 @@ export class Primitive { getBool( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBoolOperationSpec ) as Promise; } @@ -184,8 +211,11 @@ export class Primitive { complexBody: BooleanWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putBoolOperationSpec ) as Promise; } @@ -197,8 +227,11 @@ export class Primitive { getString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringOperationSpec ) as Promise; } @@ -212,8 +245,11 @@ export class Primitive { complexBody: StringWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putStringOperationSpec ) as Promise; } @@ -225,8 +261,11 @@ export class Primitive { getDate( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateOperationSpec ) as Promise; } @@ -240,8 +279,11 @@ export class Primitive { complexBody: DateWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putDateOperationSpec ) as Promise; } @@ -253,8 +295,11 @@ export class Primitive { getDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeOperationSpec ) as Promise; } @@ -268,8 +313,11 @@ export class Primitive { complexBody: DatetimeWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putDateTimeOperationSpec ) as Promise; } @@ -281,8 +329,11 @@ export class Primitive { getDateTimeRfc1123( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeRfc1123OperationSpec ) as Promise; } @@ -296,8 +347,11 @@ export class Primitive { complexBody: Datetimerfc1123Wrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putDateTimeRfc1123OperationSpec ) as Promise; } @@ -309,8 +363,11 @@ export class Primitive { getDuration( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDurationOperationSpec ) as Promise; } @@ -324,8 +381,11 @@ export class Primitive { complexBody: DurationWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putDurationOperationSpec ) as Promise; } @@ -337,8 +397,11 @@ export class Primitive { getByte( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getByteOperationSpec ) as Promise; } @@ -352,8 +415,11 @@ export class Primitive { complexBody: ByteWrapper, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putByteOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts b/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts index 46eab57a95..bf9d50af26 100644 --- a/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts +++ b/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts @@ -33,8 +33,11 @@ export class Readonlyproperty { getValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getValidOperationSpec ) as Promise; } @@ -48,8 +51,11 @@ export class Readonlyproperty { complexBody: ReadonlyObj, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { complexBody, options }, + { complexBody, options: operationOptions }, putValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyDate/src/operations/date.ts b/test/integration/generated/bodyDate/src/operations/date.ts index 1a997a4eef..74746aa9c0 100644 --- a/test/integration/generated/bodyDate/src/operations/date.ts +++ b/test/integration/generated/bodyDate/src/operations/date.ts @@ -40,8 +40,11 @@ export class DateModel { getNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -53,8 +56,11 @@ export class DateModel { getInvalidDate( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidDateOperationSpec ) as Promise; } @@ -66,8 +72,11 @@ export class DateModel { getOverflowDate( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOverflowDateOperationSpec ) as Promise; } @@ -79,8 +88,11 @@ export class DateModel { getUnderflowDate( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUnderflowDateOperationSpec ) as Promise; } @@ -94,8 +106,11 @@ export class DateModel { dateBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { dateBody, options }, + { dateBody, options: operationOptions }, putMaxDateOperationSpec ) as Promise; } @@ -107,8 +122,11 @@ export class DateModel { getMaxDate( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMaxDateOperationSpec ) as Promise; } @@ -122,8 +140,11 @@ export class DateModel { dateBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { dateBody, options }, + { dateBody, options: operationOptions }, putMinDateOperationSpec ) as Promise; } @@ -135,8 +156,11 @@ export class DateModel { getMinDate( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMinDateOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyDateTime/src/operations/datetime.ts b/test/integration/generated/bodyDateTime/src/operations/datetime.ts index 2501e430bb..fd1038b061 100644 --- a/test/integration/generated/bodyDateTime/src/operations/datetime.ts +++ b/test/integration/generated/bodyDateTime/src/operations/datetime.ts @@ -48,8 +48,11 @@ export class Datetime { getNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -61,8 +64,11 @@ export class Datetime { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } @@ -74,8 +80,11 @@ export class Datetime { getOverflow( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOverflowOperationSpec ) as Promise; } @@ -87,8 +96,11 @@ export class Datetime { getUnderflow( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUnderflowOperationSpec ) as Promise; } @@ -102,8 +114,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putUtcMaxDateTimeOperationSpec ) as Promise; } @@ -117,8 +132,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putUtcMaxDateTime7DigitsOperationSpec ) as Promise; } @@ -130,8 +148,11 @@ export class Datetime { getUtcLowercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcLowercaseMaxDateTimeOperationSpec ) as Promise; } @@ -143,8 +164,11 @@ export class Datetime { getUtcUppercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcUppercaseMaxDateTimeOperationSpec ) as Promise; } @@ -156,8 +180,11 @@ export class Datetime { getUtcUppercaseMaxDateTime7Digits( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcUppercaseMaxDateTime7DigitsOperationSpec ) as Promise; } @@ -171,8 +198,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putLocalPositiveOffsetMaxDateTimeOperationSpec ) as Promise; } @@ -184,8 +214,11 @@ export class Datetime { getLocalPositiveOffsetLowercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLocalPositiveOffsetLowercaseMaxDateTimeOperationSpec ) as Promise; } @@ -197,8 +230,11 @@ export class Datetime { getLocalPositiveOffsetUppercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLocalPositiveOffsetUppercaseMaxDateTimeOperationSpec ) as Promise; } @@ -212,8 +248,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putLocalNegativeOffsetMaxDateTimeOperationSpec ) as Promise; } @@ -225,8 +264,11 @@ export class Datetime { getLocalNegativeOffsetUppercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLocalNegativeOffsetUppercaseMaxDateTimeOperationSpec ) as Promise; } @@ -238,8 +280,11 @@ export class Datetime { getLocalNegativeOffsetLowercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLocalNegativeOffsetLowercaseMaxDateTimeOperationSpec ) as Promise; } @@ -253,8 +298,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putUtcMinDateTimeOperationSpec ) as Promise; } @@ -266,8 +314,11 @@ export class Datetime { getUtcMinDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcMinDateTimeOperationSpec ) as Promise; } @@ -281,8 +332,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putLocalPositiveOffsetMinDateTimeOperationSpec ) as Promise; } @@ -294,8 +348,11 @@ export class Datetime { getLocalPositiveOffsetMinDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLocalPositiveOffsetMinDateTimeOperationSpec ) as Promise; } @@ -309,8 +366,11 @@ export class Datetime { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putLocalNegativeOffsetMinDateTimeOperationSpec ) as Promise; } @@ -322,8 +382,11 @@ export class Datetime { getLocalNegativeOffsetMinDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLocalNegativeOffsetMinDateTimeOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts b/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts index 0a67f033aa..7af2fc5e69 100644 --- a/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts +++ b/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts @@ -41,8 +41,11 @@ export class Datetimerfc1123 { getNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -54,8 +57,11 @@ export class Datetimerfc1123 { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } @@ -67,8 +73,11 @@ export class Datetimerfc1123 { getOverflow( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOverflowOperationSpec ) as Promise; } @@ -80,8 +89,11 @@ export class Datetimerfc1123 { getUnderflow( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUnderflowOperationSpec ) as Promise; } @@ -95,8 +107,11 @@ export class Datetimerfc1123 { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putUtcMaxDateTimeOperationSpec ) as Promise; } @@ -108,8 +123,11 @@ export class Datetimerfc1123 { getUtcLowercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcLowercaseMaxDateTimeOperationSpec ) as Promise; } @@ -121,8 +139,11 @@ export class Datetimerfc1123 { getUtcUppercaseMaxDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcUppercaseMaxDateTimeOperationSpec ) as Promise; } @@ -136,8 +157,11 @@ export class Datetimerfc1123 { datetimeBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datetimeBody, options }, + { datetimeBody, options: operationOptions }, putUtcMinDateTimeOperationSpec ) as Promise; } @@ -149,8 +173,11 @@ export class Datetimerfc1123 { getUtcMinDateTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUtcMinDateTimeOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyDictionary/src/operations/dictionary.ts b/test/integration/generated/bodyDictionary/src/operations/dictionary.ts index bc6e7db2b3..d2c61424c3 100644 --- a/test/integration/generated/bodyDictionary/src/operations/dictionary.ts +++ b/test/integration/generated/bodyDictionary/src/operations/dictionary.ts @@ -85,8 +85,11 @@ export class Dictionary { getNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -98,8 +101,11 @@ export class Dictionary { getEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -113,8 +119,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: string }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putEmptyOperationSpec ) as Promise; } @@ -126,8 +135,11 @@ export class Dictionary { getNullValue( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullValueOperationSpec ) as Promise; } @@ -139,8 +151,11 @@ export class Dictionary { getNullKey( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullKeyOperationSpec ) as Promise; } @@ -152,8 +167,11 @@ export class Dictionary { getEmptyStringKey( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyStringKeyOperationSpec ) as Promise; } @@ -165,8 +183,11 @@ export class Dictionary { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } @@ -178,8 +199,11 @@ export class Dictionary { getBooleanTfft( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanTfftOperationSpec ) as Promise; } @@ -193,8 +217,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: boolean }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putBooleanTfftOperationSpec ) as Promise; } @@ -206,8 +233,11 @@ export class Dictionary { getBooleanInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanInvalidNullOperationSpec ) as Promise; } @@ -219,8 +249,11 @@ export class Dictionary { getBooleanInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanInvalidStringOperationSpec ) as Promise; } @@ -232,8 +265,11 @@ export class Dictionary { getIntegerValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntegerValidOperationSpec ) as Promise; } @@ -247,8 +283,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: number }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putIntegerValidOperationSpec ) as Promise; } @@ -260,8 +299,11 @@ export class Dictionary { getIntInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntInvalidNullOperationSpec ) as Promise; } @@ -273,8 +315,11 @@ export class Dictionary { getIntInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntInvalidStringOperationSpec ) as Promise; } @@ -286,8 +331,11 @@ export class Dictionary { getLongValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongValidOperationSpec ) as Promise; } @@ -301,8 +349,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: number }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putLongValidOperationSpec ) as Promise; } @@ -314,8 +365,11 @@ export class Dictionary { getLongInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongInvalidNullOperationSpec ) as Promise; } @@ -327,8 +381,11 @@ export class Dictionary { getLongInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongInvalidStringOperationSpec ) as Promise; } @@ -340,8 +397,11 @@ export class Dictionary { getFloatValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatValidOperationSpec ) as Promise; } @@ -355,8 +415,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: number }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putFloatValidOperationSpec ) as Promise; } @@ -368,8 +431,11 @@ export class Dictionary { getFloatInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatInvalidNullOperationSpec ) as Promise; } @@ -381,8 +447,11 @@ export class Dictionary { getFloatInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getFloatInvalidStringOperationSpec ) as Promise; } @@ -394,8 +463,11 @@ export class Dictionary { getDoubleValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleValidOperationSpec ) as Promise; } @@ -409,8 +481,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: number }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDoubleValidOperationSpec ) as Promise; } @@ -422,8 +497,11 @@ export class Dictionary { getDoubleInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleInvalidNullOperationSpec ) as Promise; } @@ -435,8 +513,11 @@ export class Dictionary { getDoubleInvalidString( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDoubleInvalidStringOperationSpec ) as Promise; } @@ -448,8 +529,11 @@ export class Dictionary { getStringValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringValidOperationSpec ) as Promise; } @@ -463,8 +547,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: string }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putStringValidOperationSpec ) as Promise; } @@ -476,8 +563,11 @@ export class Dictionary { getStringWithNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringWithNullOperationSpec ) as Promise; } @@ -489,8 +579,11 @@ export class Dictionary { getStringWithInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getStringWithInvalidOperationSpec ) as Promise; } @@ -502,8 +595,11 @@ export class Dictionary { getDateValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateValidOperationSpec ) as Promise; } @@ -517,8 +613,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: Date }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDateValidOperationSpec ) as Promise; } @@ -530,8 +629,11 @@ export class Dictionary { getDateInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateInvalidNullOperationSpec ) as Promise; } @@ -543,8 +645,11 @@ export class Dictionary { getDateInvalidChars( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateInvalidCharsOperationSpec ) as Promise; } @@ -557,8 +662,11 @@ export class Dictionary { getDateTimeValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeValidOperationSpec ) as Promise; } @@ -574,8 +682,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: Date }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDateTimeValidOperationSpec ) as Promise; } @@ -587,8 +698,11 @@ export class Dictionary { getDateTimeInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeInvalidNullOperationSpec ) as Promise; } @@ -600,8 +714,11 @@ export class Dictionary { getDateTimeInvalidChars( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeInvalidCharsOperationSpec ) as Promise; } @@ -614,8 +731,11 @@ export class Dictionary { getDateTimeRfc1123Valid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDateTimeRfc1123ValidOperationSpec ) as Promise; } @@ -631,8 +751,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: Date }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDateTimeRfc1123ValidOperationSpec ) as Promise; } @@ -644,8 +767,11 @@ export class Dictionary { getDurationValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDurationValidOperationSpec ) as Promise; } @@ -659,8 +785,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: string }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDurationValidOperationSpec ) as Promise; } @@ -673,8 +802,11 @@ export class Dictionary { getByteValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getByteValidOperationSpec ) as Promise; } @@ -690,8 +822,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: Uint8Array }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putByteValidOperationSpec ) as Promise; } @@ -703,8 +838,11 @@ export class Dictionary { getByteInvalidNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getByteInvalidNullOperationSpec ) as Promise; } @@ -717,8 +855,11 @@ export class Dictionary { getBase64Url( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBase64UrlOperationSpec ) as Promise; } @@ -730,8 +871,11 @@ export class Dictionary { getComplexNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexNullOperationSpec ) as Promise; } @@ -743,8 +887,11 @@ export class Dictionary { getComplexEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexEmptyOperationSpec ) as Promise; } @@ -757,8 +904,11 @@ export class Dictionary { getComplexItemNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexItemNullOperationSpec ) as Promise; } @@ -771,8 +921,11 @@ export class Dictionary { getComplexItemEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexItemEmptyOperationSpec ) as Promise; } @@ -785,8 +938,11 @@ export class Dictionary { getComplexValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexValidOperationSpec ) as Promise; } @@ -802,8 +958,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: Widget }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putComplexValidOperationSpec ) as Promise; } @@ -815,8 +974,11 @@ export class Dictionary { getArrayNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayNullOperationSpec ) as Promise; } @@ -828,8 +990,11 @@ export class Dictionary { getArrayEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayEmptyOperationSpec ) as Promise; } @@ -841,8 +1006,11 @@ export class Dictionary { getArrayItemNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayItemNullOperationSpec ) as Promise; } @@ -854,8 +1022,11 @@ export class Dictionary { getArrayItemEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayItemEmptyOperationSpec ) as Promise; } @@ -867,8 +1038,11 @@ export class Dictionary { getArrayValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayValidOperationSpec ) as Promise; } @@ -883,8 +1057,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: string[] }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putArrayValidOperationSpec ) as Promise; } @@ -896,8 +1073,11 @@ export class Dictionary { getDictionaryNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryNullOperationSpec ) as Promise; } @@ -909,8 +1089,11 @@ export class Dictionary { getDictionaryEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryEmptyOperationSpec ) as Promise; } @@ -923,8 +1106,11 @@ export class Dictionary { getDictionaryItemNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryItemNullOperationSpec ) as Promise; } @@ -937,8 +1123,11 @@ export class Dictionary { getDictionaryItemEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryItemEmptyOperationSpec ) as Promise; } @@ -952,8 +1141,11 @@ export class Dictionary { getDictionaryValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryValidOperationSpec ) as Promise; } @@ -971,8 +1163,11 @@ export class Dictionary { arrayBody: { [propertyName: string]: any }, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayBody, options }, + { arrayBody, options: operationOptions }, putDictionaryValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyDuration/src/operations/duration.ts b/test/integration/generated/bodyDuration/src/operations/duration.ts index af1bf2dd08..270c070efb 100644 --- a/test/integration/generated/bodyDuration/src/operations/duration.ts +++ b/test/integration/generated/bodyDuration/src/operations/duration.ts @@ -37,8 +37,11 @@ export class Duration { getNull( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -52,8 +55,11 @@ export class Duration { durationBody: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { durationBody, options }, + { durationBody, options: operationOptions }, putPositiveDurationOperationSpec ) as Promise; } @@ -65,8 +71,11 @@ export class Duration { getPositiveDuration( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getPositiveDurationOperationSpec ) as Promise; } @@ -78,8 +87,11 @@ export class Duration { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyInteger/src/operations/int.ts b/test/integration/generated/bodyInteger/src/operations/int.ts index ca863f82b9..fb27cadf6b 100644 --- a/test/integration/generated/bodyInteger/src/operations/int.ts +++ b/test/integration/generated/bodyInteger/src/operations/int.ts @@ -41,8 +41,11 @@ export class Int { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -54,8 +57,11 @@ export class Int { getInvalid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidOperationSpec ) as Promise; } @@ -67,8 +73,11 @@ export class Int { getOverflowInt32( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOverflowInt32OperationSpec ) as Promise; } @@ -80,8 +89,11 @@ export class Int { getUnderflowInt32( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUnderflowInt32OperationSpec ) as Promise; } @@ -93,8 +105,11 @@ export class Int { getOverflowInt64( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOverflowInt64OperationSpec ) as Promise; } @@ -106,8 +121,11 @@ export class Int { getUnderflowInt64( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUnderflowInt64OperationSpec ) as Promise; } @@ -121,8 +139,11 @@ export class Int { intBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { intBody, options }, + { intBody, options: operationOptions }, putMax32OperationSpec ) as Promise; } @@ -136,8 +157,11 @@ export class Int { intBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { intBody, options }, + { intBody, options: operationOptions }, putMax64OperationSpec ) as Promise; } @@ -151,8 +175,11 @@ export class Int { intBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { intBody, options }, + { intBody, options: operationOptions }, putMin32OperationSpec ) as Promise; } @@ -166,8 +193,11 @@ export class Int { intBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { intBody, options }, + { intBody, options: operationOptions }, putMin64OperationSpec ) as Promise; } @@ -179,8 +209,11 @@ export class Int { getUnixTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getUnixTimeOperationSpec ) as Promise; } @@ -194,8 +227,11 @@ export class Int { intBody: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { intBody, options }, + { intBody, options: operationOptions }, putUnixTimeDateOperationSpec ) as Promise; } @@ -207,8 +243,11 @@ export class Int { getInvalidUnixTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidUnixTimeOperationSpec ) as Promise; } @@ -220,8 +259,11 @@ export class Int { getNullUnixTime( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullUnixTimeOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyNumber/src/operations/number.ts b/test/integration/generated/bodyNumber/src/operations/number.ts index f9477181ee..7a7a12f31f 100644 --- a/test/integration/generated/bodyNumber/src/operations/number.ts +++ b/test/integration/generated/bodyNumber/src/operations/number.ts @@ -46,8 +46,11 @@ export class Number { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -59,8 +62,11 @@ export class Number { getInvalidFloat( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidFloatOperationSpec ) as Promise; } @@ -72,8 +78,11 @@ export class Number { getInvalidDouble( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidDoubleOperationSpec ) as Promise; } @@ -85,8 +94,11 @@ export class Number { getInvalidDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getInvalidDecimalOperationSpec ) as Promise; } @@ -100,8 +112,11 @@ export class Number { numberBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { numberBody, options }, + { numberBody, options: operationOptions }, putBigFloatOperationSpec ) as Promise; } @@ -113,8 +128,11 @@ export class Number { getBigFloat( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigFloatOperationSpec ) as Promise; } @@ -128,8 +146,11 @@ export class Number { numberBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { numberBody, options }, + { numberBody, options: operationOptions }, putBigDoubleOperationSpec ) as Promise; } @@ -141,8 +162,11 @@ export class Number { getBigDouble( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigDoubleOperationSpec ) as Promise; } @@ -154,8 +178,11 @@ export class Number { putBigDoublePositiveDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putBigDoublePositiveDecimalOperationSpec ) as Promise; } @@ -167,8 +194,11 @@ export class Number { getBigDoublePositiveDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigDoublePositiveDecimalOperationSpec ) as Promise; } @@ -180,8 +210,11 @@ export class Number { putBigDoubleNegativeDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putBigDoubleNegativeDecimalOperationSpec ) as Promise; } @@ -193,8 +226,11 @@ export class Number { getBigDoubleNegativeDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigDoubleNegativeDecimalOperationSpec ) as Promise; } @@ -208,8 +244,11 @@ export class Number { numberBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { numberBody, options }, + { numberBody, options: operationOptions }, putBigDecimalOperationSpec ) as Promise; } @@ -221,8 +260,11 @@ export class Number { getBigDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigDecimalOperationSpec ) as Promise; } @@ -234,8 +276,11 @@ export class Number { putBigDecimalPositiveDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putBigDecimalPositiveDecimalOperationSpec ) as Promise; } @@ -247,8 +292,11 @@ export class Number { getBigDecimalPositiveDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigDecimalPositiveDecimalOperationSpec ) as Promise; } @@ -260,8 +308,11 @@ export class Number { putBigDecimalNegativeDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putBigDecimalNegativeDecimalOperationSpec ) as Promise; } @@ -273,8 +324,11 @@ export class Number { getBigDecimalNegativeDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBigDecimalNegativeDecimalOperationSpec ) as Promise; } @@ -288,8 +342,11 @@ export class Number { numberBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { numberBody, options }, + { numberBody, options: operationOptions }, putSmallFloatOperationSpec ) as Promise; } @@ -301,8 +358,11 @@ export class Number { getSmallFloat( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getSmallFloatOperationSpec ) as Promise; } @@ -316,8 +376,11 @@ export class Number { numberBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { numberBody, options }, + { numberBody, options: operationOptions }, putSmallDoubleOperationSpec ) as Promise; } @@ -329,8 +392,11 @@ export class Number { getSmallDouble( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getSmallDoubleOperationSpec ) as Promise; } @@ -344,8 +410,11 @@ export class Number { numberBody: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { numberBody, options }, + { numberBody, options: operationOptions }, putSmallDecimalOperationSpec ) as Promise; } @@ -357,8 +426,11 @@ export class Number { getSmallDecimal( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getSmallDecimalOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyString/src/operations/enum.ts b/test/integration/generated/bodyString/src/operations/enum.ts index e2b29fa35e..c8c32c6093 100644 --- a/test/integration/generated/bodyString/src/operations/enum.ts +++ b/test/integration/generated/bodyString/src/operations/enum.ts @@ -39,8 +39,11 @@ export class Enum { getNotExpandable( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNotExpandableOperationSpec ) as Promise; } @@ -54,8 +57,11 @@ export class Enum { stringBody: Colors, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { stringBody, options }, + { stringBody, options: operationOptions }, putNotExpandableOperationSpec ) as Promise; } @@ -67,8 +73,11 @@ export class Enum { getReferenced( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getReferencedOperationSpec ) as Promise; } @@ -82,8 +91,11 @@ export class Enum { enumStringBody: Colors, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { enumStringBody, options }, + { enumStringBody, options: operationOptions }, putReferencedOperationSpec ) as Promise; } @@ -95,8 +107,11 @@ export class Enum { getReferencedConstant( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getReferencedConstantOperationSpec ) as Promise; } @@ -110,8 +125,11 @@ export class Enum { enumStringBody: RefColorConstant, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { enumStringBody, options }, + { enumStringBody, options: operationOptions }, putReferencedConstantOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyString/src/operations/string.ts b/test/integration/generated/bodyString/src/operations/string.ts index b8edd93faa..aaf151d3ec 100644 --- a/test/integration/generated/bodyString/src/operations/string.ts +++ b/test/integration/generated/bodyString/src/operations/string.ts @@ -41,8 +41,11 @@ export class String { * @param options The options parameters. */ getNull(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullOperationSpec ) as Promise; } @@ -54,8 +57,11 @@ export class String { putNull( options?: StringPutNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putNullOperationSpec ) as Promise; } @@ -67,8 +73,11 @@ export class String { getEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyOperationSpec ) as Promise; } @@ -80,8 +89,11 @@ export class String { putEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putEmptyOperationSpec ) as Promise; } @@ -91,8 +103,11 @@ export class String { * @param options The options parameters. */ getMbcs(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMbcsOperationSpec ) as Promise; } @@ -102,8 +117,11 @@ export class String { * @param options The options parameters. */ putMbcs(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putMbcsOperationSpec ) as Promise; } @@ -116,8 +134,11 @@ export class String { getWhitespace( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getWhitespaceOperationSpec ) as Promise; } @@ -130,8 +151,11 @@ export class String { putWhitespace( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, putWhitespaceOperationSpec ) as Promise; } @@ -143,8 +167,11 @@ export class String { getNotProvided( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNotProvidedOperationSpec ) as Promise; } @@ -156,8 +183,11 @@ export class String { getBase64Encoded( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBase64EncodedOperationSpec ) as Promise; } @@ -169,8 +199,11 @@ export class String { getBase64UrlEncoded( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBase64UrlEncodedOperationSpec ) as Promise; } @@ -184,8 +217,11 @@ export class String { stringBody: Uint8Array, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { stringBody, options }, + { stringBody, options: operationOptions }, putBase64UrlEncodedOperationSpec ) as Promise; } @@ -197,8 +233,11 @@ export class String { getNullBase64UrlEncoded( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullBase64UrlEncodedOperationSpec ) as Promise; } diff --git a/test/integration/generated/bodyTime/src/operations/time.ts b/test/integration/generated/bodyTime/src/operations/time.ts index eabc3bcbe5..9cd4ebe527 100644 --- a/test/integration/generated/bodyTime/src/operations/time.ts +++ b/test/integration/generated/bodyTime/src/operations/time.ts @@ -31,8 +31,11 @@ export class Time { * @param options The options parameters. */ get(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOperationSpec ) as Promise; } @@ -48,8 +51,11 @@ export class Time { timeBody: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { timeBody, options }, + { timeBody, options: operationOptions }, putOperationSpec ) as Promise; } diff --git a/test/integration/generated/customUrl/src/operations/paths.ts b/test/integration/generated/customUrl/src/operations/paths.ts index c6c2626f9d..187b63b265 100644 --- a/test/integration/generated/customUrl/src/operations/paths.ts +++ b/test/integration/generated/customUrl/src/operations/paths.ts @@ -34,8 +34,11 @@ export class Paths { accountName: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { accountName, options }, + { accountName, options: operationOptions }, getEmptyOperationSpec ) as Promise; } diff --git a/test/integration/generated/header/src/operations/header.ts b/test/integration/generated/header/src/operations/header.ts index 57b6b633cc..2f624875d7 100644 --- a/test/integration/generated/header/src/operations/header.ts +++ b/test/integration/generated/header/src/operations/header.ts @@ -53,8 +53,11 @@ export class Header { userAgent: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { userAgent, options }, + { userAgent, options: operationOptions }, paramExistingKeyOperationSpec ) as Promise; } @@ -66,8 +69,11 @@ export class Header { responseExistingKey( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, responseExistingKeyOperationSpec ) as Promise; } @@ -81,8 +87,11 @@ export class Header { contentType: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { contentType, options }, + { contentType, options: operationOptions }, paramProtectedKeyOperationSpec ) as Promise; } @@ -94,8 +103,11 @@ export class Header { responseProtectedKey( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, responseProtectedKeyOperationSpec ) as Promise; } @@ -112,8 +124,11 @@ export class Header { value: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramIntegerOperationSpec ) as Promise; } @@ -127,8 +142,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseIntegerOperationSpec ) as Promise; } @@ -145,8 +163,11 @@ export class Header { value: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramLongOperationSpec ) as Promise; } @@ -160,8 +181,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseLongOperationSpec ) as Promise; } @@ -178,8 +202,11 @@ export class Header { value: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramFloatOperationSpec ) as Promise; } @@ -193,8 +220,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseFloatOperationSpec ) as Promise; } @@ -211,8 +241,11 @@ export class Header { value: number, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramDoubleOperationSpec ) as Promise; } @@ -226,8 +259,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseDoubleOperationSpec ) as Promise; } @@ -244,8 +280,11 @@ export class Header { value: boolean, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramBoolOperationSpec ) as Promise; } @@ -259,8 +298,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseBoolOperationSpec ) as Promise; } @@ -275,8 +317,11 @@ export class Header { scenario: string, options?: HeaderParamStringOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, paramStringOperationSpec ) as Promise; } @@ -290,8 +335,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseStringOperationSpec ) as Promise; } @@ -308,8 +356,11 @@ export class Header { value: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramDateOperationSpec ) as Promise; } @@ -323,8 +374,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseDateOperationSpec ) as Promise; } @@ -341,8 +395,11 @@ export class Header { value: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramDatetimeOperationSpec ) as Promise; } @@ -356,8 +413,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseDatetimeOperationSpec ) as Promise; } @@ -372,8 +432,11 @@ export class Header { scenario: string, options?: HeaderParamDatetimeRfc1123OptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, paramDatetimeRfc1123OperationSpec ) as Promise; } @@ -387,8 +450,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseDatetimeRfc1123OperationSpec ) as Promise; } @@ -404,8 +470,11 @@ export class Header { value: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramDurationOperationSpec ) as Promise; } @@ -419,8 +488,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseDurationOperationSpec ) as Promise; } @@ -436,8 +508,11 @@ export class Header { value: Uint8Array, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, value, options }, + { scenario, value, options: operationOptions }, paramByteOperationSpec ) as Promise; } @@ -451,8 +526,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseByteOperationSpec ) as Promise; } @@ -467,8 +545,11 @@ export class Header { scenario: string, options?: HeaderParamEnumOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, paramEnumOperationSpec ) as Promise; } @@ -482,8 +563,11 @@ export class Header { scenario: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { scenario, options }, + { scenario, options: operationOptions }, responseEnumOperationSpec ) as Promise; } @@ -495,8 +579,11 @@ export class Header { customRequestId( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, customRequestIdOperationSpec ) as Promise; } diff --git a/test/integration/generated/lro/src/lROClientContext.ts b/test/integration/generated/lro/src/lROClientContext.ts index 17544bc558..6da1ef96ac 100644 --- a/test/integration/generated/lro/src/lROClientContext.ts +++ b/test/integration/generated/lro/src/lROClientContext.ts @@ -8,6 +8,7 @@ import * as coreHttp from "@azure/core-http"; import * as Models from "./models"; +import { lroPolicy } from "./lro"; const packageName = "lro"; const packageVersion = "1.0.0-preview1"; @@ -30,6 +31,14 @@ export class LROClientContext extends coreHttp.ServiceClient { options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } + const defaultPipelines = coreHttp.createPipelineFromOptions(options) + .requestPolicyFactories as coreHttp.RequestPolicyFactory[]; + + options = { + ...options, + requestPolicyFactories: [lroPolicy(), ...defaultPipelines] + }; + super(undefined, options); this.requestContentType = "application/json; charset=utf-8"; diff --git a/test/integration/generated/lro/src/lro/azureAsyncOperationStrategy.ts b/test/integration/generated/lro/src/lro/azureAsyncOperationStrategy.ts new file mode 100644 index 0000000000..ecdc300c1f --- /dev/null +++ b/test/integration/generated/lro/src/lro/azureAsyncOperationStrategy.ts @@ -0,0 +1,197 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + LROStrategy, + BaseResult, + LROOperationStep, + LROResponseInfo, + FinalStateVia +} from "./models"; +import { OperationSpec, OperationArguments } from "@azure/core-http"; +import { terminalStates } from "./constants"; +import { SendOperationFn } from "."; + +export function createAzureAsyncOperationStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + finalStateVia?: FinalStateVia +): LROStrategy { + const lroData = initialOperation.result._lroData; + if (!lroData) { + throw new Error( + "Expected lroData to be defined for Azure-AsyncOperation strategy" + ); + } + + let currentOperation = initialOperation; + let lastKnownPollingUrl = + lroData.azureAsyncOperation || lroData.operationLocation; + + return { + isTerminal: () => { + const currentResult = currentOperation.result._lroData; + + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (currentOperation === initialOperation) { + // Azure-AsyncOperations don't need to check for terminal state + // on originalOperation result, always need to poll + return false; + } + + const { status = "succeeded" } = currentResult; + return terminalStates.includes(status.toLowerCase()); + }, + sendFinalRequest: async () => { + if (!initialOperation.result._lroData) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (!currentOperation.result._lroData) { + throw new Error("Expected lroData to determine terminal status"); + } + + const initialOperationResult = initialOperation.result._lroData; + const currentOperationResult = currentOperation.result._lroData; + + if ( + !shouldPerformFinalGet(initialOperationResult, currentOperationResult) + ) { + return currentOperation; + } + + if (initialOperationResult.requestMethod === "PUT") { + currentOperation = await sendFinalGet( + initialOperation, + sendOperationFn + ); + + return currentOperation; + } + + if (initialOperationResult.location) { + switch (finalStateVia) { + case "original-uri": + currentOperation = await sendFinalGet( + initialOperation, + sendOperationFn + ); + return currentOperation; + + case "azure-async-operation": + return currentOperation; + case "location": + default: + const location = + initialOperationResult.location || + currentOperationResult.location; + + if (!location) { + throw new Error("Couldn't determine final GET URL from location"); + } + + return await sendFinalGet( + initialOperation, + sendOperationFn, + location + ); + } + } + + // All other cases return the last operation + return currentOperation; + }, + poll: async () => { + if (!lastKnownPollingUrl) { + throw new Error("Unable to determine polling url"); + } + + const pollingArgs = currentOperation.args; + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = currentOperation.spec; + const pollingSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET", + path: lastKnownPollingUrl + }; + + const result = await sendOperationFn(pollingArgs, pollingSpec); + + // Update latest polling url + lastKnownPollingUrl = + result._lroData?.azureAsyncOperation || + result._lroData?.operationLocation || + lastKnownPollingUrl; + + // Update lastOperation result + currentOperation = { + args: pollingArgs, + spec: pollingSpec, + result + }; + + return currentOperation; + } + }; +} + +function shouldPerformFinalGet( + initialResult: LROResponseInfo, + currentResult: LROResponseInfo +) { + const { status } = currentResult; + const { requestMethod: initialRequestMethod, location } = initialResult; + if (status && status.toLowerCase() !== "succeeded") { + return false; + } + + if (initialRequestMethod === "DELETE") { + return false; + } + + if (initialRequestMethod !== "PUT" && !location) { + return false; + } + + return true; +} + +async function sendFinalGet( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + path?: string +): Promise> { + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = initialOperation.spec; + const finalGetSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET" + }; + + // Send final GET request to the Original URL + const spec = { + ...finalGetSpec, + ...(path && { path }) + }; + + let operationArgs: OperationArguments = initialOperation.args; + if (operationArgs.options) { + operationArgs.options.shouldDeserialize = true; + } + + const finalResult = await sendOperationFn(initialOperation.args, spec); + + return { + args: initialOperation.args, + spec, + result: finalResult + }; +} diff --git a/test/integration/generated/lro/src/lro/bodyPollingStrategy.ts b/test/integration/generated/lro/src/lro/bodyPollingStrategy.ts index fd2c4e83ae..5ffd51e5ea 100644 --- a/test/integration/generated/lro/src/lro/bodyPollingStrategy.ts +++ b/test/integration/generated/lro/src/lro/bodyPollingStrategy.ts @@ -6,49 +6,62 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { LROStrategy, BaseResult, LROOperationState } from "./models"; +import { + LROStrategy, + BaseResult, + LROOperationStep, + LROResponseInfo +} from "./models"; import { OperationSpec } from "@azure/core-http"; - -const terminalStates = ["succeeded", "failed", "canceled", "cancelled"]; +import { terminalStates } from "./constants"; +import { SendOperationFn } from "./lroPoller"; /** * Creates a polling strategy based on BodyPolling which uses the provisioning state * from the result to determine the current operation state */ -export function createBodyPollingStrategy({ - lastOperation: operation, - sendOperation -}: LROOperationState): LROStrategy { - let lastOperation = { ...operation }; +export function createBodyPollingStrategy( + initialOperation: LROOperationStep, + sendOperation: SendOperationFn +): LROStrategy { + if (!initialOperation.result._lroData) { + throw new Error("Expected lroData to be defined for BodyPolling strategy"); + } + + let currentOperation = initialOperation; + return { isTerminal: () => { + const currentResult = currentOperation.result._lroData; + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + const { provisioningState = "succeeded" } = currentResult; // If provisioning state is missing, default to Success - const provisioningState = ( - lastOperation.result.provisioningState || - lastOperation.result.properties?.provisioningState || - "succeeded" - ).toLowerCase(); - return terminalStates.includes(provisioningState); + return terminalStates.includes(provisioningState.toLowerCase()); }, sendFinalRequest: () => { // BodyPolling doesn't require a final get so return the lastOperation - return Promise.resolve(lastOperation); + return Promise.resolve(currentOperation); }, poll: async () => { // When doing BodyPolling, we need to poll to the original url with a // GET http method + const { requestBody, ...restSpec } = initialOperation.spec; const pollingSpec: OperationSpec = { - ...lastOperation.spec, + // Make sure we don't send any body to the get request + ...restSpec, httpMethod: "GET" }; // Execute the polling operation - const result = await sendOperation(lastOperation.args, pollingSpec); - - // Update lastOperation result - lastOperation.result = result; - return lastOperation; + initialOperation.result = await sendOperation( + initialOperation.args, + pollingSpec + ); + return initialOperation; } }; } diff --git a/test/integration/generated/lro/src/lro/constants.ts b/test/integration/generated/lro/src/lro/constants.ts new file mode 100644 index 0000000000..fa0ee2d994 --- /dev/null +++ b/test/integration/generated/lro/src/lro/constants.ts @@ -0,0 +1,9 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export const terminalStates = ["succeeded", "failed", "canceled", "cancelled"]; diff --git a/test/integration/generated/lro/src/lro/index.ts b/test/integration/generated/lro/src/lro/index.ts new file mode 100644 index 0000000000..f605ce7ee3 --- /dev/null +++ b/test/integration/generated/lro/src/lro/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { shouldDeserializeLRO } from "./requestUtils"; +export { createBodyPollingStrategy } from "./bodyPollingStrategy"; +export { terminalStates } from "./constants"; +export { lroPolicy } from "./lroPolicy"; +export { LROPoller, LROPollerOptions, SendOperationFn } from "./lroPoller"; +export { + LROResponseInfo, + BaseResult, + LROOperationStep, + LROOperationState, + LROStrategy, + LROOperation +} from "./models"; +export { makeOperation } from "./operation"; +export * from "./locationStrategy"; diff --git a/test/integration/generated/lro/src/lro/locationStrategy.ts b/test/integration/generated/lro/src/lro/locationStrategy.ts new file mode 100644 index 0000000000..1a5c8d462e --- /dev/null +++ b/test/integration/generated/lro/src/lro/locationStrategy.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { BaseResult, LROOperationStep, LROStrategy } from "./models"; +import { SendOperationFn } from "./lroPoller"; +import { OperationSpec } from "@azure/core-http"; + +export function createLocationStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn +): LROStrategy { + const lroData = initialOperation.result._lroData; + if (!lroData) { + throw new Error( + "Expected lroData to be defined for Azure-AsyncOperation strategy" + ); + } + + let currentOperation = initialOperation; + let lastKnownPollingUrl = lroData.location; + + return { + isTerminal: () => { + const currentResult = currentOperation.result._lroData; + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (currentOperation === initialOperation) { + return false; + } + + if (currentResult.statusCode === 202) { + return false; + } + + return true; + }, + sendFinalRequest: () => Promise.resolve(currentOperation), + poll: async () => { + if (!lastKnownPollingUrl) { + throw new Error("Unable to determine polling url"); + } + + const pollingArgs = currentOperation.args; + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = currentOperation.spec; + const pollingSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET", + path: lastKnownPollingUrl + }; + + const result = await sendOperationFn(pollingArgs, pollingSpec); + + // Update latest polling url + lastKnownPollingUrl = result._lroData?.location || lastKnownPollingUrl; + + // Update lastOperation result + currentOperation = { + args: pollingArgs, + spec: pollingSpec, + result + }; + + return currentOperation; + } + }; +} diff --git a/test/integration/generated/lro/src/lro/lroPolicy.ts b/test/integration/generated/lro/src/lro/lroPolicy.ts new file mode 100644 index 0000000000..3606072efd --- /dev/null +++ b/test/integration/generated/lro/src/lro/lroPolicy.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + RequestPolicy, + RequestPolicyOptions, + BaseRequestPolicy, + HttpOperationResponse, + WebResource +} from "@azure/core-http"; +import { getLROData } from "./requestUtils"; +import { isEmpty } from "lodash"; + +export function lroPolicy() { + return { + create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => { + return new LROPolicy(nextPolicy, options); + } + }; +} + +class LROPolicy extends BaseRequestPolicy { + constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) { + super(nextPolicy, options); + } + + public async sendRequest( + webResource: WebResource + ): Promise { + let result = await this._nextPolicy.sendRequest(webResource); + + if (webResource.shouldDeserialize !== undefined) { + const _lroData = getLROData(result); + result.parsedBody = { ...result.parsedBody, _lroData }; + } + + return result; + } +} diff --git a/test/integration/generated/lro/src/lro/lroPoller.ts b/test/integration/generated/lro/src/lro/lroPoller.ts index 65207bf4a3..226c4f8861 100644 --- a/test/integration/generated/lro/src/lro/lroPoller.ts +++ b/test/integration/generated/lro/src/lro/lroPoller.ts @@ -6,10 +6,24 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { Poller } from "@azure/core-lro"; -import { OperationSpec, OperationArguments, delay } from "@azure/core-http"; -import { BaseResult, LROOperationState } from "./models"; +import { Poller, PollOperationState } from "@azure/core-lro"; +import { + OperationSpec, + OperationArguments, + delay, + RestError +} from "@azure/core-http"; +import { + BaseResult, + LROOperationState, + LROOperationStep, + FinalStateVia +} from "./models"; import { makeOperation } from "./operation"; +import { createBodyPollingStrategy } from "./bodyPollingStrategy"; +import { createAzureAsyncOperationStrategy } from "./azureAsyncOperationStrategy"; +import { createLocationStrategy } from "./locationStrategy"; +import { createPassthroughStrategy } from "./passthroughStrategy"; export type SendOperationFn = ( args: OperationArguments, @@ -37,6 +51,10 @@ export interface LROPollerOptions { * Function to execute an operation based on an operation spec and arguments */ sendOperation: SendOperationFn; + /** + * Optional information on where to poll. When not defined it defaults to "Location" + */ + finalStateVia?: FinalStateVia; } export class LROPoller extends Poller< @@ -50,17 +68,27 @@ export class LROPoller extends Poller< initialOperationResult, initialOperationSpec, sendOperation, + finalStateVia, intervalInMs = 2000 }: LROPollerOptions) { + const initialOperation = { + args: initialOperationArguments, + spec: initialOperationSpec, + result: initialOperationResult + }; + + const pollingStrategy = getPollingStrategy( + initialOperation, + sendOperation, + finalStateVia + ); + const state: LROOperationState = { // Initial operation will become the last operation - lastOperation: { - args: initialOperationArguments, - spec: initialOperationSpec, - result: initialOperationResult - }, - sendOperation, - result: initialOperationResult + initialOperation, + lastOperation: initialOperation, + pollingStrategy, + finalStateVia }; const operation = makeOperation(state); @@ -76,3 +104,51 @@ export class LROPoller extends Poller< return delay(this.intervalInMs); } } + +/** + * This function determines which strategy to use based on the response from + * the last operation executed, this last operation can be an initial operation + * or a polling operation. The 3 possible strategies are described below: + * + * A) Azure-AsyncOperation or Operation-Location + * B) Location + * C) BodyPolling (provisioningState) + * - This strategy is used when: + * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location + * - Last operation method is PUT + */ +function getPollingStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + finalStateVia?: FinalStateVia +) { + const lroData = initialOperation.result._lroData; + + if (!lroData) { + const error = new RestError( + "Service response doesn't include the required LRO data to continue polling" + ); + error.statusCode = initialOperation.result._response.status; + error.response = initialOperation.result._response; + throw error; + } + + if (lroData.azureAsyncOperation || lroData.operationLocation) { + return createAzureAsyncOperationStrategy( + initialOperation, + sendOperationFn, + finalStateVia + ); + } + + if (lroData.location) { + return createLocationStrategy(initialOperation, sendOperationFn); + } + + if (["PUT", "PATCH"].includes(lroData.requestMethod || "")) { + return createBodyPollingStrategy(initialOperation, sendOperationFn); + } + + // Default strategy is just a passthrough returning the initial operation + return createPassthroughStrategy(initialOperation); +} diff --git a/test/integration/generated/lro/src/lro/models.ts b/test/integration/generated/lro/src/lro/models.ts index a4d90168ca..a90afc5b41 100644 --- a/test/integration/generated/lro/src/lro/models.ts +++ b/test/integration/generated/lro/src/lro/models.ts @@ -9,21 +9,32 @@ import { OperationArguments, OperationSpec, - RestResponse + RestResponse, + HttpMethods } from "@azure/core-http"; import { PollOperationState, PollOperation } from "@azure/core-lro"; -export interface BaseResult extends RestResponse { - location?: string; - operationLocation?: string; +export type FinalStateVia = + | "azure-async-operation" + | "location" + | "original-uri"; + +export interface LROResponseInfo { + requestMethod: HttpMethods; + statusCode: number; + isInitialRequest?: boolean; azureAsyncOperation?: string; + operationLocation?: string; + location?: string; provisioningState?: string; - properties?: { - provisioningState?: string; - }; + status?: string; +} + +export interface BaseResult extends RestResponse { + _lroData?: LROResponseInfo; } -export interface LastOperation { +export interface LROOperationStep { args: OperationArguments; spec: OperationSpec; result: TResult; @@ -31,17 +42,16 @@ export interface LastOperation { export interface LROOperationState extends PollOperationState { - lastOperation: LastOperation; - sendOperation: ( - args: OperationArguments, - spec: OperationSpec - ) => Promise; + lastOperation: LROOperationStep; + initialOperation: LROOperationStep; + pollingStrategy: LROStrategy; + finalStateVia?: FinalStateVia; } export interface LROStrategy { isTerminal: () => boolean; - sendFinalRequest: () => Promise>; - poll: () => Promise>; + sendFinalRequest: () => Promise>; + poll: () => Promise>; } export type LROOperation = PollOperation< diff --git a/test/integration/generated/lro/src/lro/operation.ts b/test/integration/generated/lro/src/lro/operation.ts index 05478cbbd1..a7e6f4bd54 100644 --- a/test/integration/generated/lro/src/lro/operation.ts +++ b/test/integration/generated/lro/src/lro/operation.ts @@ -6,12 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { - BaseResult, - LROOperationState, - LROOperation, - LROStrategy -} from "./models"; +import { BaseResult, LROOperationState, LROOperation } from "./models"; import { createBodyPollingStrategy } from "./bodyPollingStrategy"; /** @@ -50,19 +45,27 @@ async function update( ): Promise> { const state = { ...this.state }; - // Get strategy from last operation - const lroStrategy: LROStrategy = getStrategyFromResult(state); + const { sendFinalRequest, poll, isTerminal } = state.pollingStrategy; + const currentResponse = state.lastOperation; + const currentLroData = currentResponse.result._lroData; + + if (!currentLroData) { + throw new Error( + "Expected lroData to be defined for updating LRO operation" + ); + } + + if (state.result) { + state.isCompleted = true; + return makeOperation(state); + } // Check if last result is terminal - if (lroStrategy.isTerminal()) { - const result = await lroStrategy.sendFinalRequest(); - state.lastOperation = result; + if (isTerminal()) { + state.lastOperation = await sendFinalRequest(); state.result = state.lastOperation.result; - state.isCompleted = true; } else { - const result = await lroStrategy.poll(); - state.lastOperation = result; - state.result = state.lastOperation.result; + state.lastOperation = await poll(); } // Return operation @@ -78,37 +81,3 @@ async function cancel( ): Promise> { return makeOperation({ ...this.state, isCancelled: true }); } - -/** - * This function determines which strategy to use based on the response from - * the last operation executed, this last operation can be an initial operation - * or a polling operation. The 3 possible strategies are described below: - * - * A) Azure-AsyncOperation or Operation-Location - * B) Location - * C) BodyPolling (provisioningState) - * - This strategy is used when: - * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location - * - Last operation method is PUT - */ -function getStrategyFromResult( - state: LROOperationState -): LROStrategy { - const { - lastOperation: { spec, result } - } = state; - - if (result.azureAsyncOperation) { - throw new Error("Azure-AsyncOperation strategy is not yet implemented"); - } - - if (result.location) { - throw new Error("Location strategy is not yet implemented"); - } - - if (["PUT", "PATCH"].includes(spec.httpMethod)) { - return createBodyPollingStrategy(state); - } - - throw new Error("Unknown Long Running Operation strategy"); -} diff --git a/test/integration/generated/lro/src/lro/passthroughStrategy.ts b/test/integration/generated/lro/src/lro/passthroughStrategy.ts new file mode 100644 index 0000000000..689e851485 --- /dev/null +++ b/test/integration/generated/lro/src/lro/passthroughStrategy.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { LROStrategy, BaseResult, LROOperationStep } from "./models"; +import { SendOperationFn } from "./lroPoller"; + +/** + * Creates a polling strategy based on BodyPolling which uses the provisioning state + * from the result to determine the current operation state + */ +export function createPassthroughStrategy( + initialOperation: LROOperationStep +): LROStrategy { + return { + isTerminal: () => { + return true; + }, + sendFinalRequest: () => { + // BodyPolling doesn't require a final get so return the lastOperation + return Promise.resolve(initialOperation); + }, + poll: async () => { + throw new Error("Passthrough strategy should never poll"); + } + }; +} diff --git a/test/integration/generated/lro/src/lro/requestUtils.ts b/test/integration/generated/lro/src/lro/requestUtils.ts new file mode 100644 index 0000000000..e9af4cde5e --- /dev/null +++ b/test/integration/generated/lro/src/lro/requestUtils.ts @@ -0,0 +1,117 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { HttpOperationResponse } from "@azure/core-http"; +import { terminalStates } from "./constants"; +import { LROResponseInfo } from "./models"; + +/** + * We need to selectively deserialize our responses, only deserializing if we + * are in a final LRO response, not deserializing any polling non-terminal responses + */ +export function shouldDeserializeLRO(finalStateVia?: string) { + let initialOperationInfo: LROResponseInfo | undefined; + let isInitialRequest = true; + + return (response: HttpOperationResponse) => { + if (response.status < 200 || response.status >= 300) { + return true; + } + + if (!initialOperationInfo) { + initialOperationInfo = getLROData(response); + } else { + isInitialRequest = false; + } + + if ( + initialOperationInfo.azureAsyncOperation || + initialOperationInfo.operationLocation + ) { + return ( + !isInitialRequest && + isAsyncOperationFinalResponse( + response, + initialOperationInfo, + finalStateVia + ) + ); + } + + if (initialOperationInfo.location) { + return isLocationFinalResponse(response); + } + + if (initialOperationInfo.requestMethod === "PUT") { + return isBodyPollingFinalResponse(response); + } + + return true; + }; +} + +function isAsyncOperationFinalResponse( + response: HttpOperationResponse, + initialOperationInfo: LROResponseInfo, + finalStateVia?: string +): boolean { + const status: string = response.parsedBody?.status || "Succeeded"; + if (!terminalStates.includes(status.toLowerCase())) { + return false; + } + + if (initialOperationInfo.requestMethod === "DELETE") { + return true; + } + + if ( + initialOperationInfo.requestMethod === "PUT" && + finalStateVia && + finalStateVia.toLowerCase() === "azure-asyncoperation" + ) { + return true; + } + + if ( + initialOperationInfo.requestMethod !== "PUT" && + !initialOperationInfo.location + ) { + return true; + } + + return false; +} + +function isLocationFinalResponse(response: HttpOperationResponse): boolean { + return response.status !== 202; +} + +function isBodyPollingFinalResponse(response: HttpOperationResponse): boolean { + const provisioningState: string = + response.parsedBody?.properties?.provisioningState || "Succeeded"; + + if (terminalStates.includes(provisioningState.toLowerCase())) { + return true; + } + + return false; +} + +export function getLROData(result: HttpOperationResponse): LROResponseInfo { + const statusCode = result.status; + const { status, properties } = result.parsedBody || {}; + return { + statusCode, + azureAsyncOperation: result.headers.get("azure-asyncoperation"), + operationLocation: result.headers.get("operation-location"), + location: result.headers.get("location"), + requestMethod: result.request.method, + status, + provisioningState: properties?.provisioningState + }; +} diff --git a/test/integration/generated/lro/src/operations/lRORetrys.ts b/test/integration/generated/lro/src/operations/lRORetrys.ts index 6955624a4d..2c56192da4 100644 --- a/test/integration/generated/lro/src/operations/lRORetrys.ts +++ b/test/integration/generated/lro/src/operations/lRORetrys.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { LROClient } from "../lROClient"; -import { LROPoller } from "../lro/lroPoller"; +import { LROPoller, shouldDeserializeLRO } from "../lro"; import { LRORetrysPut201CreatingSucceeded200OptionalParams, LRORetrysPut201CreatingSucceeded200Response, @@ -48,7 +48,11 @@ export class LRORetrys { async put201CreatingSucceeded200( options?: LRORetrysPut201CreatingSucceeded200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -78,7 +82,11 @@ export class LRORetrys { async putAsyncRelativeRetrySucceeded( options?: LRORetrysPutAsyncRelativeRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -110,7 +118,11 @@ export class LRORetrys { ): Promise< LROPoller > { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -139,7 +151,11 @@ export class LRORetrys { async delete202Retry200( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -168,7 +184,11 @@ export class LRORetrys { async deleteAsyncRelativeRetrySucceeded( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -197,7 +217,11 @@ export class LRORetrys { async post202Retry200( options?: LRORetrysPost202Retry200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -227,7 +251,11 @@ export class LRORetrys { async postAsyncRelativeRetrySucceeded( options?: LRORetrysPostAsyncRelativeRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -247,6 +275,18 @@ export class LRORetrys { sendOperation }); } + + private getOperationOptions( + options: TOptions | undefined, + finalStateVia?: string + ): coreHttp.RequestOptionsBase { + const operationOptions: coreHttp.OperationOptions = options || {}; + operationOptions.requestOptions = { + ...operationOptions.requestOptions, + shouldDeserialize: shouldDeserializeLRO(finalStateVia) + }; + return coreHttp.operationOptionsToRequestOptionsBase(operationOptions); + } } // Operation Specifications @@ -258,6 +298,15 @@ const put201CreatingSucceeded200OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -273,6 +322,18 @@ const putAsyncRelativeRetrySucceededOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LRORetrysPutAsyncRelativeRetrySucceededHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LRORetrysPutAsyncRelativeRetrySucceededHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LRORetrysPutAsyncRelativeRetrySucceededHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LRORetrysPutAsyncRelativeRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -288,6 +349,15 @@ const deleteProvisioning202Accepted200SucceededOperationSpec: coreHttp.Operation responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, urlParameters: [Parameters.$host], @@ -297,9 +367,18 @@ const delete202Retry200OperationSpec: coreHttp.OperationSpec = { path: "/lro/retryerror/delete/202/retry/200", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LRORetrysDelete202Retry200Headers + }, + 201: { + headersMapper: Mappers.LRORetrysDelete202Retry200Headers + }, 202: { headersMapper: Mappers.LRORetrysDelete202Retry200Headers }, + 204: { + headersMapper: Mappers.LRORetrysDelete202Retry200Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -311,9 +390,18 @@ const deleteAsyncRelativeRetrySucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/retryerror/deleteasync/retry/succeeded", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LRORetrysDeleteAsyncRelativeRetrySucceededHeaders + }, + 201: { + headersMapper: Mappers.LRORetrysDeleteAsyncRelativeRetrySucceededHeaders + }, 202: { headersMapper: Mappers.LRORetrysDeleteAsyncRelativeRetrySucceededHeaders }, + 204: { + headersMapper: Mappers.LRORetrysDeleteAsyncRelativeRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -325,9 +413,18 @@ const post202Retry200OperationSpec: coreHttp.OperationSpec = { path: "/lro/retryerror/post/202/retry/200", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LRORetrysPost202Retry200Headers + }, + 201: { + headersMapper: Mappers.LRORetrysPost202Retry200Headers + }, 202: { headersMapper: Mappers.LRORetrysPost202Retry200Headers }, + 204: { + headersMapper: Mappers.LRORetrysPost202Retry200Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -341,9 +438,18 @@ const postAsyncRelativeRetrySucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/retryerror/postasync/retry/succeeded", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LRORetrysPostAsyncRelativeRetrySucceededHeaders + }, + 201: { + headersMapper: Mappers.LRORetrysPostAsyncRelativeRetrySucceededHeaders + }, 202: { headersMapper: Mappers.LRORetrysPostAsyncRelativeRetrySucceededHeaders }, + 204: { + headersMapper: Mappers.LRORetrysPostAsyncRelativeRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } diff --git a/test/integration/generated/lro/src/operations/lROs.ts b/test/integration/generated/lro/src/operations/lROs.ts index 2a8efc7858..bfeaf1fae7 100644 --- a/test/integration/generated/lro/src/operations/lROs.ts +++ b/test/integration/generated/lro/src/operations/lROs.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { LROClient } from "../lROClient"; -import { LROPoller } from "../lro/lroPoller"; +import { LROPoller, shouldDeserializeLRO } from "../lro"; import { LROsPut200SucceededOptionalParams, LROsPut200SucceededResponse, @@ -95,7 +95,11 @@ export class LROs { async put200Succeeded( options?: LROsPut200SucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -124,7 +128,11 @@ export class LROs { async put200SucceededNoState( options?: LROsPut200SucceededNoStateOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -153,7 +161,11 @@ export class LROs { async put202Retry200( options?: LROsPut202Retry200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -183,7 +195,11 @@ export class LROs { async put201CreatingSucceeded200( options?: LROsPut201CreatingSucceeded200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -213,7 +229,11 @@ export class LROs { async put200UpdatingSucceeded204( options?: LROsPut200UpdatingSucceeded204OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -243,7 +263,11 @@ export class LROs { async put201CreatingFailed200( options?: LROsPut201CreatingFailed200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -273,7 +297,11 @@ export class LROs { async put200Acceptedcanceled200( options?: LROsPut200Acceptedcanceled200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -302,7 +330,11 @@ export class LROs { async putNoHeaderInRetry( options?: LROsPutNoHeaderInRetryOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -332,7 +364,11 @@ export class LROs { async putAsyncRetrySucceeded( options?: LROsPutAsyncRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -362,7 +398,11 @@ export class LROs { async putAsyncNoRetrySucceeded( options?: LROsPutAsyncNoRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -392,7 +432,11 @@ export class LROs { async putAsyncRetryFailed( options?: LROsPutAsyncRetryFailedOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -422,7 +466,11 @@ export class LROs { async putAsyncNoRetrycanceled( options?: LROsPutAsyncNoRetrycanceledOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -451,7 +499,11 @@ export class LROs { async putAsyncNoHeaderInRetry( options?: LROsPutAsyncNoHeaderInRetryOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -479,7 +531,11 @@ export class LROs { async putNonResource( options?: LROsPutNonResourceOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -507,7 +563,11 @@ export class LROs { async putAsyncNonResource( options?: LROsPutAsyncNonResourceOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -535,7 +595,11 @@ export class LROs { async putSubResource( options?: LROsPutSubResourceOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -563,7 +627,11 @@ export class LROs { async putAsyncSubResource( options?: LROsPutAsyncSubResourceOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -593,7 +661,11 @@ export class LROs { async deleteProvisioning202Accepted200Succeeded( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -623,7 +695,11 @@ export class LROs { async deleteProvisioning202DeletingFailed200( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -653,7 +729,11 @@ export class LROs { async deleteProvisioning202Deletingcanceled200( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -681,7 +761,11 @@ export class LROs { async delete204Succeeded( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -710,7 +794,11 @@ export class LROs { async delete202Retry200( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -739,7 +827,11 @@ export class LROs { async delete202NoRetry204( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -768,7 +860,11 @@ export class LROs { async deleteNoHeaderInRetry( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -797,7 +893,11 @@ export class LROs { async deleteAsyncNoHeaderInRetry( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -826,7 +926,11 @@ export class LROs { async deleteAsyncRetrySucceeded( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -855,7 +959,11 @@ export class LROs { async deleteAsyncNoRetrySucceeded( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -884,7 +992,11 @@ export class LROs { async deleteAsyncRetryFailed( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -913,7 +1025,11 @@ export class LROs { async deleteAsyncRetrycanceled( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -942,7 +1058,11 @@ export class LROs { async post200WithPayload( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -971,7 +1091,11 @@ export class LROs { async post202Retry200( options?: LROsPost202Retry200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1000,7 +1124,11 @@ export class LROs { async post202NoRetry204( options?: LROsPost202NoRetry204OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1029,7 +1157,12 @@ export class LROs { async postDoubleHeadersFinalLocationGet( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options, + "location" + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1046,7 +1179,8 @@ export class LROs { initialOperationArguments: args, initialOperationSpec: postDoubleHeadersFinalLocationGetOperationSpec, initialOperationResult, - sendOperation + sendOperation, + finalStateVia: "location" }); } @@ -1059,7 +1193,12 @@ export class LROs { async postDoubleHeadersFinalAzureHeaderGet( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options, + "azure-async-operation" + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1076,7 +1215,8 @@ export class LROs { initialOperationArguments: args, initialOperationSpec: postDoubleHeadersFinalAzureHeaderGetOperationSpec, initialOperationResult, - sendOperation + sendOperation, + finalStateVia: "azure-async-operation" }); } @@ -1091,7 +1231,11 @@ export class LROs { ): Promise< LROPoller > { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1121,7 +1265,11 @@ export class LROs { async postAsyncRetrySucceeded( options?: LROsPostAsyncRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1151,7 +1299,11 @@ export class LROs { async postAsyncNoRetrySucceeded( options?: LROsPostAsyncNoRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1181,7 +1333,11 @@ export class LROs { async postAsyncRetryFailed( options?: LROsPostAsyncRetryFailedOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1211,7 +1367,11 @@ export class LROs { async postAsyncRetrycanceled( options?: LROsPostAsyncRetrycanceledOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -1231,6 +1391,18 @@ export class LROs { sendOperation }); } + + private getOperationOptions( + options: TOptions | undefined, + finalStateVia?: string + ): coreHttp.RequestOptionsBase { + const operationOptions: coreHttp.OperationOptions = options || {}; + operationOptions.requestOptions = { + ...operationOptions.requestOptions, + shouldDeserialize: shouldDeserializeLRO(finalStateVia) + }; + return coreHttp.operationOptionsToRequestOptionsBase(operationOptions); + } } // Operation Specifications @@ -1243,6 +1415,12 @@ const put200SucceededOperationSpec: coreHttp.OperationSpec = { 200: { bodyMapper: Mappers.Product }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, 204: {} }, requestBody: Parameters.product, @@ -1257,6 +1435,15 @@ const put200SucceededNoStateOperationSpec: coreHttp.OperationSpec = { 200: { bodyMapper: Mappers.Product }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1270,9 +1457,18 @@ const put202Retry200OperationSpec: coreHttp.OperationSpec = { path: "/lro/put/202/retry/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, 202: { bodyMapper: Mappers.Product }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1288,6 +1484,15 @@ const put201CreatingSucceeded200OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -1302,6 +1507,15 @@ const put200UpdatingSucceeded204OperationSpec: coreHttp.OperationSpec = { 200: { bodyMapper: Mappers.Product }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1317,6 +1531,15 @@ const put201CreatingFailed200OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -1331,6 +1554,15 @@ const put200Acceptedcanceled200OperationSpec: coreHttp.OperationSpec = { 200: { bodyMapper: Mappers.Product }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1344,10 +1576,22 @@ const putNoHeaderInRetryOperationSpec: coreHttp.OperationSpec = { path: "/lro/put/noheader/202/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutNoHeaderInRetryHeaders + }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutNoHeaderInRetryHeaders + }, 202: { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPutNoHeaderInRetryHeaders }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutNoHeaderInRetryHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1365,6 +1609,18 @@ const putAsyncRetrySucceededOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPutAsyncRetrySucceededHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncRetrySucceededHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncRetrySucceededHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1382,6 +1638,18 @@ const putAsyncNoRetrySucceededOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPutAsyncNoRetrySucceededHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoRetrySucceededHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoRetrySucceededHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1399,6 +1667,18 @@ const putAsyncRetryFailedOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPutAsyncRetryFailedHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncRetryFailedHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncRetryFailedHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncRetryFailedHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1416,6 +1696,18 @@ const putAsyncNoRetrycanceledOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPutAsyncNoRetrycanceledHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoRetrycanceledHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoRetrycanceledHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoRetrycanceledHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1429,10 +1721,22 @@ const putAsyncNoHeaderInRetryOperationSpec: coreHttp.OperationSpec = { path: "/lro/putasync/noheader/201/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoHeaderInRetryHeaders + }, 201: { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPutAsyncNoHeaderInRetryHeaders }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoHeaderInRetryHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPutAsyncNoHeaderInRetryHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1446,9 +1750,18 @@ const putNonResourceOperationSpec: coreHttp.OperationSpec = { path: "/lro/putnonresource/202/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.Sku + }, + 201: { + bodyMapper: Mappers.Sku + }, 202: { bodyMapper: Mappers.Sku }, + 204: { + bodyMapper: Mappers.Sku + }, default: { bodyMapper: Mappers.CloudError } @@ -1462,9 +1775,18 @@ const putAsyncNonResourceOperationSpec: coreHttp.OperationSpec = { path: "/lro/putnonresourceasync/202/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.Sku + }, + 201: { + bodyMapper: Mappers.Sku + }, 202: { bodyMapper: Mappers.Sku }, + 204: { + bodyMapper: Mappers.Sku + }, default: { bodyMapper: Mappers.CloudError } @@ -1478,9 +1800,18 @@ const putSubResourceOperationSpec: coreHttp.OperationSpec = { path: "/lro/putsubresource/202/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.SubProduct + }, + 201: { + bodyMapper: Mappers.SubProduct + }, 202: { bodyMapper: Mappers.SubProduct }, + 204: { + bodyMapper: Mappers.SubProduct + }, default: { bodyMapper: Mappers.CloudError } @@ -1494,9 +1825,18 @@ const putAsyncSubResourceOperationSpec: coreHttp.OperationSpec = { path: "/lro/putsubresourceasync/202/200", httpMethod: "PUT", responses: { + 200: { + bodyMapper: Mappers.SubProduct + }, + 201: { + bodyMapper: Mappers.SubProduct + }, 202: { bodyMapper: Mappers.SubProduct }, + 204: { + bodyMapper: Mappers.SubProduct + }, default: { bodyMapper: Mappers.CloudError } @@ -1512,6 +1852,15 @@ const deleteProvisioning202Accepted200SucceededOperationSpec: coreHttp.Operation responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, urlParameters: [Parameters.$host], @@ -1523,6 +1872,15 @@ const deleteProvisioning202DeletingFailed200OperationSpec: coreHttp.OperationSpe responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, urlParameters: [Parameters.$host], @@ -1534,6 +1892,15 @@ const deleteProvisioning202Deletingcanceled200OperationSpec: coreHttp.OperationS responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, urlParameters: [Parameters.$host], @@ -1543,6 +1910,9 @@ const delete204SucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/delete/204/succeeded", httpMethod: "DELETE", responses: { + 200: {}, + 201: {}, + 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError @@ -1557,6 +1927,15 @@ const delete202Retry200OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, urlParameters: [Parameters.$host], @@ -1568,6 +1947,15 @@ const delete202NoRetry204OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, urlParameters: [Parameters.$host], @@ -1576,14 +1964,14 @@ const delete202NoRetry204OperationSpec: coreHttp.OperationSpec = { const deleteNoHeaderInRetryOperationSpec: coreHttp.OperationSpec = { path: "/lro/delete/noheader", httpMethod: "DELETE", - responses: { 204: {} }, + responses: { 200: {}, 201: {}, 202: {}, 204: {} }, urlParameters: [Parameters.$host], serializer }; const deleteAsyncNoHeaderInRetryOperationSpec: coreHttp.OperationSpec = { path: "/lro/deleteasync/noheader/202/204", httpMethod: "DELETE", - responses: { 204: {} }, + responses: { 200: {}, 201: {}, 202: {}, 204: {} }, urlParameters: [Parameters.$host], serializer }; @@ -1591,9 +1979,18 @@ const deleteAsyncRetrySucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/deleteasync/retry/succeeded", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LROsDeleteAsyncRetrySucceededHeaders + }, + 201: { + headersMapper: Mappers.LROsDeleteAsyncRetrySucceededHeaders + }, 202: { headersMapper: Mappers.LROsDeleteAsyncRetrySucceededHeaders }, + 204: { + headersMapper: Mappers.LROsDeleteAsyncRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1605,9 +2002,18 @@ const deleteAsyncNoRetrySucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/deleteasync/noretry/succeeded", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LROsDeleteAsyncNoRetrySucceededHeaders + }, + 201: { + headersMapper: Mappers.LROsDeleteAsyncNoRetrySucceededHeaders + }, 202: { headersMapper: Mappers.LROsDeleteAsyncNoRetrySucceededHeaders }, + 204: { + headersMapper: Mappers.LROsDeleteAsyncNoRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1619,9 +2025,18 @@ const deleteAsyncRetryFailedOperationSpec: coreHttp.OperationSpec = { path: "/lro/deleteasync/retry/failed", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LROsDeleteAsyncRetryFailedHeaders + }, + 201: { + headersMapper: Mappers.LROsDeleteAsyncRetryFailedHeaders + }, 202: { headersMapper: Mappers.LROsDeleteAsyncRetryFailedHeaders }, + 204: { + headersMapper: Mappers.LROsDeleteAsyncRetryFailedHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1633,9 +2048,18 @@ const deleteAsyncRetrycanceledOperationSpec: coreHttp.OperationSpec = { path: "/lro/deleteasync/retry/canceled", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LROsDeleteAsyncRetrycanceledHeaders + }, + 201: { + headersMapper: Mappers.LROsDeleteAsyncRetrycanceledHeaders + }, 202: { headersMapper: Mappers.LROsDeleteAsyncRetrycanceledHeaders }, + 204: { + headersMapper: Mappers.LROsDeleteAsyncRetrycanceledHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1649,6 +2073,15 @@ const post200WithPayloadOperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Sku + }, + 201: { + bodyMapper: Mappers.Sku + }, + 202: { + bodyMapper: Mappers.Sku + }, + 204: { + bodyMapper: Mappers.Sku } }, urlParameters: [Parameters.$host], @@ -1658,9 +2091,18 @@ const post202Retry200OperationSpec: coreHttp.OperationSpec = { path: "/lro/post/202/retry/200", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LROsPost202Retry200Headers + }, + 201: { + headersMapper: Mappers.LROsPost202Retry200Headers + }, 202: { headersMapper: Mappers.LROsPost202Retry200Headers }, + 204: { + headersMapper: Mappers.LROsPost202Retry200Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -1674,10 +2116,22 @@ const post202NoRetry204OperationSpec: coreHttp.OperationSpec = { path: "/lro/post/202/noretry/204", httpMethod: "POST", responses: { + 200: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPost202NoRetry204Headers + }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPost202NoRetry204Headers + }, 202: { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsPost202NoRetry204Headers }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsPost202NoRetry204Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -1691,9 +2145,18 @@ const postDoubleHeadersFinalLocationGetOperationSpec: coreHttp.OperationSpec = { path: "/lro/LROPostDoubleHeadersFinalLocationGet", httpMethod: "POST", responses: { + 200: { + bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, 202: { bodyMapper: Mappers.Product }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1705,9 +2168,18 @@ const postDoubleHeadersFinalAzureHeaderGetOperationSpec: coreHttp.OperationSpec path: "/lro/LROPostDoubleHeadersFinalAzureHeaderGet", httpMethod: "POST", responses: { + 200: { + bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, 202: { bodyMapper: Mappers.Product }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1719,9 +2191,18 @@ const postDoubleHeadersFinalAzureHeaderGetDefaultOperationSpec: coreHttp.Operati path: "/lro/LROPostDoubleHeadersFinalAzureHeaderGetDefault", httpMethod: "POST", responses: { + 200: { + bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, 202: { bodyMapper: Mappers.Product }, + 204: { + bodyMapper: Mappers.Product + }, default: { bodyMapper: Mappers.CloudError } @@ -1735,6 +2216,15 @@ const postAsyncRetrySucceededOperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -1748,6 +2238,15 @@ const postAsyncNoRetrySucceededOperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -1759,9 +2258,18 @@ const postAsyncRetryFailedOperationSpec: coreHttp.OperationSpec = { path: "/lro/postasync/retry/failed", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LROsPostAsyncRetryFailedHeaders + }, + 201: { + headersMapper: Mappers.LROsPostAsyncRetryFailedHeaders + }, 202: { headersMapper: Mappers.LROsPostAsyncRetryFailedHeaders }, + 204: { + headersMapper: Mappers.LROsPostAsyncRetryFailedHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1775,9 +2283,18 @@ const postAsyncRetrycanceledOperationSpec: coreHttp.OperationSpec = { path: "/lro/postasync/retry/canceled", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LROsPostAsyncRetrycanceledHeaders + }, + 201: { + headersMapper: Mappers.LROsPostAsyncRetrycanceledHeaders + }, 202: { headersMapper: Mappers.LROsPostAsyncRetrycanceledHeaders }, + 204: { + headersMapper: Mappers.LROsPostAsyncRetrycanceledHeaders + }, default: { bodyMapper: Mappers.CloudError } diff --git a/test/integration/generated/lro/src/operations/lROsCustomHeader.ts b/test/integration/generated/lro/src/operations/lROsCustomHeader.ts index 02968eee10..51c1ce927e 100644 --- a/test/integration/generated/lro/src/operations/lROsCustomHeader.ts +++ b/test/integration/generated/lro/src/operations/lROsCustomHeader.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { LROClient } from "../lROClient"; -import { LROPoller } from "../lro/lroPoller"; +import { LROPoller, shouldDeserializeLRO } from "../lro"; import { LROsCustomHeaderPutAsyncRetrySucceededOptionalParams, LROsCustomHeaderPutAsyncRetrySucceededResponse, @@ -46,7 +46,11 @@ export class LROsCustomHeader { async putAsyncRetrySucceeded( options?: LROsCustomHeaderPutAsyncRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -77,7 +81,11 @@ export class LROsCustomHeader { async put201CreatingSucceeded200( options?: LROsCustomHeaderPut201CreatingSucceeded200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -107,7 +115,11 @@ export class LROsCustomHeader { async post202Retry200( options?: LROsCustomHeaderPost202Retry200OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -138,7 +150,11 @@ export class LROsCustomHeader { async postAsyncRetrySucceeded( options?: LROsCustomHeaderPostAsyncRetrySucceededOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -158,6 +174,18 @@ export class LROsCustomHeader { sendOperation }); } + + private getOperationOptions( + options: TOptions | undefined, + finalStateVia?: string + ): coreHttp.RequestOptionsBase { + const operationOptions: coreHttp.OperationOptions = options || {}; + operationOptions.requestOptions = { + ...operationOptions.requestOptions, + shouldDeserialize: shouldDeserializeLRO(finalStateVia) + }; + return coreHttp.operationOptionsToRequestOptionsBase(operationOptions); + } } // Operation Specifications @@ -171,6 +199,18 @@ const putAsyncRetrySucceededOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LROsCustomHeaderPutAsyncRetrySucceededHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsCustomHeaderPutAsyncRetrySucceededHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsCustomHeaderPutAsyncRetrySucceededHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LROsCustomHeaderPutAsyncRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -186,6 +226,15 @@ const put201CreatingSucceeded200OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -197,9 +246,18 @@ const post202Retry200OperationSpec: coreHttp.OperationSpec = { path: "/lro/customheader/post/202/retry/200", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LROsCustomHeaderPost202Retry200Headers + }, + 201: { + headersMapper: Mappers.LROsCustomHeaderPost202Retry200Headers + }, 202: { headersMapper: Mappers.LROsCustomHeaderPost202Retry200Headers }, + 204: { + headersMapper: Mappers.LROsCustomHeaderPost202Retry200Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -213,9 +271,18 @@ const postAsyncRetrySucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/customheader/postasync/retry/succeeded", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LROsCustomHeaderPostAsyncRetrySucceededHeaders + }, + 201: { + headersMapper: Mappers.LROsCustomHeaderPostAsyncRetrySucceededHeaders + }, 202: { headersMapper: Mappers.LROsCustomHeaderPostAsyncRetrySucceededHeaders }, + 204: { + headersMapper: Mappers.LROsCustomHeaderPostAsyncRetrySucceededHeaders + }, default: { bodyMapper: Mappers.CloudError } diff --git a/test/integration/generated/lro/src/operations/lrosaDs.ts b/test/integration/generated/lro/src/operations/lrosaDs.ts index 7af0b6d105..92b94a7537 100644 --- a/test/integration/generated/lro/src/operations/lrosaDs.ts +++ b/test/integration/generated/lro/src/operations/lrosaDs.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { LROClient } from "../lROClient"; -import { LROPoller } from "../lro/lroPoller"; +import { LROPoller, shouldDeserializeLRO } from "../lro"; import { LrosaDsPutNonRetry400OptionalParams, LrosaDsPutNonRetry400Response, @@ -78,7 +78,11 @@ export class LrosaDs { async putNonRetry400( options?: LrosaDsPutNonRetry400OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -107,7 +111,11 @@ export class LrosaDs { async putNonRetry201Creating400( options?: LrosaDsPutNonRetry201Creating400OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -136,7 +144,11 @@ export class LrosaDs { async putNonRetry201Creating400InvalidJson( options?: LrosaDsPutNonRetry201Creating400InvalidJsonOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -165,7 +177,11 @@ export class LrosaDs { async putAsyncRelativeRetry400( options?: LrosaDsPutAsyncRelativeRetry400OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -193,7 +209,11 @@ export class LrosaDs { async deleteNonRetry400( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -221,7 +241,11 @@ export class LrosaDs { async delete202NonRetry400( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -250,7 +274,11 @@ export class LrosaDs { async deleteAsyncRelativeRetry400( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -278,7 +306,11 @@ export class LrosaDs { async postNonRetry400( options?: LrosaDsPostNonRetry400OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -306,7 +338,11 @@ export class LrosaDs { async post202NonRetry400( options?: LrosaDsPost202NonRetry400OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -335,7 +371,11 @@ export class LrosaDs { async postAsyncRelativeRetry400( options?: LrosaDsPostAsyncRelativeRetry400OptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -363,7 +403,11 @@ export class LrosaDs { async putError201NoProvisioningStatePayload( options?: LrosaDsPutError201NoProvisioningStatePayloadOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -393,7 +437,11 @@ export class LrosaDs { async putAsyncRelativeRetryNoStatus( options?: LrosaDsPutAsyncRelativeRetryNoStatusOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -423,7 +471,11 @@ export class LrosaDs { async putAsyncRelativeRetryNoStatusPayload( options?: LrosaDsPutAsyncRelativeRetryNoStatusPayloadOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -451,7 +503,11 @@ export class LrosaDs { async delete204Succeeded( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -480,7 +536,11 @@ export class LrosaDs { async deleteAsyncRelativeRetryNoStatus( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -508,7 +568,11 @@ export class LrosaDs { async post202NoLocation( options?: LrosaDsPost202NoLocationOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -538,7 +602,11 @@ export class LrosaDs { async postAsyncRelativeRetryNoPayload( options?: LrosaDsPostAsyncRelativeRetryNoPayloadOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -567,7 +635,11 @@ export class LrosaDs { async put200InvalidJson( options?: LrosaDsPut200InvalidJsonOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -596,7 +668,11 @@ export class LrosaDs { async putAsyncRelativeRetryInvalidHeader( options?: LrosaDsPutAsyncRelativeRetryInvalidHeaderOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -628,7 +704,11 @@ export class LrosaDs { ): Promise< LROPoller > { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -657,7 +737,11 @@ export class LrosaDs { async delete202RetryInvalidHeader( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -686,7 +770,11 @@ export class LrosaDs { async deleteAsyncRelativeRetryInvalidHeader( options?: coreHttp.OperationOptions ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -717,7 +805,11 @@ export class LrosaDs { ): Promise< LROPoller > { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -746,7 +838,11 @@ export class LrosaDs { async post202RetryInvalidHeader( options?: LrosaDsPost202RetryInvalidHeaderOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -776,7 +872,11 @@ export class LrosaDs { async postAsyncRelativeRetryInvalidHeader( options?: LrosaDsPostAsyncRelativeRetryInvalidHeaderOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -808,7 +908,11 @@ export class LrosaDs { ): Promise< LROPoller > { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -828,6 +932,18 @@ export class LrosaDs { sendOperation }); } + + private getOperationOptions( + options: TOptions | undefined, + finalStateVia?: string + ): coreHttp.RequestOptionsBase { + const operationOptions: coreHttp.OperationOptions = options || {}; + operationOptions.requestOptions = { + ...operationOptions.requestOptions, + shouldDeserialize: shouldDeserializeLRO(finalStateVia) + }; + return coreHttp.operationOptionsToRequestOptionsBase(operationOptions); + } } // Operation Specifications @@ -839,6 +955,15 @@ const putNonRetry400OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -852,6 +977,15 @@ const putNonRetry201Creating400OperationSpec: coreHttp.OperationSpec = { responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -865,6 +999,15 @@ const putNonRetry201Creating400InvalidJsonOperationSpec: coreHttp.OperationSpec responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -880,6 +1023,18 @@ const putAsyncRelativeRetry400OperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LrosaDsPutAsyncRelativeRetry400Headers }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetry400Headers + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetry400Headers + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -893,9 +1048,18 @@ const deleteNonRetry400OperationSpec: coreHttp.OperationSpec = { path: "/lro/nonretryerror/delete/400", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LrosaDsDeleteNonRetry400Headers + }, + 201: { + headersMapper: Mappers.LrosaDsDeleteNonRetry400Headers + }, 202: { headersMapper: Mappers.LrosaDsDeleteNonRetry400Headers }, + 204: { + headersMapper: Mappers.LrosaDsDeleteNonRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -907,9 +1071,18 @@ const delete202NonRetry400OperationSpec: coreHttp.OperationSpec = { path: "/lro/nonretryerror/delete/202/retry/400", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LrosaDsDelete202NonRetry400Headers + }, + 201: { + headersMapper: Mappers.LrosaDsDelete202NonRetry400Headers + }, 202: { headersMapper: Mappers.LrosaDsDelete202NonRetry400Headers }, + 204: { + headersMapper: Mappers.LrosaDsDelete202NonRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -921,9 +1094,18 @@ const deleteAsyncRelativeRetry400OperationSpec: coreHttp.OperationSpec = { path: "/lro/nonretryerror/deleteasync/retry/400", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetry400Headers + }, + 201: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetry400Headers + }, 202: { headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetry400Headers }, + 204: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -935,9 +1117,18 @@ const postNonRetry400OperationSpec: coreHttp.OperationSpec = { path: "/lro/nonretryerror/post/400", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPostNonRetry400Headers + }, + 201: { + headersMapper: Mappers.LrosaDsPostNonRetry400Headers + }, 202: { headersMapper: Mappers.LrosaDsPostNonRetry400Headers }, + 204: { + headersMapper: Mappers.LrosaDsPostNonRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -951,9 +1142,18 @@ const post202NonRetry400OperationSpec: coreHttp.OperationSpec = { path: "/lro/nonretryerror/post/202/retry/400", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPost202NonRetry400Headers + }, + 201: { + headersMapper: Mappers.LrosaDsPost202NonRetry400Headers + }, 202: { headersMapper: Mappers.LrosaDsPost202NonRetry400Headers }, + 204: { + headersMapper: Mappers.LrosaDsPost202NonRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -967,9 +1167,18 @@ const postAsyncRelativeRetry400OperationSpec: coreHttp.OperationSpec = { path: "/lro/nonretryerror/postasync/retry/400", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetry400Headers + }, + 201: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetry400Headers + }, 202: { headersMapper: Mappers.LrosaDsPostAsyncRelativeRetry400Headers }, + 204: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetry400Headers + }, default: { bodyMapper: Mappers.CloudError } @@ -985,6 +1194,15 @@ const putError201NoProvisioningStatePayloadOperationSpec: coreHttp.OperationSpec responses: { 200: { bodyMapper: Mappers.Product + }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, + 204: { + bodyMapper: Mappers.Product } }, requestBody: Parameters.product, @@ -1000,6 +1218,18 @@ const putAsyncRelativeRetryNoStatusOperationSpec: coreHttp.OperationSpec = { bodyMapper: Mappers.Product, headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1017,6 +1247,18 @@ const putAsyncRelativeRetryNoStatusPayloadOperationSpec: coreHttp.OperationSpec bodyMapper: Mappers.Product, headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusPayloadHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusPayloadHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusPayloadHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryNoStatusPayloadHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1030,6 +1272,9 @@ const delete204SucceededOperationSpec: coreHttp.OperationSpec = { path: "/lro/error/delete/204/nolocation", httpMethod: "DELETE", responses: { + 200: {}, + 201: {}, + 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError @@ -1042,9 +1287,18 @@ const deleteAsyncRelativeRetryNoStatusOperationSpec: coreHttp.OperationSpec = { path: "/lro/error/deleteasync/retry/nostatus", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryNoStatusHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryNoStatusHeaders + }, 202: { headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryNoStatusHeaders }, + 204: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryNoStatusHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1056,9 +1310,18 @@ const post202NoLocationOperationSpec: coreHttp.OperationSpec = { path: "/lro/error/post/202/nolocation", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPost202NoLocationHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsPost202NoLocationHeaders + }, 202: { headersMapper: Mappers.LrosaDsPost202NoLocationHeaders }, + 204: { + headersMapper: Mappers.LrosaDsPost202NoLocationHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1072,9 +1335,18 @@ const postAsyncRelativeRetryNoPayloadOperationSpec: coreHttp.OperationSpec = { path: "/lro/error/postasync/retry/nopayload", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryNoPayloadHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryNoPayloadHeaders + }, 202: { headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryNoPayloadHeaders }, + 204: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryNoPayloadHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1091,6 +1363,12 @@ const put200InvalidJsonOperationSpec: coreHttp.OperationSpec = { 200: { bodyMapper: Mappers.Product }, + 201: { + bodyMapper: Mappers.Product + }, + 202: { + bodyMapper: Mappers.Product + }, 204: {} }, requestBody: Parameters.product, @@ -1106,6 +1384,18 @@ const putAsyncRelativeRetryInvalidHeaderOperationSpec: coreHttp.OperationSpec = bodyMapper: Mappers.Product, headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryInvalidHeaderHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryInvalidHeaderHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryInvalidHeaderHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryInvalidHeaderHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1124,6 +1414,21 @@ const putAsyncRelativeRetryInvalidJsonPollingOperationSpec: coreHttp.OperationSp headersMapper: Mappers.LrosaDsPutAsyncRelativeRetryInvalidJsonPollingHeaders }, + 201: { + bodyMapper: Mappers.Product, + headersMapper: + Mappers.LrosaDsPutAsyncRelativeRetryInvalidJsonPollingHeaders + }, + 202: { + bodyMapper: Mappers.Product, + headersMapper: + Mappers.LrosaDsPutAsyncRelativeRetryInvalidJsonPollingHeaders + }, + 204: { + bodyMapper: Mappers.Product, + headersMapper: + Mappers.LrosaDsPutAsyncRelativeRetryInvalidJsonPollingHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1137,9 +1442,18 @@ const delete202RetryInvalidHeaderOperationSpec: coreHttp.OperationSpec = { path: "/lro/error/delete/202/retry/invalidheader", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LrosaDsDelete202RetryInvalidHeaderHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsDelete202RetryInvalidHeaderHeaders + }, 202: { headersMapper: Mappers.LrosaDsDelete202RetryInvalidHeaderHeaders }, + 204: { + headersMapper: Mappers.LrosaDsDelete202RetryInvalidHeaderHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1151,9 +1465,18 @@ const deleteAsyncRelativeRetryInvalidHeaderOperationSpec: coreHttp.OperationSpec path: "/lro/error/deleteasync/retry/invalidheader", httpMethod: "DELETE", responses: { + 200: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidHeaderHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidHeaderHeaders + }, 202: { headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidHeaderHeaders }, + 204: { + headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidHeaderHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1165,10 +1488,22 @@ const deleteAsyncRelativeRetryInvalidJsonPollingOperationSpec: coreHttp.Operatio path: "/lro/error/deleteasync/retry/invalidjsonpolling", httpMethod: "DELETE", responses: { + 200: { + headersMapper: + Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingHeaders + }, + 201: { + headersMapper: + Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingHeaders + }, 202: { headersMapper: Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingHeaders }, + 204: { + headersMapper: + Mappers.LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1180,9 +1515,18 @@ const post202RetryInvalidHeaderOperationSpec: coreHttp.OperationSpec = { path: "/lro/error/post/202/retry/invalidheader", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPost202RetryInvalidHeaderHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsPost202RetryInvalidHeaderHeaders + }, 202: { headersMapper: Mappers.LrosaDsPost202RetryInvalidHeaderHeaders }, + 204: { + headersMapper: Mappers.LrosaDsPost202RetryInvalidHeaderHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1196,9 +1540,18 @@ const postAsyncRelativeRetryInvalidHeaderOperationSpec: coreHttp.OperationSpec = path: "/lro/error/postasync/retry/invalidheader", httpMethod: "POST", responses: { + 200: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryInvalidHeaderHeaders + }, + 201: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryInvalidHeaderHeaders + }, 202: { headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryInvalidHeaderHeaders }, + 204: { + headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryInvalidHeaderHeaders + }, default: { bodyMapper: Mappers.CloudError } @@ -1212,10 +1565,22 @@ const postAsyncRelativeRetryInvalidJsonPollingOperationSpec: coreHttp.OperationS path: "/lro/error/postasync/retry/invalidjsonpolling", httpMethod: "POST", responses: { + 200: { + headersMapper: + Mappers.LrosaDsPostAsyncRelativeRetryInvalidJsonPollingHeaders + }, + 201: { + headersMapper: + Mappers.LrosaDsPostAsyncRelativeRetryInvalidJsonPollingHeaders + }, 202: { headersMapper: Mappers.LrosaDsPostAsyncRelativeRetryInvalidJsonPollingHeaders }, + 204: { + headersMapper: + Mappers.LrosaDsPostAsyncRelativeRetryInvalidJsonPollingHeaders + }, default: { bodyMapper: Mappers.CloudError } diff --git a/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts b/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts index dc08fe9f61..f4704ee903 100644 --- a/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts +++ b/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts @@ -44,8 +44,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { putArray( options?: ModelFlatteningClientPutArrayOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, putArrayOperationSpec ) as Promise; } @@ -57,8 +60,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { getArray( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getArrayOperationSpec ) as Promise; } @@ -71,8 +77,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { putWrappedArray( options?: ModelFlatteningClientPutWrappedArrayOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, putWrappedArrayOperationSpec ) as Promise; } @@ -85,8 +94,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { getWrappedArray( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getWrappedArrayOperationSpec ) as Promise; } @@ -98,8 +110,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { putDictionary( options?: ModelFlatteningClientPutDictionaryOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, putDictionaryOperationSpec ) as Promise; } @@ -111,8 +126,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { getDictionary( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getDictionaryOperationSpec ) as Promise; } @@ -124,8 +142,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { putResourceCollection( options?: ModelFlatteningClientPutResourceCollectionOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, putResourceCollectionOperationSpec ) as Promise; } @@ -137,8 +158,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { getResourceCollection( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getResourceCollectionOperationSpec ) as Promise; } @@ -150,8 +174,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { putSimpleProduct( options?: ModelFlatteningClientPutSimpleProductOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, putSimpleProductOperationSpec ) as Promise; } @@ -163,8 +190,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { postFlattenedSimpleProduct( options?: ModelFlatteningClientPostFlattenedSimpleProductOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, postFlattenedSimpleProductOperationSpec ) as Promise; } @@ -178,8 +208,11 @@ class ModelFlatteningClient extends ModelFlatteningClientContext { flattenParameterGroup: FlattenParameterGroup, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { flattenParameterGroup, options }, + { flattenParameterGroup, options: operationOptions }, putSimpleProductWithGroupingOperationSpec ) as Promise; } diff --git a/test/integration/generated/noMappers/src/noMappersClient.ts b/test/integration/generated/noMappers/src/noMappersClient.ts index c785520f13..a24af88dbf 100644 --- a/test/integration/generated/noMappers/src/noMappersClient.ts +++ b/test/integration/generated/noMappers/src/noMappersClient.ts @@ -28,8 +28,11 @@ class NoMappersClient extends NoMappersClientContext { apiV1ValueGet( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, apiV1ValueGetOperationSpec ) as Promise; } diff --git a/test/integration/generated/paging/src/lro/azureAsyncOperationStrategy.ts b/test/integration/generated/paging/src/lro/azureAsyncOperationStrategy.ts new file mode 100644 index 0000000000..ecdc300c1f --- /dev/null +++ b/test/integration/generated/paging/src/lro/azureAsyncOperationStrategy.ts @@ -0,0 +1,197 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + LROStrategy, + BaseResult, + LROOperationStep, + LROResponseInfo, + FinalStateVia +} from "./models"; +import { OperationSpec, OperationArguments } from "@azure/core-http"; +import { terminalStates } from "./constants"; +import { SendOperationFn } from "."; + +export function createAzureAsyncOperationStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + finalStateVia?: FinalStateVia +): LROStrategy { + const lroData = initialOperation.result._lroData; + if (!lroData) { + throw new Error( + "Expected lroData to be defined for Azure-AsyncOperation strategy" + ); + } + + let currentOperation = initialOperation; + let lastKnownPollingUrl = + lroData.azureAsyncOperation || lroData.operationLocation; + + return { + isTerminal: () => { + const currentResult = currentOperation.result._lroData; + + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (currentOperation === initialOperation) { + // Azure-AsyncOperations don't need to check for terminal state + // on originalOperation result, always need to poll + return false; + } + + const { status = "succeeded" } = currentResult; + return terminalStates.includes(status.toLowerCase()); + }, + sendFinalRequest: async () => { + if (!initialOperation.result._lroData) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (!currentOperation.result._lroData) { + throw new Error("Expected lroData to determine terminal status"); + } + + const initialOperationResult = initialOperation.result._lroData; + const currentOperationResult = currentOperation.result._lroData; + + if ( + !shouldPerformFinalGet(initialOperationResult, currentOperationResult) + ) { + return currentOperation; + } + + if (initialOperationResult.requestMethod === "PUT") { + currentOperation = await sendFinalGet( + initialOperation, + sendOperationFn + ); + + return currentOperation; + } + + if (initialOperationResult.location) { + switch (finalStateVia) { + case "original-uri": + currentOperation = await sendFinalGet( + initialOperation, + sendOperationFn + ); + return currentOperation; + + case "azure-async-operation": + return currentOperation; + case "location": + default: + const location = + initialOperationResult.location || + currentOperationResult.location; + + if (!location) { + throw new Error("Couldn't determine final GET URL from location"); + } + + return await sendFinalGet( + initialOperation, + sendOperationFn, + location + ); + } + } + + // All other cases return the last operation + return currentOperation; + }, + poll: async () => { + if (!lastKnownPollingUrl) { + throw new Error("Unable to determine polling url"); + } + + const pollingArgs = currentOperation.args; + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = currentOperation.spec; + const pollingSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET", + path: lastKnownPollingUrl + }; + + const result = await sendOperationFn(pollingArgs, pollingSpec); + + // Update latest polling url + lastKnownPollingUrl = + result._lroData?.azureAsyncOperation || + result._lroData?.operationLocation || + lastKnownPollingUrl; + + // Update lastOperation result + currentOperation = { + args: pollingArgs, + spec: pollingSpec, + result + }; + + return currentOperation; + } + }; +} + +function shouldPerformFinalGet( + initialResult: LROResponseInfo, + currentResult: LROResponseInfo +) { + const { status } = currentResult; + const { requestMethod: initialRequestMethod, location } = initialResult; + if (status && status.toLowerCase() !== "succeeded") { + return false; + } + + if (initialRequestMethod === "DELETE") { + return false; + } + + if (initialRequestMethod !== "PUT" && !location) { + return false; + } + + return true; +} + +async function sendFinalGet( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + path?: string +): Promise> { + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = initialOperation.spec; + const finalGetSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET" + }; + + // Send final GET request to the Original URL + const spec = { + ...finalGetSpec, + ...(path && { path }) + }; + + let operationArgs: OperationArguments = initialOperation.args; + if (operationArgs.options) { + operationArgs.options.shouldDeserialize = true; + } + + const finalResult = await sendOperationFn(initialOperation.args, spec); + + return { + args: initialOperation.args, + spec, + result: finalResult + }; +} diff --git a/test/integration/generated/paging/src/lro/bodyPollingStrategy.ts b/test/integration/generated/paging/src/lro/bodyPollingStrategy.ts index fd2c4e83ae..5ffd51e5ea 100644 --- a/test/integration/generated/paging/src/lro/bodyPollingStrategy.ts +++ b/test/integration/generated/paging/src/lro/bodyPollingStrategy.ts @@ -6,49 +6,62 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { LROStrategy, BaseResult, LROOperationState } from "./models"; +import { + LROStrategy, + BaseResult, + LROOperationStep, + LROResponseInfo +} from "./models"; import { OperationSpec } from "@azure/core-http"; - -const terminalStates = ["succeeded", "failed", "canceled", "cancelled"]; +import { terminalStates } from "./constants"; +import { SendOperationFn } from "./lroPoller"; /** * Creates a polling strategy based on BodyPolling which uses the provisioning state * from the result to determine the current operation state */ -export function createBodyPollingStrategy({ - lastOperation: operation, - sendOperation -}: LROOperationState): LROStrategy { - let lastOperation = { ...operation }; +export function createBodyPollingStrategy( + initialOperation: LROOperationStep, + sendOperation: SendOperationFn +): LROStrategy { + if (!initialOperation.result._lroData) { + throw new Error("Expected lroData to be defined for BodyPolling strategy"); + } + + let currentOperation = initialOperation; + return { isTerminal: () => { + const currentResult = currentOperation.result._lroData; + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + const { provisioningState = "succeeded" } = currentResult; // If provisioning state is missing, default to Success - const provisioningState = ( - lastOperation.result.provisioningState || - lastOperation.result.properties?.provisioningState || - "succeeded" - ).toLowerCase(); - return terminalStates.includes(provisioningState); + return terminalStates.includes(provisioningState.toLowerCase()); }, sendFinalRequest: () => { // BodyPolling doesn't require a final get so return the lastOperation - return Promise.resolve(lastOperation); + return Promise.resolve(currentOperation); }, poll: async () => { // When doing BodyPolling, we need to poll to the original url with a // GET http method + const { requestBody, ...restSpec } = initialOperation.spec; const pollingSpec: OperationSpec = { - ...lastOperation.spec, + // Make sure we don't send any body to the get request + ...restSpec, httpMethod: "GET" }; // Execute the polling operation - const result = await sendOperation(lastOperation.args, pollingSpec); - - // Update lastOperation result - lastOperation.result = result; - return lastOperation; + initialOperation.result = await sendOperation( + initialOperation.args, + pollingSpec + ); + return initialOperation; } }; } diff --git a/test/integration/generated/paging/src/lro/constants.ts b/test/integration/generated/paging/src/lro/constants.ts new file mode 100644 index 0000000000..fa0ee2d994 --- /dev/null +++ b/test/integration/generated/paging/src/lro/constants.ts @@ -0,0 +1,9 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export const terminalStates = ["succeeded", "failed", "canceled", "cancelled"]; diff --git a/test/integration/generated/paging/src/lro/index.ts b/test/integration/generated/paging/src/lro/index.ts new file mode 100644 index 0000000000..f605ce7ee3 --- /dev/null +++ b/test/integration/generated/paging/src/lro/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { shouldDeserializeLRO } from "./requestUtils"; +export { createBodyPollingStrategy } from "./bodyPollingStrategy"; +export { terminalStates } from "./constants"; +export { lroPolicy } from "./lroPolicy"; +export { LROPoller, LROPollerOptions, SendOperationFn } from "./lroPoller"; +export { + LROResponseInfo, + BaseResult, + LROOperationStep, + LROOperationState, + LROStrategy, + LROOperation +} from "./models"; +export { makeOperation } from "./operation"; +export * from "./locationStrategy"; diff --git a/test/integration/generated/paging/src/lro/locationStrategy.ts b/test/integration/generated/paging/src/lro/locationStrategy.ts new file mode 100644 index 0000000000..1a5c8d462e --- /dev/null +++ b/test/integration/generated/paging/src/lro/locationStrategy.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { BaseResult, LROOperationStep, LROStrategy } from "./models"; +import { SendOperationFn } from "./lroPoller"; +import { OperationSpec } from "@azure/core-http"; + +export function createLocationStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn +): LROStrategy { + const lroData = initialOperation.result._lroData; + if (!lroData) { + throw new Error( + "Expected lroData to be defined for Azure-AsyncOperation strategy" + ); + } + + let currentOperation = initialOperation; + let lastKnownPollingUrl = lroData.location; + + return { + isTerminal: () => { + const currentResult = currentOperation.result._lroData; + if (!currentResult) { + throw new Error("Expected lroData to determine terminal status"); + } + + if (currentOperation === initialOperation) { + return false; + } + + if (currentResult.statusCode === 202) { + return false; + } + + return true; + }, + sendFinalRequest: () => Promise.resolve(currentOperation), + poll: async () => { + if (!lastKnownPollingUrl) { + throw new Error("Unable to determine polling url"); + } + + const pollingArgs = currentOperation.args; + // Make sure we don't send any body to the get request + const { requestBody, ...restSpec } = currentOperation.spec; + const pollingSpec: OperationSpec = { + ...restSpec, + httpMethod: "GET", + path: lastKnownPollingUrl + }; + + const result = await sendOperationFn(pollingArgs, pollingSpec); + + // Update latest polling url + lastKnownPollingUrl = result._lroData?.location || lastKnownPollingUrl; + + // Update lastOperation result + currentOperation = { + args: pollingArgs, + spec: pollingSpec, + result + }; + + return currentOperation; + } + }; +} diff --git a/test/integration/generated/paging/src/lro/lroPolicy.ts b/test/integration/generated/paging/src/lro/lroPolicy.ts new file mode 100644 index 0000000000..3606072efd --- /dev/null +++ b/test/integration/generated/paging/src/lro/lroPolicy.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + RequestPolicy, + RequestPolicyOptions, + BaseRequestPolicy, + HttpOperationResponse, + WebResource +} from "@azure/core-http"; +import { getLROData } from "./requestUtils"; +import { isEmpty } from "lodash"; + +export function lroPolicy() { + return { + create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => { + return new LROPolicy(nextPolicy, options); + } + }; +} + +class LROPolicy extends BaseRequestPolicy { + constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) { + super(nextPolicy, options); + } + + public async sendRequest( + webResource: WebResource + ): Promise { + let result = await this._nextPolicy.sendRequest(webResource); + + if (webResource.shouldDeserialize !== undefined) { + const _lroData = getLROData(result); + result.parsedBody = { ...result.parsedBody, _lroData }; + } + + return result; + } +} diff --git a/test/integration/generated/paging/src/lro/lroPoller.ts b/test/integration/generated/paging/src/lro/lroPoller.ts index 65207bf4a3..226c4f8861 100644 --- a/test/integration/generated/paging/src/lro/lroPoller.ts +++ b/test/integration/generated/paging/src/lro/lroPoller.ts @@ -6,10 +6,24 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { Poller } from "@azure/core-lro"; -import { OperationSpec, OperationArguments, delay } from "@azure/core-http"; -import { BaseResult, LROOperationState } from "./models"; +import { Poller, PollOperationState } from "@azure/core-lro"; +import { + OperationSpec, + OperationArguments, + delay, + RestError +} from "@azure/core-http"; +import { + BaseResult, + LROOperationState, + LROOperationStep, + FinalStateVia +} from "./models"; import { makeOperation } from "./operation"; +import { createBodyPollingStrategy } from "./bodyPollingStrategy"; +import { createAzureAsyncOperationStrategy } from "./azureAsyncOperationStrategy"; +import { createLocationStrategy } from "./locationStrategy"; +import { createPassthroughStrategy } from "./passthroughStrategy"; export type SendOperationFn = ( args: OperationArguments, @@ -37,6 +51,10 @@ export interface LROPollerOptions { * Function to execute an operation based on an operation spec and arguments */ sendOperation: SendOperationFn; + /** + * Optional information on where to poll. When not defined it defaults to "Location" + */ + finalStateVia?: FinalStateVia; } export class LROPoller extends Poller< @@ -50,17 +68,27 @@ export class LROPoller extends Poller< initialOperationResult, initialOperationSpec, sendOperation, + finalStateVia, intervalInMs = 2000 }: LROPollerOptions) { + const initialOperation = { + args: initialOperationArguments, + spec: initialOperationSpec, + result: initialOperationResult + }; + + const pollingStrategy = getPollingStrategy( + initialOperation, + sendOperation, + finalStateVia + ); + const state: LROOperationState = { // Initial operation will become the last operation - lastOperation: { - args: initialOperationArguments, - spec: initialOperationSpec, - result: initialOperationResult - }, - sendOperation, - result: initialOperationResult + initialOperation, + lastOperation: initialOperation, + pollingStrategy, + finalStateVia }; const operation = makeOperation(state); @@ -76,3 +104,51 @@ export class LROPoller extends Poller< return delay(this.intervalInMs); } } + +/** + * This function determines which strategy to use based on the response from + * the last operation executed, this last operation can be an initial operation + * or a polling operation. The 3 possible strategies are described below: + * + * A) Azure-AsyncOperation or Operation-Location + * B) Location + * C) BodyPolling (provisioningState) + * - This strategy is used when: + * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location + * - Last operation method is PUT + */ +function getPollingStrategy( + initialOperation: LROOperationStep, + sendOperationFn: SendOperationFn, + finalStateVia?: FinalStateVia +) { + const lroData = initialOperation.result._lroData; + + if (!lroData) { + const error = new RestError( + "Service response doesn't include the required LRO data to continue polling" + ); + error.statusCode = initialOperation.result._response.status; + error.response = initialOperation.result._response; + throw error; + } + + if (lroData.azureAsyncOperation || lroData.operationLocation) { + return createAzureAsyncOperationStrategy( + initialOperation, + sendOperationFn, + finalStateVia + ); + } + + if (lroData.location) { + return createLocationStrategy(initialOperation, sendOperationFn); + } + + if (["PUT", "PATCH"].includes(lroData.requestMethod || "")) { + return createBodyPollingStrategy(initialOperation, sendOperationFn); + } + + // Default strategy is just a passthrough returning the initial operation + return createPassthroughStrategy(initialOperation); +} diff --git a/test/integration/generated/paging/src/lro/models.ts b/test/integration/generated/paging/src/lro/models.ts index a4d90168ca..a90afc5b41 100644 --- a/test/integration/generated/paging/src/lro/models.ts +++ b/test/integration/generated/paging/src/lro/models.ts @@ -9,21 +9,32 @@ import { OperationArguments, OperationSpec, - RestResponse + RestResponse, + HttpMethods } from "@azure/core-http"; import { PollOperationState, PollOperation } from "@azure/core-lro"; -export interface BaseResult extends RestResponse { - location?: string; - operationLocation?: string; +export type FinalStateVia = + | "azure-async-operation" + | "location" + | "original-uri"; + +export interface LROResponseInfo { + requestMethod: HttpMethods; + statusCode: number; + isInitialRequest?: boolean; azureAsyncOperation?: string; + operationLocation?: string; + location?: string; provisioningState?: string; - properties?: { - provisioningState?: string; - }; + status?: string; +} + +export interface BaseResult extends RestResponse { + _lroData?: LROResponseInfo; } -export interface LastOperation { +export interface LROOperationStep { args: OperationArguments; spec: OperationSpec; result: TResult; @@ -31,17 +42,16 @@ export interface LastOperation { export interface LROOperationState extends PollOperationState { - lastOperation: LastOperation; - sendOperation: ( - args: OperationArguments, - spec: OperationSpec - ) => Promise; + lastOperation: LROOperationStep; + initialOperation: LROOperationStep; + pollingStrategy: LROStrategy; + finalStateVia?: FinalStateVia; } export interface LROStrategy { isTerminal: () => boolean; - sendFinalRequest: () => Promise>; - poll: () => Promise>; + sendFinalRequest: () => Promise>; + poll: () => Promise>; } export type LROOperation = PollOperation< diff --git a/test/integration/generated/paging/src/lro/operation.ts b/test/integration/generated/paging/src/lro/operation.ts index 05478cbbd1..a7e6f4bd54 100644 --- a/test/integration/generated/paging/src/lro/operation.ts +++ b/test/integration/generated/paging/src/lro/operation.ts @@ -6,12 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { - BaseResult, - LROOperationState, - LROOperation, - LROStrategy -} from "./models"; +import { BaseResult, LROOperationState, LROOperation } from "./models"; import { createBodyPollingStrategy } from "./bodyPollingStrategy"; /** @@ -50,19 +45,27 @@ async function update( ): Promise> { const state = { ...this.state }; - // Get strategy from last operation - const lroStrategy: LROStrategy = getStrategyFromResult(state); + const { sendFinalRequest, poll, isTerminal } = state.pollingStrategy; + const currentResponse = state.lastOperation; + const currentLroData = currentResponse.result._lroData; + + if (!currentLroData) { + throw new Error( + "Expected lroData to be defined for updating LRO operation" + ); + } + + if (state.result) { + state.isCompleted = true; + return makeOperation(state); + } // Check if last result is terminal - if (lroStrategy.isTerminal()) { - const result = await lroStrategy.sendFinalRequest(); - state.lastOperation = result; + if (isTerminal()) { + state.lastOperation = await sendFinalRequest(); state.result = state.lastOperation.result; - state.isCompleted = true; } else { - const result = await lroStrategy.poll(); - state.lastOperation = result; - state.result = state.lastOperation.result; + state.lastOperation = await poll(); } // Return operation @@ -78,37 +81,3 @@ async function cancel( ): Promise> { return makeOperation({ ...this.state, isCancelled: true }); } - -/** - * This function determines which strategy to use based on the response from - * the last operation executed, this last operation can be an initial operation - * or a polling operation. The 3 possible strategies are described below: - * - * A) Azure-AsyncOperation or Operation-Location - * B) Location - * C) BodyPolling (provisioningState) - * - This strategy is used when: - * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location - * - Last operation method is PUT - */ -function getStrategyFromResult( - state: LROOperationState -): LROStrategy { - const { - lastOperation: { spec, result } - } = state; - - if (result.azureAsyncOperation) { - throw new Error("Azure-AsyncOperation strategy is not yet implemented"); - } - - if (result.location) { - throw new Error("Location strategy is not yet implemented"); - } - - if (["PUT", "PATCH"].includes(spec.httpMethod)) { - return createBodyPollingStrategy(state); - } - - throw new Error("Unknown Long Running Operation strategy"); -} diff --git a/test/integration/generated/paging/src/lro/passthroughStrategy.ts b/test/integration/generated/paging/src/lro/passthroughStrategy.ts new file mode 100644 index 0000000000..689e851485 --- /dev/null +++ b/test/integration/generated/paging/src/lro/passthroughStrategy.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { LROStrategy, BaseResult, LROOperationStep } from "./models"; +import { SendOperationFn } from "./lroPoller"; + +/** + * Creates a polling strategy based on BodyPolling which uses the provisioning state + * from the result to determine the current operation state + */ +export function createPassthroughStrategy( + initialOperation: LROOperationStep +): LROStrategy { + return { + isTerminal: () => { + return true; + }, + sendFinalRequest: () => { + // BodyPolling doesn't require a final get so return the lastOperation + return Promise.resolve(initialOperation); + }, + poll: async () => { + throw new Error("Passthrough strategy should never poll"); + } + }; +} diff --git a/test/integration/generated/paging/src/lro/requestUtils.ts b/test/integration/generated/paging/src/lro/requestUtils.ts new file mode 100644 index 0000000000..e9af4cde5e --- /dev/null +++ b/test/integration/generated/paging/src/lro/requestUtils.ts @@ -0,0 +1,117 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { HttpOperationResponse } from "@azure/core-http"; +import { terminalStates } from "./constants"; +import { LROResponseInfo } from "./models"; + +/** + * We need to selectively deserialize our responses, only deserializing if we + * are in a final LRO response, not deserializing any polling non-terminal responses + */ +export function shouldDeserializeLRO(finalStateVia?: string) { + let initialOperationInfo: LROResponseInfo | undefined; + let isInitialRequest = true; + + return (response: HttpOperationResponse) => { + if (response.status < 200 || response.status >= 300) { + return true; + } + + if (!initialOperationInfo) { + initialOperationInfo = getLROData(response); + } else { + isInitialRequest = false; + } + + if ( + initialOperationInfo.azureAsyncOperation || + initialOperationInfo.operationLocation + ) { + return ( + !isInitialRequest && + isAsyncOperationFinalResponse( + response, + initialOperationInfo, + finalStateVia + ) + ); + } + + if (initialOperationInfo.location) { + return isLocationFinalResponse(response); + } + + if (initialOperationInfo.requestMethod === "PUT") { + return isBodyPollingFinalResponse(response); + } + + return true; + }; +} + +function isAsyncOperationFinalResponse( + response: HttpOperationResponse, + initialOperationInfo: LROResponseInfo, + finalStateVia?: string +): boolean { + const status: string = response.parsedBody?.status || "Succeeded"; + if (!terminalStates.includes(status.toLowerCase())) { + return false; + } + + if (initialOperationInfo.requestMethod === "DELETE") { + return true; + } + + if ( + initialOperationInfo.requestMethod === "PUT" && + finalStateVia && + finalStateVia.toLowerCase() === "azure-asyncoperation" + ) { + return true; + } + + if ( + initialOperationInfo.requestMethod !== "PUT" && + !initialOperationInfo.location + ) { + return true; + } + + return false; +} + +function isLocationFinalResponse(response: HttpOperationResponse): boolean { + return response.status !== 202; +} + +function isBodyPollingFinalResponse(response: HttpOperationResponse): boolean { + const provisioningState: string = + response.parsedBody?.properties?.provisioningState || "Succeeded"; + + if (terminalStates.includes(provisioningState.toLowerCase())) { + return true; + } + + return false; +} + +export function getLROData(result: HttpOperationResponse): LROResponseInfo { + const statusCode = result.status; + const { status, properties } = result.parsedBody || {}; + return { + statusCode, + azureAsyncOperation: result.headers.get("azure-asyncoperation"), + operationLocation: result.headers.get("operation-location"), + location: result.headers.get("location"), + requestMethod: result.request.method, + status, + provisioningState: properties?.provisioningState + }; +} diff --git a/test/integration/generated/paging/src/operations/paging.ts b/test/integration/generated/paging/src/operations/paging.ts index ffa23d5841..401d578ae1 100644 --- a/test/integration/generated/paging/src/operations/paging.ts +++ b/test/integration/generated/paging/src/operations/paging.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { PagingClient } from "../pagingClient"; -import { LROPoller } from "../lro/lroPoller"; +import { LROPoller, shouldDeserializeLRO } from "../lro"; import { PagingGetNoItemNamePagesResponse, PagingGetNullNextLinkNamePagesResponse, @@ -72,8 +72,11 @@ export class Paging { getNoItemNamePages( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNoItemNamePagesOperationSpec ) as Promise; } @@ -85,8 +88,11 @@ export class Paging { getNullNextLinkNamePages( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNullNextLinkNamePagesOperationSpec ) as Promise; } @@ -98,8 +104,11 @@ export class Paging { getSinglePages( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getSinglePagesOperationSpec ) as Promise; } @@ -111,8 +120,11 @@ export class Paging { getMultiplePages( options?: PagingGetMultiplePagesOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMultiplePagesOperationSpec ) as Promise; } @@ -124,8 +136,11 @@ export class Paging { getOdataMultiplePages( options?: PagingGetOdataMultiplePagesOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getOdataMultiplePagesOperationSpec ) as Promise; } @@ -139,8 +154,11 @@ export class Paging { pagingGetMultiplePagesWithOffsetOptions: PagingGetMultiplePagesWithOffsetOptions, options?: PagingGetMultiplePagesWithOffsetOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { pagingGetMultiplePagesWithOffsetOptions, options }, + { pagingGetMultiplePagesWithOffsetOptions, options: operationOptions }, getMultiplePagesWithOffsetOperationSpec ) as Promise; } @@ -153,8 +171,11 @@ export class Paging { getMultiplePagesRetryFirst( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMultiplePagesRetryFirstOperationSpec ) as Promise; } @@ -167,8 +188,11 @@ export class Paging { getMultiplePagesRetrySecond( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMultiplePagesRetrySecondOperationSpec ) as Promise; } @@ -180,8 +204,11 @@ export class Paging { getSinglePagesFailure( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getSinglePagesFailureOperationSpec ) as Promise; } @@ -193,8 +220,11 @@ export class Paging { getMultiplePagesFailure( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMultiplePagesFailureOperationSpec ) as Promise; } @@ -206,8 +236,11 @@ export class Paging { getMultiplePagesFailureUri( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getMultiplePagesFailureUriOperationSpec ) as Promise; } @@ -223,8 +256,11 @@ export class Paging { tenant: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { apiVersion, tenant, options }, + { apiVersion, tenant, options: operationOptions }, getMultiplePagesFragmentNextLinkOperationSpec ) as Promise; } @@ -238,8 +274,11 @@ export class Paging { customParameterGroup: CustomParameterGroup, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { customParameterGroup, options }, + { customParameterGroup, options: operationOptions }, getMultiplePagesFragmentWithGroupingNextLinkOperationSpec ) as Promise; } @@ -251,7 +290,11 @@ export class Paging { async getMultiplePagesLRO( options?: PagingGetMultiplePagesLROOptionalParams ): Promise> { - const args = { options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { options: operationOptions }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -285,8 +328,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { apiVersion, tenant, nextLink, options }, + { apiVersion, tenant, nextLink, options: operationOptions }, nextFragmentOperationSpec ) as Promise; } @@ -302,8 +348,11 @@ export class Paging { customParameterGroup: CustomParameterGroup, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, customParameterGroup, options }, + { nextLink, customParameterGroup, options: operationOptions }, nextFragmentWithGroupingOperationSpec ) as Promise; } @@ -317,8 +366,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getNoItemNamePagesNextOperationSpec ) as Promise; } @@ -332,8 +384,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getSinglePagesNextOperationSpec ) as Promise; } @@ -347,8 +402,11 @@ export class Paging { nextLink: string, options?: PagingGetMultiplePagesNextOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getMultiplePagesNextOperationSpec ) as Promise; } @@ -362,8 +420,11 @@ export class Paging { nextLink: string, options?: PagingGetOdataMultiplePagesNextOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getOdataMultiplePagesNextOperationSpec ) as Promise; } @@ -380,8 +441,15 @@ export class Paging { pagingGetMultiplePagesWithOffsetOptions: PagingGetMultiplePagesWithOffsetOptions, options?: PagingGetMultiplePagesWithOffsetNextOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, pagingGetMultiplePagesWithOffsetOptions, options }, + { + nextLink, + pagingGetMultiplePagesWithOffsetOptions, + options: operationOptions + }, getMultiplePagesWithOffsetNextOperationSpec ) as Promise; } @@ -396,8 +464,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getMultiplePagesRetryFirstNextOperationSpec ) as Promise; } @@ -412,8 +483,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getMultiplePagesRetrySecondNextOperationSpec ) as Promise; } @@ -427,8 +501,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getSinglePagesFailureNextOperationSpec ) as Promise; } @@ -443,8 +520,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getMultiplePagesFailureNextOperationSpec ) as Promise; } @@ -459,8 +539,11 @@ export class Paging { nextLink: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { nextLink, options }, + { nextLink, options: operationOptions }, getMultiplePagesFailureUriNextOperationSpec ) as Promise; } @@ -474,7 +557,14 @@ export class Paging { nextLink: string, options?: PagingGetMultiplePagesLRONextOptionalParams ): Promise> { - const args = { nextLink, options }; + const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions( + options + ); + + const args: coreHttp.OperationArguments = { + nextLink, + options: operationOptions + }; const sendOperation = ( args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec @@ -494,6 +584,18 @@ export class Paging { sendOperation }); } + + private getOperationOptions( + options: TOptions | undefined, + finalStateVia?: string + ): coreHttp.RequestOptionsBase { + const operationOptions: coreHttp.OperationOptions = options || {}; + operationOptions.requestOptions = { + ...operationOptions.requestOptions, + shouldDeserialize: shouldDeserializeLRO(finalStateVia) + }; + return coreHttp.operationOptionsToRequestOptionsBase(operationOptions); + } } // Operation Specifications @@ -676,9 +778,18 @@ const getMultiplePagesLROOperationSpec: coreHttp.OperationSpec = { path: "/paging/multiple/lro", httpMethod: "POST", responses: { + 200: { + bodyMapper: Mappers.ProductResult + }, + 201: { + bodyMapper: Mappers.ProductResult + }, 202: { bodyMapper: Mappers.ProductResult }, + 204: { + bodyMapper: Mappers.ProductResult + }, default: {} }, urlParameters: [Parameters.$host], @@ -854,9 +965,18 @@ const getMultiplePagesLRONextOperationSpec: coreHttp.OperationSpec = { path: "{nextLink}", httpMethod: "POST", responses: { + 200: { + bodyMapper: Mappers.ProductResult + }, + 201: { + bodyMapper: Mappers.ProductResult + }, 202: { bodyMapper: Mappers.ProductResult }, + 204: { + bodyMapper: Mappers.ProductResult + }, default: {} }, urlParameters: [Parameters.$host, Parameters.nextLink11], diff --git a/test/integration/generated/paging/src/pagingClientContext.ts b/test/integration/generated/paging/src/pagingClientContext.ts index c98583c876..f70b8fca44 100644 --- a/test/integration/generated/paging/src/pagingClientContext.ts +++ b/test/integration/generated/paging/src/pagingClientContext.ts @@ -8,6 +8,7 @@ import * as coreHttp from "@azure/core-http"; import * as Models from "./models"; +import { lroPolicy } from "./lro"; const packageName = "paging-service"; const packageVersion = "1.0.0-preview1"; @@ -30,6 +31,14 @@ export class PagingClientContext extends coreHttp.ServiceClient { options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } + const defaultPipelines = coreHttp.createPipelineFromOptions(options) + .requestPolicyFactories as coreHttp.RequestPolicyFactory[]; + + options = { + ...options, + requestPolicyFactories: [lroPolicy(), ...defaultPipelines] + }; + super(undefined, options); this.requestContentType = "application/json; charset=utf-8"; diff --git a/test/integration/generated/report/src/reportClient.ts b/test/integration/generated/report/src/reportClient.ts index 873d207a21..84e4d56ab2 100644 --- a/test/integration/generated/report/src/reportClient.ts +++ b/test/integration/generated/report/src/reportClient.ts @@ -34,8 +34,11 @@ class ReportClient extends ReportClientContext { getReport( options?: ReportClientGetReportOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getReportOperationSpec ) as Promise; } @@ -47,8 +50,11 @@ class ReportClient extends ReportClientContext { getOptionalReport( options?: ReportClientGetOptionalReportOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.sendOperationRequest( - { options }, + { options: operationOptions }, getOptionalReportOperationSpec ) as Promise; } diff --git a/test/integration/generated/url/src/operations/pathItems.ts b/test/integration/generated/url/src/operations/pathItems.ts index e25efa9c9d..a71349335b 100644 --- a/test/integration/generated/url/src/operations/pathItems.ts +++ b/test/integration/generated/url/src/operations/pathItems.ts @@ -44,8 +44,11 @@ export class PathItems { localStringPath: string, options?: PathItemsGetAllWithValuesOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { pathItemStringPath, localStringPath, options }, + { pathItemStringPath, localStringPath, options: operationOptions }, getAllWithValuesOperationSpec ) as Promise; } @@ -63,8 +66,11 @@ export class PathItems { localStringPath: string, options?: PathItemsGetGlobalQueryNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { pathItemStringPath, localStringPath, options }, + { pathItemStringPath, localStringPath, options: operationOptions }, getGlobalQueryNullOperationSpec ) as Promise; } @@ -82,8 +88,11 @@ export class PathItems { localStringPath: string, options?: PathItemsGetGlobalAndLocalQueryNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { pathItemStringPath, localStringPath, options }, + { pathItemStringPath, localStringPath, options: operationOptions }, getGlobalAndLocalQueryNullOperationSpec ) as Promise; } @@ -101,8 +110,11 @@ export class PathItems { localStringPath: string, options?: PathItemsGetLocalPathItemQueryNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { pathItemStringPath, localStringPath, options }, + { pathItemStringPath, localStringPath, options: operationOptions }, getLocalPathItemQueryNullOperationSpec ) as Promise; } diff --git a/test/integration/generated/url/src/operations/paths.ts b/test/integration/generated/url/src/operations/paths.ts index 51af0d659a..2fb893367a 100644 --- a/test/integration/generated/url/src/operations/paths.ts +++ b/test/integration/generated/url/src/operations/paths.ts @@ -33,8 +33,11 @@ export class Paths { getBooleanTrue( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanTrueOperationSpec ) as Promise; } @@ -46,8 +49,11 @@ export class Paths { getBooleanFalse( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanFalseOperationSpec ) as Promise; } @@ -59,8 +65,11 @@ export class Paths { getIntOneMillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntOneMillionOperationSpec ) as Promise; } @@ -72,8 +81,11 @@ export class Paths { getIntNegativeOneMillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntNegativeOneMillionOperationSpec ) as Promise; } @@ -85,8 +97,11 @@ export class Paths { getTenBillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getTenBillionOperationSpec ) as Promise; } @@ -98,8 +113,11 @@ export class Paths { getNegativeTenBillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNegativeTenBillionOperationSpec ) as Promise; } @@ -111,8 +129,11 @@ export class Paths { floatScientificPositive( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, floatScientificPositiveOperationSpec ) as Promise; } @@ -124,8 +145,11 @@ export class Paths { floatScientificNegative( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, floatScientificNegativeOperationSpec ) as Promise; } @@ -137,8 +161,11 @@ export class Paths { doubleDecimalPositive( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, doubleDecimalPositiveOperationSpec ) as Promise; } @@ -150,8 +177,11 @@ export class Paths { doubleDecimalNegative( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, doubleDecimalNegativeOperationSpec ) as Promise; } @@ -163,8 +193,11 @@ export class Paths { stringUnicode( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringUnicodeOperationSpec ) as Promise; } @@ -176,8 +209,11 @@ export class Paths { stringUrlEncoded( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringUrlEncodedOperationSpec ) as Promise; } @@ -189,8 +225,11 @@ export class Paths { stringUrlNonEncoded( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringUrlNonEncodedOperationSpec ) as Promise; } @@ -202,8 +241,11 @@ export class Paths { stringEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringEmptyOperationSpec ) as Promise; } @@ -217,8 +259,11 @@ export class Paths { stringPath: string, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { stringPath, options }, + { stringPath, options: operationOptions }, stringNullOperationSpec ) as Promise; } @@ -232,8 +277,11 @@ export class Paths { enumPath: UriColor, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { enumPath, options }, + { enumPath, options: operationOptions }, enumValidOperationSpec ) as Promise; } @@ -247,8 +295,11 @@ export class Paths { enumPath: UriColor, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { enumPath, options }, + { enumPath, options: operationOptions }, enumNullOperationSpec ) as Promise; } @@ -262,8 +313,11 @@ export class Paths { bytePath: Uint8Array, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { bytePath, options }, + { bytePath, options: operationOptions }, byteMultiByteOperationSpec ) as Promise; } @@ -275,8 +329,11 @@ export class Paths { byteEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, byteEmptyOperationSpec ) as Promise; } @@ -290,8 +347,11 @@ export class Paths { bytePath: Uint8Array, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { bytePath, options }, + { bytePath, options: operationOptions }, byteNullOperationSpec ) as Promise; } @@ -303,8 +363,11 @@ export class Paths { dateValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, dateValidOperationSpec ) as Promise; } @@ -319,8 +382,11 @@ export class Paths { datePath: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { datePath, options }, + { datePath, options: operationOptions }, dateNullOperationSpec ) as Promise; } @@ -332,8 +398,11 @@ export class Paths { dateTimeValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, dateTimeValidOperationSpec ) as Promise; } @@ -347,8 +416,11 @@ export class Paths { dateTimePath: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { dateTimePath, options }, + { dateTimePath, options: operationOptions }, dateTimeNullOperationSpec ) as Promise; } @@ -362,8 +434,11 @@ export class Paths { base64UrlPath: Uint8Array, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { base64UrlPath, options }, + { base64UrlPath, options: operationOptions }, base64UrlOperationSpec ) as Promise; } @@ -379,8 +454,11 @@ export class Paths { arrayPath: string[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { arrayPath, options }, + { arrayPath, options: operationOptions }, arrayCsvInPathOperationSpec ) as Promise; } @@ -394,8 +472,11 @@ export class Paths { unixTimeUrlPath: Date, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { unixTimeUrlPath, options }, + { unixTimeUrlPath, options: operationOptions }, unixTimeUrlOperationSpec ) as Promise; } diff --git a/test/integration/generated/url/src/operations/queries.ts b/test/integration/generated/url/src/operations/queries.ts index f2faf89b81..565f5a6f02 100644 --- a/test/integration/generated/url/src/operations/queries.ts +++ b/test/integration/generated/url/src/operations/queries.ts @@ -52,8 +52,11 @@ export class Queries { getBooleanTrue( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanTrueOperationSpec ) as Promise; } @@ -65,8 +68,11 @@ export class Queries { getBooleanFalse( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanFalseOperationSpec ) as Promise; } @@ -78,8 +84,11 @@ export class Queries { getBooleanNull( options?: QueriesGetBooleanNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getBooleanNullOperationSpec ) as Promise; } @@ -91,8 +100,11 @@ export class Queries { getIntOneMillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntOneMillionOperationSpec ) as Promise; } @@ -104,8 +116,11 @@ export class Queries { getIntNegativeOneMillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntNegativeOneMillionOperationSpec ) as Promise; } @@ -117,8 +132,11 @@ export class Queries { getIntNull( options?: QueriesGetIntNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getIntNullOperationSpec ) as Promise; } @@ -130,8 +148,11 @@ export class Queries { getTenBillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getTenBillionOperationSpec ) as Promise; } @@ -143,8 +164,11 @@ export class Queries { getNegativeTenBillion( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getNegativeTenBillionOperationSpec ) as Promise; } @@ -156,8 +180,11 @@ export class Queries { getLongNull( options?: QueriesGetLongNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getLongNullOperationSpec ) as Promise; } @@ -169,8 +196,11 @@ export class Queries { floatScientificPositive( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, floatScientificPositiveOperationSpec ) as Promise; } @@ -182,8 +212,11 @@ export class Queries { floatScientificNegative( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, floatScientificNegativeOperationSpec ) as Promise; } @@ -195,8 +228,11 @@ export class Queries { floatNull( options?: QueriesFloatNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, floatNullOperationSpec ) as Promise; } @@ -208,8 +244,11 @@ export class Queries { doubleDecimalPositive( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, doubleDecimalPositiveOperationSpec ) as Promise; } @@ -221,8 +260,11 @@ export class Queries { doubleDecimalNegative( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, doubleDecimalNegativeOperationSpec ) as Promise; } @@ -234,8 +276,11 @@ export class Queries { doubleNull( options?: QueriesDoubleNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, doubleNullOperationSpec ) as Promise; } @@ -247,8 +292,11 @@ export class Queries { stringUnicode( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringUnicodeOperationSpec ) as Promise; } @@ -260,8 +308,11 @@ export class Queries { stringUrlEncoded( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringUrlEncodedOperationSpec ) as Promise; } @@ -273,8 +324,11 @@ export class Queries { stringEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringEmptyOperationSpec ) as Promise; } @@ -286,8 +340,11 @@ export class Queries { stringNull( options?: QueriesStringNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, stringNullOperationSpec ) as Promise; } @@ -299,8 +356,11 @@ export class Queries { enumValid( options?: QueriesEnumValidOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, enumValidOperationSpec ) as Promise; } @@ -312,8 +372,11 @@ export class Queries { enumNull( options?: QueriesEnumNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, enumNullOperationSpec ) as Promise; } @@ -325,8 +388,11 @@ export class Queries { byteMultiByte( options?: QueriesByteMultiByteOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, byteMultiByteOperationSpec ) as Promise; } @@ -338,8 +404,11 @@ export class Queries { byteEmpty( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, byteEmptyOperationSpec ) as Promise; } @@ -351,8 +420,11 @@ export class Queries { byteNull( options?: QueriesByteNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, byteNullOperationSpec ) as Promise; } @@ -364,8 +436,11 @@ export class Queries { dateValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, dateValidOperationSpec ) as Promise; } @@ -377,8 +452,11 @@ export class Queries { dateNull( options?: QueriesDateNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, dateNullOperationSpec ) as Promise; } @@ -390,8 +468,11 @@ export class Queries { dateTimeValid( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, dateTimeValidOperationSpec ) as Promise; } @@ -403,8 +484,11 @@ export class Queries { dateTimeNull( options?: QueriesDateTimeNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, dateTimeNullOperationSpec ) as Promise; } @@ -417,8 +501,11 @@ export class Queries { arrayStringCsvValid( options?: QueriesArrayStringCsvValidOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, arrayStringCsvValidOperationSpec ) as Promise; } @@ -430,8 +517,11 @@ export class Queries { arrayStringCsvNull( options?: QueriesArrayStringCsvNullOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, arrayStringCsvNullOperationSpec ) as Promise; } @@ -443,8 +533,11 @@ export class Queries { arrayStringCsvEmpty( options?: QueriesArrayStringCsvEmptyOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, arrayStringCsvEmptyOperationSpec ) as Promise; } @@ -457,8 +550,11 @@ export class Queries { arrayStringSsvValid( options?: QueriesArrayStringSsvValidOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, arrayStringSsvValidOperationSpec ) as Promise; } @@ -471,8 +567,11 @@ export class Queries { arrayStringTsvValid( options?: QueriesArrayStringTsvValidOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, arrayStringTsvValidOperationSpec ) as Promise; } @@ -485,8 +584,11 @@ export class Queries { arrayStringPipesValid( options?: QueriesArrayStringPipesValidOptionalParams ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, arrayStringPipesValidOperationSpec ) as Promise; } diff --git a/test/integration/generated/xmlservice/src/operations/xml.ts b/test/integration/generated/xmlservice/src/operations/xml.ts index 1e6f428d19..9fc62347a5 100644 --- a/test/integration/generated/xmlservice/src/operations/xml.ts +++ b/test/integration/generated/xmlservice/src/operations/xml.ts @@ -58,8 +58,11 @@ export class Xml { getComplexTypeRefNoMeta( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexTypeRefNoMetaOperationSpec ) as Promise; } @@ -73,8 +76,11 @@ export class Xml { model: RootWithRefAndNoMeta, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { model, options }, + { model, options: operationOptions }, putComplexTypeRefNoMetaOperationSpec ) as Promise; } @@ -86,8 +92,11 @@ export class Xml { getComplexTypeRefWithMeta( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getComplexTypeRefWithMetaOperationSpec ) as Promise; } @@ -101,8 +110,11 @@ export class Xml { model: RootWithRefAndMeta, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { model, options }, + { model, options: operationOptions }, putComplexTypeRefWithMetaOperationSpec ) as Promise; } @@ -114,8 +126,11 @@ export class Xml { getSimple( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getSimpleOperationSpec ) as Promise; } @@ -129,8 +144,11 @@ export class Xml { slideshow: Slideshow, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { slideshow, options }, + { slideshow, options: operationOptions }, putSimpleOperationSpec ) as Promise; } @@ -142,8 +160,11 @@ export class Xml { getWrappedLists( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getWrappedListsOperationSpec ) as Promise; } @@ -157,8 +178,11 @@ export class Xml { wrappedLists: AppleBarrel, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { wrappedLists, options }, + { wrappedLists, options: operationOptions }, putWrappedListsOperationSpec ) as Promise; } @@ -170,8 +194,11 @@ export class Xml { getHeaders( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getHeadersOperationSpec ) as Promise; } @@ -183,8 +210,11 @@ export class Xml { getEmptyList( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyListOperationSpec ) as Promise; } @@ -198,8 +228,11 @@ export class Xml { slideshow: Slideshow, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { slideshow, options }, + { slideshow, options: operationOptions }, putEmptyListOperationSpec ) as Promise; } @@ -211,8 +244,11 @@ export class Xml { getEmptyWrappedLists( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyWrappedListsOperationSpec ) as Promise; } @@ -226,8 +262,11 @@ export class Xml { appleBarrel: AppleBarrel, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { appleBarrel, options }, + { appleBarrel, options: operationOptions }, putEmptyWrappedListsOperationSpec ) as Promise; } @@ -239,8 +278,11 @@ export class Xml { getRootList( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getRootListOperationSpec ) as Promise; } @@ -254,8 +296,11 @@ export class Xml { bananas: Banana[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { bananas, options }, + { bananas, options: operationOptions }, putRootListOperationSpec ) as Promise; } @@ -267,8 +312,11 @@ export class Xml { getRootListSingleItem( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getRootListSingleItemOperationSpec ) as Promise; } @@ -282,8 +330,11 @@ export class Xml { bananas: Banana[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { bananas, options }, + { bananas, options: operationOptions }, putRootListSingleItemOperationSpec ) as Promise; } @@ -295,8 +346,11 @@ export class Xml { getEmptyRootList( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyRootListOperationSpec ) as Promise; } @@ -310,8 +364,11 @@ export class Xml { bananas: Banana[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { bananas, options }, + { bananas, options: operationOptions }, putEmptyRootListOperationSpec ) as Promise; } @@ -323,8 +380,11 @@ export class Xml { getEmptyChildElement( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getEmptyChildElementOperationSpec ) as Promise; } @@ -338,8 +398,11 @@ export class Xml { banana: Banana, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { banana, options }, + { banana, options: operationOptions }, putEmptyChildElementOperationSpec ) as Promise; } @@ -351,8 +414,11 @@ export class Xml { listContainers( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, listContainersOperationSpec ) as Promise; } @@ -364,8 +430,11 @@ export class Xml { getServiceProperties( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getServicePropertiesOperationSpec ) as Promise; } @@ -379,8 +448,11 @@ export class Xml { properties: StorageServiceProperties, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { properties, options }, + { properties, options: operationOptions }, putServicePropertiesOperationSpec ) as Promise; } @@ -390,8 +462,11 @@ export class Xml { * @param options The options parameters. */ getAcls(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, getAclsOperationSpec ) as Promise; } @@ -405,8 +480,11 @@ export class Xml { properties: SignedIdentifier[], options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { properties, options }, + { properties, options: operationOptions }, putAclsOperationSpec ) as Promise; } @@ -418,8 +496,11 @@ export class Xml { listBlobs( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, listBlobsOperationSpec ) as Promise; } @@ -434,8 +515,11 @@ export class Xml { properties: JsonInput, options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { properties, options }, + { properties, options: operationOptions }, jsonInputOperationSpec ) as Promise; } @@ -447,8 +531,11 @@ export class Xml { jsonOutput( options?: coreHttp.OperationOptions ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); return this.client.sendOperationRequest( - { options }, + { options: operationOptions }, jsonOutputOperationSpec ) as Promise; } diff --git a/test/integration/lro.spec.ts b/test/integration/lro.spec.ts index 3ab088b59f..8c21856f79 100644 --- a/test/integration/lro.spec.ts +++ b/test/integration/lro.spec.ts @@ -1,33 +1,759 @@ import { LROClient } from "./generated/lro/src/lROClient"; import { assert } from "chai"; +import { BaseResult } from "./generated/lro/src/lro"; +import { Product } from "./generated/lro/src/models"; +import { InternalPipelineOptions, OperationOptions } from "@azure/core-http"; -describe("LRO", () => { +describe("LROs", () => { let client: LROClient; beforeEach(() => { client = new LROClient(); }); - it("should handle initial response with terminal state through an Azure Resource", async () => { - const poller = await client.lROs.put200Succeeded(); + describe("BodyPolling Strategy", () => { + it("should handle initial response with terminal state through an Azure Resource", async () => { + const poller = await client.lROs.put200Succeeded(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.provisioningState, "Succeeded"); + }); + + it("should handle initial response with terminal state without provisioning State", async () => { + const poller = await client.lROs.put200SucceededNoState(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepEqual(result.id, "100"); + assert.deepEqual(result.name, "foo"); + }); + + it("should handle initial response creating followed by success through an Azure Resource", async () => { + const poller = await client.lROs.put201CreatingSucceeded200(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepEqual(result.provisioningState, "Succeeded"); + assert.deepEqual(result.id, "100"); + assert.deepEqual(result.name, "foo"); + }); + + it("should handle put200Acceptedcanceled200", async () => { + const poller = await client.lROs.put200Acceptedcanceled200(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepEqual(result.provisioningState, "Canceled"); + assert.deepEqual(result.id, "100"); + assert.deepEqual(result.name, "foo"); + }); + + it("should handle put200UpdatingSucceeded204", async () => { + const poller = await client.lROs.put200UpdatingSucceeded204(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepEqual(result.provisioningState, "Succeeded"); + assert.deepEqual(result.id, "100"); + assert.deepEqual(result.name, "foo"); + }); + + it("should handle put201CreatingFailed200", async () => { + const poller = await client.lROs.put201CreatingFailed200(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + assert.equal(result.provisioningState, "Failed"); + }); + }); + + describe("Location Strategy", () => { + it("should handle post202Retry200", async () => { + const poller = await client.lROs.post202Retry200(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle post202NoRetry204", async () => { + const poller = await client.lROs.post202NoRetry204(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 204); + }); + + it("should handle deleteNoHeaderInRetry", async () => { + const poller = await client.lROs.deleteNoHeaderInRetry(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 204); + }); + + it("should handle put202Retry200", async () => { + const poller = await client.lROs.put202Retry200(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepEqual(result._response.status, 200); + }); + + it("should handle putNoHeaderInRetry", async () => { + const poller = await client.lROs.putNoHeaderInRetry(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + assert.equal(result.provisioningState, "Succeeded"); + }); + + it("should handle putSubResource", async () => { + const poller = await client.lROs.putSubResource(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "100"); + assert.equal(result.provisioningState, "Succeeded"); + }); + + it("should handle putNonResource", async () => { + const poller = await client.lROs.putNonResource(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "100"); + assert.equal(result.name, "sku"); + }); + + it("should handle delete202Retry200", async () => { + const poller = await client.lROs.delete202Retry200(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle delete202NoRetry204", async () => { + const poller = await client.lROs.delete202NoRetry204(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 204); + }); + + it("should handle deleteProvisioning202Accepted200Succeeded", async () => { + const poller = await client.lROs.deleteProvisioning202Accepted200Succeeded(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle deleteProvisioning202DeletingFailed200", async () => { + const poller = await client.lROs.deleteProvisioning202DeletingFailed200(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.provisioningState, "Failed"); + }); + + it("should handle deleteProvisioning202Deletingcanceled200", async () => { + const poller = await client.lROs.deleteProvisioning202Deletingcanceled200(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.provisioningState, "Canceled"); + }); + }); + + describe("Passthrough strategy", () => { + it("should handle delete204Succeeded", async () => { + const poller = await client.lROs.delete204Succeeded(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 204); + }); + }); + + describe("Azure Async Operation Strategy", () => { + let product: Product; + beforeEach(() => { + product = { + location: "West US" + }; + }); + + it("should handle postDoubleHeadersFinalLocationGet", async () => { + const poller = await client.lROs.postDoubleHeadersFinalLocationGet(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + }); + + it("should handle postDoubleHeadersFinalAzureHeaderGet", async () => { + const poller = await client.lROs.postDoubleHeadersFinalAzureHeaderGet(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + assert.equal(result.id, "100"); + }); + + it("should handle post200WithPayload", async () => { + const poller = await client.lROs.post200WithPayload(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "1"); + assert.equal(result.name, "product"); + }); + + it("should handle postDoubleHeadersFinalAzureHeaderGetDefault", async () => { + const poller = await client.lROs.postDoubleHeadersFinalAzureHeaderGetDefault(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + assert.equal(result.id, "100"); + }); + + it("should handle deleteAsyncRetrySucceeded", async () => { + const poller = await client.lROs.deleteAsyncRetrySucceeded(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle deleteAsyncNoRetrySucceeded", async () => { + const poller = await client.lROs.deleteAsyncNoRetrySucceeded(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle deleteAsyncRetrycanceled", async () => { + const poller = await client.lROs.deleteAsyncRetrycanceled(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.equal(result._lroData?.status, "Canceled"); + }); + + it("should handle DeleteAsyncRetryFailed", async () => { + const poller = await client.lROs.deleteAsyncRetryFailed(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.equal(result._lroData?.status, "Failed"); + }); + + it("should handle putAsyncRetrySucceeded", async () => { + const poller = await client.lROs.putAsyncRetrySucceeded(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + assert.equal(result.provisioningState, "Succeeded"); + }); + + it("should handle putAsyncRetryFailed", async () => { + const poller = await client.lROs.putAsyncRetryFailed(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.equal(result._lroData?.status, "Failed"); + }); + + it("should handle putAsyncNonResource", async () => { + const poller = await client.lROs.putAsyncNonResource(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + await poller.poll(); + const result = await poller.pollUntilDone(); + assert.equal(result.name, "sku"); + assert.equal(result.id, "100"); + }); + + it("should handle putAsyncNoHeaderInRetry", async () => { + const poller = await client.lROs.putAsyncNoHeaderInRetry(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.name, "foo"); + assert.equal(result.id, "100"); + assert.deepEqual(result.provisioningState, "Succeeded"); + }); + + it("should handle putAsyncNoRetrySucceeded", async () => { + const poller = await client.lROs.putAsyncNoRetrySucceeded(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.name, "foo"); + assert.equal(result.id, "100"); + }); + + it("should handle putAsyncNoRetrycanceled", async () => { + const poller = await client.lROs.putAsyncNoRetrycanceled(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.equal(result._lroData?.status, "Canceled"); + }); + + it("should handle putAsyncSubResource", async () => { + const poller = await client.lROs.putAsyncSubResource(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.id, "100"); + assert.equal(result.provisioningState, "Succeeded"); + }); + + it("should handle deleteAsyncNoHeaderInRetry", async () => { + const poller = await client.lROs.deleteAsyncNoHeaderInRetry(); + // To avoid timing out, override the default delay function + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle postAsyncNoRetrySucceeded", async () => { + const poller = await client.lROs.postAsyncNoRetrySucceeded({ + product + }); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepInclude(result, { id: "100", name: "foo" }); + }); + + it("should handle postAsyncRetryFailed", async () => { + const poller = await client.lROs.postAsyncRetryFailed({ + product + }); + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.deepEqual(result.status, "Failed"); + }); + + it("should handle postAsyncRetrySucceeded", async () => { + const poller = await client.lROs.postAsyncRetrySucceeded({ + product + }); + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.deepInclude(result, { id: "100", name: "foo" }); + }); + + it("should handle postAsyncRetrycanceled", async () => { + const poller = await client.lROs.postAsyncRetrycanceled({ + product + }); + poller.delay = () => Promise.resolve(); + const result: BaseResult = await poller.pollUntilDone(); + assert.deepInclude(result._lroData?.status, "Canceled"); + }); + }); +}); + +describe("Custom Headers", () => { + let client: LROClient; + let options: OperationOptions; + + beforeEach(() => { + options = { + requestOptions: { + customHeaders: { + "x-ms-client-request-id": "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0" + } + } + }; + client = new LROClient(); + }); + + it("should handle putAsyncRetrySucceeded with customheaders ", async () => { + const poller = await client.lROsCustomHeader.putAsyncRetrySucceeded( + options + ); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.deepInclude(result.provisioningState, "Succeeded"); + assert.deepInclude(result.id, "100"); + assert.deepInclude(result.name, "foo"); + }); + + // TODO: Check why test server returns 202 to final get which is expected to be made + it.skip("should handle postAsyncRetrySucceeded with customheaders ", async () => { + const poller = await client.lROsCustomHeader.postAsyncRetrySucceeded( + options + ); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle put201CreatingSucceeded200 with customheaders ", async () => { + const poller = await client.lROsCustomHeader.put201CreatingSucceeded200( + options + ); + poller.delay = () => Promise.resolve(); const result = await poller.pollUntilDone(); assert.equal(result.provisioningState, "Succeeded"); + assert.equal(result.name, "foo"); + assert.equal(result.id, "100"); + }); + + it("should handle post202Retry200 with customheaders ", async () => { + const poller = await client.lROsCustomHeader.post202Retry200(options); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); +}); + +describe("LRO Sad scenarios", () => { + let client: LROClient; + + beforeEach(() => { + const pipelineOptions: InternalPipelineOptions = { + retryOptions: { + retryDelayInMs: 0 + } + }; + client = new LROClient(pipelineOptions); + }); + + it("should handle PutNonRetry400 ", async () => { + const poller = await client.lrosaDs.putNonRetry400(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 400); + }); + + it("should handle putNonRetry201Creating400 ", async () => { + const poller = await client.lrosaDs.putNonRetry201Creating400(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 400); + }); + + it("should throw with putNonRetry201Creating400InvalidJson ", async () => { + const poller = await client.lrosaDs.putNonRetry201Creating400InvalidJson(); + poller.delay = () => Promise.resolve(); + try { + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.code, "PARSE_ERROR"); + assert.equal(error.statusCode, 400); + } + }); + + it("should handle putAsyncRelativeRetry400 ", async () => { + const poller = await client.lrosaDs.putAsyncRelativeRetry400(); + poller.delay = () => Promise.resolve(); + try { + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } + }); + + it("should handle delete202NonRetry400 ", async () => { + const poller = await client.lrosaDs.delete202NonRetry400(); + poller.delay = () => Promise.resolve(); + try { + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } + }); + + it("should handle deleteNonRetry400 ", async () => { + try { + const poller = await client.lrosaDs.deleteNonRetry400(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } }); - it("should handle initial response with terminal state without provisioning State", async () => { - const poller = await client.lROs.put200SucceededNoState(); + it("should handle deleteAsyncRelativeRetry400 ", async () => { + const poller = await client.lrosaDs.deleteAsyncRelativeRetry400(); + poller.delay = () => Promise.resolve(); + + try { + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } + }); + + it("should handle postNonRetry400 ", async () => { + try { + const poller = await client.lrosaDs.postNonRetry400(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } + }); + + it("should handle post202NonRetry400 ", async () => { + const poller = await client.lrosaDs.post202NonRetry400(); + poller.delay = () => Promise.resolve(); + try { + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } + }); + + it("should handle postAsyncRelativeRetry400 ", async () => { + const poller = await client.lrosaDs.postAsyncRelativeRetry400(); + poller.delay = () => Promise.resolve(); + try { + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 400); + } + }); + + it("should handle PutError201NoProvisioningStatePayload ", async () => { + const poller = await client.lrosaDs.putError201NoProvisioningStatePayload(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + // Test server doesn't return a provisioningState so success is assumed as + // expected in this scenario + assert.equal(result._response.status, 201); + }); + + it("should handle putAsyncRelativeRetryNoStatusPayload ", async () => { + const poller = await client.lrosaDs.putAsyncRelativeRetryNoStatusPayload(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + // Test server doesn't return a provisioningState so success is assumed as + // expected in this scenario + assert.equal(result._response.status, 200); + }); + + it("should handle putAsyncRelativeRetryNoStatus ", async () => { + const poller = await client.lrosaDs.putAsyncRelativeRetryNoStatus(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + // Test server doesn't return a provisioningState so success is assumed as + // expected in this scenario + assert.equal(result._response.status, 200); + }); + + it("should handle delete204Succeeded ", async () => { + const poller = await client.lrosaDs.delete204Succeeded(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + // since no location or asyncoperation headers were returned + // just pass through + assert.equal(result._response.status, 204); + }); + + it("should handle deleteAsyncRelativeRetryNoStatus ", async () => { + const poller = await client.lrosaDs.deleteAsyncRelativeRetryNoStatus(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + // Test server doesn't return a status so success is assumed as + // expected in this scenario + assert.equal(result._response.status, 200); + }); + + it("should handle post202NoLocation ", async () => { + const poller = await client.lrosaDs.post202NoLocation(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + // since no location or asyncoperation headers were returned + // just pass through + assert.equal(result._response.status, 202); + }); + + it("should handle postAsyncRelativeRetryNoPayload ", async () => { + const poller = await client.lrosaDs.postAsyncRelativeRetryNoPayload(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should handle put200InvalidJson ", async () => { + try { + const poller = await client.lrosaDs.put200InvalidJson(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.code, "PARSE_ERROR"); + } + }); + + it("should handle putAsyncRelativeRetryInvalidHeader ", async () => { + try { + const poller = await client.lrosaDs.putAsyncRelativeRetryInvalidHeader(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 404); + } + }); + + it("should handle putAsyncRelativeRetryInvalidJsonPolling ", async () => { + try { + const poller = await client.lrosaDs.putAsyncRelativeRetryInvalidJsonPolling(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.code, "PARSE_ERROR"); + } + }); + + it("should handle delete202RetryInvalidHeader ", async () => { + try { + const poller = await client.lrosaDs.delete202RetryInvalidHeader(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 404); + } + }); + + it("should handle deleteAsyncRelativeRetryInvalidHeader ", async () => { + try { + const poller = await client.lrosaDs.deleteAsyncRelativeRetryInvalidHeader(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 404); + } + }); + + it("should handle DeleteAsyncRelativeRetryInvalidJsonPolling ", async () => { + try { + const poller = await client.lrosaDs.deleteAsyncRelativeRetryInvalidJsonPolling(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.code, "PARSE_ERROR"); + } + }); + + it("should handle post202RetryInvalidHeader ", async () => { + try { + const poller = await client.lrosaDs.post202RetryInvalidHeader(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 404); + } + }); + + it("should handle postAsyncRelativeRetryInvalidHeader ", async () => { + try { + const poller = await client.lrosaDs.postAsyncRelativeRetryInvalidHeader(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.statusCode, 404); + } + }); + + it("should handle postAsyncRelativeRetryInvalidJsonPolling ", async () => { + try { + const poller = await client.lrosaDs.postAsyncRelativeRetryInvalidJsonPolling(); + poller.delay = () => Promise.resolve(); + await poller.pollUntilDone(); + assert.fail("Scenario should throw"); + } catch (error) { + assert.equal(error.code, "PARSE_ERROR"); + } + }); +}); + +describe("LRORetries", () => { + let client: LROClient; + + beforeEach(() => { + const pipelineOptions: InternalPipelineOptions = { + retryOptions: { + retryDelayInMs: 0 + } + }; + client = new LROClient(pipelineOptions); + }); + + it("should retry put201CreatingSucceeded200", async () => { + const poller = await client.lRORetrys.put201CreatingSucceeded200(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.provisioningState, "Succeeded"); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + }); + + it("should retry putAsyncRelativeRetrySucceeded", async () => { + const poller = await client.lRORetrys.putAsyncRelativeRetrySucceeded(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.provisioningState, "Succeeded"); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + }); + + it("should retry deleteProvisioning202Accepted200Succeeded", async () => { + const poller = await client.lRORetrys.deleteProvisioning202Accepted200Succeeded(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result.provisioningState, "Succeeded"); + assert.equal(result.id, "100"); + assert.equal(result.name, "foo"); + }); + + it("should retry delete202Retry200", async () => { + const poller = await client.lRORetrys.delete202Retry200(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should retry deleteAsyncRelativeRetrySucceeded", async () => { + const poller = await client.lRORetrys.deleteAsyncRelativeRetrySucceeded(); + poller.delay = () => Promise.resolve(); + const result = await poller.pollUntilDone(); + assert.equal(result._response.status, 200); + }); + + it("should retry post202Retry200", async () => { + const poller = await client.lRORetrys.post202Retry200(); + poller.delay = () => Promise.resolve(); const result = await poller.pollUntilDone(); - assert.deepEqual(result.id, "100"); - assert.deepEqual(result.name, "foo"); + assert.equal(result._response.status, 200); }); - it("should handle initial response creating followed by success through an Azure Resource", async () => { - const poller = await client.lROs.put201CreatingSucceeded200(); - // To avoid timing out, override the default delay function + it("should retry postAsyncRelativeRetrySucceeded", async () => { + const poller = await client.lRORetrys.postAsyncRelativeRetrySucceeded(); poller.delay = () => Promise.resolve(); const result = await poller.pollUntilDone(); - assert.deepEqual(result.provisioningState, "Succeeded"); - assert.deepEqual(result.id, "100"); - assert.deepEqual(result.name, "foo"); + assert.equal(result._response.status, 200); }); }); diff --git a/test/unit/lro/azureAsyncOperationStrategy.spec.ts b/test/unit/lro/azureAsyncOperationStrategy.spec.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/unit/lro/bodyPollingStrategy.spec.ts b/test/unit/lro/bodyPollingStrategy.spec.ts index 3078c5c5f8..38e704265c 100644 --- a/test/unit/lro/bodyPollingStrategy.spec.ts +++ b/test/unit/lro/bodyPollingStrategy.spec.ts @@ -1,74 +1,82 @@ import { assert } from "chai"; import { createBodyPollingStrategy } from "../../../src/lro/bodyPollingStrategy"; -import { LastOperation } from "../../../src/lro/models"; +import { LROOperationStep, LROResponseInfo } from "../../../src/lro/models"; import { OperationSpec, OperationArguments } from "@azure/core-http"; +import { SendOperationFn } from "../../../src/lro/lroPoller"; describe("BodyPollingStrategy", () => { const mockSendOperation: any = () => Promise.resolve({}); - let lastOperation: LastOperation; + let lastOperation: LROOperationStep; + let lroData: LROResponseInfo; beforeEach(() => { + lroData = { + requestMethod: "PUT", + statusCode: 200 + }; lastOperation = { args: {}, spec: { httpMethod: "PUT", path: "originalPath" } as any, - result: {} + result: { _lroData: lroData } }; }); describe("isTerminal", () => { it("should default to Succeeded and be terminal when no provisioning state was returned", () => { - const pollingStrategy = createBodyPollingStrategy({ + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: mockSendOperation - }); + mockSendOperation + ); assert.isTrue(pollingStrategy.isTerminal()); }); it("should be terminal state when provisioningState is succeeded", () => { - lastOperation.result = { provisioningState: "Succeeded" }; - const pollingStrategy = createBodyPollingStrategy({ - lastOperation, - sendOperation: mockSendOperation - }); - - assert.isTrue(pollingStrategy.isTerminal()); - }); - - it("should be terminal state when properties.provisioningState is succeeded", () => { - lastOperation.result = { properties: { provisioningState: "Succeeded" } }; - const pollingStrategy = createBodyPollingStrategy({ + lroData = { ...lroData, provisioningState: "Succeeded" }; + lastOperation.result = { + _lroData: lroData + }; + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: mockSendOperation - }); + mockSendOperation + ); assert.isTrue(pollingStrategy.isTerminal()); }); it("should be terminal state when provisioningState is Failed", () => { - lastOperation.result = { provisioningState: "Failed" }; - const pollingStrategy = createBodyPollingStrategy({ + lroData = { ...lroData, provisioningState: "Failed" }; + lastOperation.result = { + _lroData: lroData + }; + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: mockSendOperation - }); + mockSendOperation + ); assert.isTrue(pollingStrategy.isTerminal()); }); it("should be terminal state when provisioningState is Canceled", () => { - lastOperation.result = { provisioningState: "Canceled" }; - const pollingStrategy = createBodyPollingStrategy({ + lroData = { ...lroData, provisioningState: "Canceled" }; + lastOperation.result = { + _lroData: lroData + }; + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: mockSendOperation - }); + mockSendOperation + ); assert.isTrue(pollingStrategy.isTerminal()); }); it("should be not terminal state when provisioningState is not a terminal one", () => { - lastOperation.result = { provisioningState: "InProgress" }; - const pollingStrategy = createBodyPollingStrategy({ + lroData = { ...lroData, provisioningState: "InProgress" }; + lastOperation.result = { + _lroData: lroData + }; + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: mockSendOperation - }); + mockSendOperation + ); assert.isFalse(pollingStrategy.isTerminal()); }); @@ -76,10 +84,10 @@ describe("BodyPollingStrategy", () => { describe("sendFinalRequest", () => { it("should return last operation", async () => { - const pollingStrategy = createBodyPollingStrategy({ + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: mockSendOperation - }); + mockSendOperation + ); const result = await pollingStrategy.sendFinalRequest(); assert.deepEqual(result, lastOperation); @@ -90,14 +98,20 @@ describe("BodyPollingStrategy", () => { it("should return polling operation with GET http method", async () => { let pollingMethod = ""; let pollingUrl = ""; - const pollingStrategy = createBodyPollingStrategy({ + + const sendOperation: SendOperationFn = ( + _args: OperationArguments, + spec: OperationSpec + ) => { + pollingMethod = spec.httpMethod; + pollingUrl = spec.path || ""; + return "" as any; + }; + + const pollingStrategy = createBodyPollingStrategy( lastOperation, - sendOperation: (args: OperationArguments, spec: OperationSpec) => { - pollingMethod = spec.httpMethod; - pollingUrl = spec.path || ""; - return "" as any; - } - }); + sendOperation + ); await pollingStrategy.poll(); assert.equal(pollingMethod, "GET"); diff --git a/test/unit/lro/locationStrategy.spec.ts b/test/unit/lro/locationStrategy.spec.ts new file mode 100644 index 0000000000..1fa9f699b3 --- /dev/null +++ b/test/unit/lro/locationStrategy.spec.ts @@ -0,0 +1,97 @@ +import { + createLocationStrategy, + LROStrategy, + SendOperationFn, + LROOperationStep +} from "../.././../src/lro"; +import { assert } from "chai"; +describe("LocationStrategy", () => { + let locationStrategy: LROStrategy; + let dummyInitialOperation: LROOperationStep; + let dummySendOperationFn: SendOperationFn; + + beforeEach(async () => { + dummyInitialOperation = { + args: {} as any, + spec: {} as any, + result: { _lroData: { location: "dummyUrl" } } as any + }; + dummySendOperationFn = () => { + return {} as any; + }; + + locationStrategy = createLocationStrategy( + dummyInitialOperation, + dummySendOperationFn + ); + await locationStrategy.poll(); + }); + + describe("isTerminal", () => { + it("should never be terminal before the first poll", async () => { + locationStrategy = createLocationStrategy( + dummyInitialOperation, + dummySendOperationFn + ); + + const isTerminal = locationStrategy.isTerminal(); + + assert.isFalse(isTerminal); + }); + it("should be terminal when status code is not 202", async () => { + locationStrategy = createLocationStrategy( + dummyInitialOperation, + (_args, _spec) => { + return Promise.resolve({ _lroData: { statusCode: 200 } }); + } + ); + + await locationStrategy.poll(); + const isTerminal = locationStrategy.isTerminal(); + + assert.isTrue(isTerminal); + }); + + it("should not be terminal when status code is 202", async () => { + locationStrategy = createLocationStrategy( + dummyInitialOperation, + (_args, _spec) => { + return Promise.resolve({ _lroData: { statusCode: 202 } }); + } + ); + + await locationStrategy.poll(); + const isTerminal = locationStrategy.isTerminal(); + + assert.isFalse(isTerminal); + }); + }); + + describe("sendFinalResponse", () => { + it("should always return the last operation", async () => { + locationStrategy = createLocationStrategy( + dummyInitialOperation, + dummySendOperationFn + ); + const result = await locationStrategy.sendFinalRequest(); + assert.equal(result, dummyInitialOperation); + }); + }); + + describe("Poll", () => { + it("should do a GET call to the URL in location header from last result", async () => { + const expectedUrl = "pollingURL"; + dummySendOperationFn = (_args, spec) => { + return Promise.resolve({ _lroData: { location: expectedUrl } }); + }; + locationStrategy = createLocationStrategy( + dummyInitialOperation, + dummySendOperationFn + ); + await locationStrategy.poll(); + const result = await locationStrategy.poll(); + + assert.equal(result.spec.path, expectedUrl); + }); + }); +});