diff --git a/.gitignore b/.gitignore index d8fc4026ea..0a96780ad9 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ vitest.config.ts.timestamp* .tshy **/test/**/metadata.json .turbo/ +submodules +.gitmodules \ No newline at end of file diff --git a/RESEARCH_FINDINGS.md b/RESEARCH_FINDINGS.md new file mode 100644 index 0000000000..bd65336d3f --- /dev/null +++ b/RESEARCH_FINDINGS.md @@ -0,0 +1,493 @@ +# Research Findings: Headers in Operation Return Types + +## Problem Summary + +When an operation returns a model with header properties using TypeSpec syntax like: + +```typespec +model User { + name: string; + email: string; +} + +op getUser(): User & {@header requestId: string}; +``` + +The generated operation signature incorrectly returns only the model type: + +```typescript +Promise; +``` + +Instead of including both model and header properties: + +```typescript +Promise<{ name: string; email: string; requestId: string }>; +``` + +--- + +## Key File Locations + +### Primary Generation Files + +1. **[packages/typespec-ts/src/modular/helpers/operationHelpers.ts](packages/typespec-ts/src/modular/helpers/operationHelpers.ts)** + - Contains core logic for generating operation signatures and deserialization + - Functions: `getOperationFunction()`, `getDeserializePrivateFunction()`, `getResponseMapping()` + +2. **[packages/typespec-ts/src/modular/emitModels.ts](packages/typespec-ts/src/modular/emitModels.ts)** + - Handles emission of model types and header-only response interfaces + - Functions: `emitTypes()`, `emitHeaderOnlyResponseInterface()` + +3. **[packages/typespec-ts/src/modular/buildOperations.ts](packages/typespec-ts/src/modular/buildOperations.ts)** + - Builds operation files and calls the operation function generators + +### Test Case Reference + +- **[packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelInResponse.md](packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelInResponse.md)** + - Shows expected behavior: return type should be `Promise<{ name: string; email: string; requestId: string }>` + +--- + +## Current Code Patterns for Handling Headers + +### 1. Return Type Generation in `getOperationFunction()` (lines 562-720) + +**Current flow** (lines 598-618): + +```typescript +let returnType = { name: "", type: "void" }; +if (response.type) { + const type = response.type; + returnType = { + name: (type as any).name ?? "", + type: getTypeExpression(context, type!), // ← PROBLEM: Only returns model type + }; +} else if (hasHeaderOnlyResponse) { + const headerOnlyInterfaceName = generateHeaderOnlyResponseTypeName(operation); + registerHeaderOnlyResponseInterface( + operation, + responseHeaders, + headerOnlyInterfaceName, + ); + returnType = { + name: headerOnlyInterfaceName, + type: resolveReference(refkey(operation.operation.__raw, "headerResponse")), + }; +} +``` + +**Issue**: When `response.type` exists, the code: + +- ✓ Retrieves `responseHeaders` (line 603) +- ✓ Checks `hasHeaderOnlyResponse` (line 604) +- ✗ **Does NOT check if the response model has header properties** +- ✗ **Does NOT combine model properties with headers in the return type** + +### 2. Return Type Generation in `getDeserializePrivateFunction()` (lines 147-400) + +Similar pattern at lines 168-197: + +```typescript +const response = operation.response; +const restResponse = operation.operation.responses[0]; +const responseHeaders = getResponseHeaders(operation.operation.responses); +const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0; + +let returnType; +if (isLroOnly || isLroAndPaging) { + returnType = buildLroReturnType(context, operation); +} else if (response.type && restResponse) { + returnType = { + name: (restResponse as any).name ?? "", + type: getTypeExpression(context, restResponse.type!), // ← Only model type + }; +} else if (hasHeaderOnlyResponse) { + const headerOnlyTypeName = generateHeaderOnlyResponseTypeName(operation); + registerHeaderOnlyResponseInterface( + operation, + responseHeaders, + headerOnlyTypeName, + ); + returnType = { + name: headerOnlyTypeName, + type: resolveReference(refkey(operation.operation.__raw, "headerResponse")), + }; +} +``` + +--- + +## How Headers Are Currently Handled + +### Header Property Detection + +**Function**: `hasHeaderProperties()` (line 1793) + +```typescript +function hasHeaderProperties(context: SdkContext, type: SdkModelType): boolean { + const allProps = type.properties ?? []; + const ancestorProps = getAllAncestors(type) + .filter((p) => p.kind === "model") + .flatMap((p) => (p as SdkModelType).properties ?? []); + return [...allProps, ...ancestorProps].some((p) => + isHeader(context.program, p.__raw!), + ); +} +``` + +- ✓ Already checks if a model has header properties +- ✓ Already checks inherited properties + +### Extracting Response Headers + +**Function**: `getResponseHeaders()` (line 2321) + +```typescript +export function getResponseHeaders( + responses: SdkHttpOperation["responses"], +): SdkServiceResponseHeader[] { + const headerMap = new Map(); + for (const response of responses ?? []) { + for (const header of response.headers ?? []) { + const key = header.serializedName ?? header.name; + if (!headerMap.has(key)) { + headerMap.set(key, header); + } + } + } + return Array.from(headerMap.values()); +} +``` + +### Header-Only Response Handling + +**Functions**: + +- `generateHeaderOnlyResponseTypeName()` (line 2289) - Names like `GetUserResponse` +- `registerHeaderOnlyResponseInterface()` (line 2302) - Registers the header-only interface for emission +- `emitHeaderOnlyResponseInterface()` (line 1063 in emitModels.ts) - Generates the actual interface + +**Example generated interface**: + +```typescript +export interface GetUserResponse { + requestId?: string; +} +``` + +--- + +## The KEY: How Deserialization Already Combines Model + Headers + +**Function**: `getResponseMapping()` (lines 1688-1800) - **THIS IS THE REFERENCE IMPLEMENTATION** + +This function is used during deserialization and it ALREADY correctly combines model and header properties: + +```typescript +export function getResponseMapping( + context: SdkContext, + type: SdkType, + propertyPath: string = "result.body", + overrides?: ModelOverrideOptions, + enableFlatten: boolean = true, + headers?: string, +) { + const allParents = type.kind === "model" ? getAllAncestors(type) : []; + + // Include header properties when deserializing responses + const properties = + type.kind === "model" ? getAllProperties(context, type, allParents) : []; + + if (type.kind === "model") { + const headerProps: SdkModelPropertyType[] = []; + const addHeaderProps = (model: SdkModelType) => { + model.properties?.forEach((p) => { + if (isHeader(context.program, p.__raw!)) { + headerProps.push(p); + } + }); + }; + addHeaderProps(type); + allParents.forEach((parent) => { + if (parent.kind === "model") { + addHeaderProps(parent as SdkModelType); + } + }); + // ✓ Adds header properties to the properties list + headerProps.forEach((p) => { + if (!properties.some((prop) => prop.name === p.name)) { + properties.push(p); + } + }); + } + + const props: string[] = []; + for (const prop of properties) { + // Filters out metadata that isn't a header + if ( + isMetadata(context.program, prop.__raw!) && + !isHeader(context.program, prop.__raw!) + ) { + continue; + } + // ✓ Deserializes both body properties and header properties correctly + const isHeaderProp = isHeader(context.program, prop.__raw!); + const basePath = isHeaderProp && headers ? headers : propertyPath; + // ... generates deserialization for each property + } + return props; +} +``` + +**What it does**: + +- Lines 1700-1725: Combines model properties with header properties +- Lines 1726-1800: Generates proper deserialization that reads from both `result.body` (for model props) and `result.headers` (for header props) + +**Where it's called**: + +- Line 260-261 in `getDeserializePrivateFunction()`: + ```typescript + const shouldPassHeaders = + deserializedType.kind === "model" && + hasHeaderProperties(context, deserializedType); + const deserializedArgs = shouldPassHeaders + ? `${deserializedRoot}, result.headers` + : deserializedRoot; + ``` + +--- + +## Where Model/Header Properties Are Extracted + +### Model Properties Extraction + +**Function**: `getAllProperties()` - Used throughout codebase + +Retrieves all properties from a model, including: + +- Direct properties: `model.properties` +- Inherited properties: Using `getAllAncestors()` to walk the inheritance chain + +### Header Property Identification + +Uses `isHeader()` from `@typespec/http`: + +```typescript +if (isHeader(context.program, p.__raw!)) { + // This is a header property +} +``` + +### Type Expression Generation + +**Function**: `getTypeExpression()` in [packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts](packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts) (line 28) + +Generates TypeScript type expressions for SDK types: + +- Models → interface reference (e.g., `User`) +- Primitives → primitive type (e.g., `string`, `number`) +- Arrays → `SomeType[]` +- Unions → `Type1 | Type2` +- etc. + +--- + +## How Response Types Combine Model + Headers (When It Works) + +### For Header-Only Responses + +**When**: Operation returns no body, only headers +**What happens**: + +1. `hasHeaderOnlyResponse` is detected (no response.type, has responseHeaders) +2. A dedicated interface is created: `GetUserResponse` +3. Interface has properties for each header +4. Return type is: `Promise` + +**Function**: `buildHeaderOnlyResponseValue()` (line 1810) builds the runtime object: + +```typescript +return { serializedHeaderName: value, ... } as GetUserResponse; +``` + +### For Responses With Body + Headers (When It SHOULD Work But Doesn't) + +**What happens NOW**: + +1. Return type is: `Promise` (only the model) +2. But at runtime, the deserialization combines model + headers correctly +3. **Type mismatch**: returned value has `{ name, email, requestId }` but type says just `User` + +**What SHOULD happen**: + +1. Return type should be: `Promise<{ name: string; email: string; requestId: string }>` +2. This can be either: + - An **inline object literal type**: `{ name: string; email: string; requestId: string }` + - A **generated interface**: Similar to header-only responses + +--- + +## Existing Patterns for Generating Combined Types + +### 1. Model Expression Generation + +**File**: [packages/typespec-ts/src/modular/type-expressions/get-model-expression.ts](packages/typespec-ts/src/modular/type-expressions/get-model-expression.ts) + +Can generate inline object literal types: + +```typescript +// For discriminated unions or other complex models +`${normalizeModelPropertyName(context, p)}${p.optional ? "?" : ""}: ${getTypeExpression(context, p.type)}`; +``` + +### 2. Header-Only Response Interface + +**File**: [packages/typespec-ts/src/modular/emitModels.ts](packages/typespec-ts/src/modular/emitModels.ts) (line 1063) + +```typescript +const properties: PropertySignatureStructure[] = headers.map((header) => { + const name = normalizeName(header.name, NameType.Property); + const type = getTypeExpression(context, header.type); + const isOptional = header.optional; + return { + kind: StructureKind.PropertySignature, + name, + type, + hasQuestionToken: isOptional, + }; +}); + +const interfaceStructure: InterfaceStructure = { + kind: StructureKind.Interface, + name: typeName, + isExported: true, + properties, +}; +``` + +--- + +## Technical Details Needed for Implementation + +### 1. Property Combination Logic + +Need to combine: + +- **Model properties** from `response.type.kind === "model"` properties +- **Header properties** from `response.type` properties where `isHeader(context.program, prop.__raw!)` is true + +### 2. Type Expression Generation + +For return type, build object literal like: + +```typescript +{ + name: string; + email: string; + requestId: string; +} +``` + +Using pattern similar to model property serialization: + +```typescript +const propertyTypes = allProperties.map((prop) => { + const name = normalizeModelPropertyName(context, prop); + const type = getTypeExpression(context, prop.type); + const optional = prop.optional ? "?" : ""; + return `${name}${optional}: ${type}`; +}); +const objectType = `{ ${propertyTypes.join("; ")} }`; +``` + +### 3. Two Implementation Approaches + +**Option A: Inline Object Literal (Simpler)** + +- Generate inline type in return statement +- Example: `Promise<{ name: string; email: string; requestId: string }>` +- Pros: No new interface generation needed +- Cons: Type can be verbose for large models + +**Option B: Generate Response Interface (More Consistent)** + +- Similar to header-only response interfaces +- Create `UserResponse` interface with all properties (model + headers) +- Example: `Promise` +- Pros: Cleaner, matches header-only pattern +- Cons: Additional interface to manage + +### 4. Where to Make Changes + +Three main locations: + +1. **`getOperationFunction()`** (line 598-618) - Generate return type for public function signature +2. **`getDeserializePrivateFunction()`** (line 168-197) - Generate return type for private deserialize function +3. **Possibly `emitModels.ts`** - If creating response interfaces for Option B + +### 5. Key Utility Functions to Use + +- `hasHeaderProperties(context, type)` - Detect if model has headers ✓ (already exists) +- `getAllProperties(context, model, ancestors)` - Get all model properties +- `isHeader(context.program, prop.__raw!)` - Identify header properties +- `getTypeExpression(context, type)` - Generate type expressions +- `normalizeModelPropertyName(context, prop)` - Normalize property names +- `getAllAncestors(type)` - Get inherited properties + +--- + +## Summary of Issues + +| Issue | Impact | Current Code | Needed Change | +| ----------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------- | --------------------------------------------------------------------- | +| Return type doesn't include headers | Type mismatch between signature and implementation | `getTypeExpression(context, type!)` only returns model type | Check for header properties and combine types | +| Header properties filtered out from return type | Public API doesn't reflect actual returned object | Response mapping correctly includes headers, but return type doesn't | Generate response type that includes both model and header properties | +| Works for header-only responses but not hybrid | Inconsistent behavior | Special case for `hasHeaderOnlyResponse` | Extend logic to cover model + headers case | +| No interface for combined response | Larger return type expressions or workarounds | Header-only interfaces are generated | Consider generating response interfaces for model + headers | + +--- + +## Code Flow Diagram + +``` +TypeSpec Input: + model User { name: string; email: string; } + op getUser(): User & {@header requestId: string}; + + ↓ + +Parse & Extract: + - response.type = User (SdkModelType) + - responseHeaders = [{ name: "requestId", ... }] + - hasHeaderProperties(context, User) = true ✓ + + ↓ + +Generate Return Type (CURRENTLY BROKEN): + getOperationFunction() line 598-618: + if (response.type) { + returnType = getTypeExpression(context, User) ← Returns "User" only + } + + ↓ + +Expected Return Type: + Promise<{ name: string; email: string; requestId: string }> + + ↓ + +Runtime Deserialization (WORKS CORRECTLY): + getDeserializePrivateFunction() line 260-270: + shouldPassHeaders = true (has header properties) ✓ + Calls: deserializer(result.body, result.headers) + + getResponseMapping() line 1700-1800: + Combines model props + header props ✓ + Returns: { name: "...", email: "...", requestId: "..." } ✓ + + ↓ + +Result: Type mismatch between declared return type and actual runtime type +``` diff --git a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/review/arm-networkanalytics.api.md b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/review/arm-networkanalytics.api.md index ae7897fc73..1a407ebf48 100644 --- a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/review/arm-networkanalytics.api.md +++ b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/review/arm-networkanalytics.api.md @@ -3,27 +3,26 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts - -import { AbortSignalLike } from '@azure/abort-controller'; -import { CancelOnProgress } from '@azure/core-lro'; -import { ClientOptions } from '@azure-rest/core-client'; -import { OperationOptions } from '@azure-rest/core-client'; -import { OperationState } from '@azure/core-lro'; -import { PathUncheckedResponse } from '@azure-rest/core-client'; -import { Pipeline } from '@azure/core-rest-pipeline'; -import { PollerLike } from '@azure/core-lro'; -import { TokenCredential } from '@azure/core-auth'; +import { AbortSignalLike } from "@azure/abort-controller"; +import { CancelOnProgress } from "@azure/core-lro"; +import { ClientOptions } from "@azure-rest/core-client"; +import { OperationOptions } from "@azure-rest/core-client"; +import { OperationState } from "@azure/core-lro"; +import { PathUncheckedResponse } from "@azure-rest/core-client"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { PollerLike } from "@azure/core-lro"; +import { TokenCredential } from "@azure/core-auth"; // @public export interface AccountSas { - expiryTimeStamp: Date; - ipAddress: string; - startTimeStamp: Date; + expiryTimeStamp: Date; + ipAddress: string; + startTimeStamp: Date; } // @public export interface AccountSasToken { - storageAccountSasToken: string; + storageAccountSasToken: string; } // @public @@ -31,9 +30,9 @@ export type ActionType = string; // @public export enum AzureClouds { - AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", - AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", - AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT" + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT", } // @public @@ -41,29 +40,29 @@ export type AzureSupportedClouds = `${AzureClouds}`; // @public export interface ConsumptionEndpointsProperties { - readonly fileAccessResourceId?: string; - readonly fileAccessUrl?: string; - readonly ingestionResourceId?: string; - readonly ingestionUrl?: string; - readonly queryResourceId?: string; - readonly queryUrl?: string; + readonly fileAccessResourceId?: string; + readonly fileAccessUrl?: string; + readonly ingestionResourceId?: string; + readonly ingestionUrl?: string; + readonly queryResourceId?: string; + readonly queryUrl?: string; } // @public export interface ContainerSaS { - expiryTimeStamp: Date; - ipAddress: string; - startTimeStamp: Date; + expiryTimeStamp: Date; + ipAddress: string; + startTimeStamp: Date; } // @public export interface ContainerSasToken { - storageContainerSasToken: string; + storageContainerSasToken: string; } // @public export type ContinuablePage = TPage & { - continuationToken?: string; + continuationToken?: string; }; // @public @@ -74,186 +73,259 @@ export type CreatedByType = string; // @public export interface DataProduct extends TrackedResource { - readonly availableMinorVersions?: string[]; - readonly consumptionEndpoints?: ConsumptionEndpointsProperties; - currentMinorVersion?: string; - customerEncryptionKey?: EncryptionKeyDetails; - customerManagedKeyEncryptionEnabled?: ControlState; - readonly documentation?: string; - identity?: ManagedServiceIdentityV4; - readonly keyVaultUrl?: string; - majorVersion?: string; - managedResourceGroupConfiguration?: ManagedResourceGroupConfiguration; - networkacls?: DataProductNetworkAcls; - owners?: string[]; - privateLinksEnabled?: ControlState; - product?: string; - readonly provisioningState?: ProvisioningState; - publicNetworkAccess?: ControlState; - publisher?: string; - purviewAccount?: string; - purviewCollection?: string; - redundancy?: ControlState; - readonly resourceGuid?: string; + readonly availableMinorVersions?: string[]; + readonly consumptionEndpoints?: ConsumptionEndpointsProperties; + currentMinorVersion?: string; + customerEncryptionKey?: EncryptionKeyDetails; + customerManagedKeyEncryptionEnabled?: ControlState; + readonly documentation?: string; + identity?: ManagedServiceIdentityV4; + readonly keyVaultUrl?: string; + majorVersion?: string; + managedResourceGroupConfiguration?: ManagedResourceGroupConfiguration; + networkacls?: DataProductNetworkAcls; + owners?: string[]; + privateLinksEnabled?: ControlState; + product?: string; + readonly provisioningState?: ProvisioningState; + publicNetworkAccess?: ControlState; + publisher?: string; + purviewAccount?: string; + purviewCollection?: string; + redundancy?: ControlState; + readonly resourceGuid?: string; } // @public export interface DataProductInformation { - dataProductName: string; - dataProductVersions: DataProductVersion[]; - description: string; + dataProductName: string; + dataProductVersions: DataProductVersion[]; + description: string; } // @public export interface DataProductNetworkAcls { - allowedQueryIpRangeList: string[]; - defaultAction: DefaultAction; - ipRules: IPRules[]; - virtualNetworkRule: VirtualNetworkRule[]; + allowedQueryIpRangeList: string[]; + defaultAction: DefaultAction; + ipRules: IPRules[]; + virtualNetworkRule: VirtualNetworkRule[]; } // @public export interface DataProductProperties { - readonly availableMinorVersions?: string[]; - readonly consumptionEndpoints?: ConsumptionEndpointsProperties; - currentMinorVersion?: string; - customerEncryptionKey?: EncryptionKeyDetails; - customerManagedKeyEncryptionEnabled?: ControlState; - readonly documentation?: string; - readonly keyVaultUrl?: string; - majorVersion: string; - managedResourceGroupConfiguration?: ManagedResourceGroupConfiguration; - networkacls?: DataProductNetworkAcls; - owners?: string[]; - privateLinksEnabled?: ControlState; - product: string; - readonly provisioningState?: ProvisioningState; - publicNetworkAccess?: ControlState; - publisher: string; - purviewAccount?: string; - purviewCollection?: string; - redundancy?: ControlState; - readonly resourceGuid?: string; -} - -// @public -export interface DataProductsAddUserRoleOptionalParams extends OperationOptions { -} + readonly availableMinorVersions?: string[]; + readonly consumptionEndpoints?: ConsumptionEndpointsProperties; + currentMinorVersion?: string; + customerEncryptionKey?: EncryptionKeyDetails; + customerManagedKeyEncryptionEnabled?: ControlState; + readonly documentation?: string; + readonly keyVaultUrl?: string; + majorVersion: string; + managedResourceGroupConfiguration?: ManagedResourceGroupConfiguration; + networkacls?: DataProductNetworkAcls; + owners?: string[]; + privateLinksEnabled?: ControlState; + product: string; + readonly provisioningState?: ProvisioningState; + publicNetworkAccess?: ControlState; + publisher: string; + purviewAccount?: string; + purviewCollection?: string; + redundancy?: ControlState; + readonly resourceGuid?: string; +} + +// @public +export interface DataProductsAddUserRoleOptionalParams extends OperationOptions {} // @public export interface DataProductsCatalog extends ProxyResource { - properties?: DataProductsCatalogProperties; + properties?: DataProductsCatalogProperties; } // @public export interface DataProductsCatalogProperties { - readonly provisioningState?: ProvisioningState; - publishers: PublisherInformation[]; + readonly provisioningState?: ProvisioningState; + publishers: PublisherInformation[]; } // @public -export interface DataProductsCatalogsGetOptionalParams extends OperationOptions { -} +export interface DataProductsCatalogsGetOptionalParams extends OperationOptions {} // @public -export interface DataProductsCatalogsListByResourceGroupOptionalParams extends OperationOptions { -} +export interface DataProductsCatalogsListByResourceGroupOptionalParams extends OperationOptions {} // @public -export interface DataProductsCatalogsListBySubscriptionOptionalParams extends OperationOptions { -} +export interface DataProductsCatalogsListBySubscriptionOptionalParams extends OperationOptions {} // @public export interface DataProductsCatalogsOperations { - get: (resourceGroupName: string, options?: DataProductsCatalogsGetOptionalParams) => Promise; - listByResourceGroup: (resourceGroupName: string, options?: DataProductsCatalogsListByResourceGroupOptionalParams) => PagedAsyncIterableIterator; - listBySubscription: (options?: DataProductsCatalogsListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; + get: ( + resourceGroupName: string, + options?: DataProductsCatalogsGetOptionalParams, + ) => Promise; + listByResourceGroup: ( + resourceGroupName: string, + options?: DataProductsCatalogsListByResourceGroupOptionalParams, + ) => PagedAsyncIterableIterator; + listBySubscription: ( + options?: DataProductsCatalogsListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; } // @public export interface DataProductsCreateOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public export interface DataProductsDeleteOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public -export interface DataProductsGenerateStorageAccountSasTokenOptionalParams extends OperationOptions { -} +export interface DataProductsGenerateStorageAccountSasTokenOptionalParams extends OperationOptions {} // @public -export interface DataProductsGetOptionalParams extends OperationOptions { -} +export interface DataProductsGetOptionalParams extends OperationOptions {} // @public -export interface DataProductsListByResourceGroupOptionalParams extends OperationOptions { -} +export interface DataProductsListByResourceGroupOptionalParams extends OperationOptions {} // @public -export interface DataProductsListBySubscriptionOptionalParams extends OperationOptions { -} +export interface DataProductsListBySubscriptionOptionalParams extends OperationOptions {} // @public -export interface DataProductsListRolesAssignmentsOptionalParams extends OperationOptions { -} +export interface DataProductsListRolesAssignmentsOptionalParams extends OperationOptions {} // @public export interface DataProductsOperations { - addUserRole: (resourceGroupName: string, dataProductName: string, body: RoleAssignmentCommonProperties, options?: DataProductsAddUserRoleOptionalParams) => Promise; - // @deprecated (undocumented) - beginCreate: (resourceGroupName: string, dataProductName: string, resource: DataProduct, options?: DataProductsCreateOptionalParams) => Promise, DataProduct>>; - // @deprecated (undocumented) - beginCreateAndWait: (resourceGroupName: string, dataProductName: string, resource: DataProduct, options?: DataProductsCreateOptionalParams) => Promise; - // @deprecated (undocumented) - beginDelete: (resourceGroupName: string, dataProductName: string, options?: DataProductsDeleteOptionalParams) => Promise, void>>; - // @deprecated (undocumented) - beginDeleteAndWait: (resourceGroupName: string, dataProductName: string, options?: DataProductsDeleteOptionalParams) => Promise; - // @deprecated (undocumented) - beginUpdate: (resourceGroupName: string, dataProductName: string, properties: DataProductUpdate, options?: DataProductsUpdateOptionalParams) => Promise, DataProduct>>; - // @deprecated (undocumented) - beginUpdateAndWait: (resourceGroupName: string, dataProductName: string, properties: DataProductUpdate, options?: DataProductsUpdateOptionalParams) => Promise; - create: (resourceGroupName: string, dataProductName: string, resource: DataProduct, options?: DataProductsCreateOptionalParams) => PollerLike, DataProduct>; - delete: (resourceGroupName: string, dataProductName: string, options?: DataProductsDeleteOptionalParams) => PollerLike, void>; - generateStorageAccountSasToken: (resourceGroupName: string, dataProductName: string, body: AccountSas, options?: DataProductsGenerateStorageAccountSasTokenOptionalParams) => Promise; - get: (resourceGroupName: string, dataProductName: string, options?: DataProductsGetOptionalParams) => Promise; - listByResourceGroup: (resourceGroupName: string, options?: DataProductsListByResourceGroupOptionalParams) => PagedAsyncIterableIterator; - listBySubscription: (options?: DataProductsListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; - listRolesAssignments: (resourceGroupName: string, dataProductName: string, body: Record, options?: DataProductsListRolesAssignmentsOptionalParams) => Promise; - removeUserRole: (resourceGroupName: string, dataProductName: string, body: RoleAssignmentDetail, options?: DataProductsRemoveUserRoleOptionalParams) => Promise; - rotateKey: (resourceGroupName: string, dataProductName: string, body: KeyVaultInfo, options?: DataProductsRotateKeyOptionalParams) => Promise; - update: (resourceGroupName: string, dataProductName: string, properties: DataProductUpdate, options?: DataProductsUpdateOptionalParams) => PollerLike, DataProduct>; -} - -// @public -export interface DataProductsRemoveUserRoleOptionalParams extends OperationOptions { -} - -// @public -export interface DataProductsRotateKeyOptionalParams extends OperationOptions { -} + addUserRole: ( + resourceGroupName: string, + dataProductName: string, + body: RoleAssignmentCommonProperties, + options?: DataProductsAddUserRoleOptionalParams, + ) => Promise; + // @deprecated (undocumented) + beginCreate: ( + resourceGroupName: string, + dataProductName: string, + resource: DataProduct, + options?: DataProductsCreateOptionalParams, + ) => Promise, DataProduct>>; + // @deprecated (undocumented) + beginCreateAndWait: ( + resourceGroupName: string, + dataProductName: string, + resource: DataProduct, + options?: DataProductsCreateOptionalParams, + ) => Promise; + // @deprecated (undocumented) + beginDelete: ( + resourceGroupName: string, + dataProductName: string, + options?: DataProductsDeleteOptionalParams, + ) => Promise, void>>; + // @deprecated (undocumented) + beginDeleteAndWait: ( + resourceGroupName: string, + dataProductName: string, + options?: DataProductsDeleteOptionalParams, + ) => Promise; + // @deprecated (undocumented) + beginUpdate: ( + resourceGroupName: string, + dataProductName: string, + properties: DataProductUpdate, + options?: DataProductsUpdateOptionalParams, + ) => Promise, DataProduct>>; + // @deprecated (undocumented) + beginUpdateAndWait: ( + resourceGroupName: string, + dataProductName: string, + properties: DataProductUpdate, + options?: DataProductsUpdateOptionalParams, + ) => Promise; + create: ( + resourceGroupName: string, + dataProductName: string, + resource: DataProduct, + options?: DataProductsCreateOptionalParams, + ) => PollerLike, DataProduct>; + delete: ( + resourceGroupName: string, + dataProductName: string, + options?: DataProductsDeleteOptionalParams, + ) => PollerLike, void>; + generateStorageAccountSasToken: ( + resourceGroupName: string, + dataProductName: string, + body: AccountSas, + options?: DataProductsGenerateStorageAccountSasTokenOptionalParams, + ) => Promise; + get: ( + resourceGroupName: string, + dataProductName: string, + options?: DataProductsGetOptionalParams, + ) => Promise; + listByResourceGroup: ( + resourceGroupName: string, + options?: DataProductsListByResourceGroupOptionalParams, + ) => PagedAsyncIterableIterator; + listBySubscription: ( + options?: DataProductsListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + listRolesAssignments: ( + resourceGroupName: string, + dataProductName: string, + body: Record, + options?: DataProductsListRolesAssignmentsOptionalParams, + ) => Promise; + removeUserRole: ( + resourceGroupName: string, + dataProductName: string, + body: RoleAssignmentDetail, + options?: DataProductsRemoveUserRoleOptionalParams, + ) => Promise; + rotateKey: ( + resourceGroupName: string, + dataProductName: string, + body: KeyVaultInfo, + options?: DataProductsRotateKeyOptionalParams, + ) => Promise; + update: ( + resourceGroupName: string, + dataProductName: string, + properties: DataProductUpdate, + options?: DataProductsUpdateOptionalParams, + ) => PollerLike, DataProduct>; +} + +// @public +export interface DataProductsRemoveUserRoleOptionalParams extends OperationOptions {} + +// @public +export interface DataProductsRotateKeyOptionalParams extends OperationOptions {} // @public export interface DataProductsUpdateOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public export interface DataProductUpdate { - identity?: ManagedServiceIdentityV4; - properties?: DataProductUpdateProperties; - tags?: Record; + identity?: ManagedServiceIdentityV4; + properties?: DataProductUpdateProperties; + tags?: Record; } // @public export interface DataProductUpdateProperties { - currentMinorVersion?: string; - owners?: string[]; - privateLinksEnabled?: ControlState; - purviewAccount?: string; - purviewCollection?: string; + currentMinorVersion?: string; + owners?: string[]; + privateLinksEnabled?: ControlState; + purviewAccount?: string; + purviewCollection?: string; } // @public @@ -261,83 +333,164 @@ export type DataProductUserRole = string; // @public export interface DataProductVersion { - version: string; + version: string; } // @public export interface DataType extends ProxyResource { - databaseCacheRetention?: number; - databaseRetention?: number; - readonly provisioningState?: ProvisioningState; - state?: DataTypeState; - readonly stateReason?: string; - storageOutputRetention?: number; - readonly visualizationUrl?: string; + databaseCacheRetention?: number; + databaseRetention?: number; + readonly provisioningState?: ProvisioningState; + state?: DataTypeState; + readonly stateReason?: string; + storageOutputRetention?: number; + readonly visualizationUrl?: string; } // @public export interface DataTypeProperties { - databaseCacheRetention?: number; - databaseRetention?: number; - readonly provisioningState?: ProvisioningState; - state?: DataTypeState; - readonly stateReason?: string; - storageOutputRetention?: number; - readonly visualizationUrl?: string; + databaseCacheRetention?: number; + databaseRetention?: number; + readonly provisioningState?: ProvisioningState; + state?: DataTypeState; + readonly stateReason?: string; + storageOutputRetention?: number; + readonly visualizationUrl?: string; } // @public export interface DataTypesCreateOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public export interface DataTypesDeleteDataOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public export interface DataTypesDeleteOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public -export interface DataTypesGenerateStorageContainerSasTokenOptionalParams extends OperationOptions { -} +export interface DataTypesGenerateStorageContainerSasTokenOptionalParams extends OperationOptions {} // @public -export interface DataTypesGetOptionalParams extends OperationOptions { -} +export interface DataTypesGetOptionalParams extends OperationOptions {} // @public -export interface DataTypesListByDataProductOptionalParams extends OperationOptions { -} +export interface DataTypesListByDataProductOptionalParams extends OperationOptions {} // @public export interface DataTypesOperations { - // @deprecated (undocumented) - beginCreate: (resourceGroupName: string, dataProductName: string, dataTypeName: string, resource: DataType, options?: DataTypesCreateOptionalParams) => Promise, DataType>>; - // @deprecated (undocumented) - beginCreateAndWait: (resourceGroupName: string, dataProductName: string, dataTypeName: string, resource: DataType, options?: DataTypesCreateOptionalParams) => Promise; - // @deprecated (undocumented) - beginDelete: (resourceGroupName: string, dataProductName: string, dataTypeName: string, options?: DataTypesDeleteOptionalParams) => Promise, void>>; - // @deprecated (undocumented) - beginDeleteAndWait: (resourceGroupName: string, dataProductName: string, dataTypeName: string, options?: DataTypesDeleteOptionalParams) => Promise; - // @deprecated (undocumented) - beginDeleteData: (resourceGroupName: string, dataProductName: string, dataTypeName: string, body: Record, options?: DataTypesDeleteDataOptionalParams) => Promise, void>>; - // @deprecated (undocumented) - beginDeleteDataAndWait: (resourceGroupName: string, dataProductName: string, dataTypeName: string, body: Record, options?: DataTypesDeleteDataOptionalParams) => Promise; - // @deprecated (undocumented) - beginUpdate: (resourceGroupName: string, dataProductName: string, dataTypeName: string, properties: DataTypeUpdate, options?: DataTypesUpdateOptionalParams) => Promise, DataType>>; - // @deprecated (undocumented) - beginUpdateAndWait: (resourceGroupName: string, dataProductName: string, dataTypeName: string, properties: DataTypeUpdate, options?: DataTypesUpdateOptionalParams) => Promise; - create: (resourceGroupName: string, dataProductName: string, dataTypeName: string, resource: DataType, options?: DataTypesCreateOptionalParams) => PollerLike, DataType>; - delete: (resourceGroupName: string, dataProductName: string, dataTypeName: string, options?: DataTypesDeleteOptionalParams) => PollerLike, void>; - deleteData: (resourceGroupName: string, dataProductName: string, dataTypeName: string, body: Record, options?: DataTypesDeleteDataOptionalParams) => PollerLike, void>; - generateStorageContainerSasToken: (resourceGroupName: string, dataProductName: string, dataTypeName: string, body: ContainerSaS, options?: DataTypesGenerateStorageContainerSasTokenOptionalParams) => Promise; - get: (resourceGroupName: string, dataProductName: string, dataTypeName: string, options?: DataTypesGetOptionalParams) => Promise; - listByDataProduct: (resourceGroupName: string, dataProductName: string, options?: DataTypesListByDataProductOptionalParams) => PagedAsyncIterableIterator; - update: (resourceGroupName: string, dataProductName: string, dataTypeName: string, properties: DataTypeUpdate, options?: DataTypesUpdateOptionalParams) => PollerLike, DataType>; + // @deprecated (undocumented) + beginCreate: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + resource: DataType, + options?: DataTypesCreateOptionalParams, + ) => Promise, DataType>>; + // @deprecated (undocumented) + beginCreateAndWait: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + resource: DataType, + options?: DataTypesCreateOptionalParams, + ) => Promise; + // @deprecated (undocumented) + beginDelete: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + options?: DataTypesDeleteOptionalParams, + ) => Promise, void>>; + // @deprecated (undocumented) + beginDeleteAndWait: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + options?: DataTypesDeleteOptionalParams, + ) => Promise; + // @deprecated (undocumented) + beginDeleteData: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + body: Record, + options?: DataTypesDeleteDataOptionalParams, + ) => Promise, void>>; + // @deprecated (undocumented) + beginDeleteDataAndWait: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + body: Record, + options?: DataTypesDeleteDataOptionalParams, + ) => Promise; + // @deprecated (undocumented) + beginUpdate: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + properties: DataTypeUpdate, + options?: DataTypesUpdateOptionalParams, + ) => Promise, DataType>>; + // @deprecated (undocumented) + beginUpdateAndWait: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + properties: DataTypeUpdate, + options?: DataTypesUpdateOptionalParams, + ) => Promise; + create: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + resource: DataType, + options?: DataTypesCreateOptionalParams, + ) => PollerLike, DataType>; + delete: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + options?: DataTypesDeleteOptionalParams, + ) => PollerLike, void>; + deleteData: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + body: Record, + options?: DataTypesDeleteDataOptionalParams, + ) => PollerLike, void>; + generateStorageContainerSasToken: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + body: ContainerSaS, + options?: DataTypesGenerateStorageContainerSasTokenOptionalParams, + ) => Promise; + get: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + options?: DataTypesGetOptionalParams, + ) => Promise; + listByDataProduct: ( + resourceGroupName: string, + dataProductName: string, + options?: DataTypesListByDataProductOptionalParams, + ) => PagedAsyncIterableIterator; + update: ( + resourceGroupName: string, + dataProductName: string, + dataTypeName: string, + properties: DataTypeUpdate, + options?: DataTypesUpdateOptionalParams, + ) => PollerLike, DataType>; } // @public @@ -345,141 +498,157 @@ export type DataTypeState = string; // @public export interface DataTypesUpdateOptionalParams extends OperationOptions { - updateIntervalInMs?: number; + updateIntervalInMs?: number; } // @public export interface DataTypeUpdate { - properties?: DataTypeUpdateProperties; + properties?: DataTypeUpdateProperties; } // @public export interface DataTypeUpdateProperties { - databaseCacheRetention?: number; - databaseRetention?: number; - state?: DataTypeState; - storageOutputRetention?: number; + databaseCacheRetention?: number; + databaseRetention?: number; + state?: DataTypeState; + storageOutputRetention?: number; } // @public export type DefaultAction = string; +// @public +export interface DeleteDataResponse { + // (undocumented) + location?: string; + // (undocumented) + retryAfter?: number; +} + +// @public +export interface DeleteResponse { + // (undocumented) + location?: string; + // (undocumented) + retryAfter?: number; +} + // @public export interface EncryptionKeyDetails { - keyName: string; - keyVaultUri: string; - keyVersion: string; + keyName: string; + keyVaultUri: string; + keyVersion: string; } // @public export interface ErrorAdditionalInfo { - readonly info?: any; - readonly type?: string; + readonly info?: any; + readonly type?: string; } // @public export interface ErrorDetail { - readonly additionalInfo?: ErrorAdditionalInfo[]; - readonly code?: string; - readonly details?: ErrorDetail[]; - readonly message?: string; - readonly target?: string; + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; } // @public export interface ErrorResponse { - error?: ErrorDetail; + error?: ErrorDetail; } // @public export interface IPRules { - action: string; - value?: string; + action: string; + value?: string; } // @public export interface KeyVaultInfo { - keyVaultUrl: string; + keyVaultUrl: string; } // @public export enum KnownActionType { - Internal = "Internal" + Internal = "Internal", } // @public export enum KnownControlState { - Disabled = "Disabled", - Enabled = "Enabled" + Disabled = "Disabled", + Enabled = "Enabled", } // @public export enum KnownCreatedByType { - Application = "Application", - Key = "Key", - ManagedIdentity = "ManagedIdentity", - User = "User" + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User", } // @public export enum KnownDataProductUserRole { - Reader = "Reader", - SensitiveReader = "SensitiveReader" + Reader = "Reader", + SensitiveReader = "SensitiveReader", } // @public export enum KnownDataTypeState { - Running = "Running", - Stopped = "Stopped" + Running = "Running", + Stopped = "Stopped", } // @public export enum KnownDefaultAction { - Allow = "Allow", - Deny = "Deny" + Allow = "Allow", + Deny = "Deny", } // @public export enum KnownManagedServiceIdentityType { - None = "None", - SystemAndUserAssigned = "SystemAssigned, UserAssigned", - SystemAssigned = "SystemAssigned", - UserAssigned = "UserAssigned" + None = "None", + SystemAndUserAssigned = "SystemAssigned, UserAssigned", + SystemAssigned = "SystemAssigned", + UserAssigned = "UserAssigned", } // @public export enum KnownOrigin { - System = "system", - User = "user", - UserSystem = "user,system" + System = "system", + User = "user", + UserSystem = "user,system", } // @public export enum KnownProvisioningState { - Accepted = "Accepted", - Canceled = "Canceled", - Deleting = "Deleting", - Failed = "Failed", - Provisioning = "Provisioning", - Succeeded = "Succeeded", - Updating = "Updating" + Accepted = "Accepted", + Canceled = "Canceled", + Deleting = "Deleting", + Failed = "Failed", + Provisioning = "Provisioning", + Succeeded = "Succeeded", + Updating = "Updating", } // @public export enum KnownVersions { - V20231115 = "2023-11-15" + V20231115 = "2023-11-15", } // @public export interface ListRoleAssignments { - count: number; - roleAssignmentResponse: RoleAssignmentDetail[]; + count: number; + roleAssignmentResponse: RoleAssignmentDetail[]; } // @public export interface ManagedResourceGroupConfiguration { - location: string; - name: string; + location: string; + name: string; } // @public @@ -487,172 +656,196 @@ export type ManagedServiceIdentityType = string; // @public export interface ManagedServiceIdentityV4 { - readonly principalId?: string; - readonly tenantId?: string; - type: ManagedServiceIdentityType; - userAssignedIdentities?: Record; + readonly principalId?: string; + readonly tenantId?: string; + type: ManagedServiceIdentityType; + userAssignedIdentities?: Record; } // @public (undocumented) export class NetworkAnalyticsApi { - constructor(credential: TokenCredential, subscriptionId: string, options?: NetworkAnalyticsApiOptionalParams); - readonly dataProducts: DataProductsOperations; - readonly dataProductsCatalogs: DataProductsCatalogsOperations; - readonly dataTypes: DataTypesOperations; - readonly operations: OperationsOperations; - readonly pipeline: Pipeline; + constructor( + credential: TokenCredential, + subscriptionId: string, + options?: NetworkAnalyticsApiOptionalParams, + ); + readonly dataProducts: DataProductsOperations; + readonly dataProductsCatalogs: DataProductsCatalogsOperations; + readonly dataTypes: DataTypesOperations; + readonly operations: OperationsOperations; + readonly pipeline: Pipeline; } // @public export interface NetworkAnalyticsApiOptionalParams extends ClientOptions { - apiVersion?: string; - cloudSetting?: AzureSupportedClouds; + apiVersion?: string; + cloudSetting?: AzureSupportedClouds; } // @public export interface Operation { - readonly actionType?: ActionType; - display?: OperationDisplay; - readonly isDataAction?: boolean; - readonly name?: string; - readonly origin?: Origin; + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; } // @public export interface OperationDisplay { - readonly description?: string; - readonly operation?: string; - readonly provider?: string; - readonly resource?: string; + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; } // @public -export interface OperationsListOptionalParams extends OperationOptions { -} +export interface OperationsListOptionalParams extends OperationOptions {} // @public export interface OperationsOperations { - list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; + list: ( + options?: OperationsListOptionalParams, + ) => PagedAsyncIterableIterator; } // @public export type Origin = string; // @public -export interface PagedAsyncIterableIterator { - [Symbol.asyncIterator](): PagedAsyncIterableIterator; - byPage: (settings?: TPageSettings) => AsyncIterableIterator>; - next(): Promise>; +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + byPage: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; + next(): Promise>; } // @public export interface PageSettings { - continuationToken?: string; + continuationToken?: string; } // @public export type ProvisioningState = string; // @public -export interface ProxyResource extends Resource { -} +export interface ProxyResource extends Resource {} // @public export interface PublisherInformation { - dataProducts: DataProductInformation[]; - publisherName: string; + dataProducts: DataProductInformation[]; + publisherName: string; } // @public export interface Resource { - readonly id?: string; - readonly name?: string; - readonly systemData?: SystemData; - readonly type?: string; + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; } // @public -export function restorePoller(client: NetworkAnalyticsApi, serializedState: string, sourceOperation: (...args: any[]) => PollerLike, TResult>, options?: RestorePollerOptions): PollerLike, TResult>; +export function restorePoller( + client: NetworkAnalyticsApi, + serializedState: string, + sourceOperation: ( + ...args: any[] + ) => PollerLike, TResult>, + options?: RestorePollerOptions, +): PollerLike, TResult>; // @public (undocumented) -export interface RestorePollerOptions extends OperationOptions { - abortSignal?: AbortSignalLike; - processResponseBody?: (result: TResponse) => Promise; - updateIntervalInMs?: number; +export interface RestorePollerOptions< + TResult, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +> extends OperationOptions { + abortSignal?: AbortSignalLike; + processResponseBody?: (result: TResponse) => Promise; + updateIntervalInMs?: number; } // @public export interface RoleAssignmentCommonProperties { - dataTypeScope: string[]; - principalId: string; - principalType: string; - role: DataProductUserRole; - roleId: string; - userName: string; + dataTypeScope: string[]; + principalId: string; + principalType: string; + role: DataProductUserRole; + roleId: string; + userName: string; } // @public export interface RoleAssignmentDetail { - dataTypeScope: string[]; - principalId: string; - principalType: string; - role: DataProductUserRole; - roleAssignmentId: string; - roleId: string; - userName: string; -} - -// @public -export interface SimplePollerLike, TResult> { - getOperationState(): TState; - getResult(): TResult | undefined; - isDone(): boolean; - // @deprecated - isStopped(): boolean; - onProgress(callback: (state: TState) => void): CancelOnProgress; - poll(options?: { - abortSignal?: AbortSignalLike; - }): Promise; - pollUntilDone(pollOptions?: { - abortSignal?: AbortSignalLike; - }): Promise; - serialize(): Promise; - // @deprecated - stopPolling(): void; - submitted(): Promise; - // @deprecated - toString(): string; + dataTypeScope: string[]; + principalId: string; + principalType: string; + role: DataProductUserRole; + roleAssignmentId: string; + roleId: string; + userName: string; +} + +// @public +export interface SimplePollerLike< + TState extends OperationState, + TResult, +> { + getOperationState(): TState; + getResult(): TResult | undefined; + isDone(): boolean; + // @deprecated + isStopped(): boolean; + onProgress(callback: (state: TState) => void): CancelOnProgress; + poll(options?: { abortSignal?: AbortSignalLike }): Promise; + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + serialize(): Promise; + // @deprecated + stopPolling(): void; + submitted(): Promise; + // @deprecated + toString(): string; } // @public export interface SystemData { - createdAt?: Date; - createdBy?: string; - createdByType?: CreatedByType; - lastModifiedAt?: Date; - lastModifiedBy?: string; - lastModifiedByType?: CreatedByType; + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; } // @public export interface TrackedResource extends Resource { - location: string; - tags?: Record; + location: string; + tags?: Record; } // @public export interface UserAssignedIdentity { - readonly clientId?: string; - readonly principalId?: string; + readonly clientId?: string; + readonly principalId?: string; } // @public export interface VirtualNetworkRule { - action?: string; - id: string; - state?: string; + action?: string; + id: string; + state?: string; } // (No @packageDocumentation comment for this package) - ``` diff --git a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/index.ts b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/index.ts index 4f90224b22..58fe4b0a58 100644 --- a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/index.ts +++ b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/index.ts @@ -69,6 +69,8 @@ export { RoleAssignmentDetail, ListRoleAssignments, KnownVersions, + DeleteResponse, + DeleteDataResponse, } from "./models/index.js"; export { NetworkAnalyticsApiOptionalParams } from "./api/index.js"; export { diff --git a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/index.ts b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/index.ts index b444e813e8..cdb0e0759e 100644 --- a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/index.ts +++ b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/index.ts @@ -59,4 +59,6 @@ export { RoleAssignmentDetail, ListRoleAssignments, KnownVersions, + DeleteResponse, + DeleteDataResponse, } from "./models.js"; diff --git a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/models.ts b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/models.ts index f0cafaf338..70ec874bec 100644 --- a/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/models.ts +++ b/packages/typespec-test/test/NetworkAnalytics.Management/generated/typespec-ts/sdk/test/arm-test/src/models/models.ts @@ -1523,3 +1523,15 @@ export function _dataProductPropertiesDeserializer(item: any) { keyVaultUrl: item["keyVaultUrl"], }; } + +/** Defines headers for operation response. */ +export interface DeleteResponse { + location?: string; + retryAfter?: number; +} + +/** Defines headers for operation response. */ +export interface DeleteDataResponse { + location?: string; + retryAfter?: number; +} diff --git a/packages/typespec-test/test/ai/generated/typespec-ts/src/api/evaluations/operations.ts b/packages/typespec-test/test/ai/generated/typespec-ts/src/api/evaluations/operations.ts index 40ed3d06ea..bb2cb219ed 100644 --- a/packages/typespec-test/test/ai/generated/typespec-ts/src/api/evaluations/operations.ts +++ b/packages/typespec-test/test/ai/generated/typespec-ts/src/api/evaluations/operations.ts @@ -111,7 +111,7 @@ export async function _listScheduleDeserialize( throw createRestError(result); } - return _pagedEvaluationScheduleDeserializer(result.body); + return _pagedEvaluationScheduleDeserializer(result.body, result.headers); } /** Resource list operation template. */ @@ -324,7 +324,7 @@ export async function _listDeserialize(result: PathUncheckedResponse): Promise<_ throw createRestError(result); } - return _pagedEvaluationDeserializer(result.body); + return _pagedEvaluationDeserializer(result.body, result.headers); } /** Resource list operation template. */ diff --git a/packages/typespec-test/test/ai/generated/typespec-ts/src/models/models.ts b/packages/typespec-test/test/ai/generated/typespec-ts/src/models/models.ts index 0177dc63c5..df24290be5 100644 --- a/packages/typespec-test/test/ai/generated/typespec-ts/src/models/models.ts +++ b/packages/typespec-test/test/ai/generated/typespec-ts/src/models/models.ts @@ -477,12 +477,15 @@ export interface _PagedEvaluation { value: Evaluation[]; /** The link to the next page of items */ nextLink?: string; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; } -export function _pagedEvaluationDeserializer(item: any): _PagedEvaluation { +export function _pagedEvaluationDeserializer(item: any, headers?: any): _PagedEvaluation { return { value: evaluationArrayDeserializer(item["value"]), nextLink: item["nextLink"], + clientRequestId: headers?.["x-ms-client-request-id"], }; } @@ -723,12 +726,18 @@ export interface _PagedEvaluationSchedule { value: EvaluationSchedule[]; /** The link to the next page of items */ nextLink?: string; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; } -export function _pagedEvaluationScheduleDeserializer(item: any): _PagedEvaluationSchedule { +export function _pagedEvaluationScheduleDeserializer( + item: any, + headers?: any, +): _PagedEvaluationSchedule { return { value: evaluationScheduleArrayDeserializer(item["value"]), nextLink: item["nextLink"], + clientRequestId: headers?.["x-ms-client-request-id"], }; } diff --git a/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/review/ai-anomaly-detector.api.md b/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/review/ai-anomaly-detector.api.md index 23ac822a9b..1a0c126bfc 100644 --- a/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/review/ai-anomaly-detector.api.md +++ b/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/review/ai-anomaly-detector.api.md @@ -3,23 +3,26 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts - -import { ClientOptions } from '@azure-rest/core-client'; -import { KeyCredential } from '@azure/core-auth'; -import { OperationOptions } from '@azure-rest/core-client'; -import { Pipeline } from '@azure/core-rest-pipeline'; +import { ClientOptions } from "@azure-rest/core-client"; +import { KeyCredential } from "@azure/core-auth"; +import { OperationOptions } from "@azure-rest/core-client"; +import { Pipeline } from "@azure/core-rest-pipeline"; // @public (undocumented) export class AnomalyDetectorClient { - constructor(endpointParam: string, credential: KeyCredential, options?: AnomalyDetectorClientOptionalParams); - readonly multivariate: MultivariateOperations; - readonly pipeline: Pipeline; - readonly univariate: UnivariateOperations; + constructor( + endpointParam: string, + credential: KeyCredential, + options?: AnomalyDetectorClientOptionalParams, + ); + readonly multivariate: MultivariateOperations; + readonly pipeline: Pipeline; + readonly univariate: UnivariateOperations; } // @public export interface AnomalyDetectorClientOptionalParams extends ClientOptions { - apiVersion?: string; + apiVersion?: string; } // @public @@ -27,7 +30,7 @@ export type APIVersion = "v1.1"; // @public export type ContinuablePage = TPage & { - continuationToken?: string; + continuationToken?: string; }; // @public @@ -35,296 +38,368 @@ export type MultivariateAlignMode = "Inner" | "Outer"; // @public export interface MultivariateAlignPolicy { - alignMode?: MultivariateAlignMode; - fillNAMethod?: MultivariateFillNAMethod; - paddingValue?: number; + alignMode?: MultivariateAlignMode; + fillNAMethod?: MultivariateFillNAMethod; + paddingValue?: number; } // @public export interface MultivariateAnomalyDetectionModel { - createdTime: Date; - lastUpdatedTime: Date; - modelId: string; - modelInfo?: MultivariateModelInfo; + createdTime: Date; + lastUpdatedTime: Date; + modelId: string; + modelInfo?: MultivariateModelInfo; } // @public export interface MultivariateAnomalyInterpretation { - contributionScore?: number; - correlationChanges?: MultivariateCorrelationChanges; - variable?: string; + contributionScore?: number; + correlationChanges?: MultivariateCorrelationChanges; + variable?: string; } // @public export interface MultivariateAnomalyState { - errors?: MultivariateErrorResponse[]; - timestamp: Date; - value?: MultivariateAnomalyValue; + errors?: MultivariateErrorResponse[]; + timestamp: Date; + value?: MultivariateAnomalyValue; } // @public export interface MultivariateAnomalyValue { - interpretation?: MultivariateAnomalyInterpretation[]; - isAnomaly: boolean; - score: number; - severity: number; + interpretation?: MultivariateAnomalyInterpretation[]; + isAnomaly: boolean; + score: number; + severity: number; } // @public export interface MultivariateCorrelationChanges { - changedVariables?: string[]; + changedVariables?: string[]; } // @public export type MultivariateDataSchema = "OneTable" | "MultiTable"; // @public -export interface MultivariateDeleteMultivariateModelOptionalParams extends OperationOptions { -} +export interface MultivariateDeleteMultivariateModelOptionalParams extends OperationOptions {} // @public -export interface MultivariateDetectMultivariateBatchAnomalyOptionalParams extends OperationOptions { -} +export interface MultivariateDetectMultivariateBatchAnomalyOptionalParams extends OperationOptions {} // @public -export interface MultivariateDetectMultivariateLastAnomalyOptionalParams extends OperationOptions { -} +export interface MultivariateDetectMultivariateLastAnomalyOptionalParams extends OperationOptions {} // @public export interface MultivariateDiagnosticsInfo { - modelState?: MultivariateModelState; - variableStates?: MultivariateVariableState[]; + modelState?: MultivariateModelState; + variableStates?: MultivariateVariableState[]; } // @public export interface MultivariateErrorResponse { - code: string; - message: string; + code: string; + message: string; } // @public -export type MultivariateFillNAMethod = "Previous" | "Subsequent" | "Linear" | "Zero" | "Fixed"; +export type MultivariateFillNAMethod = + | "Previous" + | "Subsequent" + | "Linear" + | "Zero" + | "Fixed"; // @public -export interface MultivariateGetMultivariateBatchDetectionResultOptionalParams extends OperationOptions { -} +export interface MultivariateGetMultivariateBatchDetectionResultOptionalParams extends OperationOptions {} // @public -export interface MultivariateGetMultivariateModelOptionalParams extends OperationOptions { -} +export interface MultivariateGetMultivariateModelOptionalParams extends OperationOptions {} // @public export interface MultivariateListMultivariateModelsOptionalParams extends OperationOptions { - skip?: number; - top?: number; + skip?: number; + top?: number; } // @public export interface MultivariateModelInfo { - alignPolicy?: MultivariateAlignPolicy; - dataSchema?: MultivariateDataSchema; - dataSource: string; - readonly diagnosticsInfo?: MultivariateDiagnosticsInfo; - displayName?: string; - endTime: Date; - readonly errors?: MultivariateErrorResponse[]; - slidingWindow?: number; - startTime: Date; - readonly status?: MultivariateModelStatus; + alignPolicy?: MultivariateAlignPolicy; + dataSchema?: MultivariateDataSchema; + dataSource: string; + readonly diagnosticsInfo?: MultivariateDiagnosticsInfo; + displayName?: string; + endTime: Date; + readonly errors?: MultivariateErrorResponse[]; + slidingWindow?: number; + startTime: Date; + readonly status?: MultivariateModelStatus; } // @public export interface MultivariateModelState { - epochIds?: number[]; - latenciesInSeconds?: number[]; - trainLosses?: number[]; - validationLosses?: number[]; + epochIds?: number[]; + latenciesInSeconds?: number[]; + trainLosses?: number[]; + validationLosses?: number[]; } // @public -export type MultivariateModelStatus = "CREATED" | "RUNNING" | "READY" | "FAILED"; +export type MultivariateModelStatus = + | "CREATED" + | "RUNNING" + | "READY" + | "FAILED"; // @public export interface MultivariateMultivariateBatchDetectionOptions { - dataSource: string; - endTime: Date; - startTime: Date; - topContributorCount?: number; + dataSource: string; + endTime: Date; + startTime: Date; + topContributorCount?: number; } // @public export interface MultivariateMultivariateBatchDetectionResultSummary { - errors?: MultivariateErrorResponse[]; - setupInfo: MultivariateMultivariateBatchDetectionOptions; - status: MultivariateMultivariateBatchDetectionStatus; - variableStates?: MultivariateVariableState[]; + errors?: MultivariateErrorResponse[]; + setupInfo: MultivariateMultivariateBatchDetectionOptions; + status: MultivariateMultivariateBatchDetectionStatus; + variableStates?: MultivariateVariableState[]; } // @public -export type MultivariateMultivariateBatchDetectionStatus = "CREATED" | "RUNNING" | "READY" | "FAILED"; +export type MultivariateMultivariateBatchDetectionStatus = + | "CREATED" + | "RUNNING" + | "READY" + | "FAILED"; // @public export interface MultivariateMultivariateDetectionResult { - resultId: string; - results: MultivariateAnomalyState[]; - summary: MultivariateMultivariateBatchDetectionResultSummary; + resultId: string; + results: MultivariateAnomalyState[]; + summary: MultivariateMultivariateBatchDetectionResultSummary; } // @public export interface MultivariateMultivariateLastDetectionOptions { - topContributorCount?: number; - variables: MultivariateVariableValues[]; + topContributorCount?: number; + variables: MultivariateVariableValues[]; } // @public export interface MultivariateMultivariateLastDetectionResult { - results?: MultivariateAnomalyState[]; - variableStates?: MultivariateVariableState[]; + results?: MultivariateAnomalyState[]; + variableStates?: MultivariateVariableState[]; } // @public export interface MultivariateOperations { - deleteMultivariateModel: (modelId: string, options?: MultivariateDeleteMultivariateModelOptionalParams) => Promise; - detectMultivariateBatchAnomaly: (modelId: string, options: MultivariateMultivariateBatchDetectionOptions, optionalParams?: MultivariateDetectMultivariateBatchAnomalyOptionalParams) => Promise; - detectMultivariateLastAnomaly: (modelId: string, options: MultivariateMultivariateLastDetectionOptions, optionalParams?: MultivariateDetectMultivariateLastAnomalyOptionalParams) => Promise; - getMultivariateBatchDetectionResult: (resultId: string, options?: MultivariateGetMultivariateBatchDetectionResultOptionalParams) => Promise; - getMultivariateModel: (modelId: string, options?: MultivariateGetMultivariateModelOptionalParams) => Promise; - listMultivariateModels: (options?: MultivariateListMultivariateModelsOptionalParams) => PagedAsyncIterableIterator; - trainMultivariateModel: (modelInfo: MultivariateModelInfo, options?: MultivariateTrainMultivariateModelOptionalParams) => Promise; + deleteMultivariateModel: ( + modelId: string, + options?: MultivariateDeleteMultivariateModelOptionalParams, + ) => Promise; + detectMultivariateBatchAnomaly: ( + modelId: string, + options: MultivariateMultivariateBatchDetectionOptions, + optionalParams?: MultivariateDetectMultivariateBatchAnomalyOptionalParams, + ) => Promise; + detectMultivariateLastAnomaly: ( + modelId: string, + options: MultivariateMultivariateLastDetectionOptions, + optionalParams?: MultivariateDetectMultivariateLastAnomalyOptionalParams, + ) => Promise; + getMultivariateBatchDetectionResult: ( + resultId: string, + options?: MultivariateGetMultivariateBatchDetectionResultOptionalParams, + ) => Promise; + getMultivariateModel: ( + modelId: string, + options?: MultivariateGetMultivariateModelOptionalParams, + ) => Promise; + listMultivariateModels: ( + options?: MultivariateListMultivariateModelsOptionalParams, + ) => PagedAsyncIterableIterator; + trainMultivariateModel: ( + modelInfo: MultivariateModelInfo, + options?: MultivariateTrainMultivariateModelOptionalParams, + ) => Promise; } // @public export interface MultivariateResponseError { - code: string; - message: string; + code: string; + message: string; + msErrorCode?: string; } // @public -export interface MultivariateTrainMultivariateModelOptionalParams extends OperationOptions { -} +export interface MultivariateTrainMultivariateModelOptionalParams extends OperationOptions {} // @public export interface MultivariateVariableState { - effectiveCount?: number; - filledNARatio?: number; - firstTimestamp?: Date; - lastTimestamp?: Date; - variable?: string; + effectiveCount?: number; + filledNARatio?: number; + firstTimestamp?: Date; + lastTimestamp?: Date; + variable?: string; } // @public export interface MultivariateVariableValues { - timestamps: string[]; - values: number[]; - variable: string; + timestamps: string[]; + values: number[]; + variable: string; } // @public -export interface PagedAsyncIterableIterator { - [Symbol.asyncIterator](): PagedAsyncIterableIterator; - byPage: (settings?: TPageSettings) => AsyncIterableIterator>; - next(): Promise>; +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + byPage: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; + next(): Promise>; } // @public export interface PageSettings { - continuationToken?: string; + continuationToken?: string; } // @public export interface UnivariateAnomalyDetectorError { - code: UnivariateAnomalyDetectorErrorCodes; - message: string; + code: UnivariateAnomalyDetectorErrorCodes; + message: string; + msErrorCode: string; } // @public -export type UnivariateAnomalyDetectorErrorCodes = "InvalidCustomInterval" | "BadArgument" | "InvalidGranularity" | "InvalidPeriod" | "InvalidModelArgument" | "InvalidSeries" | "InvalidJsonFormat" | "RequiredGranularity" | "RequiredSeries" | "InvalidImputeMode" | "InvalidImputeFixedValue"; +export type UnivariateAnomalyDetectorErrorCodes = + | "InvalidCustomInterval" + | "BadArgument" + | "InvalidGranularity" + | "InvalidPeriod" + | "InvalidModelArgument" + | "InvalidSeries" + | "InvalidJsonFormat" + | "RequiredGranularity" + | "RequiredSeries" + | "InvalidImputeMode" + | "InvalidImputeFixedValue"; // @public -export interface UnivariateDetectUnivariateChangePointOptionalParams extends OperationOptions { -} +export interface UnivariateDetectUnivariateChangePointOptionalParams extends OperationOptions {} // @public -export interface UnivariateDetectUnivariateEntireSeriesOptionalParams extends OperationOptions { -} +export interface UnivariateDetectUnivariateEntireSeriesOptionalParams extends OperationOptions {} // @public -export interface UnivariateDetectUnivariateLastPointOptionalParams extends OperationOptions { -} +export interface UnivariateDetectUnivariateLastPointOptionalParams extends OperationOptions {} // @public -export type UnivariateImputeMode = "auto" | "previous" | "linear" | "fixed" | "zero" | "notFill"; +export type UnivariateImputeMode = + | "auto" + | "previous" + | "linear" + | "fixed" + | "zero" + | "notFill"; // @public export interface UnivariateOperations { - detectUnivariateChangePoint: (options: UnivariateUnivariateChangePointDetectionOptions, optionalParams?: UnivariateDetectUnivariateChangePointOptionalParams) => Promise; - detectUnivariateEntireSeries: (options: UnivariateUnivariateDetectionOptions, optionalParams?: UnivariateDetectUnivariateEntireSeriesOptionalParams) => Promise; - detectUnivariateLastPoint: (options: UnivariateUnivariateDetectionOptions, optionalParams?: UnivariateDetectUnivariateLastPointOptionalParams) => Promise; -} - -// @public -export type UnivariateTimeGranularity = "yearly" | "monthly" | "weekly" | "daily" | "hourly" | "minutely" | "secondly" | "microsecond" | "none"; + detectUnivariateChangePoint: ( + options: UnivariateUnivariateChangePointDetectionOptions, + optionalParams?: UnivariateDetectUnivariateChangePointOptionalParams, + ) => Promise; + detectUnivariateEntireSeries: ( + options: UnivariateUnivariateDetectionOptions, + optionalParams?: UnivariateDetectUnivariateEntireSeriesOptionalParams, + ) => Promise; + detectUnivariateLastPoint: ( + options: UnivariateUnivariateDetectionOptions, + optionalParams?: UnivariateDetectUnivariateLastPointOptionalParams, + ) => Promise; +} + +// @public +export type UnivariateTimeGranularity = + | "yearly" + | "monthly" + | "weekly" + | "daily" + | "hourly" + | "minutely" + | "secondly" + | "microsecond" + | "none"; // @public export interface UnivariateTimeSeriesPoint { - timestamp?: Date; - value: number; + timestamp?: Date; + value: number; } // @public export interface UnivariateUnivariateChangePointDetectionOptions { - customInterval?: number; - granularity: UnivariateTimeGranularity; - period?: number; - series: UnivariateTimeSeriesPoint[]; - stableTrendWindow?: number; - threshold?: number; + customInterval?: number; + granularity: UnivariateTimeGranularity; + period?: number; + series: UnivariateTimeSeriesPoint[]; + stableTrendWindow?: number; + threshold?: number; } // @public export interface UnivariateUnivariateChangePointDetectionResult { - confidenceScores?: number[]; - isChangePoint?: boolean[]; - readonly period?: number; + confidenceScores?: number[]; + isChangePoint?: boolean[]; + readonly period?: number; } // @public export interface UnivariateUnivariateDetectionOptions { - customInterval?: number; - granularity?: UnivariateTimeGranularity; - imputeFixedValue?: number; - imputeMode?: UnivariateImputeMode; - maxAnomalyRatio?: number; - period?: number; - sensitivity?: number; - series: UnivariateTimeSeriesPoint[]; + customInterval?: number; + granularity?: UnivariateTimeGranularity; + imputeFixedValue?: number; + imputeMode?: UnivariateImputeMode; + maxAnomalyRatio?: number; + period?: number; + sensitivity?: number; + series: UnivariateTimeSeriesPoint[]; } // @public export interface UnivariateUnivariateEntireDetectionResult { - expectedValues: number[]; - isAnomaly: boolean[]; - isNegativeAnomaly: boolean[]; - isPositiveAnomaly: boolean[]; - lowerMargins: number[]; - period: number; - severity?: number[]; - upperMargins: number[]; + expectedValues: number[]; + isAnomaly: boolean[]; + isNegativeAnomaly: boolean[]; + isPositiveAnomaly: boolean[]; + lowerMargins: number[]; + period: number; + severity?: number[]; + upperMargins: number[]; } // @public export interface UnivariateUnivariateLastDetectionResult { - expectedValue: number; - isAnomaly: boolean; - isNegativeAnomaly: boolean; - isPositiveAnomaly: boolean; - lowerMargin: number; - period: number; - severity?: number; - suggestedWindow: number; - upperMargin: number; + expectedValue: number; + isAnomaly: boolean; + isNegativeAnomaly: boolean; + isPositiveAnomaly: boolean; + lowerMargin: number; + period: number; + severity?: number; + suggestedWindow: number; + upperMargin: number; } // (No @packageDocumentation comment for this package) - ``` diff --git a/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/multivariate/models.ts b/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/multivariate/models.ts index 3e541a1950..35ab821c9a 100644 --- a/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/multivariate/models.ts +++ b/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/multivariate/models.ts @@ -278,16 +278,22 @@ export function multivariateCorrelationChangesDeserializer( /** Error response. */ export interface MultivariateResponseError { + /** Error code. */ + msErrorCode?: string; /** Error code. */ code: string; /** Message that explains the error that the service reported. */ message: string; } -export function multivariateResponseErrorDeserializer(item: any): MultivariateResponseError { +export function multivariateResponseErrorDeserializer( + item: any, + headers?: any, +): MultivariateResponseError { return { code: item["code"], message: item["message"], + msErrorCode: headers?.["x-ms-error-code"], }; } diff --git a/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/univariate/models.ts b/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/univariate/models.ts index 7dcf233a4a..403b71645d 100644 --- a/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/univariate/models.ts +++ b/packages/typespec-test/test/anomalyDetector/generated/typespec-ts/src/models/univariate/models.ts @@ -194,6 +194,8 @@ export function univariateUnivariateEntireDetectionResultDeserializer( /** Error information that the API returned. */ export interface UnivariateAnomalyDetectorError { + /** Error code. */ + msErrorCode: string; /** Error code. */ code: UnivariateAnomalyDetectorErrorCodes; /** Message that explains the error that the service reported. */ @@ -202,10 +204,12 @@ export interface UnivariateAnomalyDetectorError { export function univariateAnomalyDetectorErrorDeserializer( item: any, + headers?: any, ): UnivariateAnomalyDetectorError { return { code: item["code"], message: item["message"], + msErrorCode: headers?.["x-ms-error-code"], }; } diff --git a/packages/typespec-test/test/batch_modular/generated/typespec-ts/review/batch.api.md b/packages/typespec-test/test/batch_modular/generated/typespec-ts/review/batch.api.md index ba84f7b9c0..79cde0b7b3 100644 --- a/packages/typespec-test/test/batch_modular/generated/typespec-ts/review/batch.api.md +++ b/packages/typespec-test/test/batch_modular/generated/typespec-ts/review/batch.api.md @@ -3,18 +3,17 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts - -import { ClientOptions } from '@azure-rest/core-client'; -import { OperationOptions } from '@azure-rest/core-client'; -import { Pipeline } from '@azure/core-rest-pipeline'; -import { TokenCredential } from '@azure/core-auth'; +import { ClientOptions } from "@azure-rest/core-client"; +import { OperationOptions } from "@azure-rest/core-client"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; // @public export type AccessScope = "job"; // @public export interface AffinityInformation { - affinityId: string; + affinityId: string; } // @public @@ -22,35 +21,35 @@ export type AllocationState = "steady" | "resizing" | "stopping"; // @public export interface ApplicationPackageReference { - applicationId: string; - version?: string; + applicationId: string; + version?: string; } // @public export interface AuthenticationTokenSettings { - access?: AccessScope[]; + access?: AccessScope[]; } // @public export interface AutoPoolSpecification { - autoPoolIdPrefix?: string; - keepAlive?: boolean; - pool?: PoolSpecification; - poolLifetimeOption: PoolLifetimeOption; + autoPoolIdPrefix?: string; + keepAlive?: boolean; + pool?: PoolSpecification; + poolLifetimeOption: PoolLifetimeOption; } // @public export interface AutoScaleRun { - error?: AutoScaleRunError; - results?: string; - timestamp: Date; + error?: AutoScaleRunError; + results?: string; + timestamp: Date; } // @public export interface AutoScaleRunError { - code?: string; - message?: string; - values?: NameValuePair[]; + code?: string; + message?: string; + values?: NameValuePair[]; } // @public @@ -58,299 +57,577 @@ export type AutoUserScope = "task" | "pool"; // @public export interface AutoUserSpecification { - elevationLevel?: ElevationLevel; - scope?: AutoUserScope; + elevationLevel?: ElevationLevel; + scope?: AutoUserScope; } // @public export interface AzureBlobFileSystemConfiguration { - accountKey?: string; - accountName: string; - blobfuseOptions?: string; - containerName: string; - identityReference?: BatchNodeIdentityReference; - relativeMountPath: string; - sasKey?: string; + accountKey?: string; + accountName: string; + blobfuseOptions?: string; + containerName: string; + identityReference?: BatchNodeIdentityReference; + relativeMountPath: string; + sasKey?: string; } // @public export interface AzureFileShareConfiguration { - accountKey: string; - accountName: string; - azureFileUrl: string; - mountOptions?: string; - relativeMountPath: string; + accountKey: string; + accountName: string; + azureFileUrl: string; + mountOptions?: string; + relativeMountPath: string; } // @public export interface BatchApplication { - displayName: string; - id: string; - versions: string[]; + displayName: string; + id: string; + versions: string[]; } // @public export interface BatchCertificate { - certificateFormat?: CertificateFormat; - data: Uint8Array; - readonly deleteCertificateError?: DeleteCertificateError; - password?: string; - readonly previousState?: CertificateState; - readonly previousStateTransitionTime?: Date; - readonly publicData?: Uint8Array; - readonly state?: CertificateState; - readonly stateTransitionTime?: Date; - thumbprint: string; - thumbprintAlgorithm: string; - readonly url?: string; + certificateFormat?: CertificateFormat; + data: Uint8Array; + readonly deleteCertificateError?: DeleteCertificateError; + password?: string; + readonly previousState?: CertificateState; + readonly previousStateTransitionTime?: Date; + readonly publicData?: Uint8Array; + readonly state?: CertificateState; + readonly stateTransitionTime?: Date; + thumbprint: string; + thumbprintAlgorithm: string; + readonly url?: string; } // @public (undocumented) export class BatchClient { - constructor(endpointParam: string, credential: TokenCredential, options?: BatchClientOptionalParams); - cancelCertificateDeletion(thumbprintAlgorithm: string, thumbprint: string, options?: CancelCertificateDeletionOptionalParams): Promise; - createCertificate(body: BatchCertificate, options?: CreateCertificateOptionalParams): Promise; - createJob(body: BatchJobCreateOptions, options?: CreateJobOptionalParams): Promise; - createJobSchedule(body: BatchJobScheduleCreateOptions, options?: CreateJobScheduleOptionalParams): Promise; - createNodeUser(poolId: string, nodeId: string, body: BatchNodeUserCreateOptions, options?: CreateNodeUserOptionalParams): Promise; - createPool(body: BatchPoolCreateOptions, options?: CreatePoolOptionalParams): Promise; - createTask(jobId: string, body: BatchTaskCreateOptions, options?: CreateTaskOptionalParams): Promise; - createTaskCollection(jobId: string, collection: BatchTaskCollection, options?: CreateTaskCollectionOptionalParams): Promise; - deleteCertificate(thumbprintAlgorithm: string, thumbprint: string, options?: DeleteCertificateOptionalParams): Promise; - deleteJob(jobId: string, options?: DeleteJobOptionalParams): Promise; - deleteJobSchedule(jobScheduleId: string, options?: DeleteJobScheduleOptionalParams): Promise; - deleteNodeFile(poolId: string, nodeId: string, filePath: string, options?: DeleteNodeFileOptionalParams): Promise; - deleteNodeUser(poolId: string, nodeId: string, userName: string, options?: DeleteNodeUserOptionalParams): Promise; - deletePool(poolId: string, options?: DeletePoolOptionalParams): Promise; - deleteTask(jobId: string, taskId: string, options?: DeleteTaskOptionalParams): Promise; - deleteTaskFile(jobId: string, taskId: string, filePath: string, options?: DeleteTaskFileOptionalParams): Promise; - disableJob(jobId: string, body: BatchJobDisableOptions, options?: DisableJobOptionalParams): Promise; - disableJobSchedule(jobScheduleId: string, options?: DisableJobScheduleOptionalParams): Promise; - disableNodeScheduling(poolId: string, nodeId: string, options?: DisableNodeSchedulingOptionalParams): Promise; - disablePoolAutoScale(poolId: string, options?: DisablePoolAutoScaleOptionalParams): Promise; - enableJob(jobId: string, options?: EnableJobOptionalParams): Promise; - enableJobSchedule(jobScheduleId: string, options?: EnableJobScheduleOptionalParams): Promise; - enableNodeScheduling(poolId: string, nodeId: string, options?: EnableNodeSchedulingOptionalParams): Promise; - enablePoolAutoScale(poolId: string, body: BatchPoolEnableAutoScaleOptions, options?: EnablePoolAutoScaleOptionalParams): Promise; - evaluatePoolAutoScale(poolId: string, body: BatchPoolEvaluateAutoScaleOptions, options?: EvaluatePoolAutoScaleOptionalParams): Promise; - getApplication(applicationId: string, options?: GetApplicationOptionalParams): Promise; - getCertificate(thumbprintAlgorithm: string, thumbprint: string, options?: GetCertificateOptionalParams): Promise; - getJob(jobId: string, options?: GetJobOptionalParams): Promise; - getJobSchedule(jobScheduleId: string, options?: GetJobScheduleOptionalParams): Promise; - getJobTaskCounts(jobId: string, options?: GetJobTaskCountsOptionalParams): Promise; - getNode(poolId: string, nodeId: string, options?: GetNodeOptionalParams): Promise; - getNodeExtension(poolId: string, nodeId: string, extensionName: string, options?: GetNodeExtensionOptionalParams): Promise; - getNodeFile(poolId: string, nodeId: string, filePath: string, options?: GetNodeFileOptionalParams): Promise; - getNodeFileProperties(poolId: string, nodeId: string, filePath: string, options?: GetNodeFilePropertiesOptionalParams): Promise; - getNodeRemoteDesktopFile(poolId: string, nodeId: string, options?: GetNodeRemoteDesktopFileOptionalParams): Promise; - getNodeRemoteLoginSettings(poolId: string, nodeId: string, options?: GetNodeRemoteLoginSettingsOptionalParams): Promise; - getPool(poolId: string, options?: GetPoolOptionalParams): Promise; - getTask(jobId: string, taskId: string, options?: GetTaskOptionalParams): Promise; - getTaskFile(jobId: string, taskId: string, filePath: string, options?: GetTaskFileOptionalParams): Promise; - getTaskFileProperties(jobId: string, taskId: string, filePath: string, options?: GetTaskFilePropertiesOptionalParams): Promise; - jobScheduleExists(jobScheduleId: string, options?: JobScheduleExistsOptionalParams): Promise; - listApplications(options?: ListApplicationsOptionalParams): PagedAsyncIterableIterator; - listCertificates(options?: ListCertificatesOptionalParams): PagedAsyncIterableIterator; - listJobPreparationAndReleaseTaskStatus(jobId: string, options?: ListJobPreparationAndReleaseTaskStatusOptionalParams): PagedAsyncIterableIterator; - listJobs(options?: ListJobsOptionalParams): PagedAsyncIterableIterator; - listJobSchedules(options?: ListJobSchedulesOptionalParams): PagedAsyncIterableIterator; - listJobsFromSchedule(jobScheduleId: string, options?: ListJobsFromScheduleOptionalParams): PagedAsyncIterableIterator; - listNodeExtensions(poolId: string, nodeId: string, options?: ListNodeExtensionsOptionalParams): PagedAsyncIterableIterator; - listNodeFiles(poolId: string, nodeId: string, options?: ListNodeFilesOptionalParams): PagedAsyncIterableIterator; - listNodes(poolId: string, options?: ListNodesOptionalParams): PagedAsyncIterableIterator; - listPoolNodeCounts(options?: ListPoolNodeCountsOptionalParams): PagedAsyncIterableIterator; - listPools(options?: ListPoolsOptionalParams): PagedAsyncIterableIterator; - listPoolUsageMetrics(options?: ListPoolUsageMetricsOptionalParams): PagedAsyncIterableIterator; - listSubTasks(jobId: string, taskId: string, options?: ListSubTasksOptionalParams): Promise; - listSupportedImages(options?: ListSupportedImagesOptionalParams): PagedAsyncIterableIterator; - listTaskFiles(jobId: string, taskId: string, options?: ListTaskFilesOptionalParams): PagedAsyncIterableIterator; - listTasks(jobId: string, options?: ListTasksOptionalParams): PagedAsyncIterableIterator; - readonly pipeline: Pipeline; - poolExists(poolId: string, options?: PoolExistsOptionalParams): Promise; - reactivateTask(jobId: string, taskId: string, options?: ReactivateTaskOptionalParams): Promise; - rebootNode(poolId: string, nodeId: string, options?: RebootNodeOptionalParams): Promise; - reimageNode(poolId: string, nodeId: string, options?: ReimageNodeOptionalParams): Promise; - removeNodes(poolId: string, body: NodeRemoveOptions, options?: RemoveNodesOptionalParams): Promise; - replaceJob(jobId: string, body: BatchJob, options?: ReplaceJobOptionalParams): Promise; - replaceJobSchedule(jobScheduleId: string, body: BatchJobSchedule, options?: ReplaceJobScheduleOptionalParams): Promise; - replaceNodeUser(poolId: string, nodeId: string, userName: string, body: BatchNodeUserUpdateOptions, options?: ReplaceNodeUserOptionalParams): Promise; - replacePoolProperties(poolId: string, body: BatchPoolReplaceOptions, options?: ReplacePoolPropertiesOptionalParams): Promise; - replaceTask(jobId: string, taskId: string, body: BatchTask, options?: ReplaceTaskOptionalParams): Promise; - resizePool(poolId: string, body: BatchPoolResizeOptions, options?: ResizePoolOptionalParams): Promise; - stopPoolResize(poolId: string, options?: StopPoolResizeOptionalParams): Promise; - terminateJob(jobId: string, options?: TerminateJobOptionalParams): Promise; - terminateJobSchedule(jobScheduleId: string, options?: TerminateJobScheduleOptionalParams): Promise; - terminateTask(jobId: string, taskId: string, options?: TerminateTaskOptionalParams): Promise; - updateJob(jobId: string, body: BatchJobUpdateOptions, options?: UpdateJobOptionalParams): Promise; - updateJobSchedule(jobScheduleId: string, body: BatchJobScheduleUpdateOptions, options?: UpdateJobScheduleOptionalParams): Promise; - updatePool(poolId: string, body: BatchPoolUpdateOptions, options?: UpdatePoolOptionalParams): Promise; - uploadNodeLogs(poolId: string, nodeId: string, body: UploadBatchServiceLogsOptions, options?: UploadNodeLogsOptionalParams): Promise; + constructor( + endpointParam: string, + credential: TokenCredential, + options?: BatchClientOptionalParams, + ); + cancelCertificateDeletion( + thumbprintAlgorithm: string, + thumbprint: string, + options?: CancelCertificateDeletionOptionalParams, + ): Promise; + createCertificate( + body: BatchCertificate, + options?: CreateCertificateOptionalParams, + ): Promise; + createJob( + body: BatchJobCreateOptions, + options?: CreateJobOptionalParams, + ): Promise; + createJobSchedule( + body: BatchJobScheduleCreateOptions, + options?: CreateJobScheduleOptionalParams, + ): Promise; + createNodeUser( + poolId: string, + nodeId: string, + body: BatchNodeUserCreateOptions, + options?: CreateNodeUserOptionalParams, + ): Promise; + createPool( + body: BatchPoolCreateOptions, + options?: CreatePoolOptionalParams, + ): Promise; + createTask( + jobId: string, + body: BatchTaskCreateOptions, + options?: CreateTaskOptionalParams, + ): Promise; + createTaskCollection( + jobId: string, + collection: BatchTaskCollection, + options?: CreateTaskCollectionOptionalParams, + ): Promise; + deleteCertificate( + thumbprintAlgorithm: string, + thumbprint: string, + options?: DeleteCertificateOptionalParams, + ): Promise; + deleteJob( + jobId: string, + options?: DeleteJobOptionalParams, + ): Promise; + deleteJobSchedule( + jobScheduleId: string, + options?: DeleteJobScheduleOptionalParams, + ): Promise; + deleteNodeFile( + poolId: string, + nodeId: string, + filePath: string, + options?: DeleteNodeFileOptionalParams, + ): Promise; + deleteNodeUser( + poolId: string, + nodeId: string, + userName: string, + options?: DeleteNodeUserOptionalParams, + ): Promise; + deletePool( + poolId: string, + options?: DeletePoolOptionalParams, + ): Promise; + deleteTask( + jobId: string, + taskId: string, + options?: DeleteTaskOptionalParams, + ): Promise; + deleteTaskFile( + jobId: string, + taskId: string, + filePath: string, + options?: DeleteTaskFileOptionalParams, + ): Promise; + disableJob( + jobId: string, + body: BatchJobDisableOptions, + options?: DisableJobOptionalParams, + ): Promise; + disableJobSchedule( + jobScheduleId: string, + options?: DisableJobScheduleOptionalParams, + ): Promise; + disableNodeScheduling( + poolId: string, + nodeId: string, + options?: DisableNodeSchedulingOptionalParams, + ): Promise; + disablePoolAutoScale( + poolId: string, + options?: DisablePoolAutoScaleOptionalParams, + ): Promise; + enableJob( + jobId: string, + options?: EnableJobOptionalParams, + ): Promise; + enableJobSchedule( + jobScheduleId: string, + options?: EnableJobScheduleOptionalParams, + ): Promise; + enableNodeScheduling( + poolId: string, + nodeId: string, + options?: EnableNodeSchedulingOptionalParams, + ): Promise; + enablePoolAutoScale( + poolId: string, + body: BatchPoolEnableAutoScaleOptions, + options?: EnablePoolAutoScaleOptionalParams, + ): Promise; + evaluatePoolAutoScale( + poolId: string, + body: BatchPoolEvaluateAutoScaleOptions, + options?: EvaluatePoolAutoScaleOptionalParams, + ): Promise; + getApplication( + applicationId: string, + options?: GetApplicationOptionalParams, + ): Promise; + getCertificate( + thumbprintAlgorithm: string, + thumbprint: string, + options?: GetCertificateOptionalParams, + ): Promise; + getJob(jobId: string, options?: GetJobOptionalParams): Promise; + getJobSchedule( + jobScheduleId: string, + options?: GetJobScheduleOptionalParams, + ): Promise; + getJobTaskCounts( + jobId: string, + options?: GetJobTaskCountsOptionalParams, + ): Promise; + getNode( + poolId: string, + nodeId: string, + options?: GetNodeOptionalParams, + ): Promise; + getNodeExtension( + poolId: string, + nodeId: string, + extensionName: string, + options?: GetNodeExtensionOptionalParams, + ): Promise; + getNodeFile( + poolId: string, + nodeId: string, + filePath: string, + options?: GetNodeFileOptionalParams, + ): Promise; + getNodeFileProperties( + poolId: string, + nodeId: string, + filePath: string, + options?: GetNodeFilePropertiesOptionalParams, + ): Promise; + getNodeRemoteDesktopFile( + poolId: string, + nodeId: string, + options?: GetNodeRemoteDesktopFileOptionalParams, + ): Promise; + getNodeRemoteLoginSettings( + poolId: string, + nodeId: string, + options?: GetNodeRemoteLoginSettingsOptionalParams, + ): Promise; + getPool(poolId: string, options?: GetPoolOptionalParams): Promise; + getTask( + jobId: string, + taskId: string, + options?: GetTaskOptionalParams, + ): Promise; + getTaskFile( + jobId: string, + taskId: string, + filePath: string, + options?: GetTaskFileOptionalParams, + ): Promise; + getTaskFileProperties( + jobId: string, + taskId: string, + filePath: string, + options?: GetTaskFilePropertiesOptionalParams, + ): Promise; + jobScheduleExists( + jobScheduleId: string, + options?: JobScheduleExistsOptionalParams, + ): Promise; + listApplications( + options?: ListApplicationsOptionalParams, + ): PagedAsyncIterableIterator; + listCertificates( + options?: ListCertificatesOptionalParams, + ): PagedAsyncIterableIterator; + listJobPreparationAndReleaseTaskStatus( + jobId: string, + options?: ListJobPreparationAndReleaseTaskStatusOptionalParams, + ): PagedAsyncIterableIterator; + listJobs( + options?: ListJobsOptionalParams, + ): PagedAsyncIterableIterator; + listJobSchedules( + options?: ListJobSchedulesOptionalParams, + ): PagedAsyncIterableIterator; + listJobsFromSchedule( + jobScheduleId: string, + options?: ListJobsFromScheduleOptionalParams, + ): PagedAsyncIterableIterator; + listNodeExtensions( + poolId: string, + nodeId: string, + options?: ListNodeExtensionsOptionalParams, + ): PagedAsyncIterableIterator; + listNodeFiles( + poolId: string, + nodeId: string, + options?: ListNodeFilesOptionalParams, + ): PagedAsyncIterableIterator; + listNodes( + poolId: string, + options?: ListNodesOptionalParams, + ): PagedAsyncIterableIterator; + listPoolNodeCounts( + options?: ListPoolNodeCountsOptionalParams, + ): PagedAsyncIterableIterator; + listPools( + options?: ListPoolsOptionalParams, + ): PagedAsyncIterableIterator; + listPoolUsageMetrics( + options?: ListPoolUsageMetricsOptionalParams, + ): PagedAsyncIterableIterator; + listSubTasks( + jobId: string, + taskId: string, + options?: ListSubTasksOptionalParams, + ): Promise; + listSupportedImages( + options?: ListSupportedImagesOptionalParams, + ): PagedAsyncIterableIterator; + listTaskFiles( + jobId: string, + taskId: string, + options?: ListTaskFilesOptionalParams, + ): PagedAsyncIterableIterator; + listTasks( + jobId: string, + options?: ListTasksOptionalParams, + ): PagedAsyncIterableIterator; + readonly pipeline: Pipeline; + poolExists( + poolId: string, + options?: PoolExistsOptionalParams, + ): Promise; + reactivateTask( + jobId: string, + taskId: string, + options?: ReactivateTaskOptionalParams, + ): Promise; + rebootNode( + poolId: string, + nodeId: string, + options?: RebootNodeOptionalParams, + ): Promise; + reimageNode( + poolId: string, + nodeId: string, + options?: ReimageNodeOptionalParams, + ): Promise; + removeNodes( + poolId: string, + body: NodeRemoveOptions, + options?: RemoveNodesOptionalParams, + ): Promise; + replaceJob( + jobId: string, + body: BatchJob, + options?: ReplaceJobOptionalParams, + ): Promise; + replaceJobSchedule( + jobScheduleId: string, + body: BatchJobSchedule, + options?: ReplaceJobScheduleOptionalParams, + ): Promise; + replaceNodeUser( + poolId: string, + nodeId: string, + userName: string, + body: BatchNodeUserUpdateOptions, + options?: ReplaceNodeUserOptionalParams, + ): Promise; + replacePoolProperties( + poolId: string, + body: BatchPoolReplaceOptions, + options?: ReplacePoolPropertiesOptionalParams, + ): Promise; + replaceTask( + jobId: string, + taskId: string, + body: BatchTask, + options?: ReplaceTaskOptionalParams, + ): Promise; + resizePool( + poolId: string, + body: BatchPoolResizeOptions, + options?: ResizePoolOptionalParams, + ): Promise; + stopPoolResize( + poolId: string, + options?: StopPoolResizeOptionalParams, + ): Promise; + terminateJob( + jobId: string, + options?: TerminateJobOptionalParams, + ): Promise; + terminateJobSchedule( + jobScheduleId: string, + options?: TerminateJobScheduleOptionalParams, + ): Promise; + terminateTask( + jobId: string, + taskId: string, + options?: TerminateTaskOptionalParams, + ): Promise; + updateJob( + jobId: string, + body: BatchJobUpdateOptions, + options?: UpdateJobOptionalParams, + ): Promise; + updateJobSchedule( + jobScheduleId: string, + body: BatchJobScheduleUpdateOptions, + options?: UpdateJobScheduleOptionalParams, + ): Promise; + updatePool( + poolId: string, + body: BatchPoolUpdateOptions, + options?: UpdatePoolOptionalParams, + ): Promise; + uploadNodeLogs( + poolId: string, + nodeId: string, + body: UploadBatchServiceLogsOptions, + options?: UploadNodeLogsOptionalParams, + ): Promise; } // @public export interface BatchClientOptionalParams extends ClientOptions { - apiVersion?: string; + apiVersion?: string; } // @public export interface BatchError { - code: string; - message?: ErrorMessage; - values?: BatchErrorDetail[]; + code: string; + message?: ErrorMessage; + values?: BatchErrorDetail[]; } // @public export interface BatchErrorDetail { - key?: string; - value?: string; + key?: string; + value?: string; } // @public export interface BatchJob { - allowTaskPreemption?: boolean; - readonly commonEnvironmentSettings?: EnvironmentSetting[]; - constraints?: JobConstraints; - readonly creationTime?: Date; - readonly displayName?: string; - readonly eTag?: string; - readonly executionInfo?: JobExecutionInformation; - readonly id?: string; - readonly jobManagerTask?: JobManagerTask; - readonly jobPreparationTask?: JobPreparationTask; - readonly jobReleaseTask?: JobReleaseTask; - readonly lastModified?: Date; - maxParallelTasks?: number; - metadata?: MetadataItem[]; - readonly networkConfiguration?: JobNetworkConfiguration; - onAllTasksComplete?: OnAllTasksComplete; - readonly onTaskFailure?: OnTaskFailure; - poolInfo: PoolInformation; - readonly previousState?: JobState; - readonly previousStateTransitionTime?: Date; - priority?: number; - readonly state?: JobState; - readonly stateTransitionTime?: Date; - readonly stats?: JobStatistics; - readonly url?: string; - readonly usesTaskDependencies?: boolean; + allowTaskPreemption?: boolean; + readonly commonEnvironmentSettings?: EnvironmentSetting[]; + constraints?: JobConstraints; + readonly creationTime?: Date; + readonly displayName?: string; + readonly eTag?: string; + readonly executionInfo?: JobExecutionInformation; + readonly id?: string; + readonly jobManagerTask?: JobManagerTask; + readonly jobPreparationTask?: JobPreparationTask; + readonly jobReleaseTask?: JobReleaseTask; + readonly lastModified?: Date; + maxParallelTasks?: number; + metadata?: MetadataItem[]; + readonly networkConfiguration?: JobNetworkConfiguration; + onAllTasksComplete?: OnAllTasksComplete; + readonly onTaskFailure?: OnTaskFailure; + poolInfo: PoolInformation; + readonly previousState?: JobState; + readonly previousStateTransitionTime?: Date; + priority?: number; + readonly state?: JobState; + readonly stateTransitionTime?: Date; + readonly stats?: JobStatistics; + readonly url?: string; + readonly usesTaskDependencies?: boolean; } // @public export interface BatchJobCreateOptions { - allowTaskPreemption?: boolean; - commonEnvironmentSettings?: EnvironmentSetting[]; - constraints?: JobConstraints; - displayName?: string; - id: string; - jobManagerTask?: JobManagerTask; - jobPreparationTask?: JobPreparationTask; - jobReleaseTask?: JobReleaseTask; - maxParallelTasks?: number; - metadata?: MetadataItem[]; - networkConfiguration?: JobNetworkConfiguration; - onAllTasksComplete?: OnAllTasksComplete; - onTaskFailure?: OnTaskFailure; - poolInfo: PoolInformation; - priority?: number; - usesTaskDependencies?: boolean; + allowTaskPreemption?: boolean; + commonEnvironmentSettings?: EnvironmentSetting[]; + constraints?: JobConstraints; + displayName?: string; + id: string; + jobManagerTask?: JobManagerTask; + jobPreparationTask?: JobPreparationTask; + jobReleaseTask?: JobReleaseTask; + maxParallelTasks?: number; + metadata?: MetadataItem[]; + networkConfiguration?: JobNetworkConfiguration; + onAllTasksComplete?: OnAllTasksComplete; + onTaskFailure?: OnTaskFailure; + poolInfo: PoolInformation; + priority?: number; + usesTaskDependencies?: boolean; } // @public export interface BatchJobDisableOptions { - disableTasks: DisableJobOption; + disableTasks: DisableJobOption; } // @public export interface BatchJobSchedule { - readonly creationTime?: Date; - readonly displayName?: string; - readonly eTag?: string; - readonly executionInfo?: JobScheduleExecutionInformation; - readonly id?: string; - jobSpecification: JobSpecification; - readonly lastModified?: Date; - metadata?: MetadataItem[]; - readonly previousState?: JobScheduleState; - readonly previousStateTransitionTime?: Date; - schedule: Schedule; - readonly state?: JobScheduleState; - readonly stateTransitionTime?: Date; - readonly stats?: JobScheduleStatistics; - readonly url?: string; + readonly creationTime?: Date; + readonly displayName?: string; + readonly eTag?: string; + readonly executionInfo?: JobScheduleExecutionInformation; + readonly id?: string; + jobSpecification: JobSpecification; + readonly lastModified?: Date; + metadata?: MetadataItem[]; + readonly previousState?: JobScheduleState; + readonly previousStateTransitionTime?: Date; + schedule: Schedule; + readonly state?: JobScheduleState; + readonly stateTransitionTime?: Date; + readonly stats?: JobScheduleStatistics; + readonly url?: string; } // @public export interface BatchJobScheduleCreateOptions { - displayName?: string; - id: string; - jobSpecification: JobSpecification; - metadata?: MetadataItem[]; - schedule: Schedule; + displayName?: string; + id: string; + jobSpecification: JobSpecification; + metadata?: MetadataItem[]; + schedule: Schedule; } // @public export interface BatchJobScheduleUpdateOptions { - jobSpecification?: JobSpecification; - metadata?: MetadataItem[]; - schedule?: Schedule; + jobSpecification?: JobSpecification; + metadata?: MetadataItem[]; + schedule?: Schedule; } // @public export interface BatchJobTerminateOptions { - terminateReason?: string; + terminateReason?: string; } // @public export interface BatchJobUpdateOptions { - allowTaskPreemption?: boolean; - constraints?: JobConstraints; - maxParallelTasks?: number; - metadata?: MetadataItem[]; - onAllTasksComplete?: OnAllTasksComplete; - poolInfo?: PoolInformation; - priority?: number; + allowTaskPreemption?: boolean; + constraints?: JobConstraints; + maxParallelTasks?: number; + metadata?: MetadataItem[]; + onAllTasksComplete?: OnAllTasksComplete; + poolInfo?: PoolInformation; + priority?: number; } // @public export interface BatchNode { - affinityId?: string; - allocationTime?: Date; - certificateReferences?: CertificateReference[]; - endpointConfiguration?: BatchNodeEndpointConfiguration; - errors?: BatchNodeError[]; - id?: string; - ipAddress?: string; - isDedicated?: boolean; - lastBootTime?: Date; - nodeAgentInfo?: NodeAgentInformation; - recentTasks?: TaskInformation[]; - runningTasksCount?: number; - runningTaskSlotsCount?: number; - schedulingState?: SchedulingState; - startTask?: StartTask; - startTaskInfo?: StartTaskInformation; - state?: BatchNodeState; - stateTransitionTime?: Date; - totalTasksRun?: number; - totalTasksSucceeded?: number; - url?: string; - virtualMachineInfo?: VirtualMachineInfo; - vmSize?: string; -} - -// @public -export type BatchNodeDeallocationOption = "requeue" | "terminate" | "taskcompletion" | "retaineddata"; + affinityId?: string; + allocationTime?: Date; + certificateReferences?: CertificateReference[]; + endpointConfiguration?: BatchNodeEndpointConfiguration; + errors?: BatchNodeError[]; + id?: string; + ipAddress?: string; + isDedicated?: boolean; + lastBootTime?: Date; + nodeAgentInfo?: NodeAgentInformation; + recentTasks?: TaskInformation[]; + runningTasksCount?: number; + runningTaskSlotsCount?: number; + schedulingState?: SchedulingState; + startTask?: StartTask; + startTaskInfo?: StartTaskInformation; + state?: BatchNodeState; + stateTransitionTime?: Date; + totalTasksRun?: number; + totalTasksSucceeded?: number; + url?: string; + virtualMachineInfo?: VirtualMachineInfo; + vmSize?: string; +} + +// @public +export type BatchNodeDeallocationOption = + | "requeue" + | "terminate" + | "taskcompletion" + | "retaineddata"; // @public export interface BatchNodeEndpointConfiguration { - inboundEndpoints: InboundEndpoint[]; + inboundEndpoints: InboundEndpoint[]; } // @public export interface BatchNodeError { - code?: string; - errorDetails?: NameValuePair[]; - message?: string; + code?: string; + errorDetails?: NameValuePair[]; + message?: string; } // @public @@ -358,221 +635,242 @@ export type BatchNodeFillType = "spread" | "pack"; // @public export interface BatchNodeIdentityReference { - resourceId?: string; + resourceId?: string; } // @public export interface BatchNodeInformation { - affinityId?: string; - nodeId?: string; - nodeUrl?: string; - poolId?: string; - taskRootDirectory?: string; - taskRootDirectoryUrl?: string; + affinityId?: string; + nodeId?: string; + nodeUrl?: string; + poolId?: string; + taskRootDirectory?: string; + taskRootDirectoryUrl?: string; } // @public -export type BatchNodeRebootOption = "requeue" | "terminate" | "taskcompletion" | "retaineddata"; +export type BatchNodeRebootOption = + | "requeue" + | "terminate" + | "taskcompletion" + | "retaineddata"; // @public -export type BatchNodeReimageOption = "requeue" | "terminate" | "taskcompletion" | "retaineddata"; +export type BatchNodeReimageOption = + | "requeue" + | "terminate" + | "taskcompletion" + | "retaineddata"; // @public export interface BatchNodeRemoteLoginSettingsResult { - remoteLoginIpAddress: string; - remoteLoginPort: number; + remoteLoginIpAddress: string; + remoteLoginPort: number; } // @public -export type BatchNodeState = "idle" | "rebooting" | "reimaging" | "running" | "unusable" | "creating" | "starting" | "waitingforstarttask" | "starttaskfailed" | "unknown" | "leavingpool" | "offline" | "preempted"; +export type BatchNodeState = + | "idle" + | "rebooting" + | "reimaging" + | "running" + | "unusable" + | "creating" + | "starting" + | "waitingforstarttask" + | "starttaskfailed" + | "unknown" + | "leavingpool" + | "offline" + | "preempted"; // @public export interface BatchNodeUserCreateOptions { - expiryTime?: Date; - isAdmin?: boolean; - name: string; - password?: string; - sshPublicKey?: string; + expiryTime?: Date; + isAdmin?: boolean; + name: string; + password?: string; + sshPublicKey?: string; } // @public export interface BatchNodeUserUpdateOptions { - expiryTime?: Date; - password?: string; - sshPublicKey?: string; + expiryTime?: Date; + password?: string; + sshPublicKey?: string; } // @public export interface BatchPool { - readonly allocationState?: AllocationState; - readonly allocationStateTransitionTime?: Date; - readonly applicationLicenses?: string[]; - readonly applicationPackageReferences?: ApplicationPackageReference[]; - readonly autoScaleEvaluationInterval?: string; - readonly autoScaleFormula?: string; - readonly autoScaleRun?: AutoScaleRun; - readonly certificateReferences?: CertificateReference[]; - readonly cloudServiceConfiguration?: CloudServiceConfiguration; - readonly creationTime?: Date; - readonly currentDedicatedNodes?: number; - readonly currentLowPriorityNodes?: number; - readonly currentNodeCommunicationMode?: NodeCommunicationMode; - readonly displayName?: string; - readonly enableAutoScale?: boolean; - readonly enableInterNodeCommunication?: boolean; - readonly eTag?: string; - readonly id?: string; - readonly identity?: BatchPoolIdentity; - readonly lastModified?: Date; - readonly metadata?: MetadataItem[]; - readonly mountConfiguration?: MountConfiguration[]; - readonly networkConfiguration?: NetworkConfiguration; - readonly resizeErrors?: ResizeError[]; - readonly resizeTimeout?: string; - startTask?: StartTask; - readonly state?: PoolState; - readonly stateTransitionTime?: Date; - readonly stats?: PoolStatistics; - readonly targetDedicatedNodes?: number; - readonly targetLowPriorityNodes?: number; - targetNodeCommunicationMode?: NodeCommunicationMode; - readonly taskSchedulingPolicy?: TaskSchedulingPolicy; - readonly taskSlotsPerNode?: number; - readonly url?: string; - readonly userAccounts?: UserAccount[]; - readonly virtualMachineConfiguration?: VirtualMachineConfiguration; - readonly vmSize?: string; + readonly allocationState?: AllocationState; + readonly allocationStateTransitionTime?: Date; + readonly applicationLicenses?: string[]; + readonly applicationPackageReferences?: ApplicationPackageReference[]; + readonly autoScaleEvaluationInterval?: string; + readonly autoScaleFormula?: string; + readonly autoScaleRun?: AutoScaleRun; + readonly certificateReferences?: CertificateReference[]; + readonly cloudServiceConfiguration?: CloudServiceConfiguration; + readonly creationTime?: Date; + readonly currentDedicatedNodes?: number; + readonly currentLowPriorityNodes?: number; + readonly currentNodeCommunicationMode?: NodeCommunicationMode; + readonly displayName?: string; + readonly enableAutoScale?: boolean; + readonly enableInterNodeCommunication?: boolean; + readonly eTag?: string; + readonly id?: string; + readonly identity?: BatchPoolIdentity; + readonly lastModified?: Date; + readonly metadata?: MetadataItem[]; + readonly mountConfiguration?: MountConfiguration[]; + readonly networkConfiguration?: NetworkConfiguration; + readonly resizeErrors?: ResizeError[]; + readonly resizeTimeout?: string; + startTask?: StartTask; + readonly state?: PoolState; + readonly stateTransitionTime?: Date; + readonly stats?: PoolStatistics; + readonly targetDedicatedNodes?: number; + readonly targetLowPriorityNodes?: number; + targetNodeCommunicationMode?: NodeCommunicationMode; + readonly taskSchedulingPolicy?: TaskSchedulingPolicy; + readonly taskSlotsPerNode?: number; + readonly url?: string; + readonly userAccounts?: UserAccount[]; + readonly virtualMachineConfiguration?: VirtualMachineConfiguration; + readonly vmSize?: string; } // @public export interface BatchPoolCreateOptions { - applicationLicenses?: string[]; - applicationPackageReferences?: ApplicationPackageReference[]; - autoScaleEvaluationInterval?: string; - autoScaleFormula?: string; - certificateReferences?: CertificateReference[]; - cloudServiceConfiguration?: CloudServiceConfiguration; - displayName?: string; - enableAutoScale?: boolean; - enableInterNodeCommunication?: boolean; - id: string; - metadata?: MetadataItem[]; - mountConfiguration?: MountConfiguration[]; - networkConfiguration?: NetworkConfiguration; - resizeTimeout?: string; - startTask?: StartTask; - targetDedicatedNodes?: number; - targetLowPriorityNodes?: number; - targetNodeCommunicationMode?: NodeCommunicationMode; - taskSchedulingPolicy?: TaskSchedulingPolicy; - taskSlotsPerNode?: number; - userAccounts?: UserAccount[]; - virtualMachineConfiguration?: VirtualMachineConfiguration; - vmSize: string; + applicationLicenses?: string[]; + applicationPackageReferences?: ApplicationPackageReference[]; + autoScaleEvaluationInterval?: string; + autoScaleFormula?: string; + certificateReferences?: CertificateReference[]; + cloudServiceConfiguration?: CloudServiceConfiguration; + displayName?: string; + enableAutoScale?: boolean; + enableInterNodeCommunication?: boolean; + id: string; + metadata?: MetadataItem[]; + mountConfiguration?: MountConfiguration[]; + networkConfiguration?: NetworkConfiguration; + resizeTimeout?: string; + startTask?: StartTask; + targetDedicatedNodes?: number; + targetLowPriorityNodes?: number; + targetNodeCommunicationMode?: NodeCommunicationMode; + taskSchedulingPolicy?: TaskSchedulingPolicy; + taskSlotsPerNode?: number; + userAccounts?: UserAccount[]; + virtualMachineConfiguration?: VirtualMachineConfiguration; + vmSize: string; } // @public export interface BatchPoolEnableAutoScaleOptions { - autoScaleEvaluationInterval?: string; - autoScaleFormula?: string; + autoScaleEvaluationInterval?: string; + autoScaleFormula?: string; } // @public export interface BatchPoolEvaluateAutoScaleOptions { - autoScaleFormula: string; + autoScaleFormula: string; } // @public export interface BatchPoolIdentity { - type: PoolIdentityType; - userAssignedIdentities?: UserAssignedIdentity[]; + type: PoolIdentityType; + userAssignedIdentities?: UserAssignedIdentity[]; } // @public export interface BatchPoolReplaceOptions { - applicationPackageReferences: ApplicationPackageReference[]; - certificateReferences: CertificateReference[]; - metadata: MetadataItem[]; - startTask?: StartTask; - targetNodeCommunicationMode?: NodeCommunicationMode; + applicationPackageReferences: ApplicationPackageReference[]; + certificateReferences: CertificateReference[]; + metadata: MetadataItem[]; + startTask?: StartTask; + targetNodeCommunicationMode?: NodeCommunicationMode; } // @public export interface BatchPoolResizeOptions { - nodeDeallocationOption?: BatchNodeDeallocationOption; - resizeTimeout?: string; - targetDedicatedNodes?: number; - targetLowPriorityNodes?: number; + nodeDeallocationOption?: BatchNodeDeallocationOption; + resizeTimeout?: string; + targetDedicatedNodes?: number; + targetLowPriorityNodes?: number; } // @public export interface BatchPoolUpdateOptions { - applicationPackageReferences?: ApplicationPackageReference[]; - certificateReferences?: CertificateReference[]; - metadata?: MetadataItem[]; - startTask?: StartTask; - targetNodeCommunicationMode?: NodeCommunicationMode; + applicationPackageReferences?: ApplicationPackageReference[]; + certificateReferences?: CertificateReference[]; + metadata?: MetadataItem[]; + startTask?: StartTask; + targetNodeCommunicationMode?: NodeCommunicationMode; } // @public export interface BatchTask { - readonly affinityInfo?: AffinityInformation; - readonly applicationPackageReferences?: ApplicationPackageReference[]; - readonly authenticationTokenSettings?: AuthenticationTokenSettings; - readonly commandLine?: string; - constraints?: TaskConstraints; - readonly containerSettings?: TaskContainerSettings; - readonly creationTime?: Date; - readonly dependsOn?: TaskDependencies; - readonly displayName?: string; - readonly environmentSettings?: EnvironmentSetting[]; - readonly eTag?: string; - readonly executionInfo?: TaskExecutionInformation; - readonly exitConditions?: ExitConditions; - readonly id?: string; - readonly lastModified?: Date; - readonly multiInstanceSettings?: MultiInstanceSettings; - readonly nodeInfo?: BatchNodeInformation; - readonly outputFiles?: OutputFile[]; - readonly previousState?: TaskState; - readonly previousStateTransitionTime?: Date; - readonly requiredSlots?: number; - readonly resourceFiles?: ResourceFile[]; - readonly state?: TaskState; - readonly stateTransitionTime?: Date; - readonly stats?: TaskStatistics; - readonly url?: string; - readonly userIdentity?: UserIdentity; + readonly affinityInfo?: AffinityInformation; + readonly applicationPackageReferences?: ApplicationPackageReference[]; + readonly authenticationTokenSettings?: AuthenticationTokenSettings; + readonly commandLine?: string; + constraints?: TaskConstraints; + readonly containerSettings?: TaskContainerSettings; + readonly creationTime?: Date; + readonly dependsOn?: TaskDependencies; + readonly displayName?: string; + readonly environmentSettings?: EnvironmentSetting[]; + readonly eTag?: string; + readonly executionInfo?: TaskExecutionInformation; + readonly exitConditions?: ExitConditions; + readonly id?: string; + readonly lastModified?: Date; + readonly multiInstanceSettings?: MultiInstanceSettings; + readonly nodeInfo?: BatchNodeInformation; + readonly outputFiles?: OutputFile[]; + readonly previousState?: TaskState; + readonly previousStateTransitionTime?: Date; + readonly requiredSlots?: number; + readonly resourceFiles?: ResourceFile[]; + readonly state?: TaskState; + readonly stateTransitionTime?: Date; + readonly stats?: TaskStatistics; + readonly url?: string; + readonly userIdentity?: UserIdentity; } // @public export interface BatchTaskCollection { - value: BatchTaskCreateOptions[]; + value: BatchTaskCreateOptions[]; } // @public export interface BatchTaskCreateOptions { - affinityInfo?: AffinityInformation; - applicationPackageReferences?: ApplicationPackageReference[]; - authenticationTokenSettings?: AuthenticationTokenSettings; - commandLine: string; - constraints?: TaskConstraints; - containerSettings?: TaskContainerSettings; - dependsOn?: TaskDependencies; - displayName?: string; - environmentSettings?: EnvironmentSetting[]; - exitConditions?: ExitConditions; - id: string; - multiInstanceSettings?: MultiInstanceSettings; - outputFiles?: OutputFile[]; - requiredSlots?: number; - resourceFiles?: ResourceFile[]; - userIdentity?: UserIdentity; + affinityInfo?: AffinityInformation; + applicationPackageReferences?: ApplicationPackageReference[]; + authenticationTokenSettings?: AuthenticationTokenSettings; + commandLine: string; + constraints?: TaskConstraints; + containerSettings?: TaskContainerSettings; + dependsOn?: TaskDependencies; + displayName?: string; + environmentSettings?: EnvironmentSetting[]; + exitConditions?: ExitConditions; + id: string; + multiInstanceSettings?: MultiInstanceSettings; + outputFiles?: OutputFile[]; + requiredSlots?: number; + resourceFiles?: ResourceFile[]; + userIdentity?: UserIdentity; } // @public export interface BatchTaskListSubtasksResult { - value?: SubtaskInformation[]; + value?: SubtaskInformation[]; } // @public @@ -580,10 +878,24 @@ export type CachingType = "none" | "readonly" | "readwrite"; // @public export interface CancelCertificateDeletionOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CancelCertificateDeletionResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public @@ -591,11 +903,11 @@ export type CertificateFormat = "pfx" | "cer"; // @public export interface CertificateReference { - storeLocation?: CertificateStoreLocation; - storeName?: string; - thumbprint: string; - thumbprintAlgorithm: string; - visibility?: CertificateVisibility[]; + storeLocation?: CertificateStoreLocation; + storeName?: string; + thumbprint: string; + thumbprintAlgorithm: string; + visibility?: CertificateVisibility[]; } // @public @@ -609,196 +921,350 @@ export type CertificateVisibility = "starttask" | "task" | "remoteuser"; // @public export interface CifsMountConfiguration { - mountOptions?: string; - password: string; - relativeMountPath: string; - source: string; - username: string; + mountOptions?: string; + password: string; + relativeMountPath: string; + source: string; + username: string; } // @public export interface CloudServiceConfiguration { - osFamily: string; - osVersion?: string; + osFamily: string; + osVersion?: string; } // @public export interface ContainerConfiguration { - containerImageNames?: string[]; - containerRegistries?: ContainerRegistry[]; - type: ContainerType; + containerImageNames?: string[]; + containerRegistries?: ContainerRegistry[]; + type: ContainerType; } // @public export interface ContainerRegistry { - identityReference?: BatchNodeIdentityReference; - password?: string; - registryServer?: string; - username?: string; + identityReference?: BatchNodeIdentityReference; + password?: string; + registryServer?: string; + username?: string; } // @public export type ContainerType = "dockerCompatible" | "criCompatible"; // @public -export type ContainerWorkingDirectory = "taskWorkingDirectory" | "containerImageDefault"; +export type ContainerWorkingDirectory = + | "taskWorkingDirectory" + | "containerImageDefault"; // @public export type ContinuablePage = TPage & { - continuationToken?: string; + continuationToken?: string; }; // @public export interface CreateCertificateOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CreateCertificateResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface CreateJobOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CreateJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface CreateJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CreateJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface CreateNodeUserOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CreateNodeUserResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface CreatePoolOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CreatePoolResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface CreateTaskCollectionOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface CreateTaskOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface CreateTaskResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface DataDisk { - caching?: CachingType; - diskSizeGb: number; - lun: number; - storageAccountType?: StorageAccountType; + caching?: CachingType; + diskSizeGb: number; + lun: number; + storageAccountType?: StorageAccountType; } // @public export interface DeleteCertificateError { - code?: string; - message?: string; - values?: NameValuePair[]; + code?: string; + message?: string; + values?: NameValuePair[]; } // @public export interface DeleteCertificateOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteCertificateResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface DeleteJobOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public export interface DeleteJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public export interface DeleteNodeFileOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - recursive?: boolean; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + recursive?: boolean; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteNodeFileResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public export interface DeleteNodeUserOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteNodeUserResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public export interface DeletePoolOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeletePoolResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public export interface DeleteTaskFileOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - recursive?: boolean; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + recursive?: boolean; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteTaskFileResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public export interface DeleteTaskOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DeleteTaskResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + requestId?: string; } // @public @@ -809,59 +1275,118 @@ export type DiffDiskPlacement = "cachedisk"; // @public export interface DiffDiskSettings { - placement?: DiffDiskPlacement; + placement?: DiffDiskPlacement; } // @public -export type DisableBatchNodeSchedulingOption = "requeue" | "terminate" | "taskcompletion"; +export type DisableBatchNodeSchedulingOption = + | "requeue" + | "terminate" + | "taskcompletion"; // @public export type DisableJobOption = "requeue" | "terminate" | "wait"; // @public export interface DisableJobOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DisableJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface DisableJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DisableJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface DisableNodeSchedulingOptionalParams extends OperationOptions { - body?: NodeDisableSchedulingOptions; - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + body?: NodeDisableSchedulingOptions; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DisableNodeSchedulingResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface DisablePoolAutoScaleOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface DisablePoolAutoScaleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface DiskEncryptionConfiguration { - targets?: DiskEncryptionTarget[]; + targets?: DiskEncryptionTarget[]; } // @public @@ -875,52 +1400,108 @@ export type ElevationLevel = "nonadmin" | "admin"; // @public export interface EnableJobOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface EnableJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface EnableJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface EnableJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface EnableNodeSchedulingOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface EnableNodeSchedulingResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface EnablePoolAutoScaleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface EnablePoolAutoScaleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface EnvironmentSetting { - name: string; - value?: string; + name: string; + value?: string; } // @public @@ -928,246 +1509,290 @@ export type ErrorCategory = "usererror" | "servererror"; // @public export interface ErrorMessage { - lang?: string; - value?: string; + lang?: string; + value?: string; } // @public export interface EvaluatePoolAutoScaleOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface ExitCodeMapping { - code: number; - exitOptions: ExitOptions; + code: number; + exitOptions: ExitOptions; } // @public export interface ExitCodeRangeMapping { - end: number; - exitOptions: ExitOptions; - start: number; + end: number; + exitOptions: ExitOptions; + start: number; } // @public export interface ExitConditions { - default?: ExitOptions; - exitCodeRanges?: ExitCodeRangeMapping[]; - exitCodes?: ExitCodeMapping[]; - fileUploadError?: ExitOptions; - preProcessingError?: ExitOptions; + default?: ExitOptions; + exitCodeRanges?: ExitCodeRangeMapping[]; + exitCodes?: ExitCodeMapping[]; + fileUploadError?: ExitOptions; + preProcessingError?: ExitOptions; } // @public export interface ExitOptions { - dependencyAction?: DependencyAction; - jobAction?: JobAction; + dependencyAction?: DependencyAction; + jobAction?: JobAction; } // @public export interface FileProperties { - contentLength: number; - contentType?: string; - creationTime?: Date; - fileMode?: string; - lastModified: Date; + contentLength: number; + contentType?: string; + creationTime?: Date; + fileMode?: string; + lastModified: Date; } // @public export interface GetApplicationOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface GetCertificateOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface GetJobOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface GetJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface GetJobTaskCountsOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface GetNodeExtensionOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface GetNodeFileOptionalParams extends OperationOptions { - clientRequestId?: string; - ifModifiedSince?: Date; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - ocpRange?: string; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifModifiedSince?: Date; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + ocpRange?: string; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface GetNodeFilePropertiesOptionalParams extends OperationOptions { - clientRequestId?: string; - ifModifiedSince?: Date; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifModifiedSince?: Date; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface GetNodeFilePropertiesResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + contentLength: number; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + ocpBatchFileIsdirectory: boolean; + // (undocumented) + ocpBatchFileMode: string; + // (undocumented) + ocpBatchFileUrl: string; + // (undocumented) + ocpCreationTime?: Date; + // (undocumented) + requestId?: string; } // @public export interface GetNodeOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface GetNodeRemoteDesktopFileOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface GetNodeRemoteLoginSettingsOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface GetPoolOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface GetTaskFileOptionalParams extends OperationOptions { - clientRequestId?: string; - ifModifiedSince?: Date; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - ocpRange?: string; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifModifiedSince?: Date; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + ocpRange?: string; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface GetTaskFilePropertiesOptionalParams extends OperationOptions { - clientRequestId?: string; - ifModifiedSince?: Date; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifModifiedSince?: Date; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface GetTaskFilePropertiesResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + contentLength: number; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + ocpBatchFileIsdirectory: boolean; + // (undocumented) + ocpBatchFileMode: string; + // (undocumented) + ocpBatchFileUrl: string; + // (undocumented) + ocpCreationTime?: Date; + // (undocumented) + requestId?: string; } // @public export interface GetTaskOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface HttpHeader { - name: string; - value?: string; + name: string; + value?: string; } // @public export interface ImageInformation { - batchSupportEndOfLife?: Date; - capabilities?: string[]; - imageReference: ImageReference; - nodeAgentSkuId: string; - osType: OSType; - verificationType: VerificationType; + batchSupportEndOfLife?: Date; + capabilities?: string[]; + imageReference: ImageReference; + nodeAgentSkuId: string; + osType: OSType; + verificationType: VerificationType; } // @public export interface ImageReference { - readonly exactVersion?: string; - offer?: string; - publisher?: string; - sku?: string; - version?: string; - virtualMachineImageId?: string; + readonly exactVersion?: string; + offer?: string; + publisher?: string; + sku?: string; + version?: string; + virtualMachineImageId?: string; } // @public export interface InboundEndpoint { - backendPort: number; - frontendPort: number; - name: string; - protocol: InboundEndpointProtocol; - publicFqdn?: string; - publicIpAddress?: string; + backendPort: number; + frontendPort: number; + name: string; + protocol: InboundEndpointProtocol; + publicFqdn?: string; + publicIpAddress?: string; } // @public @@ -1175,103 +1800,106 @@ export type InboundEndpointProtocol = "tcp" | "udp"; // @public export interface InboundNATPool { - backendPort: number; - frontendPortRangeEnd: number; - frontendPortRangeStart: number; - name: string; - networkSecurityGroupRules?: NetworkSecurityGroupRule[]; - protocol: InboundEndpointProtocol; + backendPort: number; + frontendPortRangeEnd: number; + frontendPortRangeStart: number; + name: string; + networkSecurityGroupRules?: NetworkSecurityGroupRule[]; + protocol: InboundEndpointProtocol; } // @public export interface InstanceViewStatus { - code?: string; - displayStatus?: string; - level?: StatusLevelTypes; - message?: string; - time?: string; + code?: string; + displayStatus?: string; + level?: StatusLevelTypes; + message?: string; + time?: string; } // @public -export type IpAddressProvisioningType = "batchmanaged" | "usermanaged" | "nopublicipaddresses"; +export type IpAddressProvisioningType = + | "batchmanaged" + | "usermanaged" + | "nopublicipaddresses"; // @public export type JobAction = "none" | "disable" | "terminate"; // @public export interface JobConstraints { - maxTaskRetryCount?: number; - maxWallClockTime?: string; + maxTaskRetryCount?: number; + maxWallClockTime?: string; } // @public export interface JobExecutionInformation { - endTime?: Date; - poolId?: string; - schedulingError?: JobSchedulingError; - startTime: Date; - terminateReason?: string; + endTime?: Date; + poolId?: string; + schedulingError?: JobSchedulingError; + startTime: Date; + terminateReason?: string; } // @public export interface JobManagerTask { - allowLowPriorityNode?: boolean; - applicationPackageReferences?: ApplicationPackageReference[]; - authenticationTokenSettings?: AuthenticationTokenSettings; - commandLine: string; - constraints?: TaskConstraints; - containerSettings?: TaskContainerSettings; - displayName?: string; - environmentSettings?: EnvironmentSetting[]; - id: string; - killJobOnCompletion?: boolean; - outputFiles?: OutputFile[]; - requiredSlots?: number; - resourceFiles?: ResourceFile[]; - runExclusive?: boolean; - userIdentity?: UserIdentity; + allowLowPriorityNode?: boolean; + applicationPackageReferences?: ApplicationPackageReference[]; + authenticationTokenSettings?: AuthenticationTokenSettings; + commandLine: string; + constraints?: TaskConstraints; + containerSettings?: TaskContainerSettings; + displayName?: string; + environmentSettings?: EnvironmentSetting[]; + id: string; + killJobOnCompletion?: boolean; + outputFiles?: OutputFile[]; + requiredSlots?: number; + resourceFiles?: ResourceFile[]; + runExclusive?: boolean; + userIdentity?: UserIdentity; } // @public export interface JobNetworkConfiguration { - subnetId: string; + subnetId: string; } // @public export interface JobPreparationAndReleaseTaskExecutionInformation { - jobPreparationTaskExecutionInfo?: JobPreparationTaskExecutionInformation; - jobReleaseTaskExecutionInfo?: JobReleaseTaskExecutionInformation; - nodeId?: string; - nodeUrl?: string; - poolId?: string; + jobPreparationTaskExecutionInfo?: JobPreparationTaskExecutionInformation; + jobReleaseTaskExecutionInfo?: JobReleaseTaskExecutionInformation; + nodeId?: string; + nodeUrl?: string; + poolId?: string; } // @public export interface JobPreparationTask { - commandLine: string; - constraints?: TaskConstraints; - containerSettings?: TaskContainerSettings; - environmentSettings?: EnvironmentSetting[]; - id?: string; - rerunOnNodeRebootAfterSuccess?: boolean; - resourceFiles?: ResourceFile[]; - userIdentity?: UserIdentity; - waitForSuccess?: boolean; + commandLine: string; + constraints?: TaskConstraints; + containerSettings?: TaskContainerSettings; + environmentSettings?: EnvironmentSetting[]; + id?: string; + rerunOnNodeRebootAfterSuccess?: boolean; + resourceFiles?: ResourceFile[]; + userIdentity?: UserIdentity; + waitForSuccess?: boolean; } // @public export interface JobPreparationTaskExecutionInformation { - containerInfo?: TaskContainerExecutionInformation; - endTime?: Date; - exitCode?: number; - failureInfo?: TaskFailureInformation; - lastRetryTime?: Date; - result?: TaskExecutionResult; - retryCount: number; - startTime: Date; - state: JobPreparationTaskState; - taskRootDirectory?: string; - taskRootDirectoryUrl?: string; + containerInfo?: TaskContainerExecutionInformation; + endTime?: Date; + exitCode?: number; + failureInfo?: TaskFailureInformation; + lastRetryTime?: Date; + result?: TaskExecutionResult; + retryCount: number; + startTime: Date; + state: JobPreparationTaskState; + taskRootDirectory?: string; + taskRootDirectoryUrl?: string; } // @public @@ -1279,27 +1907,27 @@ export type JobPreparationTaskState = "running" | "completed"; // @public export interface JobReleaseTask { - commandLine: string; - containerSettings?: TaskContainerSettings; - environmentSettings?: EnvironmentSetting[]; - id?: string; - maxWallClockTime?: string; - resourceFiles?: ResourceFile[]; - retentionTime?: string; - userIdentity?: UserIdentity; + commandLine: string; + containerSettings?: TaskContainerSettings; + environmentSettings?: EnvironmentSetting[]; + id?: string; + maxWallClockTime?: string; + resourceFiles?: ResourceFile[]; + retentionTime?: string; + userIdentity?: UserIdentity; } // @public export interface JobReleaseTaskExecutionInformation { - containerInfo?: TaskContainerExecutionInformation; - endTime?: Date; - exitCode?: number; - failureInfo?: TaskFailureInformation; - result?: TaskExecutionResult; - startTime: Date; - state: JobReleaseTaskState; - taskRootDirectory?: string; - taskRootDirectoryUrl?: string; + containerInfo?: TaskContainerExecutionInformation; + endTime?: Date; + exitCode?: number; + failureInfo?: TaskFailureInformation; + result?: TaskExecutionResult; + startTime: Date; + state: JobReleaseTaskState; + taskRootDirectory?: string; + taskRootDirectoryUrl?: string; } // @public @@ -1307,277 +1935,301 @@ export type JobReleaseTaskState = "running" | "completed"; // @public export interface JobScheduleExecutionInformation { - endTime?: Date; - nextRunTime?: Date; - recentJob?: RecentJob; + endTime?: Date; + nextRunTime?: Date; + recentJob?: RecentJob; } // @public export interface JobScheduleExistsOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public -export type JobScheduleState = "active" | "completed" | "disabled" | "terminating" | "deleting"; +export interface JobScheduleExistsResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; +} + +// @public +export type JobScheduleState = + | "active" + | "completed" + | "disabled" + | "terminating" + | "deleting"; // @public export interface JobScheduleStatistics { - kernelCPUTime: string; - lastUpdateTime: Date; - numFailedTasks: number; - numSucceededTasks: number; - numTaskRetries: number; - readIOGiB: number; - readIOps: number; - startTime: Date; - url: string; - userCPUTime: string; - waitTime: string; - wallClockTime: string; - writeIOGiB: number; - writeIOps: number; + kernelCPUTime: string; + lastUpdateTime: Date; + numFailedTasks: number; + numSucceededTasks: number; + numTaskRetries: number; + readIOGiB: number; + readIOps: number; + startTime: Date; + url: string; + userCPUTime: string; + waitTime: string; + wallClockTime: string; + writeIOGiB: number; + writeIOps: number; } // @public export interface JobSchedulingError { - category: ErrorCategory; - code?: string; - details?: NameValuePair[]; - message?: string; + category: ErrorCategory; + code?: string; + details?: NameValuePair[]; + message?: string; } // @public export interface JobSpecification { - allowTaskPreemption?: boolean; - commonEnvironmentSettings?: EnvironmentSetting[]; - constraints?: JobConstraints; - displayName?: string; - jobManagerTask?: JobManagerTask; - jobPreparationTask?: JobPreparationTask; - jobReleaseTask?: JobReleaseTask; - maxParallelTasks?: number; - metadata?: MetadataItem[]; - networkConfiguration?: JobNetworkConfiguration; - onAllTasksComplete?: OnAllTasksComplete; - onTaskFailure?: OnTaskFailure; - poolInfo: PoolInformation; - priority?: number; - usesTaskDependencies?: boolean; -} - -// @public -export type JobState = "active" | "disabling" | "disabled" | "enabling" | "terminating" | "completed" | "deleting"; + allowTaskPreemption?: boolean; + commonEnvironmentSettings?: EnvironmentSetting[]; + constraints?: JobConstraints; + displayName?: string; + jobManagerTask?: JobManagerTask; + jobPreparationTask?: JobPreparationTask; + jobReleaseTask?: JobReleaseTask; + maxParallelTasks?: number; + metadata?: MetadataItem[]; + networkConfiguration?: JobNetworkConfiguration; + onAllTasksComplete?: OnAllTasksComplete; + onTaskFailure?: OnTaskFailure; + poolInfo: PoolInformation; + priority?: number; + usesTaskDependencies?: boolean; +} + +// @public +export type JobState = + | "active" + | "disabling" + | "disabled" + | "enabling" + | "terminating" + | "completed" + | "deleting"; // @public export interface JobStatistics { - kernelCPUTime: string; - lastUpdateTime: Date; - numFailedTasks: number; - numSucceededTasks: number; - numTaskRetries: number; - readIOGiB: number; - readIOps: number; - startTime: Date; - url: string; - userCPUTime: string; - waitTime: string; - wallClockTime: string; - writeIOGiB: number; - writeIOps: number; + kernelCPUTime: string; + lastUpdateTime: Date; + numFailedTasks: number; + numSucceededTasks: number; + numTaskRetries: number; + readIOGiB: number; + readIOps: number; + startTime: Date; + url: string; + userCPUTime: string; + waitTime: string; + wallClockTime: string; + writeIOGiB: number; + writeIOps: number; } // @public export enum KnownVersions { - _20230501170 = "2023-05-01.17.0" + _20230501170 = "2023-05-01.17.0", } // @public export interface LinuxUserConfiguration { - gid?: number; - sshPrivateKey?: string; - uid?: number; + gid?: number; + sshPrivateKey?: string; + uid?: number; } // @public export interface ListApplicationsOptionalParams extends OperationOptions { - clientRequestId?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface ListCertificatesOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListJobPreparationAndReleaseTaskStatusOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListJobSchedulesOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListJobsFromScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListJobsOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListNodeExtensionsOptionalParams extends OperationOptions { - clientRequestId?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListNodeFilesOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - recursive?: boolean; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + recursive?: boolean; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface ListNodesOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListPoolNodeCountsOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface ListPoolsOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListPoolUsageMetricsOptionalParams extends OperationOptions { - clientRequestId?: string; - endtime?: Date; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - starttime?: Date; - timeOutInSeconds?: number; + clientRequestId?: string; + endtime?: Date; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + starttime?: Date; + timeOutInSeconds?: number; } // @public export interface ListSubTasksOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public export interface ListSupportedImagesOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface ListTaskFilesOptionalParams extends OperationOptions { - clientRequestId?: string; - filter?: string; - maxresults?: number; - ocpDate?: Date; - recursive?: boolean; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + filter?: string; + maxresults?: number; + ocpDate?: Date; + recursive?: boolean; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface ListTasksOptionalParams extends OperationOptions { - clientRequestId?: string; - expand?: string[]; - filter?: string; - maxresults?: number; - ocpDate?: Date; - returnClientRequestId?: boolean; - select?: string[]; - timeOutInSeconds?: number; + clientRequestId?: string; + expand?: string[]; + filter?: string; + maxresults?: number; + ocpDate?: Date; + returnClientRequestId?: boolean; + select?: string[]; + timeOutInSeconds?: number; } // @public @@ -1585,46 +2237,46 @@ export type LoginMode = "batch" | "interactive"; // @public export interface MetadataItem { - name: string; - value: string; + name: string; + value: string; } // @public export interface MountConfiguration { - azureBlobFileSystemConfiguration?: AzureBlobFileSystemConfiguration; - azureFileShareConfiguration?: AzureFileShareConfiguration; - cifsMountConfiguration?: CifsMountConfiguration; - nfsMountConfiguration?: NfsMountConfiguration; + azureBlobFileSystemConfiguration?: AzureBlobFileSystemConfiguration; + azureFileShareConfiguration?: AzureFileShareConfiguration; + cifsMountConfiguration?: CifsMountConfiguration; + nfsMountConfiguration?: NfsMountConfiguration; } // @public export interface MultiInstanceSettings { - commonResourceFiles?: ResourceFile[]; - coordinationCommandLine: string; - numberOfInstances?: number; + commonResourceFiles?: ResourceFile[]; + coordinationCommandLine: string; + numberOfInstances?: number; } // @public export interface NameValuePair { - name?: string; - value?: string; + name?: string; + value?: string; } // @public export interface NetworkConfiguration { - dynamicVNetAssignmentScope?: DynamicVNetAssignmentScope; - enableAcceleratedNetworking?: boolean; - endpointConfiguration?: PoolEndpointConfiguration; - publicIpAddressConfiguration?: PublicIpAddressConfiguration; - subnetId?: string; + dynamicVNetAssignmentScope?: DynamicVNetAssignmentScope; + enableAcceleratedNetworking?: boolean; + endpointConfiguration?: PoolEndpointConfiguration; + publicIpAddressConfiguration?: PublicIpAddressConfiguration; + subnetId?: string; } // @public export interface NetworkSecurityGroupRule { - access: NetworkSecurityGroupRuleAccess; - priority: number; - sourceAddressPrefix: string; - sourcePortRanges?: string[]; + access: NetworkSecurityGroupRuleAccess; + priority: number; + sourceAddressPrefix: string; + sourcePortRanges?: string[]; } // @public @@ -1632,15 +2284,15 @@ export type NetworkSecurityGroupRuleAccess = "allow" | "deny"; // @public export interface NfsMountConfiguration { - mountOptions?: string; - relativeMountPath: string; - source: string; + mountOptions?: string; + relativeMountPath: string; + source: string; } // @public export interface NodeAgentInformation { - lastUpdateTime: Date; - version: string; + lastUpdateTime: Date; + version: string; } // @public @@ -1648,38 +2300,38 @@ export type NodeCommunicationMode = "default" | "classic" | "simplified"; // @public export interface NodeCounts { - creating: number; - idle: number; - leavingPool: number; - offline: number; - preempted: number; - rebooting: number; - reimaging: number; - running: number; - starting: number; - startTaskFailed: number; - total: number; - unknown: number; - unusable: number; - waitingForStartTask: number; + creating: number; + idle: number; + leavingPool: number; + offline: number; + preempted: number; + rebooting: number; + reimaging: number; + running: number; + starting: number; + startTaskFailed: number; + total: number; + unknown: number; + unusable: number; + waitingForStartTask: number; } // @public export interface NodeDisableSchedulingOptions { - nodeDisableSchedulingOption?: DisableBatchNodeSchedulingOption; + nodeDisableSchedulingOption?: DisableBatchNodeSchedulingOption; } // @public export interface NodeFile { - isDirectory?: boolean; - name?: string; - properties?: FileProperties; - url?: string; + isDirectory?: boolean; + name?: string; + properties?: FileProperties; + url?: string; } // @public export interface NodePlacementConfiguration { - policy?: NodePlacementPolicyType; + policy?: NodePlacementPolicyType; } // @public @@ -1687,26 +2339,26 @@ export type NodePlacementPolicyType = "regional" | "zonal"; // @public export interface NodeRebootOptions { - nodeRebootOption?: BatchNodeRebootOption; + nodeRebootOption?: BatchNodeRebootOption; } // @public export interface NodeReimageOptions { - nodeReimageOption?: BatchNodeReimageOption; + nodeReimageOption?: BatchNodeReimageOption; } // @public export interface NodeRemoveOptions { - nodeDeallocationOption?: BatchNodeDeallocationOption; - nodeList: string[]; - resizeTimeout?: string; + nodeDeallocationOption?: BatchNodeDeallocationOption; + nodeList: string[]; + resizeTimeout?: string; } // @public export interface NodeVMExtension { - instanceView?: VMExtensionInstanceView; - provisioningState?: string; - vmExtension?: VMExtension; + instanceView?: VMExtensionInstanceView; + provisioningState?: string; + vmExtension?: VMExtension; } // @public @@ -1717,7 +2369,7 @@ export type OnTaskFailure = "noaction" | "performexitoptionsjobaction"; // @public export interface OSDisk { - ephemeralOSDiskSettings?: DiffDiskSettings; + ephemeralOSDiskSettings?: DiffDiskSettings; } // @public @@ -1725,59 +2377,84 @@ export type OSType = "linux" | "windows"; // @public export interface OutputFile { - destination: OutputFileDestination; - filePattern: string; - uploadOptions: OutputFileUploadOptions; + destination: OutputFileDestination; + filePattern: string; + uploadOptions: OutputFileUploadOptions; } // @public export interface OutputFileBlobContainerDestination { - containerUrl: string; - identityReference?: BatchNodeIdentityReference; - path?: string; - uploadHeaders?: HttpHeader[]; + containerUrl: string; + identityReference?: BatchNodeIdentityReference; + path?: string; + uploadHeaders?: HttpHeader[]; } // @public export interface OutputFileDestination { - container?: OutputFileBlobContainerDestination; + container?: OutputFileBlobContainerDestination; } // @public -export type OutputFileUploadCondition = "tasksuccess" | "taskfailure" | "taskcompletion"; +export type OutputFileUploadCondition = + | "tasksuccess" + | "taskfailure" + | "taskcompletion"; // @public export interface OutputFileUploadOptions { - uploadCondition: OutputFileUploadCondition; + uploadCondition: OutputFileUploadCondition; } // @public -export interface PagedAsyncIterableIterator { - [Symbol.asyncIterator](): PagedAsyncIterableIterator; - byPage: (settings?: TPageSettings) => AsyncIterableIterator>; - next(): Promise>; +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + byPage: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; + next(): Promise>; } // @public export interface PageSettings { - continuationToken?: string; + continuationToken?: string; } // @public export interface PoolEndpointConfiguration { - inboundNatPools: InboundNATPool[]; + inboundNatPools: InboundNATPool[]; } // @public export interface PoolExistsOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface PoolExistsResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public @@ -1785,8 +2462,8 @@ export type PoolIdentityType = "UserAssigned" | "None"; // @public export interface PoolInformation { - autoPoolSpecification?: AutoPoolSpecification; - poolId?: string; + autoPoolSpecification?: AutoPoolSpecification; + poolId?: string; } // @public @@ -1794,35 +2471,35 @@ export type PoolLifetimeOption = "jobschedule" | "job"; // @public export interface PoolNodeCounts { - dedicated?: NodeCounts; - lowPriority?: NodeCounts; - poolId: string; + dedicated?: NodeCounts; + lowPriority?: NodeCounts; + poolId: string; } // @public export interface PoolSpecification { - applicationLicenses?: string[]; - applicationPackageReferences?: ApplicationPackageReference[]; - autoScaleEvaluationInterval?: string; - autoScaleFormula?: string; - certificateReferences?: CertificateReference[]; - cloudServiceConfiguration?: CloudServiceConfiguration; - displayName?: string; - enableAutoScale?: boolean; - enableInterNodeCommunication?: boolean; - metadata?: MetadataItem[]; - mountConfiguration?: MountConfiguration[]; - networkConfiguration?: NetworkConfiguration; - resizeTimeout?: string; - startTask?: StartTask; - targetDedicatedNodes?: number; - targetLowPriorityNodes?: number; - targetNodeCommunicationMode?: NodeCommunicationMode; - taskSchedulingPolicy?: TaskSchedulingPolicy; - taskSlotsPerNode?: number; - userAccounts?: UserAccount[]; - virtualMachineConfiguration?: VirtualMachineConfiguration; - vmSize: string; + applicationLicenses?: string[]; + applicationPackageReferences?: ApplicationPackageReference[]; + autoScaleEvaluationInterval?: string; + autoScaleFormula?: string; + certificateReferences?: CertificateReference[]; + cloudServiceConfiguration?: CloudServiceConfiguration; + displayName?: string; + enableAutoScale?: boolean; + enableInterNodeCommunication?: boolean; + metadata?: MetadataItem[]; + mountConfiguration?: MountConfiguration[]; + networkConfiguration?: NetworkConfiguration; + resizeTimeout?: string; + startTask?: StartTask; + targetDedicatedNodes?: number; + targetLowPriorityNodes?: number; + targetNodeCommunicationMode?: NodeCommunicationMode; + taskSchedulingPolicy?: TaskSchedulingPolicy; + taskSlotsPerNode?: number; + userAccounts?: UserAccount[]; + virtualMachineConfiguration?: VirtualMachineConfiguration; + vmSize: string; } // @public @@ -1830,181 +2507,321 @@ export type PoolState = "active" | "deleting"; // @public export interface PoolStatistics { - lastUpdateTime: Date; - resourceStats?: ResourceStatistics; - startTime: Date; - url: string; - usageStats?: UsageStatistics; + lastUpdateTime: Date; + resourceStats?: ResourceStatistics; + startTime: Date; + url: string; + usageStats?: UsageStatistics; } // @public export interface PoolUsageMetrics { - endTime: Date; - poolId: string; - startTime: Date; - totalCoreHours: number; - vmSize: string; + endTime: Date; + poolId: string; + startTime: Date; + totalCoreHours: number; + vmSize: string; } // @public export interface PublicIpAddressConfiguration { - ipAddressIds?: string[]; - ipAddressProvisioningType?: IpAddressProvisioningType; + ipAddressIds?: string[]; + ipAddressProvisioningType?: IpAddressProvisioningType; } // @public export interface ReactivateTaskOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReactivateTaskResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface RebootNodeOptionalParams extends OperationOptions { - body?: NodeRebootOptions; - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + body?: NodeRebootOptions; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface RebootNodeResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface RecentJob { - id?: string; - url?: string; + id?: string; + url?: string; } // @public export interface ReimageNodeOptionalParams extends OperationOptions { - body?: NodeReimageOptions; - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + body?: NodeReimageOptions; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReimageNodeResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface RemoveNodesOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface RemoveNodesResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ReplaceJobOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReplaceJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ReplaceJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReplaceJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ReplaceNodeUserOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReplaceNodeUserResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ReplacePoolPropertiesOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReplacePoolPropertiesResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ReplaceTaskOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ReplaceTaskResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ResizeError { - code?: string; - message?: string; - values?: NameValuePair[]; + code?: string; + message?: string; + values?: NameValuePair[]; } // @public export interface ResizePoolOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface ResizePoolResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface ResourceFile { - autoStorageContainerName?: string; - blobPrefix?: string; - fileMode?: string; - filePath?: string; - httpUrl?: string; - identityReference?: BatchNodeIdentityReference; - storageContainerUrl?: string; + autoStorageContainerName?: string; + blobPrefix?: string; + fileMode?: string; + filePath?: string; + httpUrl?: string; + identityReference?: BatchNodeIdentityReference; + storageContainerUrl?: string; } // @public export interface ResourceStatistics { - avgCpuPercentage: number; - avgDiskGiB: number; - avgMemoryGiB: number; - diskReadGiB: number; - diskReadIOps: number; - diskWriteGiB: number; - diskWriteIOps: number; - lastUpdateTime: Date; - networkReadGiB: number; - networkWriteGiB: number; - peakDiskGiB: number; - peakMemoryGiB: number; - startTime: Date; + avgCpuPercentage: number; + avgDiskGiB: number; + avgMemoryGiB: number; + diskReadGiB: number; + diskReadIOps: number; + diskWriteGiB: number; + diskWriteIOps: number; + lastUpdateTime: Date; + networkReadGiB: number; + networkWriteGiB: number; + peakDiskGiB: number; + peakMemoryGiB: number; + startTime: Date; } // @public export interface Schedule { - doNotRunAfter?: Date; - doNotRunUntil?: Date; - recurrenceInterval?: string; - startWindow?: string; + doNotRunAfter?: Date; + doNotRunUntil?: Date; + recurrenceInterval?: string; + startWindow?: string; } // @public @@ -2012,26 +2829,26 @@ export type SchedulingState = "enabled" | "disabled"; // @public export interface StartTask { - commandLine: string; - containerSettings?: TaskContainerSettings; - environmentSettings?: EnvironmentSetting[]; - maxTaskRetryCount?: number; - resourceFiles?: ResourceFile[]; - userIdentity?: UserIdentity; - waitForSuccess?: boolean; + commandLine: string; + containerSettings?: TaskContainerSettings; + environmentSettings?: EnvironmentSetting[]; + maxTaskRetryCount?: number; + resourceFiles?: ResourceFile[]; + userIdentity?: UserIdentity; + waitForSuccess?: boolean; } // @public export interface StartTaskInformation { - containerInfo?: TaskContainerExecutionInformation; - endTime?: Date; - exitCode?: number; - failureInfo?: TaskFailureInformation; - lastRetryTime?: Date; - result?: TaskExecutionResult; - retryCount: number; - startTime: Date; - state: StartTaskState; + containerInfo?: TaskContainerExecutionInformation; + endTime?: Date; + exitCode?: number; + failureInfo?: TaskFailureInformation; + lastRetryTime?: Date; + result?: TaskExecutionResult; + retryCount: number; + startTime: Date; + state: StartTaskState; } // @public @@ -2042,14 +2859,28 @@ export type StatusLevelTypes = "Error" | "Info" | "Warning"; // @public export interface StopPoolResizeOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface StopPoolResizeResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public @@ -2057,18 +2888,18 @@ export type StorageAccountType = "standard_lrs" | "premium_lrs"; // @public export interface SubtaskInformation { - containerInfo?: TaskContainerExecutionInformation; - endTime?: Date; - exitCode?: number; - failureInfo?: TaskFailureInformation; - id?: number; - nodeInfo?: BatchNodeInformation; - previousState?: SubtaskState; - previousStateTransitionTime?: Date; - result?: TaskExecutionResult; - startTime?: Date; - state?: SubtaskState; - stateTransitionTime?: Date; + containerInfo?: TaskContainerExecutionInformation; + endTime?: Date; + exitCode?: number; + failureInfo?: TaskFailureInformation; + id?: number; + nodeInfo?: BatchNodeInformation; + previousState?: SubtaskState; + previousStateTransitionTime?: Date; + result?: TaskExecutionResult; + startTime?: Date; + state?: SubtaskState; + stateTransitionTime?: Date; } // @public @@ -2076,17 +2907,17 @@ export type SubtaskState = "preparing" | "running" | "completed"; // @public export interface TaskAddCollectionResult { - value?: TaskAddResult[]; + value?: TaskAddResult[]; } // @public export interface TaskAddResult { - error?: BatchError; - eTag?: string; - lastModified?: Date; - location?: string; - status: TaskAddStatus; - taskId: string; + error?: BatchError; + eTag?: string; + lastModified?: Date; + location?: string; + status: TaskAddStatus; + taskId: string; } // @public @@ -2094,59 +2925,59 @@ export type TaskAddStatus = "Success" | "clienterror" | "servererror"; // @public export interface TaskConstraints { - maxTaskRetryCount?: number; - maxWallClockTime?: string; - retentionTime?: string; + maxTaskRetryCount?: number; + maxWallClockTime?: string; + retentionTime?: string; } // @public export interface TaskContainerExecutionInformation { - containerId?: string; - error?: string; - state?: string; + containerId?: string; + error?: string; + state?: string; } // @public export interface TaskContainerSettings { - containerRunOptions?: string; - imageName: string; - registry?: ContainerRegistry; - workingDirectory?: ContainerWorkingDirectory; + containerRunOptions?: string; + imageName: string; + registry?: ContainerRegistry; + workingDirectory?: ContainerWorkingDirectory; } // @public export interface TaskCounts { - active: number; - completed: number; - failed: number; - running: number; - succeeded: number; + active: number; + completed: number; + failed: number; + running: number; + succeeded: number; } // @public export interface TaskCountsResult { - taskCounts: TaskCounts; - taskSlotCounts: TaskSlotCounts; + taskCounts: TaskCounts; + taskSlotCounts: TaskSlotCounts; } // @public export interface TaskDependencies { - taskIdRanges?: TaskIdRange[]; - taskIds?: string[]; + taskIdRanges?: TaskIdRange[]; + taskIds?: string[]; } // @public export interface TaskExecutionInformation { - containerInfo?: TaskContainerExecutionInformation; - endTime?: Date; - exitCode?: number; - failureInfo?: TaskFailureInformation; - lastRequeueTime?: Date; - lastRetryTime?: Date; - requeueCount: number; - result?: TaskExecutionResult; - retryCount: number; - startTime?: Date; + containerInfo?: TaskContainerExecutionInformation; + endTime?: Date; + exitCode?: number; + failureInfo?: TaskFailureInformation; + lastRequeueTime?: Date; + lastRetryTime?: Date; + requeueCount: number; + result?: TaskExecutionResult; + retryCount: number; + startTime?: Date; } // @public @@ -2154,40 +2985,40 @@ export type TaskExecutionResult = "success" | "failure"; // @public export interface TaskFailureInformation { - category: ErrorCategory; - code?: string; - details?: NameValuePair[]; - message?: string; + category: ErrorCategory; + code?: string; + details?: NameValuePair[]; + message?: string; } // @public export interface TaskIdRange { - end: number; - start: number; + end: number; + start: number; } // @public export interface TaskInformation { - executionInfo?: TaskExecutionInformation; - jobId?: string; - subtaskId?: number; - taskId?: string; - taskState: TaskState; - taskUrl?: string; + executionInfo?: TaskExecutionInformation; + jobId?: string; + subtaskId?: number; + taskId?: string; + taskState: TaskState; + taskUrl?: string; } // @public export interface TaskSchedulingPolicy { - nodeFillType: BatchNodeFillType; + nodeFillType: BatchNodeFillType; } // @public export interface TaskSlotCounts { - active: number; - completed: number; - failed: number; - running: number; - succeeded: number; + active: number; + completed: number; + failed: number; + running: number; + succeeded: number; } // @public @@ -2195,141 +3026,225 @@ export type TaskState = "active" | "preparing" | "running" | "completed"; // @public export interface TaskStatistics { - kernelCPUTime: string; - lastUpdateTime: Date; - readIOGiB: number; - readIOps: number; - startTime: Date; - url: string; - userCPUTime: string; - waitTime: string; - wallClockTime: string; - writeIOGiB: number; - writeIOps: number; + kernelCPUTime: string; + lastUpdateTime: Date; + readIOGiB: number; + readIOps: number; + startTime: Date; + url: string; + userCPUTime: string; + waitTime: string; + wallClockTime: string; + writeIOGiB: number; + writeIOps: number; } // @public export interface TerminateJobOptionalParams extends OperationOptions { - body?: BatchJobTerminateOptions; - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + body?: BatchJobTerminateOptions; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface TerminateJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface TerminateJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface TerminateJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface TerminateTaskOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface TerminateTaskResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface UpdateJobOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface UpdateJobResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface UpdateJobScheduleOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface UpdateJobScheduleResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface UpdatePoolOptionalParams extends OperationOptions { - clientRequestId?: string; - ifMatch?: string; - ifModifiedSince?: Date; - ifNoneMatch?: string; - ifUnmodifiedSince?: Date; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ifMatch?: string; + ifModifiedSince?: Date; + ifNoneMatch?: string; + ifUnmodifiedSince?: Date; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; +} + +// @public +export interface UpdatePoolResponse { + // (undocumented) + clientRequestId?: string; + // (undocumented) + dataServiceId: string; + // (undocumented) + eTag?: string; + // (undocumented) + lastModified?: Date; + // (undocumented) + requestId?: string; } // @public export interface UploadBatchServiceLogsOptions { - containerUrl: string; - endTime?: Date; - identityReference?: BatchNodeIdentityReference; - startTime: Date; + containerUrl: string; + endTime?: Date; + identityReference?: BatchNodeIdentityReference; + startTime: Date; } // @public export interface UploadBatchServiceLogsResult { - numberOfFilesUploaded: number; - virtualDirectoryName: string; + numberOfFilesUploaded: number; + virtualDirectoryName: string; } // @public export interface UploadNodeLogsOptionalParams extends OperationOptions { - clientRequestId?: string; - ocpDate?: Date; - returnClientRequestId?: boolean; - timeOutInSeconds?: number; + clientRequestId?: string; + ocpDate?: Date; + returnClientRequestId?: boolean; + timeOutInSeconds?: number; } // @public export interface UsageStatistics { - dedicatedCoreTime: string; - lastUpdateTime: Date; - startTime: Date; + dedicatedCoreTime: string; + lastUpdateTime: Date; + startTime: Date; } // @public export interface UserAccount { - elevationLevel?: ElevationLevel; - linuxUserConfiguration?: LinuxUserConfiguration; - name: string; - password: string; - windowsUserConfiguration?: WindowsUserConfiguration; + elevationLevel?: ElevationLevel; + linuxUserConfiguration?: LinuxUserConfiguration; + name: string; + password: string; + windowsUserConfiguration?: WindowsUserConfiguration; } // @public export interface UserAssignedIdentity { - readonly clientId?: string; - readonly principalId?: string; - resourceId: string; + readonly clientId?: string; + readonly principalId?: string; + resourceId: string; } // @public export interface UserIdentity { - autoUser?: AutoUserSpecification; - username?: string; + autoUser?: AutoUserSpecification; + username?: string; } // @public @@ -2337,53 +3252,52 @@ export type VerificationType = "verified" | "unverified"; // @public export interface VirtualMachineConfiguration { - containerConfiguration?: ContainerConfiguration; - dataDisks?: DataDisk[]; - diskEncryptionConfiguration?: DiskEncryptionConfiguration; - extensions?: VMExtension[]; - imageReference: ImageReference; - licenseType?: string; - nodeAgentSkuId: string; - nodePlacementConfiguration?: NodePlacementConfiguration; - osDisk?: OSDisk; - windowsConfiguration?: WindowsConfiguration; + containerConfiguration?: ContainerConfiguration; + dataDisks?: DataDisk[]; + diskEncryptionConfiguration?: DiskEncryptionConfiguration; + extensions?: VMExtension[]; + imageReference: ImageReference; + licenseType?: string; + nodeAgentSkuId: string; + nodePlacementConfiguration?: NodePlacementConfiguration; + osDisk?: OSDisk; + windowsConfiguration?: WindowsConfiguration; } // @public export interface VirtualMachineInfo { - imageReference?: ImageReference; + imageReference?: ImageReference; } // @public export interface VMExtension { - autoUpgradeMinorVersion?: boolean; - enableAutomaticUpgrade?: boolean; - name: string; - protectedSettings?: Record; - provisionAfterExtensions?: string[]; - publisher: string; - settings?: Record; - type: string; - typeHandlerVersion?: string; + autoUpgradeMinorVersion?: boolean; + enableAutomaticUpgrade?: boolean; + name: string; + protectedSettings?: Record; + provisionAfterExtensions?: string[]; + publisher: string; + settings?: Record; + type: string; + typeHandlerVersion?: string; } // @public export interface VMExtensionInstanceView { - name?: string; - statuses?: InstanceViewStatus[]; - subStatuses?: InstanceViewStatus[]; + name?: string; + statuses?: InstanceViewStatus[]; + subStatuses?: InstanceViewStatus[]; } // @public export interface WindowsConfiguration { - enableAutomaticUpdates?: boolean; + enableAutomaticUpdates?: boolean; } // @public export interface WindowsUserConfiguration { - loginMode?: LoginMode; + loginMode?: LoginMode; } // (No @packageDocumentation comment for this package) - ``` diff --git a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/api/operations.ts b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/api/operations.ts index d636850b7b..c84104dee7 100644 --- a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/api/operations.ts +++ b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/api/operations.ts @@ -105,6 +105,50 @@ import { nodeVMExtensionDeserializer, _NodeVMExtensionList, _nodeVMExtensionListDeserializer, + CreateNodeUserResponse, + DeleteNodeUserResponse, + ReplaceNodeUserResponse, + RebootNodeResponse, + ReimageNodeResponse, + DisableNodeSchedulingResponse, + EnableNodeSchedulingResponse, + DeleteNodeFileResponse, + GetNodeFilePropertiesResponse, + CreateTaskResponse, + DeleteTaskResponse, + ReplaceTaskResponse, + TerminateTaskResponse, + ReactivateTaskResponse, + DeleteTaskFileResponse, + GetTaskFilePropertiesResponse, + JobScheduleExistsResponse, + DeleteJobScheduleResponse, + UpdateJobScheduleResponse, + ReplaceJobScheduleResponse, + DisableJobScheduleResponse, + EnableJobScheduleResponse, + TerminateJobScheduleResponse, + CreateJobScheduleResponse, + CreateCertificateResponse, + CancelCertificateDeletionResponse, + DeleteCertificateResponse, + DeleteJobResponse, + UpdateJobResponse, + ReplaceJobResponse, + DisableJobResponse, + EnableJobResponse, + TerminateJobResponse, + CreateJobResponse, + CreatePoolResponse, + DeletePoolResponse, + PoolExistsResponse, + UpdatePoolResponse, + DisablePoolAutoScaleResponse, + EnablePoolAutoScaleResponse, + ResizePoolResponse, + StopPoolResizeResponse, + ReplacePoolPropertiesResponse, + RemoveNodesResponse, } from "../models/models.js"; import { PagedAsyncIterableIterator, @@ -218,24 +262,26 @@ export function _listNodeFilesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listNodeFilesDeserialize( @@ -291,42 +337,44 @@ export function _getNodeFilePropertiesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .head({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); + return context.path(path).head({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); } export async function _getNodeFilePropertiesDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -334,7 +382,22 @@ export async function _getNodeFilePropertiesDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + ocpCreationTime: result.headers["ocp-creation-time"] + ? new Date(result.headers["ocp-creation-time"]) + : undefined, + ocpBatchFileIsdirectory: + result.headers["ocp-batch-file-isdirectory"]! === "true", + ocpBatchFileUrl: result.headers["ocp-batch-file-url"]!, + ocpBatchFileMode: result.headers["ocp-batch-file-mode"]!, + contentLength: Number(result.headers["content-length"]!), + } as GetNodeFilePropertiesResponse; } /** Gets the properties of the specified Compute Node file. */ @@ -344,8 +407,14 @@ export async function getNodeFileProperties( nodeId: string, filePath: string, options: GetNodeFilePropertiesOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _getNodeFilePropertiesSend(context, poolId, nodeId, filePath, options); +): Promise { + const result = await _getNodeFilePropertiesSend( + context, + poolId, + nodeId, + filePath, + options, + ); return _getNodeFilePropertiesDeserialize(result); } @@ -369,42 +438,48 @@ export function _getNodeFileSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...(options?.ocpRange !== undefined ? { "ocp-range": options?.ocpRange } : {}), - accept: "application/octet-stream", - ...options.requestOptions?.headers, - }, - }); -} - -export async function _getNodeFileDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...(options?.ocpRange !== undefined + ? { "ocp-range": options?.ocpRange } + : {}), + accept: "application/octet-stream", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getNodeFileDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -423,7 +498,13 @@ export async function getNodeFile( filePath: string, options: GetNodeFileOptionalParams = { requestOptions: {} }, ): Promise { - const streamableMethod = _getNodeFileSend(context, poolId, nodeId, filePath, options); + const streamableMethod = _getNodeFileSend( + context, + poolId, + nodeId, + filePath, + options, + ); const result = await getBinaryResponse(streamableMethod); return _getNodeFileDeserialize(result); } @@ -449,26 +530,30 @@ export function _deleteNodeFileSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteNodeFileDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteNodeFileDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -476,7 +561,10 @@ export async function _deleteNodeFileDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeleteNodeFileResponse; } /** Deletes the specified file from the Compute Node. */ @@ -486,8 +574,14 @@ export async function deleteNodeFile( nodeId: string, filePath: string, options: DeleteNodeFileOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _deleteNodeFileSend(context, poolId, nodeId, filePath, options); +): Promise { + const result = await _deleteNodeFileSend( + context, + poolId, + nodeId, + filePath, + options, + ); return _deleteNodeFileDeserialize(result); } @@ -514,24 +608,26 @@ export function _listNodeExtensionsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listNodeExtensionsDeserialize( @@ -588,24 +684,26 @@ export function _getNodeExtensionSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _getNodeExtensionDeserialize( @@ -629,7 +727,13 @@ export async function getNodeExtension( extensionName: string, options: GetNodeExtensionOptionalParams = { requestOptions: {} }, ): Promise { - const result = await _getNodeExtensionSend(context, poolId, nodeId, extensionName, options); + const result = await _getNodeExtensionSend( + context, + poolId, + nodeId, + extensionName, + options, + ); return _getNodeExtensionDeserialize(result); } @@ -656,24 +760,26 @@ export function _listNodesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listNodesDeserialize( @@ -727,26 +833,28 @@ export function _uploadNodeLogsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - body: uploadBatchServiceLogsOptionsSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: uploadBatchServiceLogsOptionsSerializer(body), + }); } export async function _uploadNodeLogsDeserialize( @@ -775,7 +883,13 @@ export async function uploadNodeLogs( body: UploadBatchServiceLogsOptions, options: UploadNodeLogsOptionalParams = { requestOptions: {} }, ): Promise { - const result = await _uploadNodeLogsSend(context, poolId, nodeId, body, options); + const result = await _uploadNodeLogsSend( + context, + poolId, + nodeId, + body, + options, + ); return _uploadNodeLogsDeserialize(result); } @@ -797,24 +911,26 @@ export function _getNodeRemoteDesktopFileSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/octet-stream", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/octet-stream", + ...options.requestOptions?.headers, + }, + }); } export async function _getNodeRemoteDesktopFileDeserialize( @@ -842,7 +958,12 @@ export async function getNodeRemoteDesktopFile( nodeId: string, options: GetNodeRemoteDesktopFileOptionalParams = { requestOptions: {} }, ): Promise { - const streamableMethod = _getNodeRemoteDesktopFileSend(context, poolId, nodeId, options); + const streamableMethod = _getNodeRemoteDesktopFileSend( + context, + poolId, + nodeId, + options, + ); const result = await getBinaryResponse(streamableMethod); return _getNodeRemoteDesktopFileDeserialize(result); } @@ -865,24 +986,26 @@ export function _getNodeRemoteLoginSettingsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _getNodeRemoteLoginSettingsDeserialize( @@ -911,7 +1034,12 @@ export async function getNodeRemoteLoginSettings( nodeId: string, options: GetNodeRemoteLoginSettingsOptionalParams = { requestOptions: {} }, ): Promise { - const result = await _getNodeRemoteLoginSettingsSend(context, poolId, nodeId, options); + const result = await _getNodeRemoteLoginSettingsSend( + context, + poolId, + nodeId, + options, + ); return _getNodeRemoteLoginSettingsDeserialize(result); } @@ -933,28 +1061,30 @@ export function _enableNodeSchedulingSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); } export async function _enableNodeSchedulingDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -962,7 +1092,15 @@ export async function _enableNodeSchedulingDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as EnableNodeSchedulingResponse; } /** @@ -974,8 +1112,13 @@ export async function enableNodeScheduling( poolId: string, nodeId: string, options: EnableNodeSchedulingOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _enableNodeSchedulingSend(context, poolId, nodeId, options); +): Promise { + const result = await _enableNodeSchedulingSend( + context, + poolId, + nodeId, + options, + ); return _enableNodeSchedulingDeserialize(result); } @@ -997,32 +1140,34 @@ export function _disableNodeSchedulingSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: !options["body"] - ? options["body"] - : nodeDisableSchedulingOptionsSerializer(options["body"]), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: !options["body"] + ? options["body"] + : nodeDisableSchedulingOptionsSerializer(options["body"]), + }); } export async function _disableNodeSchedulingDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1030,7 +1175,15 @@ export async function _disableNodeSchedulingDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as DisableNodeSchedulingResponse; } /** @@ -1042,8 +1195,13 @@ export async function disableNodeScheduling( poolId: string, nodeId: string, options: DisableNodeSchedulingOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _disableNodeSchedulingSend(context, poolId, nodeId, options); +): Promise { + const result = await _disableNodeSchedulingSend( + context, + poolId, + nodeId, + options, + ); return _disableNodeSchedulingDeserialize(result); } @@ -1065,28 +1223,34 @@ export function _reimageNodeSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: !options["body"] ? options["body"] : nodeReimageOptionsSerializer(options["body"]), - }); -} - -export async function _reimageNodeDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: !options["body"] + ? options["body"] + : nodeReimageOptionsSerializer(options["body"]), + }); +} + +export async function _reimageNodeDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1094,7 +1258,15 @@ export async function _reimageNodeDeserialize(result: PathUncheckedResponse): Pr throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReimageNodeResponse; } /** @@ -1107,7 +1279,7 @@ export async function reimageNode( poolId: string, nodeId: string, options: ReimageNodeOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _reimageNodeSend(context, poolId, nodeId, options); return _reimageNodeDeserialize(result); } @@ -1130,28 +1302,34 @@ export function _rebootNodeSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: !options["body"] ? options["body"] : nodeRebootOptionsSerializer(options["body"]), - }); -} - -export async function _rebootNodeDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: !options["body"] + ? options["body"] + : nodeRebootOptionsSerializer(options["body"]), + }); +} + +export async function _rebootNodeDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1159,7 +1337,15 @@ export async function _rebootNodeDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as RebootNodeResponse; } /** You can restart a Compute Node only if it is in an idle or running state. */ @@ -1168,7 +1354,7 @@ export async function rebootNode( poolId: string, nodeId: string, options: RebootNodeOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _rebootNodeSend(context, poolId, nodeId, options); return _rebootNodeDeserialize(result); } @@ -1196,27 +1382,31 @@ export function _getNodeSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); -} - -export async function _getNodeDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getNodeDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1259,28 +1449,32 @@ export function _replaceNodeUserSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .put({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchNodeUserUpdateOptionsSerializer(body), - }); -} - -export async function _replaceNodeUserDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchNodeUserUpdateOptionsSerializer(body), + }); +} + +export async function _replaceNodeUserDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1288,7 +1482,15 @@ export async function _replaceNodeUserDeserialize(result: PathUncheckedResponse) throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReplaceNodeUserResponse; } /** @@ -1304,8 +1506,15 @@ export async function replaceNodeUser( userName: string, body: BatchNodeUserUpdateOptions, options: ReplaceNodeUserOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _replaceNodeUserSend(context, poolId, nodeId, userName, body, options); +): Promise { + const result = await _replaceNodeUserSend( + context, + poolId, + nodeId, + userName, + body, + options, + ); return _replaceNodeUserDeserialize(result); } @@ -1329,26 +1538,30 @@ export function _deleteNodeUserSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteNodeUserDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteNodeUserDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1356,7 +1569,10 @@ export async function _deleteNodeUserDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeleteNodeUserResponse; } /** @@ -1369,8 +1585,14 @@ export async function deleteNodeUser( nodeId: string, userName: string, options: DeleteNodeUserOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _deleteNodeUserSend(context, poolId, nodeId, userName, options); +): Promise { + const result = await _deleteNodeUserSend( + context, + poolId, + nodeId, + userName, + options, + ); return _deleteNodeUserDeserialize(result); } @@ -1393,28 +1615,32 @@ export function _createNodeUserSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchNodeUserCreateOptionsSerializer(body), - }); -} - -export async function _createNodeUserDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchNodeUserCreateOptionsSerializer(body), + }); +} + +export async function _createNodeUserDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1422,7 +1648,15 @@ export async function _createNodeUserDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CreateNodeUserResponse; } /** @@ -1435,8 +1669,14 @@ export async function createNodeUser( nodeId: string, body: BatchNodeUserCreateOptions, options: CreateNodeUserOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _createNodeUserSend(context, poolId, nodeId, body, options); +): Promise { + const result = await _createNodeUserSend( + context, + poolId, + nodeId, + body, + options, + ); return _createNodeUserDeserialize(result); } @@ -1461,24 +1701,26 @@ export function _listTaskFilesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listTaskFilesDeserialize( @@ -1534,42 +1776,44 @@ export function _getTaskFilePropertiesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .head({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); + return context.path(path).head({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); } export async function _getTaskFilePropertiesDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1577,7 +1821,22 @@ export async function _getTaskFilePropertiesDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + ocpCreationTime: result.headers["ocp-creation-time"] + ? new Date(result.headers["ocp-creation-time"]) + : undefined, + ocpBatchFileIsdirectory: + result.headers["ocp-batch-file-isdirectory"]! === "true", + ocpBatchFileUrl: result.headers["ocp-batch-file-url"]!, + ocpBatchFileMode: result.headers["ocp-batch-file-mode"]!, + contentLength: Number(result.headers["content-length"]!), + } as GetTaskFilePropertiesResponse; } /** Gets the properties of the specified Task file. */ @@ -1587,8 +1846,14 @@ export async function getTaskFileProperties( taskId: string, filePath: string, options: GetTaskFilePropertiesOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _getTaskFilePropertiesSend(context, jobId, taskId, filePath, options); +): Promise { + const result = await _getTaskFilePropertiesSend( + context, + jobId, + taskId, + filePath, + options, + ); return _getTaskFilePropertiesDeserialize(result); } @@ -1612,42 +1877,48 @@ export function _getTaskFileSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...(options?.ocpRange !== undefined ? { "ocp-range": options?.ocpRange } : {}), - accept: "application/octet-stream", - ...options.requestOptions?.headers, - }, - }); -} - -export async function _getTaskFileDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...(options?.ocpRange !== undefined + ? { "ocp-range": options?.ocpRange } + : {}), + accept: "application/octet-stream", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getTaskFileDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1666,7 +1937,13 @@ export async function getTaskFile( filePath: string, options: GetTaskFileOptionalParams = { requestOptions: {} }, ): Promise { - const streamableMethod = _getTaskFileSend(context, jobId, taskId, filePath, options); + const streamableMethod = _getTaskFileSend( + context, + jobId, + taskId, + filePath, + options, + ); const result = await getBinaryResponse(streamableMethod); return _getTaskFileDeserialize(result); } @@ -1692,26 +1969,30 @@ export function _deleteTaskFileSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteTaskFileDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteTaskFileDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1719,7 +2000,10 @@ export async function _deleteTaskFileDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeleteTaskFileResponse; } /** Deletes the specified Task file from the Compute Node where the Task ran. */ @@ -1729,8 +2013,14 @@ export async function deleteTaskFile( taskId: string, filePath: string, options: DeleteTaskFileOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _deleteTaskFileSend(context, jobId, taskId, filePath, options); +): Promise { + const result = await _deleteTaskFileSend( + context, + jobId, + taskId, + filePath, + options, + ); return _deleteTaskFileDeserialize(result); } @@ -1752,42 +2042,50 @@ export function _reactivateTaskSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _reactivateTaskDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _reactivateTaskDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1795,7 +2093,15 @@ export async function _reactivateTaskDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReactivateTaskResponse; } /** @@ -1812,7 +2118,7 @@ export async function reactivateTask( jobId: string, taskId: string, options: ReactivateTaskOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _reactivateTaskSend(context, jobId, taskId, options); return _reactivateTaskDeserialize(result); } @@ -1835,42 +2141,50 @@ export function _terminateTaskSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _terminateTaskDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _terminateTaskDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -1878,7 +2192,15 @@ export async function _terminateTaskDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as TerminateTaskResponse; } /** @@ -1891,7 +2213,7 @@ export async function terminateTask( jobId: string, taskId: string, options: TerminateTaskOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _terminateTaskSend(context, jobId, taskId, options); return _terminateTaskDeserialize(result); } @@ -1919,24 +2241,26 @@ export function _listSubTasksSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listSubTasksDeserialize( @@ -1982,44 +2306,52 @@ export function _replaceTaskSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .put({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchTaskSerializer(body), - }); -} - -export async function _replaceTaskDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchTaskSerializer(body), + }); +} + +export async function _replaceTaskDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2027,7 +2359,15 @@ export async function _replaceTaskDeserialize(result: PathUncheckedResponse): Pr throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReplaceTaskResponse; } /** Updates the properties of the specified Task. */ @@ -2037,7 +2377,7 @@ export async function replaceTask( taskId: string, body: BatchTask, options: ReplaceTaskOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _replaceTaskSend(context, jobId, taskId, body, options); return _replaceTaskDeserialize(result); } @@ -2070,43 +2410,51 @@ export function _getTaskSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); -} - -export async function _getTaskDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getTaskDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2150,42 +2498,50 @@ export function _deleteTaskSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteTaskDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteTaskDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2193,7 +2549,10 @@ export async function _deleteTaskDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeleteTaskResponse; } /** @@ -2208,7 +2567,7 @@ export async function deleteTask( jobId: string, taskId: string, options: DeleteTaskOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _deleteTaskSend(context, jobId, taskId, options); return _deleteTaskDeserialize(result); } @@ -2230,26 +2589,28 @@ export function _createTaskCollectionSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - body: batchTaskCollectionSerializer(collection), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: batchTaskCollectionSerializer(collection), + }); } export async function _createTaskCollectionDeserialize( @@ -2287,7 +2648,12 @@ export async function createTaskCollection( collection: BatchTaskCollection, options: CreateTaskCollectionOptionalParams = { requestOptions: {} }, ): Promise { - const result = await _createTaskCollectionSend(context, jobId, collection, options); + const result = await _createTaskCollectionSend( + context, + jobId, + collection, + options, + ); return _createTaskCollectionDeserialize(result); } @@ -2319,24 +2685,26 @@ export function _listTasksSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listTasksDeserialize( @@ -2392,28 +2760,32 @@ export function _createTaskSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchTaskCreateOptionsSerializer(body), - }); -} - -export async function _createTaskDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchTaskCreateOptionsSerializer(body), + }); +} + +export async function _createTaskDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2421,7 +2793,15 @@ export async function _createTaskDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CreateTaskResponse; } /** @@ -2434,7 +2814,7 @@ export async function createTask( jobId: string, body: BatchTaskCreateOptions, options: CreateTaskOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _createTaskSend(context, jobId, body, options); return _createTaskDeserialize(result); } @@ -2465,24 +2845,26 @@ export function _listJobSchedulesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listJobSchedulesDeserialize( @@ -2531,28 +2913,32 @@ export function _createJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobScheduleCreateOptionsSerializer(body), - }); -} - -export async function _createJobScheduleDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobScheduleCreateOptionsSerializer(body), + }); +} + +export async function _createJobScheduleDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2560,7 +2946,15 @@ export async function _createJobScheduleDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CreateJobScheduleResponse; } /** Creates a Job Schedule to the specified Account. */ @@ -2568,7 +2962,7 @@ export async function createJobSchedule( context: Client, body: BatchJobScheduleCreateOptions, options: CreateJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _createJobScheduleSend(context, body, options); return _createJobScheduleDeserialize(result); } @@ -2589,44 +2983,50 @@ export function _terminateJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); } export async function _terminateJobScheduleDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2634,7 +3034,15 @@ export async function _terminateJobScheduleDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as TerminateJobScheduleResponse; } /** Terminates a Job Schedule. */ @@ -2642,8 +3050,12 @@ export async function terminateJobSchedule( context: Client, jobScheduleId: string, options: TerminateJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _terminateJobScheduleSend(context, jobScheduleId, options); +): Promise { + const result = await _terminateJobScheduleSend( + context, + jobScheduleId, + options, + ); return _terminateJobScheduleDeserialize(result); } @@ -2663,42 +3075,50 @@ export function _enableJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _enableJobScheduleDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _enableJobScheduleDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2706,7 +3126,15 @@ export async function _enableJobScheduleDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as EnableJobScheduleResponse; } /** Enables a Job Schedule. */ @@ -2714,7 +3142,7 @@ export async function enableJobSchedule( context: Client, jobScheduleId: string, options: EnableJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _enableJobScheduleSend(context, jobScheduleId, options); return _enableJobScheduleDeserialize(result); } @@ -2735,42 +3163,50 @@ export function _disableJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _disableJobScheduleDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _disableJobScheduleDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2778,7 +3214,15 @@ export async function _disableJobScheduleDeserialize(result: PathUncheckedRespon throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as DisableJobScheduleResponse; } /** No new Jobs will be created until the Job Schedule is enabled again. */ @@ -2786,7 +3230,7 @@ export async function disableJobSchedule( context: Client, jobScheduleId: string, options: DisableJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _disableJobScheduleSend(context, jobScheduleId, options); return _disableJobScheduleDeserialize(result); } @@ -2808,44 +3252,52 @@ export function _replaceJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .put({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobScheduleSerializer(body), - }); -} - -export async function _replaceJobScheduleDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobScheduleSerializer(body), + }); +} + +export async function _replaceJobScheduleDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2853,7 +3305,15 @@ export async function _replaceJobScheduleDeserialize(result: PathUncheckedRespon throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReplaceJobScheduleResponse; } /** @@ -2868,8 +3328,13 @@ export async function replaceJobSchedule( jobScheduleId: string, body: BatchJobSchedule, options: ReplaceJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _replaceJobScheduleSend(context, jobScheduleId, body, options); +): Promise { + const result = await _replaceJobScheduleSend( + context, + jobScheduleId, + body, + options, + ); return _replaceJobScheduleDeserialize(result); } @@ -2890,44 +3355,52 @@ export function _updateJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .patch({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobScheduleUpdateOptionsSerializer(body), - }); -} - -export async function _updateJobScheduleDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobScheduleUpdateOptionsSerializer(body), + }); +} + +export async function _updateJobScheduleDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -2935,7 +3408,15 @@ export async function _updateJobScheduleDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as UpdateJobScheduleResponse; } /** @@ -2950,8 +3431,13 @@ export async function updateJobSchedule( jobScheduleId: string, body: BatchJobScheduleUpdateOptions, options: UpdateJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _updateJobScheduleSend(context, jobScheduleId, body, options); +): Promise { + const result = await _updateJobScheduleSend( + context, + jobScheduleId, + body, + options, + ); return _updateJobScheduleDeserialize(result); } @@ -2981,40 +3467,46 @@ export function _getJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _getJobScheduleDeserialize( @@ -3056,42 +3548,50 @@ export function _deleteJobScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteJobScheduleDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteJobScheduleDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3099,7 +3599,10 @@ export async function _deleteJobScheduleDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeleteJobScheduleResponse; } /** @@ -3113,7 +3616,7 @@ export async function deleteJobSchedule( context: Client, jobScheduleId: string, options: DeleteJobScheduleOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _deleteJobScheduleSend(context, jobScheduleId, options); return _deleteJobScheduleDeserialize(result); } @@ -3134,42 +3637,50 @@ export function _jobScheduleExistsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .head({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _jobScheduleExistsDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).head({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _jobScheduleExistsDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200", "404"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3177,7 +3688,14 @@ export async function _jobScheduleExistsDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + } as JobScheduleExistsResponse; } /** Checks the specified Job Schedule exists. */ @@ -3185,7 +3703,7 @@ export async function jobScheduleExists( context: Client, jobScheduleId: string, options: JobScheduleExistsOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _jobScheduleExistsSend(context, jobScheduleId, options); return _jobScheduleExistsDeserialize(result); } @@ -3213,24 +3731,26 @@ export function _getCertificateSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _getCertificateDeserialize( @@ -3253,7 +3773,12 @@ export async function getCertificate( thumbprint: string, options: GetCertificateOptionalParams = { requestOptions: {} }, ): Promise { - const result = await _getCertificateSend(context, thumbprintAlgorithm, thumbprint, options); + const result = await _getCertificateSend( + context, + thumbprintAlgorithm, + thumbprint, + options, + ); return _getCertificateDeserialize(result); } @@ -3275,26 +3800,30 @@ export function _deleteCertificateSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteCertificateDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteCertificateDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3302,7 +3831,14 @@ export async function _deleteCertificateDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + } as DeleteCertificateResponse; } /** @@ -3321,8 +3857,13 @@ export async function deleteCertificate( thumbprintAlgorithm: string, thumbprint: string, options: DeleteCertificateOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _deleteCertificateSend(context, thumbprintAlgorithm, thumbprint, options); +): Promise { + const result = await _deleteCertificateSend( + context, + thumbprintAlgorithm, + thumbprint, + options, + ); return _deleteCertificateDeserialize(result); } @@ -3344,28 +3885,30 @@ export function _cancelCertificateDeletionSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); } export async function _cancelCertificateDeletionDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3373,7 +3916,15 @@ export async function _cancelCertificateDeletionDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CancelCertificateDeletionResponse; } /** @@ -3390,7 +3941,7 @@ export async function cancelCertificateDeletion( thumbprintAlgorithm: string, thumbprint: string, options: CancelCertificateDeletionOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _cancelCertificateDeletionSend( context, thumbprintAlgorithm, @@ -3421,24 +3972,26 @@ export function _listCertificatesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listCertificatesDeserialize( @@ -3487,28 +4040,32 @@ export function _createCertificateSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchCertificateSerializer(body), - }); -} - -export async function _createCertificateDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchCertificateSerializer(body), + }); +} + +export async function _createCertificateDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3516,7 +4073,15 @@ export async function _createCertificateDeserialize(result: PathUncheckedRespons throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CreateCertificateResponse; } /** Creates a Certificate to the specified Account. */ @@ -3524,7 +4089,7 @@ export async function createCertificate( context: Client, body: BatchCertificate, options: CreateCertificateOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _createCertificateSend(context, body, options); return _createCertificateDeserialize(result); } @@ -3545,24 +4110,26 @@ export function _getJobTaskCountsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _getJobTaskCountsDeserialize( @@ -3596,7 +4163,9 @@ export async function getJobTaskCounts( export function _listJobPreparationAndReleaseTaskStatusSend( context: Client, jobId: string, - options: ListJobPreparationAndReleaseTaskStatusOptionalParams = { requestOptions: {} }, + options: ListJobPreparationAndReleaseTaskStatusOptionalParams = { + requestOptions: {}, + }, ): StreamableMethod { const path = expandUrlTemplate( "/jobs/{jobId}/jobpreparationandreleasetaskstatus{?maxresults,timeOut,%24filter,%24select}", @@ -3615,24 +4184,26 @@ export function _listJobPreparationAndReleaseTaskStatusSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listJobPreparationAndReleaseTaskStatusDeserialize( @@ -3645,7 +4216,9 @@ export async function _listJobPreparationAndReleaseTaskStatusDeserialize( throw error; } - return _batchJobListPreparationAndReleaseTaskStatusResultDeserializer(result.body); + return _batchJobListPreparationAndReleaseTaskStatusResultDeserializer( + result.body, + ); } /** @@ -3659,7 +4232,9 @@ export async function _listJobPreparationAndReleaseTaskStatusDeserialize( export function listJobPreparationAndReleaseTaskStatus( context: Client, jobId: string, - options: ListJobPreparationAndReleaseTaskStatusOptionalParams = { requestOptions: {} }, + options: ListJobPreparationAndReleaseTaskStatusOptionalParams = { + requestOptions: {}, + }, ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, @@ -3698,24 +4273,26 @@ export function _listJobsFromScheduleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listJobsFromScheduleDeserialize( @@ -3776,24 +4353,26 @@ export function _listJobsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listJobsDeserialize( @@ -3842,28 +4421,32 @@ export function _createJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobCreateOptionsSerializer(body), - }); -} - -export async function _createJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobCreateOptionsSerializer(body), + }); +} + +export async function _createJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3871,7 +4454,15 @@ export async function _createJobDeserialize(result: PathUncheckedResponse): Prom throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CreateJobResponse; } /** @@ -3889,7 +4480,7 @@ export async function createJob( context: Client, body: BatchJobCreateOptions, options: CreateJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _createJobSend(context, body, options); return _createJobDeserialize(result); } @@ -3910,46 +4501,54 @@ export function _terminateJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: !options["body"] - ? options["body"] - : batchJobTerminateOptionsSerializer(options["body"]), - }); -} - -export async function _terminateJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: !options["body"] + ? options["body"] + : batchJobTerminateOptionsSerializer(options["body"]), + }); +} + +export async function _terminateJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -3957,7 +4556,15 @@ export async function _terminateJobDeserialize(result: PathUncheckedResponse): P throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as TerminateJobResponse; } /** @@ -3972,7 +4579,7 @@ export async function terminateJob( context: Client, jobId: string, options: TerminateJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _terminateJobSend(context, jobId, options); return _terminateJobDeserialize(result); } @@ -3993,42 +4600,50 @@ export function _enableJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _enableJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _enableJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4036,7 +4651,15 @@ export async function _enableJobDeserialize(result: PathUncheckedResponse): Prom throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as EnableJobResponse; } /** @@ -4051,7 +4674,7 @@ export async function enableJob( context: Client, jobId: string, options: EnableJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _enableJobSend(context, jobId, options); return _enableJobDeserialize(result); } @@ -4073,44 +4696,52 @@ export function _disableJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobDisableOptionsSerializer(body), - }); -} - -export async function _disableJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobDisableOptionsSerializer(body), + }); +} + +export async function _disableJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4118,7 +4749,15 @@ export async function _disableJobDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as DisableJobResponse; } /** @@ -4136,7 +4775,7 @@ export async function disableJob( jobId: string, body: BatchJobDisableOptions, options: DisableJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _disableJobSend(context, jobId, body, options); return _disableJobDeserialize(result); } @@ -4158,44 +4797,52 @@ export function _replaceJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .put({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobSerializer(body), - }); -} - -export async function _replaceJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobSerializer(body), + }); +} + +export async function _replaceJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4203,7 +4850,15 @@ export async function _replaceJobDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReplaceJobResponse; } /** @@ -4216,7 +4871,7 @@ export async function replaceJob( jobId: string, body: BatchJob, options: ReplaceJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _replaceJobSend(context, jobId, body, options); return _replaceJobDeserialize(result); } @@ -4238,44 +4893,52 @@ export function _updateJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .patch({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchJobUpdateOptionsSerializer(body), - }); -} - -export async function _updateJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchJobUpdateOptionsSerializer(body), + }); +} + +export async function _updateJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4283,7 +4946,15 @@ export async function _updateJobDeserialize(result: PathUncheckedResponse): Prom throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as UpdateJobResponse; } /** @@ -4296,7 +4967,7 @@ export async function updateJob( jobId: string, body: BatchJobUpdateOptions, options: UpdateJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _updateJobSend(context, jobId, body, options); return _updateJobDeserialize(result); } @@ -4327,43 +4998,51 @@ export function _getJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); -} - -export async function _getJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4400,42 +5079,50 @@ export function _deleteJobSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deleteJobDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteJobDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4443,7 +5130,10 @@ export async function _deleteJobDeserialize(result: PathUncheckedResponse): Prom throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeleteJobResponse; } /** @@ -4460,7 +5150,7 @@ export async function deleteJob( context: Client, jobId: string, options: DeleteJobOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _deleteJobSend(context, jobId, options); return _deleteJobDeserialize(result); } @@ -4481,24 +5171,26 @@ export function _listPoolNodeCountsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listPoolNodeCountsDeserialize( @@ -4551,24 +5243,26 @@ export function _listSupportedImagesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listSupportedImagesDeserialize( @@ -4615,44 +5309,52 @@ export function _removeNodesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: nodeRemoveOptionsSerializer(body), - }); -} - -export async function _removeNodesDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: nodeRemoveOptionsSerializer(body), + }); +} + +export async function _removeNodesDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4660,7 +5362,15 @@ export async function _removeNodesDeserialize(result: PathUncheckedResponse): Pr throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as RemoveNodesResponse; } /** @@ -4673,7 +5383,7 @@ export async function removeNodes( poolId: string, body: NodeRemoveOptions, options: RemoveNodesOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _removeNodesSend(context, poolId, body, options); return _removeNodesDeserialize(result); } @@ -4695,30 +5405,32 @@ export function _replacePoolPropertiesSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchPoolReplaceOptionsSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchPoolReplaceOptionsSerializer(body), + }); } export async function _replacePoolPropertiesDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4726,7 +5438,15 @@ export async function _replacePoolPropertiesDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ReplacePoolPropertiesResponse; } /** @@ -4739,8 +5459,13 @@ export async function replacePoolProperties( poolId: string, body: BatchPoolReplaceOptions, options: ReplacePoolPropertiesOptionalParams = { requestOptions: {} }, -): Promise { - const result = await _replacePoolPropertiesSend(context, poolId, body, options); +): Promise { + const result = await _replacePoolPropertiesSend( + context, + poolId, + body, + options, + ); return _replacePoolPropertiesDeserialize(result); } @@ -4760,42 +5485,50 @@ export function _stopPoolResizeSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _stopPoolResizeDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _stopPoolResizeDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4803,7 +5536,15 @@ export async function _stopPoolResizeDeserialize(result: PathUncheckedResponse): throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as StopPoolResizeResponse; } /** @@ -4819,7 +5560,7 @@ export async function stopPoolResize( context: Client, poolId: string, options: StopPoolResizeOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _stopPoolResizeSend(context, poolId, options); return _stopPoolResizeDeserialize(result); } @@ -4841,44 +5582,52 @@ export function _resizePoolSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchPoolResizeOptionsSerializer(body), - }); -} - -export async function _resizePoolDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchPoolResizeOptionsSerializer(body), + }); +} + +export async function _resizePoolDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -4886,7 +5635,15 @@ export async function _resizePoolDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as ResizePoolResponse; } /** @@ -4903,7 +5660,7 @@ export async function resizePool( poolId: string, body: BatchPoolResizeOptions, options: ResizePoolOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _resizePoolSend(context, poolId, body, options); return _resizePoolDeserialize(result); } @@ -4925,26 +5682,28 @@ export function _evaluatePoolAutoScaleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - body: batchPoolEvaluateAutoScaleOptionsSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: batchPoolEvaluateAutoScaleOptionsSerializer(body), + }); } export async function _evaluatePoolAutoScaleDeserialize( @@ -4971,7 +5730,12 @@ export async function evaluatePoolAutoScale( body: BatchPoolEvaluateAutoScaleOptions, options: EvaluatePoolAutoScaleOptionalParams = { requestOptions: {} }, ): Promise { - const result = await _evaluatePoolAutoScaleSend(context, poolId, body, options); + const result = await _evaluatePoolAutoScaleSend( + context, + poolId, + body, + options, + ); return _evaluatePoolAutoScaleDeserialize(result); } @@ -4992,46 +5756,52 @@ export function _enablePoolAutoScaleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchPoolEnableAutoScaleOptionsSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchPoolEnableAutoScaleOptionsSerializer(body), + }); } export async function _enablePoolAutoScaleDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5039,7 +5809,15 @@ export async function _enablePoolAutoScaleDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as EnablePoolAutoScaleResponse; } /** @@ -5055,7 +5833,7 @@ export async function enablePoolAutoScale( poolId: string, body: BatchPoolEnableAutoScaleOptions, options: EnablePoolAutoScaleOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _enablePoolAutoScaleSend(context, poolId, body, options); return _enablePoolAutoScaleDeserialize(result); } @@ -5076,28 +5854,30 @@ export function _disablePoolAutoScaleSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); } export async function _disablePoolAutoScaleDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5105,7 +5885,15 @@ export async function _disablePoolAutoScaleDeserialize( throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as DisablePoolAutoScaleResponse; } /** Disables automatic scaling for a Pool. */ @@ -5113,7 +5901,7 @@ export async function disablePoolAutoScale( context: Client, poolId: string, options: DisablePoolAutoScaleOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _disablePoolAutoScaleSend(context, poolId, options); return _disablePoolAutoScaleDeserialize(result); } @@ -5135,44 +5923,52 @@ export function _updatePoolSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .patch({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - body: batchPoolUpdateOptionsSerializer(body), - }); -} - -export async function _updatePoolDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchPoolUpdateOptionsSerializer(body), + }); +} + +export async function _updatePoolDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5180,7 +5976,15 @@ export async function _updatePoolDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as UpdatePoolResponse; } /** @@ -5193,7 +5997,7 @@ export async function updatePool( poolId: string, body: BatchPoolUpdateOptions, options: UpdatePoolOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _updatePoolSend(context, poolId, body, options); return _updatePoolDeserialize(result); } @@ -5224,43 +6028,51 @@ export function _getPoolSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); -} - -export async function _getPoolDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getPoolDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5297,42 +6109,50 @@ export function _poolExistsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .head({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _poolExistsDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).head({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _poolExistsDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["404", "200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5340,7 +6160,14 @@ export async function _poolExistsDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + } as PoolExistsResponse; } /** Gets basic properties of a Pool. */ @@ -5348,7 +6175,7 @@ export async function poolExists( context: Client, poolId: string, options: PoolExistsOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _poolExistsSend(context, poolId, options); return _poolExistsDeserialize(result); } @@ -5369,42 +6196,50 @@ export function _deletePoolSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .delete({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.ifMatch !== undefined ? { "if-match": options?.ifMatch } : {}), - ...(options?.ifNoneMatch !== undefined ? { "if-none-match": options?.ifNoneMatch } : {}), - ...(options?.ifModifiedSince !== undefined - ? { - "if-modified-since": !options?.ifModifiedSince - ? options?.ifModifiedSince - : options?.ifModifiedSince.toUTCString(), - } - : {}), - ...(options?.ifUnmodifiedSince !== undefined - ? { - "if-unmodified-since": !options?.ifUnmodifiedSince - ? options?.ifUnmodifiedSince - : options?.ifUnmodifiedSince.toUTCString(), - } - : {}), - ...options.requestOptions?.headers, - }, - }); -} - -export async function _deletePoolDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.ifMatch !== undefined + ? { "if-match": options?.ifMatch } + : {}), + ...(options?.ifNoneMatch !== undefined + ? { "if-none-match": options?.ifNoneMatch } + : {}), + ...(options?.ifModifiedSince !== undefined + ? { + "if-modified-since": !options?.ifModifiedSince + ? options?.ifModifiedSince + : options?.ifModifiedSince.toUTCString(), + } + : {}), + ...(options?.ifUnmodifiedSince !== undefined + ? { + "if-unmodified-since": !options?.ifUnmodifiedSince + ? options?.ifUnmodifiedSince + : options?.ifUnmodifiedSince.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deletePoolDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["202"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5412,7 +6247,10 @@ export async function _deletePoolDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + } as DeletePoolResponse; } /** @@ -5433,7 +6271,7 @@ export async function deletePool( context: Client, poolId: string, options: DeletePoolOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _deletePoolSend(context, poolId, options); return _deletePoolDeserialize(result); } @@ -5464,24 +6302,26 @@ export function _listPoolsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listPoolsDeserialize( @@ -5530,28 +6370,32 @@ export function _createPoolSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json; odata=minimalmetadata", - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...options.requestOptions?.headers, - }, - body: batchPoolCreateOptionsSerializer(body), - }); -} - -export async function _createPoolDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json; odata=minimalmetadata", + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...options.requestOptions?.headers, + }, + body: batchPoolCreateOptionsSerializer(body), + }); +} + +export async function _createPoolDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -5559,7 +6403,15 @@ export async function _createPoolDeserialize(result: PathUncheckedResponse): Pro throw error; } - return; + return { + clientRequestId: result.headers?.["client-request-id"], + requestId: result.headers?.["request-id"], + eTag: result.headers?.["etag"], + lastModified: result.headers["last-modified"] + ? new Date(result.headers["last-modified"]) + : undefined, + dataServiceId: result.headers["dataserviceid"]!, + } as CreatePoolResponse; } /** @@ -5571,7 +6423,7 @@ export async function createPool( context: Client, body: BatchPoolCreateOptions, options: CreatePoolOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _createPoolSend(context, body, options); return _createPoolDeserialize(result); } @@ -5586,32 +6438,38 @@ export function _listPoolUsageMetricsSend( "api%2Dversion": context.apiVersion ?? "2023-05-01.17.0", maxresults: options?.maxresults, timeOut: options?.timeOutInSeconds, - starttime: !options?.starttime ? options?.starttime : options?.starttime.toISOString(), - endtime: !options?.endtime ? options?.endtime : options?.endtime.toISOString(), + starttime: !options?.starttime + ? options?.starttime + : options?.starttime.toISOString(), + endtime: !options?.endtime + ? options?.endtime + : options?.endtime.toISOString(), "%24filter": options?.filter, }, { allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listPoolUsageMetricsDeserialize( @@ -5668,24 +6526,26 @@ export function _getApplicationSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _getApplicationDeserialize( @@ -5732,24 +6592,26 @@ export function _listApplicationsSend( allowReserved: options?.requestOptions?.skipUrlEncoding, }, ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.ocpDate !== undefined - ? { "ocp-date": !options?.ocpDate ? options?.ocpDate : options?.ocpDate.toUTCString() } - : {}), - ...(options?.clientRequestId !== undefined - ? { "client-request-id": options?.clientRequestId } - : {}), - ...(options?.returnClientRequestId !== undefined - ? { "return-client-request-id": options?.returnClientRequestId } - : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.ocpDate !== undefined + ? { + "ocp-date": !options?.ocpDate + ? options?.ocpDate + : options?.ocpDate.toUTCString(), + } + : {}), + ...(options?.clientRequestId !== undefined + ? { "client-request-id": options?.clientRequestId } + : {}), + ...(options?.returnClientRequestId !== undefined + ? { "return-client-request-id": options?.returnClientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); } export async function _listApplicationsDeserialize( diff --git a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/batchClient.ts b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/batchClient.ts index dfebe1efb7..7c40129619 100644 --- a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/batchClient.ts +++ b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/batchClient.ts @@ -195,6 +195,50 @@ import { UploadBatchServiceLogsOptions, UploadBatchServiceLogsResult, NodeVMExtension, + CreateNodeUserResponse, + DeleteNodeUserResponse, + ReplaceNodeUserResponse, + RebootNodeResponse, + ReimageNodeResponse, + DisableNodeSchedulingResponse, + EnableNodeSchedulingResponse, + DeleteNodeFileResponse, + GetNodeFilePropertiesResponse, + CreateTaskResponse, + DeleteTaskResponse, + ReplaceTaskResponse, + TerminateTaskResponse, + ReactivateTaskResponse, + DeleteTaskFileResponse, + GetTaskFilePropertiesResponse, + JobScheduleExistsResponse, + DeleteJobScheduleResponse, + UpdateJobScheduleResponse, + ReplaceJobScheduleResponse, + DisableJobScheduleResponse, + EnableJobScheduleResponse, + TerminateJobScheduleResponse, + CreateJobScheduleResponse, + CreateCertificateResponse, + CancelCertificateDeletionResponse, + DeleteCertificateResponse, + DeleteJobResponse, + UpdateJobResponse, + ReplaceJobResponse, + DisableJobResponse, + EnableJobResponse, + TerminateJobResponse, + CreateJobResponse, + CreatePoolResponse, + DeletePoolResponse, + PoolExistsResponse, + UpdatePoolResponse, + DisablePoolAutoScaleResponse, + EnablePoolAutoScaleResponse, + ResizePoolResponse, + StopPoolResizeResponse, + ReplacePoolPropertiesResponse, + RemoveNodesResponse, } from "./models/models.js"; import { PagedAsyncIterableIterator } from "./static-helpers/pagingHelpers.js"; import { TokenCredential } from "@azure/core-auth"; @@ -239,7 +283,7 @@ export class BatchClient { nodeId: string, filePath: string, options: GetNodeFilePropertiesOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return getNodeFileProperties(this._client, poolId, nodeId, filePath, options); } @@ -259,7 +303,7 @@ export class BatchClient { nodeId: string, filePath: string, options: DeleteNodeFileOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteNodeFile(this._client, poolId, nodeId, filePath, options); } @@ -342,7 +386,7 @@ export class BatchClient { poolId: string, nodeId: string, options: EnableNodeSchedulingOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return enableNodeScheduling(this._client, poolId, nodeId, options); } @@ -354,7 +398,7 @@ export class BatchClient { poolId: string, nodeId: string, options: DisableNodeSchedulingOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return disableNodeScheduling(this._client, poolId, nodeId, options); } @@ -367,7 +411,7 @@ export class BatchClient { poolId: string, nodeId: string, options: ReimageNodeOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return reimageNode(this._client, poolId, nodeId, options); } @@ -376,7 +420,7 @@ export class BatchClient { poolId: string, nodeId: string, options: RebootNodeOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return rebootNode(this._client, poolId, nodeId, options); } @@ -401,7 +445,7 @@ export class BatchClient { userName: string, body: BatchNodeUserUpdateOptions, options: ReplaceNodeUserOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return replaceNodeUser(this._client, poolId, nodeId, userName, body, options); } @@ -414,7 +458,7 @@ export class BatchClient { nodeId: string, userName: string, options: DeleteNodeUserOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteNodeUser(this._client, poolId, nodeId, userName, options); } @@ -427,7 +471,7 @@ export class BatchClient { nodeId: string, body: BatchNodeUserCreateOptions, options: CreateNodeUserOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return createNodeUser(this._client, poolId, nodeId, body, options); } @@ -446,7 +490,7 @@ export class BatchClient { taskId: string, filePath: string, options: GetTaskFilePropertiesOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return getTaskFileProperties(this._client, jobId, taskId, filePath, options); } @@ -466,7 +510,7 @@ export class BatchClient { taskId: string, filePath: string, options: DeleteTaskFileOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteTaskFile(this._client, jobId, taskId, filePath, options); } @@ -483,7 +527,7 @@ export class BatchClient { jobId: string, taskId: string, options: ReactivateTaskOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return reactivateTask(this._client, jobId, taskId, options); } @@ -496,7 +540,7 @@ export class BatchClient { jobId: string, taskId: string, options: TerminateTaskOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return terminateTask(this._client, jobId, taskId, options); } @@ -515,7 +559,7 @@ export class BatchClient { taskId: string, body: BatchTask, options: ReplaceTaskOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return replaceTask(this._client, jobId, taskId, body, options); } @@ -543,7 +587,7 @@ export class BatchClient { jobId: string, taskId: string, options: DeleteTaskOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteTask(this._client, jobId, taskId, options); } @@ -592,7 +636,7 @@ export class BatchClient { jobId: string, body: BatchTaskCreateOptions, options: CreateTaskOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return createTask(this._client, jobId, body, options); } @@ -607,7 +651,7 @@ export class BatchClient { createJobSchedule( body: BatchJobScheduleCreateOptions, options: CreateJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return createJobSchedule(this._client, body, options); } @@ -615,7 +659,7 @@ export class BatchClient { terminateJobSchedule( jobScheduleId: string, options: TerminateJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return terminateJobSchedule(this._client, jobScheduleId, options); } @@ -623,7 +667,7 @@ export class BatchClient { enableJobSchedule( jobScheduleId: string, options: EnableJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return enableJobSchedule(this._client, jobScheduleId, options); } @@ -631,7 +675,7 @@ export class BatchClient { disableJobSchedule( jobScheduleId: string, options: DisableJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return disableJobSchedule(this._client, jobScheduleId, options); } @@ -646,7 +690,7 @@ export class BatchClient { jobScheduleId: string, body: BatchJobSchedule, options: ReplaceJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return replaceJobSchedule(this._client, jobScheduleId, body, options); } @@ -661,7 +705,7 @@ export class BatchClient { jobScheduleId: string, body: BatchJobScheduleUpdateOptions, options: UpdateJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return updateJobSchedule(this._client, jobScheduleId, body, options); } @@ -683,7 +727,7 @@ export class BatchClient { deleteJobSchedule( jobScheduleId: string, options: DeleteJobScheduleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteJobSchedule(this._client, jobScheduleId, options); } @@ -691,7 +735,7 @@ export class BatchClient { jobScheduleExists( jobScheduleId: string, options: JobScheduleExistsOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return jobScheduleExists(this._client, jobScheduleId, options); } @@ -719,7 +763,7 @@ export class BatchClient { thumbprintAlgorithm: string, thumbprint: string, options: DeleteCertificateOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteCertificate(this._client, thumbprintAlgorithm, thumbprint, options); } @@ -736,7 +780,7 @@ export class BatchClient { thumbprintAlgorithm: string, thumbprint: string, options: CancelCertificateDeletionOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return cancelCertificateDeletion(this._client, thumbprintAlgorithm, thumbprint, options); } @@ -751,7 +795,7 @@ export class BatchClient { createCertificate( body: BatchCertificate, options: CreateCertificateOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return createCertificate(this._client, body, options); } @@ -812,7 +856,7 @@ export class BatchClient { createJob( body: BatchJobCreateOptions, options: CreateJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return createJob(this._client, body, options); } @@ -827,7 +871,7 @@ export class BatchClient { terminateJob( jobId: string, options: TerminateJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return terminateJob(this._client, jobId, options); } @@ -842,7 +886,7 @@ export class BatchClient { enableJob( jobId: string, options: EnableJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return enableJob(this._client, jobId, options); } @@ -860,7 +904,7 @@ export class BatchClient { jobId: string, body: BatchJobDisableOptions, options: DisableJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return disableJob(this._client, jobId, body, options); } @@ -873,7 +917,7 @@ export class BatchClient { jobId: string, body: BatchJob, options: ReplaceJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return replaceJob(this._client, jobId, body, options); } @@ -886,7 +930,7 @@ export class BatchClient { jobId: string, body: BatchJobUpdateOptions, options: UpdateJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return updateJob(this._client, jobId, body, options); } @@ -908,7 +952,7 @@ export class BatchClient { deleteJob( jobId: string, options: DeleteJobOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deleteJob(this._client, jobId, options); } @@ -939,7 +983,7 @@ export class BatchClient { poolId: string, body: NodeRemoveOptions, options: RemoveNodesOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return removeNodes(this._client, poolId, body, options); } @@ -952,7 +996,7 @@ export class BatchClient { poolId: string, body: BatchPoolReplaceOptions, options: ReplacePoolPropertiesOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return replacePoolProperties(this._client, poolId, body, options); } @@ -968,7 +1012,7 @@ export class BatchClient { stopPoolResize( poolId: string, options: StopPoolResizeOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return stopPoolResize(this._client, poolId, options); } @@ -985,7 +1029,7 @@ export class BatchClient { poolId: string, body: BatchPoolResizeOptions, options: ResizePoolOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return resizePool(this._client, poolId, body, options); } @@ -1014,7 +1058,7 @@ export class BatchClient { poolId: string, body: BatchPoolEnableAutoScaleOptions, options: EnablePoolAutoScaleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return enablePoolAutoScale(this._client, poolId, body, options); } @@ -1022,7 +1066,7 @@ export class BatchClient { disablePoolAutoScale( poolId: string, options: DisablePoolAutoScaleOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return disablePoolAutoScale(this._client, poolId, options); } @@ -1035,7 +1079,7 @@ export class BatchClient { poolId: string, body: BatchPoolUpdateOptions, options: UpdatePoolOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return updatePool(this._client, poolId, body, options); } @@ -1051,7 +1095,7 @@ export class BatchClient { poolExists( poolId: string, options: PoolExistsOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return poolExists(this._client, poolId, options); } @@ -1072,7 +1116,7 @@ export class BatchClient { deletePool( poolId: string, options: DeletePoolOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return deletePool(this._client, poolId, options); } @@ -1091,7 +1135,7 @@ export class BatchClient { createPool( body: BatchPoolCreateOptions, options: CreatePoolOptionalParams = { requestOptions: {} }, - ): Promise { + ): Promise { return createPool(this._client, body, options); } diff --git a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/index.ts b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/index.ts index c900df3e21..803b961c32 100644 --- a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/index.ts +++ b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/index.ts @@ -201,6 +201,50 @@ export { InstanceViewStatus, StatusLevelTypes, KnownVersions, + CreateNodeUserResponse, + DeleteNodeUserResponse, + ReplaceNodeUserResponse, + RebootNodeResponse, + ReimageNodeResponse, + DisableNodeSchedulingResponse, + EnableNodeSchedulingResponse, + DeleteNodeFileResponse, + GetNodeFilePropertiesResponse, + CreateTaskResponse, + DeleteTaskResponse, + ReplaceTaskResponse, + TerminateTaskResponse, + ReactivateTaskResponse, + DeleteTaskFileResponse, + GetTaskFilePropertiesResponse, + JobScheduleExistsResponse, + DeleteJobScheduleResponse, + UpdateJobScheduleResponse, + ReplaceJobScheduleResponse, + DisableJobScheduleResponse, + EnableJobScheduleResponse, + TerminateJobScheduleResponse, + CreateJobScheduleResponse, + CreateCertificateResponse, + CancelCertificateDeletionResponse, + DeleteCertificateResponse, + DeleteJobResponse, + UpdateJobResponse, + ReplaceJobResponse, + DisableJobResponse, + EnableJobResponse, + TerminateJobResponse, + CreateJobResponse, + CreatePoolResponse, + DeletePoolResponse, + PoolExistsResponse, + UpdatePoolResponse, + DisablePoolAutoScaleResponse, + EnablePoolAutoScaleResponse, + ResizePoolResponse, + StopPoolResizeResponse, + ReplacePoolPropertiesResponse, + RemoveNodesResponse, } from "./models/index.js"; export { BatchClientOptionalParams, diff --git a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/index.ts b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/index.ts index 333ad1c295..62fc4236da 100644 --- a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/index.ts +++ b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/index.ts @@ -194,4 +194,48 @@ export { InstanceViewStatus, StatusLevelTypes, KnownVersions, + CreateNodeUserResponse, + DeleteNodeUserResponse, + ReplaceNodeUserResponse, + RebootNodeResponse, + ReimageNodeResponse, + DisableNodeSchedulingResponse, + EnableNodeSchedulingResponse, + DeleteNodeFileResponse, + GetNodeFilePropertiesResponse, + CreateTaskResponse, + DeleteTaskResponse, + ReplaceTaskResponse, + TerminateTaskResponse, + ReactivateTaskResponse, + DeleteTaskFileResponse, + GetTaskFilePropertiesResponse, + JobScheduleExistsResponse, + DeleteJobScheduleResponse, + UpdateJobScheduleResponse, + ReplaceJobScheduleResponse, + DisableJobScheduleResponse, + EnableJobScheduleResponse, + TerminateJobScheduleResponse, + CreateJobScheduleResponse, + CreateCertificateResponse, + CancelCertificateDeletionResponse, + DeleteCertificateResponse, + DeleteJobResponse, + UpdateJobResponse, + ReplaceJobResponse, + DisableJobResponse, + EnableJobResponse, + TerminateJobResponse, + CreateJobResponse, + CreatePoolResponse, + DeletePoolResponse, + PoolExistsResponse, + UpdatePoolResponse, + DisablePoolAutoScaleResponse, + EnablePoolAutoScaleResponse, + ResizePoolResponse, + StopPoolResizeResponse, + ReplacePoolPropertiesResponse, + RemoveNodesResponse, } from "./models.js"; diff --git a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/models.ts b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/models.ts index e636e72e03..32ef938a26 100644 --- a/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/models.ts +++ b/packages/typespec-test/test/batch_modular/generated/typespec-ts/src/models/models.ts @@ -5717,3 +5717,383 @@ export enum KnownVersions { /** API Version 2023-05-01.17.0 */ _20230501170 = "2023-05-01.17.0", } + +/** Defines headers for operation response. */ +export interface CreateNodeUserResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DeleteNodeUserResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface ReplaceNodeUserResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface RebootNodeResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface ReimageNodeResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DisableNodeSchedulingResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface EnableNodeSchedulingResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DeleteNodeFileResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface GetNodeFilePropertiesResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + ocpCreationTime?: Date; + ocpBatchFileIsdirectory: boolean; + ocpBatchFileUrl: string; + ocpBatchFileMode: string; + contentLength: number; +} + +/** Defines headers for operation response. */ +export interface CreateTaskResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DeleteTaskResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface ReplaceTaskResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface TerminateTaskResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface ReactivateTaskResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DeleteTaskFileResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface GetTaskFilePropertiesResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + ocpCreationTime?: Date; + ocpBatchFileIsdirectory: boolean; + ocpBatchFileUrl: string; + ocpBatchFileMode: string; + contentLength: number; +} + +/** Defines headers for operation response. */ +export interface JobScheduleExistsResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; +} + +/** Defines headers for operation response. */ +export interface DeleteJobScheduleResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface UpdateJobScheduleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface ReplaceJobScheduleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DisableJobScheduleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface EnableJobScheduleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface TerminateJobScheduleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface CreateJobScheduleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface CreateCertificateResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface CancelCertificateDeletionResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DeleteCertificateResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; +} + +/** Defines headers for operation response. */ +export interface DeleteJobResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface UpdateJobResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface ReplaceJobResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DisableJobResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface EnableJobResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface TerminateJobResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface CreateJobResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface CreatePoolResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DeletePoolResponse { + clientRequestId?: string; + requestId?: string; +} + +/** Defines headers for operation response. */ +export interface PoolExistsResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; +} + +/** Defines headers for operation response. */ +export interface UpdatePoolResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface DisablePoolAutoScaleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface EnablePoolAutoScaleResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface ResizePoolResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface StopPoolResizeResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface ReplacePoolPropertiesResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} + +/** Defines headers for operation response. */ +export interface RemoveNodesResponse { + clientRequestId?: string; + requestId?: string; + eTag?: string; + lastModified?: Date; + dataServiceId: string; +} diff --git a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/review/overload_modular.api.md b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/review/overload_modular.api.md index 344a88139a..06d1fbea26 100644 --- a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/review/overload_modular.api.md +++ b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/review/overload_modular.api.md @@ -3,44 +3,62 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { ClientOptions } from "@azure-rest/core-client"; +import { KeyCredential } from "@azure/core-auth"; +import { OperationOptions } from "@azure-rest/core-client"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; -import { ClientOptions } from '@azure-rest/core-client'; -import { KeyCredential } from '@azure/core-auth'; -import { OperationOptions } from '@azure-rest/core-client'; -import { Pipeline } from '@azure/core-rest-pipeline'; -import { TokenCredential } from '@azure/core-auth'; +// @public +export interface FooOperationsGetAvatarAsJpegOptionalParams extends OperationOptions {} + +// @public +export interface FooOperationsGetAvatarAsPngOptionalParams extends OperationOptions {} // @public -export interface FooOperationsGetAvatarAsJpegOptionalParams extends OperationOptions { +export interface FooOperationsOperations { + getAvatarAsJpeg: ( + image: Uint8Array, + options?: FooOperationsGetAvatarAsJpegOptionalParams, + ) => Promise; + getAvatarAsPng: ( + image: Uint8Array, + options?: FooOperationsGetAvatarAsPngOptionalParams, + ) => Promise; } // @public -export interface FooOperationsGetAvatarAsPngOptionalParams extends OperationOptions { +export interface GetAvatarAsJpegResponse { + // (undocumented) + accept: "image/jpeg"; } // @public -export interface FooOperationsOperations { - getAvatarAsJpeg: (image: Uint8Array, options?: FooOperationsGetAvatarAsJpegOptionalParams) => Promise; - getAvatarAsPng: (image: Uint8Array, options?: FooOperationsGetAvatarAsPngOptionalParams) => Promise; +export interface GetAvatarAsPngResponse { + // (undocumented) + accept: "image/png"; } // @public export enum KnownVersions { - _20220830 = "2022-08-30" + _20220830 = "2022-08-30", } // @public (undocumented) export class WidgetManagerClient { - constructor(endpointParam: string, credential: KeyCredential | TokenCredential, options?: WidgetManagerClientOptionalParams); - readonly fooOperations: FooOperationsOperations; - readonly pipeline: Pipeline; + constructor( + endpointParam: string, + credential: KeyCredential | TokenCredential, + options?: WidgetManagerClientOptionalParams, + ); + readonly fooOperations: FooOperationsOperations; + readonly pipeline: Pipeline; } // @public export interface WidgetManagerClientOptionalParams extends ClientOptions { - apiVersion?: string; + apiVersion?: string; } // (No @packageDocumentation comment for this package) - ``` diff --git a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/api/fooOperations/operations.ts b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/api/fooOperations/operations.ts index f831a277d0..f3fa8404d5 100644 --- a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/api/fooOperations/operations.ts +++ b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/api/fooOperations/operations.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import { WidgetManagerContext as Client } from "../index.js"; +import { GetAvatarAsPngResponse, GetAvatarAsJpegResponse } from "../../models/models.js"; import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; import { FooOperationsGetAvatarAsJpegOptionalParams, @@ -37,13 +38,15 @@ export function _getAvatarAsJpegSend( }); } -export async function _getAvatarAsJpegDeserialize(result: PathUncheckedResponse): Promise { +export async function _getAvatarAsJpegDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { accept: result.headers["accept"]! } as GetAvatarAsJpegResponse; } /** A remote procedure call (RPC) operation. */ @@ -51,7 +54,7 @@ export async function getAvatarAsJpeg( context: Client, image: Uint8Array, options: FooOperationsGetAvatarAsJpegOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _getAvatarAsJpegSend(context, image, options); return _getAvatarAsJpegDeserialize(result); } @@ -79,13 +82,15 @@ export function _getAvatarAsPngSend( }); } -export async function _getAvatarAsPngDeserialize(result: PathUncheckedResponse): Promise { +export async function _getAvatarAsPngDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { accept: result.headers["accept"]! } as GetAvatarAsPngResponse; } /** A remote procedure call (RPC) operation. */ @@ -93,7 +98,7 @@ export async function getAvatarAsPng( context: Client, image: Uint8Array, options: FooOperationsGetAvatarAsPngOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _getAvatarAsPngSend(context, image, options); return _getAvatarAsPngDeserialize(result); } diff --git a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/classic/fooOperations/index.ts b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/classic/fooOperations/index.ts index 8886c902c0..7b88e69403 100644 --- a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/classic/fooOperations/index.ts +++ b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/classic/fooOperations/index.ts @@ -7,6 +7,7 @@ import { FooOperationsGetAvatarAsJpegOptionalParams, FooOperationsGetAvatarAsPngOptionalParams, } from "../../api/fooOperations/options.js"; +import { GetAvatarAsPngResponse, GetAvatarAsJpegResponse } from "../../models/models.js"; /** Interface representing a FooOperations operations. */ export interface FooOperationsOperations { @@ -14,12 +15,12 @@ export interface FooOperationsOperations { getAvatarAsJpeg: ( image: Uint8Array, options?: FooOperationsGetAvatarAsJpegOptionalParams, - ) => Promise; + ) => Promise; /** A remote procedure call (RPC) operation. */ getAvatarAsPng: ( image: Uint8Array, options?: FooOperationsGetAvatarAsPngOptionalParams, - ) => Promise; + ) => Promise; } function _getFooOperations(context: WidgetManagerContext) { diff --git a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/index.ts b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/index.ts index 56dd2d8613..6064073242 100644 --- a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/index.ts +++ b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/index.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. export { WidgetManagerClient } from "./widgetManagerClient.js"; -export { KnownVersions } from "./models/index.js"; +export { KnownVersions, GetAvatarAsPngResponse, GetAvatarAsJpegResponse } from "./models/index.js"; export { WidgetManagerClientOptionalParams } from "./api/index.js"; export { FooOperationsGetAvatarAsJpegOptionalParams, diff --git a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/index.ts b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/index.ts index 0cc3e72d7e..577c8fad0b 100644 --- a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/index.ts +++ b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/index.ts @@ -1,4 +1,4 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { KnownVersions } from "./models.js"; +export { KnownVersions, GetAvatarAsPngResponse, GetAvatarAsJpegResponse } from "./models.js"; diff --git a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/models.ts b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/models.ts index 96f1874315..dfc0ba772b 100644 --- a/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/models.ts +++ b/packages/typespec-test/test/overloads_modular/generated/typespec-ts/src/models/models.ts @@ -12,3 +12,13 @@ export enum KnownVersions { /** Version 2022-08-31 */ _20220830 = "2022-08-30", } + +/** Defines headers for operation response. */ +export interface GetAvatarAsPngResponse { + accept: "image/png"; +} + +/** Defines headers for operation response. */ +export interface GetAvatarAsJpegResponse { + accept: "image/jpeg"; +} diff --git a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/review/schema-registry.api.md b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/review/schema-registry.api.md index 7cdc00fd16..cfde1285e8 100644 --- a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/review/schema-registry.api.md +++ b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/review/schema-registry.api.md @@ -3,116 +3,188 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts - -import { ClientOptions } from '@azure-rest/core-client'; -import { OperationOptions } from '@azure-rest/core-client'; -import { Pipeline } from '@azure/core-rest-pipeline'; -import { TokenCredential } from '@azure/core-auth'; +import { ClientOptions } from "@azure-rest/core-client"; +import { OperationOptions } from "@azure-rest/core-client"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; // @public -export type ContentTypeEnum = "application/octet-stream" | "application/json; serialization=Avro" | "application/json; serialization=json" | "text/vnd.ms.protobuf"; +export type ContentTypeEnum = + | "application/octet-stream" + | "application/json; serialization=Avro" + | "application/json; serialization=json" + | "text/vnd.ms.protobuf"; // @public export type ContinuablePage = TPage & { - continuationToken?: string; + continuationToken?: string; }; +// @public +export interface GetSchemaIdByContentResponse { + // (undocumented) + location: string; + // (undocumented) + schemaGroupName: string; + // (undocumented) + schemaId: string; + // (undocumented) + schemaIdLocation: string; + // (undocumented) + schemaName: string; + // (undocumented) + schemaVersion: number; +} + // @public export enum KnownServiceApiVersions { - V202110 = "2021-10", - V202210 = "2022-10", - V20230701 = "2023-07-01" + V202110 = "2021-10", + V202210 = "2022-10", + V20230701 = "2023-07-01", } // @public -export interface PagedAsyncIterableIterator { - [Symbol.asyncIterator](): PagedAsyncIterableIterator; - byPage: (settings?: TPageSettings) => AsyncIterableIterator>; - next(): Promise>; +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + byPage: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; + next(): Promise>; } // @public export interface PageSettings { - continuationToken?: string; + continuationToken?: string; +} + +// @public +export interface RegisterSchemaResponse { + // (undocumented) + location: string; + // (undocumented) + schemaGroupName: string; + // (undocumented) + schemaId: string; + // (undocumented) + schemaIdLocation: string; + // (undocumented) + schemaName: string; + // (undocumented) + schemaVersion: number; } // @public export interface Schema { - definition: string; - properties: SchemaProperties; + definition: string; + properties: SchemaProperties; } // @public -export type SchemaContentTypeValues = "application/json; serialization=Avro" | "application/json; serialization=json" | "text/plain; charset=utf-8" | "text/vnd.ms.protobuf"; +export type SchemaContentTypeValues = + | "application/json; serialization=Avro" + | "application/json; serialization=json" + | "text/plain; charset=utf-8" + | "text/vnd.ms.protobuf"; // @public export type SchemaFormat = "Avro" | "Json" | "Custom" | "Protobuf"; // @public export interface SchemaGroup { - readonly groupName: string; + readonly groupName: string; } // @public -export interface SchemaOperationsGetSchemaByIdOptionalParams extends OperationOptions { -} +export interface SchemaOperationsGetSchemaByIdOptionalParams extends OperationOptions {} // @public -export interface SchemaOperationsGetSchemaByVersionOptionalParams extends OperationOptions { -} +export interface SchemaOperationsGetSchemaByVersionOptionalParams extends OperationOptions {} // @public -export interface SchemaOperationsGetSchemaIdByContentOptionalParams extends OperationOptions { -} +export interface SchemaOperationsGetSchemaIdByContentOptionalParams extends OperationOptions {} // @public -export interface SchemaOperationsListSchemaGroupsOptionalParams extends OperationOptions { -} +export interface SchemaOperationsListSchemaGroupsOptionalParams extends OperationOptions {} // @public -export interface SchemaOperationsListSchemaVersionsOptionalParams extends OperationOptions { -} +export interface SchemaOperationsListSchemaVersionsOptionalParams extends OperationOptions {} // @public export interface SchemaOperationsOperations { - getSchemaById: (id: string, options?: SchemaOperationsGetSchemaByIdOptionalParams) => Promise; - getSchemaByVersion: (groupName: string, name: string, schemaVersion: number, options?: SchemaOperationsGetSchemaByVersionOptionalParams) => Promise; - getSchemaIdByContent: (groupName: string, name: string, contentType: SchemaContentTypeValues, schemaContent: Uint8Array, options?: SchemaOperationsGetSchemaIdByContentOptionalParams) => Promise; - listSchemaGroups: (options?: SchemaOperationsListSchemaGroupsOptionalParams) => PagedAsyncIterableIterator; - listSchemaVersions: (groupName: string, name: string, options?: SchemaOperationsListSchemaVersionsOptionalParams) => PagedAsyncIterableIterator; - registerSchema: (groupName: string, name: string, content: Uint8Array, contentType: SchemaContentTypeValues, options?: SchemaOperationsRegisterSchemaOptionalParams) => Promise; -} - -// @public -export interface SchemaOperationsRegisterSchemaOptionalParams extends OperationOptions { -} + getSchemaById: ( + id: string, + options?: SchemaOperationsGetSchemaByIdOptionalParams, + ) => Promise; + getSchemaByVersion: ( + groupName: string, + name: string, + schemaVersion: number, + options?: SchemaOperationsGetSchemaByVersionOptionalParams, + ) => Promise; + getSchemaIdByContent: ( + groupName: string, + name: string, + contentType: SchemaContentTypeValues, + schemaContent: Uint8Array, + options?: SchemaOperationsGetSchemaIdByContentOptionalParams, + ) => Promise; + listSchemaGroups: ( + options?: SchemaOperationsListSchemaGroupsOptionalParams, + ) => PagedAsyncIterableIterator; + listSchemaVersions: ( + groupName: string, + name: string, + options?: SchemaOperationsListSchemaVersionsOptionalParams, + ) => PagedAsyncIterableIterator; + registerSchema: ( + groupName: string, + name: string, + content: Uint8Array, + contentType: SchemaContentTypeValues, + options?: SchemaOperationsRegisterSchemaOptionalParams, + ) => Promise; +} + +// @public +export interface SchemaOperationsRegisterSchemaOptionalParams extends OperationOptions {} // @public export interface SchemaProperties { - format: SchemaFormat; - groupName: string; - id: string; - name: string; - version: number; + format: SchemaFormat; + groupName: string; + id: string; + name: string; + version: number; } // @public (undocumented) export class SchemaRegistryClient { - constructor(endpointParam: string, credential: TokenCredential, options?: SchemaRegistryClientOptionalParams); - readonly pipeline: Pipeline; - readonly schemaOperations: SchemaOperationsOperations; + constructor( + endpointParam: string, + credential: TokenCredential, + options?: SchemaRegistryClientOptionalParams, + ); + readonly pipeline: Pipeline; + readonly schemaOperations: SchemaOperationsOperations; } // @public export interface SchemaRegistryClientOptionalParams extends ClientOptions { - apiVersion?: string; + apiVersion?: string; } // @public export interface SchemaVersion { - readonly schemaVersion: number; + readonly schemaVersion: number; } // (No @packageDocumentation comment for this package) - ``` diff --git a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/api/schemaOperations/operations.ts b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/api/schemaOperations/operations.ts index 58952a54ed..b8d7e178f4 100644 --- a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/api/schemaOperations/operations.ts +++ b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/api/schemaOperations/operations.ts @@ -10,6 +10,8 @@ import { _pagedVersionDeserializer, SchemaVersion, SchemaContentTypeValues, + GetSchemaIdByContentResponse, + RegisterSchemaResponse, } from "../../models/models.js"; import { PagedAsyncIterableIterator, @@ -60,13 +62,22 @@ export function _registerSchemaSend( }); } -export async function _registerSchemaDeserialize(result: PathUncheckedResponse): Promise { +export async function _registerSchemaDeserialize( + result: PathUncheckedResponse, +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { + location: result.headers["location"]!, + schemaId: result.headers["schema-id"]!, + schemaIdLocation: result.headers["schema-id-location"]!, + schemaGroupName: result.headers["schema-group-name"]!, + schemaName: result.headers["schema-name"]!, + schemaVersion: Number(result.headers["schema-version"]!), + } as RegisterSchemaResponse; } /** Register new schema. If schema of specified name does not exist in specified group, schema is created at version 1. If schema of specified name exists already in specified group, schema is created at latest version + 1. */ @@ -77,7 +88,7 @@ export async function registerSchema( content: Uint8Array, contentType: SchemaContentTypeValues, options: SchemaOperationsRegisterSchemaOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _registerSchemaSend(context, groupName, name, content, contentType, options); return _registerSchemaDeserialize(result); } @@ -112,13 +123,20 @@ export function _getSchemaIdByContentSend( export async function _getSchemaIdByContentDeserialize( result: PathUncheckedResponse, -): Promise { +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { + location: result.headers["location"]!, + schemaId: result.headers["schema-id"]!, + schemaIdLocation: result.headers["schema-id-location"]!, + schemaGroupName: result.headers["schema-group-name"]!, + schemaName: result.headers["schema-name"]!, + schemaVersion: Number(result.headers["schema-version"]!), + } as GetSchemaIdByContentResponse; } /** Gets the ID referencing an existing schema within the specified schema group, as matched by schema content comparison. */ @@ -129,7 +147,7 @@ export async function getSchemaIdByContent( contentType: SchemaContentTypeValues, schemaContent: Uint8Array, options: SchemaOperationsGetSchemaIdByContentOptionalParams = { requestOptions: {} }, -): Promise { +): Promise { const result = await _getSchemaIdByContentSend( context, groupName, diff --git a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/classic/schemaOperations/index.ts b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/classic/schemaOperations/index.ts index abb604afb2..c7239854ae 100644 --- a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/classic/schemaOperations/index.ts +++ b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/classic/schemaOperations/index.ts @@ -18,7 +18,13 @@ import { SchemaOperationsGetSchemaByIdOptionalParams, SchemaOperationsListSchemaGroupsOptionalParams, } from "../../api/schemaOperations/options.js"; -import { SchemaGroup, SchemaVersion, SchemaContentTypeValues } from "../../models/models.js"; +import { + SchemaGroup, + SchemaVersion, + SchemaContentTypeValues, + GetSchemaIdByContentResponse, + RegisterSchemaResponse, +} from "../../models/models.js"; import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; /** Interface representing a SchemaOperations operations. */ @@ -30,7 +36,7 @@ export interface SchemaOperationsOperations { content: Uint8Array, contentType: SchemaContentTypeValues, options?: SchemaOperationsRegisterSchemaOptionalParams, - ) => Promise; + ) => Promise; /** Gets the ID referencing an existing schema within the specified schema group, as matched by schema content comparison. */ getSchemaIdByContent: ( groupName: string, @@ -38,7 +44,7 @@ export interface SchemaOperationsOperations { contentType: SchemaContentTypeValues, schemaContent: Uint8Array, options?: SchemaOperationsGetSchemaIdByContentOptionalParams, - ) => Promise; + ) => Promise; /** Gets one specific version of one schema. */ getSchemaByVersion: ( groupName: string, diff --git a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/index.ts b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/index.ts index 59632749cd..ab098f9ebd 100644 --- a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/index.ts +++ b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/index.ts @@ -17,6 +17,8 @@ export { SchemaContentTypeValues, KnownServiceApiVersions, ContentTypeEnum, + GetSchemaIdByContentResponse, + RegisterSchemaResponse, } from "./models/index.js"; export { SchemaRegistryClientOptionalParams } from "./api/index.js"; export { diff --git a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/index.ts b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/index.ts index 6a5739d220..f832ed4355 100644 --- a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/index.ts +++ b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/index.ts @@ -10,4 +10,6 @@ export { SchemaContentTypeValues, KnownServiceApiVersions, ContentTypeEnum, + GetSchemaIdByContentResponse, + RegisterSchemaResponse, } from "./models.js"; diff --git a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/models.ts b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/models.ts index 042c6c6f21..8b0c84d437 100644 --- a/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/models.ts +++ b/packages/typespec-test/test/schemaRegistry/generated/typespec-ts/src/models/models.ts @@ -155,3 +155,23 @@ export type ContentTypeEnum = | "application/json; serialization=Avro" | "application/json; serialization=json" | "text/vnd.ms.protobuf"; + +/** Defines headers for operation response. */ +export interface GetSchemaIdByContentResponse { + location: string; + schemaId: string; + schemaIdLocation: string; + schemaGroupName: string; + schemaName: string; + schemaVersion: number; +} + +/** Defines headers for operation response. */ +export interface RegisterSchemaResponse { + location: string; + schemaId: string; + schemaIdLocation: string; + schemaGroupName: string; + schemaName: string; + schemaVersion: number; +} diff --git a/packages/typespec-ts/src/contextManager.ts b/packages/typespec-ts/src/contextManager.ts index f6f53d762f..fa6b127b9e 100644 --- a/packages/typespec-ts/src/contextManager.ts +++ b/packages/typespec-ts/src/contextManager.ts @@ -5,6 +5,8 @@ import { SdkContext } from "@azure-tools/typespec-client-generator-core"; import { SdkTypeContext } from "./framework/hooks/sdkTypes.js"; import { Binder } from "./framework/hooks/binder.js"; import { ExternalDependencies } from "./framework/dependency.js"; +import { ServiceOperation } from "./utils/operationUtil.js"; +import { SdkServiceResponseHeader } from "@azure-tools/typespec-client-generator-core"; /** * Contexts Object Guidelines @@ -30,6 +32,10 @@ type Contexts = { }; binder: Binder; dependencies: ExternalDependencies; + headerOnlyResponses: Map< + string, + { operation: ServiceOperation; headers: SdkServiceResponseHeader[] } + >; }; type ContextKey = keyof Contexts; diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index c82bcb5fdd..1da884a0fa 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -128,6 +128,7 @@ export async function $onEmit(context: EmitContext) { compilerContext: context, tcgcContext: dpgContext }); + provideContext("headerOnlyResponses", new Map()); const staticHelpers = await loadStaticHelpers( outputProject, { diff --git a/packages/typespec-ts/src/modular/emitModels.ts b/packages/typespec-ts/src/modular/emitModels.ts index 896b4b607a..dbc9859109 100644 --- a/packages/typespec-ts/src/modular/emitModels.ts +++ b/packages/typespec-ts/src/modular/emitModels.ts @@ -26,6 +26,7 @@ import { SdkNullableType, SdkServiceMethod, SdkServiceOperation, + SdkServiceResponseHeader, SdkType, SdkUnionType, UsageFlags, @@ -56,7 +57,7 @@ import { import path from "path"; import { refkey } from "../framework/refkey.js"; import { useContext } from "../contextManager.js"; -import { isMetadata, isOrExtendsHttpFile } from "@typespec/http"; +import { isHeader, isMetadata, isOrExtendsHttpFile } from "@typespec/http"; import { isAzureCoreErrorType } from "../utils/modelUtils.js"; import { isExtensibleEnum } from "./type-expressions/get-enum-expression.js"; import { @@ -78,8 +79,14 @@ import { import { resolveReference } from "../framework/reference.js"; import { MultipartHelpers } from "./static-helpers-metadata.js"; import { getAllAncestors } from "./helpers/operationHelpers.js"; +import { + generateHeaderOnlyResponseTypeName, + registerHeaderOnlyResponseInterface, + getResponseHeaders +} from "./helpers/operationHelpers.js"; import { getAllProperties } from "./helpers/operationHelpers.js"; import { getDirectSubtypes } from "./helpers/typeHelpers.js"; +import { ServiceOperation } from "../utils/operationUtil.js"; type InterfaceStructure = OptionalKind & { extends?: string[]; @@ -143,6 +150,36 @@ export function emitTypes( addSerializationFunctions(context, property, sourceFile!); } + // Emit header-only response interfaces for operations that return only headers + // (no body). These interfaces are registered during operation visiting. + const headerOnlyResponses = useContext("headerOnlyResponses") as Map< + string, + { operation: ServiceOperation; headers: SdkServiceResponseHeader[] } + >; + for (const [ + typeName, + { operation, headers } + ] of headerOnlyResponses.entries()) { + const filepath = getModelsPath(sourceRoot, []); + sourceFile = outputProject.getSourceFile(filepath); + if (!sourceFile) { + sourceFile = outputProject.createSourceFile(filepath); + sourceFile.addStatements(`/** +* This file contains only generated model types and their (de)serializers. +* Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. +*/ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */`); + } + emitHeaderOnlyResponseInterface( + context, + typeName, + headers, + operation, + sourceFile + ); + } + const modelFiles = outputProject.getSourceFiles( sourceRoot + "/models/**/*.ts" ); @@ -541,7 +578,11 @@ function buildModelInterface( name: normalizeModelName(context, type, NameType.Interface, true), isExported: true, properties: type.properties - .filter((p) => !isMetadata(context.program, p.__raw!)) + .filter( + (p) => + !isMetadata(context.program, p.__raw!) || + isHeader(context.program, p.__raw!) + ) .filter((p) => { // filter out the flatten property to be processed later if (p.flatten && p.type.kind === "model") { @@ -561,7 +602,11 @@ function buildModelInterface( context, flatten.type, getAllAncestors(flatten.type) - ).filter((p) => !isMetadata(context.program, p.__raw!)); + ).filter( + (p) => + !isMetadata(context.program, p.__raw!) || + isHeader(context.program, p.__raw!) + ); interfaceStructure.properties!.push( ...allProperties.map((p) => { // when the flattened property is optional, all its child properties should be optional too @@ -818,11 +863,13 @@ function buildModelProperty( typeExpression = getTypeExpression(context, property.type); } + const isOptional = property.optional; + const propertyStructure: PropertySignatureStructure = { kind: StructureKind.PropertySignature, name: normalizedPropName, type: typeExpression, - hasQuestionToken: property.optional, + hasQuestionToken: isOptional, isReadonly: isReadOnly(property as SdkModelPropertyType) }; @@ -880,7 +927,11 @@ function visitClientMethod( case "lropaging": case "basic": visitMethod(context, method); - visitOperation(context, method.operation); + visitOperation( + context, + method.operation, + method as SdkServiceMethod + ); break; default: reportDiagnostic(context.program, { @@ -894,7 +945,11 @@ function visitClientMethod( } } -function visitOperation(context: SdkContext, operation: SdkHttpOperation) { +function visitOperation( + context: SdkContext, + operation: SdkHttpOperation, + method?: SdkServiceMethod +) { // Visit the request visitType(context, operation.bodyParam?.type); // Visit the response @@ -907,6 +962,22 @@ function visitOperation(context: SdkContext, operation: SdkHttpOperation) { }); operation.responses.forEach((response) => visitType(context, response.type)); + + // Register header-only responses + if (method) { + const responseHeaders = getResponseHeaders(operation.responses); + const hasBody = operation.responses.some((response) => response.type); + const hasHeaderOnlyResponse = !hasBody && responseHeaders.length > 0; + + if (hasHeaderOnlyResponse) { + const headerOnlyTypeName = generateHeaderOnlyResponseTypeName(method); + registerHeaderOnlyResponseInterface( + method, + responseHeaders, + headerOnlyTypeName + ); + } + } } function visitMethod( @@ -979,3 +1050,45 @@ function visitType(context: SdkContext, type: SdkType | undefined) { } } } + +/** + * Emits an interface definition for a header-only response. + * Header-only responses occur when an operation returns headers but no body. + * @param context - The SDK context + * @param typeName - Name of the interface to generate + * @param headers - The response headers to include + * @param operation - The service operation + * @param sourceFile - The source file to add the interface to + */ +function emitHeaderOnlyResponseInterface( + context: SdkContext, + typeName: string, + headers: SdkServiceResponseHeader[], + operation: ServiceOperation, + sourceFile: SourceFile +): void { + const properties: PropertySignatureStructure[] = headers.map((header) => { + const name = normalizeName(header.name, NameType.Property); + const type = getTypeExpression(context, header.type); + const isOptional = header.optional; + + return { + kind: StructureKind.PropertySignature, + name, + type, + hasQuestionToken: isOptional + }; + }); + + const interfaceStructure: InterfaceStructure = { + kind: StructureKind.Interface, + name: typeName, + isExported: true, + properties + }; + + interfaceStructure.docs = [`Defines headers for operation response.`]; + + const refKey = refkey(operation.operation.__raw, "headerResponse"); + addDeclaration(sourceFile, interfaceStructure, refKey); +} diff --git a/packages/typespec-ts/src/modular/helpers/operationHelpers.ts b/packages/typespec-ts/src/modular/helpers/operationHelpers.ts index 0f914fe19d..67c25e4577 100644 --- a/packages/typespec-ts/src/modular/helpers/operationHelpers.ts +++ b/packages/typespec-ts/src/modular/helpers/operationHelpers.ts @@ -15,7 +15,8 @@ import { import { getNullableValidType, isSpreadBodyParameter, - isTypeNullable + isTypeNullable, + isNumericTypeKind } from "./typeHelpers.js"; import { getClassicalLayerPrefix, getOperationName } from "./namingHelpers.js"; import { @@ -81,9 +82,10 @@ import { SdkModelPropertyType, SdkModelType, SdkPagingServiceMethod, + SdkServiceResponseHeader, SdkType } from "@azure-tools/typespec-client-generator-core"; -import { isMetadata } from "@typespec/http"; +import { isMetadata, isHeader, getHeaderFieldName } from "@typespec/http"; import { useContext } from "../../contextManager.js"; import { isExtensibleEnum } from "../type-expressions/get-enum-expression.js"; @@ -163,13 +165,34 @@ export function getDeserializePrivateFunction( // TODO: Support multiple responses const response = operation.response; const restResponse = operation.operation.responses[0]; + const responseHeaders = getResponseHeaders(operation.operation.responses); + const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0; let returnType; if (isLroOnly || isLroAndPaging) { returnType = buildLroReturnType(context, operation); } else if (response.type && restResponse) { + const type = response.type; + // Check if there are response headers beyond what's already in the model + if ( + type.kind === "model" && + responseHeaders.length > 0 && + !areAllResponseHeadersInModel(context, type, responseHeaders) + ) { + // Build a composite type that includes both model and additional header properties + returnType = { + name: (restResponse as any).name ?? "", + type: buildCompositeResponseType(context, type, responseHeaders) + }; + } else { + returnType = { + name: (restResponse as any).name ?? "", + type: getTypeExpression(context, restResponse.type!) + }; + } + } else if (hasHeaderOnlyResponse) { returnType = { - name: (restResponse as any).name ?? "", - type: getTypeExpression(context, restResponse.type!) + name: "", + type: buildHeaderOnlyResponseType(context, responseHeaders) }; } else { returnType = { name: "", type: "void" }; @@ -238,6 +261,12 @@ export function getDeserializePrivateFunction( // Workaround for multipart response: cast return value as any due to lack of multipart response handling in core const multipartCastSuffix = isMultipart ? " as any" : ""; + const shouldPassHeaders = + deserializedType.kind === "model" && + hasHeaderProperties(context, deserializedType); + const deserializedArgs = shouldPassHeaders + ? `${deserializedRoot}, result.headers` + : deserializedRoot; // For dual-format responses, check content-type header at runtime if ( @@ -269,9 +298,9 @@ export function getDeserializePrivateFunction( statements.push( `const responseContentType = result.headers?.["content-type"] ?? ""; if (${isXmlContentTypeRef}(responseContentType)) { - return ${xmlDeserializerName}(${deserializedRoot}); + return ${xmlDeserializerName}(${deserializedArgs}); } - return ${jsonDeserializerName}(${deserializedRoot});` + return ${jsonDeserializerName}(${deserializedArgs});` ); } else { // Fall back to JSON deserializer @@ -285,7 +314,7 @@ export function getDeserializePrivateFunction( ); if (deserializeFunctionName) { statements.push( - `return ${deserializeFunctionName}(${deserializedRoot})` + `return ${deserializeFunctionName}(${deserializedArgs})` ); } } @@ -301,7 +330,7 @@ export function getDeserializePrivateFunction( ) as string | undefined; if (xmlDeserializerName) { - statements.push(`return ${xmlDeserializerName}(${deserializedRoot})`); + statements.push(`return ${xmlDeserializerName}(${deserializedArgs});`); } else { // Fall back to JSON deserializer if XML deserializer is not available const deserializeFunctionName = buildModelDeserializer( @@ -314,7 +343,7 @@ export function getDeserializePrivateFunction( ); if (deserializeFunctionName) { statements.push( - `return ${deserializeFunctionName}(${deserializedRoot})` + `return ${deserializeFunctionName}(${deserializedArgs})` ); } else { statements.push(`return ${deserializedRoot}`); @@ -332,7 +361,7 @@ export function getDeserializePrivateFunction( ); if (deserializeFunctionName) { statements.push( - `return ${deserializeFunctionName}(${deserializedRoot})${multipartCastSuffix}` + `return ${deserializeFunctionName}(${deserializedArgs})${multipartCastSuffix}` ); } else if ( isAzureCoreErrorType(context.program, deserializedType.__raw) @@ -354,6 +383,10 @@ export function getDeserializePrivateFunction( } } else if (returnType.type === "void") { statements.push("return;"); + } else if (hasHeaderOnlyResponse) { + statements.push( + `return ${buildHeaderOnlyResponseValue(operation, responseHeaders)};` + ); } else { statements.push("return;"); } @@ -573,12 +606,32 @@ export function getOperationFunction( // TODO: Support operation overloads const response = operation.response; + const responseHeaders = getResponseHeaders(operation.operation.responses); + const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0; let returnType = { name: "", type: "void" }; if (response.type) { const type = response.type; + // Check if there are response headers beyond what's already in the model + if ( + type.kind === "model" && + responseHeaders.length > 0 && + !areAllResponseHeadersInModel(context, type, responseHeaders) + ) { + // Build a composite type that includes both model and additional header properties + returnType = { + name: (type as any).name ?? "", + type: buildCompositeResponseType(context, type, responseHeaders) + }; + } else { + returnType = { + name: (type as any).name ?? "", + type: getTypeExpression(context, type!) + }; + } + } else if (hasHeaderOnlyResponse) { returnType = { - name: (type as any).name ?? "", - type: getTypeExpression(context, type!) + name: "", + type: buildHeaderOnlyResponseType(context, responseHeaders) }; } const { name, fixme = [] } = getOperationName(operation); @@ -1648,27 +1701,65 @@ export function getResponseMapping( type: SdkType, propertyPath: string = "result.body", overrides?: ModelOverrideOptions, - enableFlatten: boolean = true + enableFlatten: boolean = true, + headers?: string ) { const allParents = type.kind === "model" ? getAllAncestors(type) : []; - const properties = + // Include header properties when deserializing responses without changing + // the existing selection of non-metadata properties. + let properties = type.kind === "model" ? getAllProperties(context, type, allParents) : []; + + if ( + overrides?.propertyFilter && + typeof overrides.propertyFilter === "function" + ) { + properties = properties.filter( + (p) => !overrides.propertyFilter || overrides.propertyFilter(p) + ); + } + if (type.kind === "model") { + const headerProps: SdkModelPropertyType[] = []; + const addHeaderProps = (model: SdkModelType) => { + model.properties?.forEach((p) => { + if (isHeader(context.program, p.__raw!)) { + headerProps.push(p); + } + }); + }; + addHeaderProps(type); + allParents.forEach((parent) => { + if (parent.kind === "model") { + addHeaderProps(parent as SdkModelType); + } + }); + headerProps.forEach((p) => { + if (!properties.some((prop) => prop.name === p.name)) { + properties.push(p); + } + }); + } const props: string[] = []; for (const prop of properties) { - if (isMetadata(context.program, prop.__raw!)) { + if ( + isMetadata(context.program, prop.__raw!) && + !isHeader(context.program, prop.__raw!) + ) { continue; } const property = getPropertyWithOverrides(prop, overrides); const dot = propertyPath.endsWith("?") ? "." : ""; - const serializedName = getPropertySerializedName(property); + const isHeaderProp = isHeader(context.program, prop.__raw!); + // For header properties, use the header field name; for other properties use serialized name + const serializedName = isHeaderProp + ? (getHeaderFieldName(context.program, prop.__raw!) ?? + getPropertySerializedName(property)) + : getPropertySerializedName(property); + const basePath = isHeaderProp && headers ? headers : propertyPath; const restValue = `${ - propertyPath ? `${propertyPath}${dot}` : `${dot}` + basePath ? `${basePath}${isHeaderProp && headers ? "?." : dot}` : `${dot}` }["${serializedName}"]`; - const nullOrUndefinedPrefix = - property.optional || isTypeNullable(property.type) - ? `!${restValue}? ${restValue}: ` - : ""; const flattenContext = useContext("sdkTypes").flattenProperties.get(property); const isSupportedFlatten = flattenContext && enableFlatten; @@ -1681,6 +1772,10 @@ export function getResponseMapping( nameOnly: true, skipDiscriminatedUnionSuffix: false }); + const nullOrUndefinedPrefix = + property.optional || isTypeNullable(property.type) + ? `!${restValue} ? ${restValue} : ` + : ""; const propertyName = normalizeModelPropertyName(context, property); if (deserializeFunctionName) { if (isSupportedFlatten) { @@ -1698,7 +1793,7 @@ export function getResponseMapping( const deserializeValue = deserializeResponseValue( context, property.type, - `${propertyPath}${dot}["${serializedName}"]`, + restValue, !property.optional, getEncodeForModelProperty(context, property) ); @@ -1708,6 +1803,238 @@ export function getResponseMapping( return props; } +/** + * Checks if a model type or any of its ancestors have header properties. + * @param context - The SDK context + * @param type - The model type to check + * @returns True if the model or its ancestors have header properties + */ +function hasHeaderProperties(context: SdkContext, type: SdkModelType): boolean { + const allProps = type.properties ?? []; + const ancestorProps = getAllAncestors(type) + .filter((p) => p.kind === "model") + .flatMap((p) => (p as SdkModelType).properties ?? []); + return [...allProps, ...ancestorProps].some((p) => + isHeader(context.program, p.__raw!) + ); +} + +/** + * Checks if all response headers are already defined as properties in the model. + * This indicates headers that are part of the model definition vs. additional headers + * from the intersection operator. + * @param context - The SDK context + * @param modelType - The model type + * @param headers - The response headers + * @returns True if all response headers are already model properties + */ +function areAllResponseHeadersInModel( + context: SdkContext, + modelType: SdkModelType, + headers: SdkServiceResponseHeader[] +): boolean { + // Collect all header properties from the model and its ancestors + const modelHeaderNames = new Set(); + + const addHeaderPropsFromModel = (model: SdkModelType) => { + model.properties?.forEach((p) => { + if (isHeader(context.program, p.__raw!)) { + // Include both the property name and any header-serialized name + const serializedName = + getHeaderFieldName(context.program, p.__raw!) ?? + getPropertySerializedName(p); + modelHeaderNames.add(serializedName.toLowerCase()); + modelHeaderNames.add(p.name.toLowerCase()); + } + }); + }; + + // Add headers from the model itself + addHeaderPropsFromModel(modelType); + + // Add headers from ancestor models + const allParents = getAllAncestors(modelType); + allParents.forEach((parent) => { + if (parent.kind === "model") { + addHeaderPropsFromModel(parent as SdkModelType); + } + }); + + // Check if all response headers are in the model + for (const header of headers) { + const headerSerializedName = ( + header.serializedName ?? header.name + ).toLowerCase(); + if ( + !modelHeaderNames.has(headerSerializedName) && + !modelHeaderNames.has(header.name.toLowerCase()) + ) { + // Found a header not in the model properties + return false; + } + } + + return true; +} + +/** + * Builds a composite return type for operations that return both a model and additional headers. + * Combines model properties and header properties into an inline object type. + * @param context - The SDK context + * @param modelType - The model type + * @param headers - The response headers that are NOT in the model + * @returns The composite type expression as a string (e.g., "{ name: string; email: string; requestId: string }") + */ +function buildCompositeResponseType( + context: SdkContext, + modelType: SdkModelType, + headers: SdkServiceResponseHeader[] +): string { + const allParents = getAllAncestors(modelType); + const modelProps = getAllProperties(context, modelType, allParents); + + const properties: string[] = []; + + // Add all model properties + for (const prop of modelProps) { + const propertyName = normalizeModelPropertyName(context, prop); + const propertyType = getTypeExpression(context, prop.type); + const isOptional = prop.optional ? "?" : ""; + properties.push(`${propertyName}${isOptional}: ${propertyType}`); + } + + // Collect header property names already in the model to avoid duplicates + const modelHeaderNames = new Set(); + const addHeaderPropsFromModel = (model: SdkModelType) => { + model.properties?.forEach((p) => { + if (isHeader(context.program, p.__raw!)) { + const serializedName = + getHeaderFieldName(context.program, p.__raw!) ?? + getPropertySerializedName(p); + modelHeaderNames.add(serializedName.toLowerCase()); + modelHeaderNames.add(p.name.toLowerCase()); + } + }); + }; + + addHeaderPropsFromModel(modelType); + allParents.forEach((parent) => { + if (parent.kind === "model") { + addHeaderPropsFromModel(parent as SdkModelType); + } + }); + + // Add only additional host response header properties not already in model + for (const header of headers) { + const headerSerializedName = ( + header.serializedName ?? header.name + ).toLowerCase(); + if ( + !modelHeaderNames.has(headerSerializedName) && + !modelHeaderNames.has(header.name.toLowerCase()) + ) { + const headerName = normalizeName(header.name, NameType.Property); + const headerType = getTypeExpression(context, header.type); + const isOptional = header.optional ? "?" : ""; + properties.push(`${headerName}${isOptional}: ${headerType}`); + } + } + + return `{ ${properties.join("; ")} }`; +} + +/** + * Builds an inline type string for header-only responses. + * @param context - The SDK context + * @param headers - The response headers + * @returns The inline type expression as a string (e.g., "{ requestId: string; optionalHeader?: string }") + */ +function buildHeaderOnlyResponseType( + context: SdkContext, + headers: SdkServiceResponseHeader[] +): string { + const properties: string[] = []; + + for (const header of headers) { + const headerName = normalizeName(header.name, NameType.Property); + const headerType = getTypeExpression(context, header.type); + const isOptional = header.optional ? "?" : ""; + properties.push(`${headerName}${isOptional}: ${headerType}`); + } + + return `{ ${properties.join("; ")} }`; +} + +/** + * Builds the object literal expression for a header-only response. + * Handles type conversions for headers (string to boolean, Date, number, Uint8Array). + * @param operation - The service operation + * @param headers - The response headers + * @returns JavaScript expression string for the header-only response object + */ +function buildHeaderOnlyResponseValue( + operation: ServiceOperation, + headers: SdkServiceResponseHeader[] +): string { + const dependencies = useDependencies(); + const stringToUint8ArrayReference = resolveReference( + dependencies.stringToUint8Array + ); + const props = headers.map((header) => { + const name = normalizeName(header.name, NameType.Property); + const serializedName = (header.serializedName ?? header.name).toLowerCase(); + // Check if header should be optional based on config or header's optional property + const isOptional = header.optional; + + // Headers are always strings on the wire, so we need special handling for type conversion + // Build the conversion logic based on the header type + let headerValue: string; + if (header.type.kind === "boolean") { + // Convert string "true"/"false" to boolean + const headerAccess = `result.headers?.[${JSON.stringify(serializedName)}]`; + headerValue = isOptional + ? `${headerAccess} === "true"` + : `result.headers[${JSON.stringify(serializedName)}]! === "true"`; + } else if ( + header.type.kind === "plainDate" || + header.type.kind === "utcDateTime" + ) { + // Convert string to Date + const headerAccess = `result.headers[${JSON.stringify(serializedName)}]`; + const dateSource = + header.type.kind === "utcDateTime" && + header.type.encode === "unixTimestamp" + ? `Number(${headerAccess}) * 1000` + : headerAccess; + headerValue = isOptional + ? `${headerAccess} ? new Date(${dateSource}) : undefined` + : `new Date(${dateSource}!)`; + } else if (header.type.kind === "bytes") { + // Convert base64-encoded string to Uint8Array + const headerAccess = `result.headers?.[${JSON.stringify(serializedName)}]`; + const format = getEncodeForType(header.type) ?? "base64"; + headerValue = isOptional + ? `${headerAccess} ? ${stringToUint8ArrayReference}(${headerAccess}, "${format}") : undefined` + : `${stringToUint8ArrayReference}(result.headers[${JSON.stringify(serializedName)}]!, "${format}")`; + } else if (isNumericTypeKind(header.type.kind)) { + // Convert string to number + const headerAccess = `result.headers?.[${JSON.stringify(serializedName)}]`; + headerValue = isOptional + ? `${headerAccess} ? Number(${headerAccess}) : undefined` + : `Number(result.headers[${JSON.stringify(serializedName)}]!)`; + } else { + // String or other types - just use the header value directly + const headerAccess = `result.headers?.[${JSON.stringify(serializedName)}]`; + headerValue = isOptional + ? headerAccess + : `result.headers[${JSON.stringify(serializedName)}]!`; + } + + return `${name}: ${headerValue}`; + }); + return `{ ${props.join(", ")} } as ${resolveReference(refkey(operation.operation.__raw!, "headerResponse"))}`; +} + /** * Converts JavaScript values to their serialized wire format for HTTP requests. */ @@ -1854,7 +2181,7 @@ export function deserializeResponseValue( ); const nullOrUndefinedPrefix = isTypeNullable(type) || getOptionalForType(type) || !required - ? `!${restValue}? ${restValue}: ` + ? `!${restValue} ? ${restValue} : ` : ""; switch (type.kind) { case "plainDate": @@ -1949,9 +2276,7 @@ export function deserializeResponseValue( } case "bytes": if (format !== "binary" && format !== "bytes") { - return `${nullOrUndefinedPrefix}typeof ${restValue} === 'string' - ? ${stringToUint8ArrayReference}(${restValue}, "${format ?? "base64"}") - : ${restValue}`; + return `${nullOrUndefinedPrefix}typeof ${restValue} === 'string' ? ${stringToUint8ArrayReference}(${restValue}, "${format ?? "base64"}") : ${restValue}`; } return restValue; case "union": @@ -2120,3 +2445,55 @@ function getApiVersionExpression( : ""; return `${paramAccess}${defaultValueSuffix}`; } + +/** + * Generates a type name for a header-only response interface. + * @param operation - The service operation + * @returns The generated interface name + */ +export function generateHeaderOnlyResponseTypeName( + operation: ServiceOperation +): string { + const { name } = getOperationName(operation); + return `${normalizeName(name, NameType.Interface)}Response`; +} + +/** + * Registers a header-only response interface for later emission. + * @param operation - The service operation + * @param headers - The response headers + * @param typeName - The name of the interface type + */ +export function registerHeaderOnlyResponseInterface( + operation: ServiceOperation, + headers: SdkServiceResponseHeader[], + typeName: string +): void { + const headerOnlyMap = useContext("headerOnlyResponses") as Map< + string, + { operation: ServiceOperation; headers: SdkServiceResponseHeader[] } + >; + if (!headerOnlyMap.has(typeName)) { + headerOnlyMap.set(typeName, { operation, headers }); + } +} + +/** + * Extracts and deduplicates all response headers from operation responses. + * @param responses - The operation responses + * @returns Array of unique response headers + */ +export function getResponseHeaders( + responses: SdkHttpOperation["responses"] +): SdkServiceResponseHeader[] { + const headerMap = new Map(); + for (const response of responses ?? []) { + for (const header of response.headers ?? []) { + const key = header.serializedName ?? header.name; + if (!headerMap.has(key)) { + headerMap.set(key, header); + } + } + } + return Array.from(headerMap.values()); +} diff --git a/packages/typespec-ts/src/modular/serialization/buildDeserializerFunction.ts b/packages/typespec-ts/src/modular/serialization/buildDeserializerFunction.ts index 259c96efdc..856f1327cd 100644 --- a/packages/typespec-ts/src/modular/serialization/buildDeserializerFunction.ts +++ b/packages/typespec-ts/src/modular/serialization/buildDeserializerFunction.ts @@ -1,4 +1,8 @@ -import { FunctionDeclarationStructure, StructureKind } from "ts-morph"; +import { + FunctionDeclarationStructure, + ParameterDeclarationStructure, + StructureKind +} from "ts-morph"; import { SdkArrayType, SdkDictionaryType, @@ -36,7 +40,7 @@ import { import { reportDiagnostic } from "../../lib.js"; import { NoTarget } from "@typespec/compiler"; import { useContext } from "../../contextManager.js"; - +import { isHeader } from "@typespec/http"; export function buildPropertyDeserializer( context: SdkContext, property: SdkModelPropertyType, @@ -397,16 +401,42 @@ function buildModelTypeDeserializer( ? resolveReference(refkey(options.flatten.property, "deserializer")) : resolveReference(refkey(type, "deserializer")); } + + // Check if model or its ancestors have header properties that need special handling. + // If so, the deserializer function will accept an optional 'headers' parameter + // to deserialize header values into the model properties. + const allProps = type.kind === "model" ? (type.properties ?? []) : []; + const ancestorProps = + type.kind === "model" + ? getAllAncestors(type) + .filter((p) => p.kind === "model") + .flatMap((p) => (p as SdkModelType).properties ?? []) + : []; + const hasHeaderProperties = [...allProps, ...ancestorProps].some((p) => + isHeader(context.program, p.__raw!) + ); + + const parameters: ParameterDeclarationStructure[] = [ + { + kind: StructureKind.Parameter, + name: "item", + type: "any" + } + ]; + if (hasHeaderProperties) { + parameters.push({ + kind: StructureKind.Parameter, + name: "headers", + type: "any", + hasQuestionToken: true + }); + } + const deserializerFunction: FunctionDeclarationStructure = { kind: StructureKind.Function, name: deserializerFunctionName, isExported: true, - parameters: [ - { - name: "item", - type: "any" - } - ], + parameters, returnType: options.flatten ? undefined // not set return type for flattened property deserializer and type system will infer correct one : resolveReference(refkey(type)), @@ -422,7 +452,8 @@ function buildModelTypeDeserializer( type, "item", options.overrides, - !options.flatten + !options.flatten, + hasHeaderProperties ? "headers" : undefined ); const propertiesDeserialization = propertiesStr.filter((p) => p.trim()); diff --git a/packages/typespec-ts/src/modular/serialization/buildXmlSerializerFunction.ts b/packages/typespec-ts/src/modular/serialization/buildXmlSerializerFunction.ts index e07977a5e9..05fa445c3f 100644 --- a/packages/typespec-ts/src/modular/serialization/buildXmlSerializerFunction.ts +++ b/packages/typespec-ts/src/modular/serialization/buildXmlSerializerFunction.ts @@ -1,7 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { FunctionDeclarationStructure, StructureKind } from "ts-morph"; +import { + FunctionDeclarationStructure, + ParameterDeclarationStructure, + StructureKind +} from "ts-morph"; import { SdkModelPropertyType, SdkModelType, @@ -26,11 +30,12 @@ import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; import { NoTarget } from "@typespec/compiler"; -import { isMetadata } from "@typespec/http"; +import { isMetadata, isHeader } from "@typespec/http"; import { normalizeModelPropertyName } from "../type-expressions/get-type-expression.js"; import { isReadOnly } from "@azure-tools/typespec-client-generator-core"; import { buildModelSerializer } from "./buildSerializerFunction.js"; import { buildModelDeserializer } from "./buildDeserializerFunction.js"; +import { getResponseMapping } from "../helpers/operationHelpers.js"; /** * Checks if a model type has XML serialization options defined @@ -191,6 +196,10 @@ function buildPropertyMetadataArray( if (isMetadata(context.program, property.__raw!)) { continue; } + // Skip header properties as they are handled separately + if (isHeader(context.program, property.__raw!)) { + continue; + } const xmlOptions = property.serializationOptions?.xml; const jsonOptions = property.serializationOptions?.json; @@ -375,6 +384,20 @@ export function buildXmlModelDeserializer( return resolveReference(refkey(type, "xmlDeserializer")); } + // Check if model or its ancestors have header properties that need special handling. + // If so, the deserializer function will accept an optional 'headers' parameter + // to deserialize header values into the model properties. + const allProps = type.kind === "model" ? (type.properties ?? []) : []; + const ancestorProps = + type.kind === "model" + ? getAllAncestors(type) + .filter((p) => p.kind === "model") + .flatMap((p) => (p as SdkModelType).properties ?? []) + : []; + const hasHeaderProperties = [...allProps, ...ancestorProps].some((p) => + isHeader(context.program, p.__raw!) + ); + const deserializeFromXmlRef = resolveReference(XmlHelpers.deserializeFromXml); const xmlPropertyDeserializeMetadataRef = resolveReference( XmlHelpers.XmlPropertyDeserializeMetadata @@ -399,26 +422,75 @@ export function buildXmlModelDeserializer( // Generate the deserialization call const typeRef = resolveReference(refkey(type)); - if (xmlRootNs) { - statements.push( - `return ${deserializeFromXmlRef}<${typeRef}>(xmlString, properties, "${xmlRootName}", { namespace: "${xmlRootNs.namespace}", prefix: "${xmlRootNs.prefix}" });` + if (hasHeaderProperties) { + // First deserialize the XML body + if (xmlRootNs) { + statements.push( + `const result = ${deserializeFromXmlRef}<${typeRef}>(xmlString, properties, "${xmlRootName}", { namespace: "${xmlRootNs.namespace}", prefix: "${xmlRootNs.prefix}" });` + ); + } else { + statements.push( + `const result = ${deserializeFromXmlRef}<${typeRef}>(xmlString, properties, "${xmlRootName}");` + ); + } + // Get header property mappings with type transformations + const headerPropertiesStr = getResponseMapping( + context, + type, + "result", + { + propertyFilter(property) { + return isHeader(context.program, property.__raw!); + } + }, + true, + "headers" ); + const headerMappings = headerPropertiesStr.filter((p) => p.trim()); + + if (headerMappings.length > 0) { + // Merge header properties into the result + statements.push(`if (headers) {`); + statements.push( + ` Object.assign(result, { ${headerMappings.join(", ")} });` + ); + statements.push(`}`); + } + statements.push(`return result;`); } else { - statements.push( - `return ${deserializeFromXmlRef}<${typeRef}>(xmlString, properties, "${xmlRootName}");` - ); + // No headers to handle, deserialize normally + if (xmlRootNs) { + statements.push( + `return ${deserializeFromXmlRef}<${typeRef}>(xmlString, properties, "${xmlRootName}", { namespace: "${xmlRootNs.namespace}", prefix: "${xmlRootNs.prefix}" });` + ); + } else { + statements.push( + `return ${deserializeFromXmlRef}<${typeRef}>(xmlString, properties, "${xmlRootName}");` + ); + } + } + + const parameters: ParameterDeclarationStructure[] = [ + { + kind: StructureKind.Parameter, + name: "xmlString", + type: "string" + } + ]; + if (hasHeaderProperties) { + parameters.push({ + kind: StructureKind.Parameter, + name: "headers", + type: "any", + hasQuestionToken: true + }); } const deserializerFunction: FunctionDeclarationStructure = { kind: StructureKind.Function, name: deserializerFunctionName, isExported: true, - parameters: [ - { - name: "xmlString", - type: "string" - } - ], + parameters, returnType: resolveReference(refkey(type)), statements }; @@ -441,8 +513,10 @@ function buildDeserializePropertyMetadataArray( } if (isMetadata(context.program, property.__raw!)) { continue; + } // Skip header properties as they are passed separately via the headers parameter + if (isHeader(context.program, property.__raw!)) { + continue; } - const xmlOptions = property.serializationOptions?.xml; const jsonOptions = property.serializationOptions?.json; const propertyName = normalizeModelPropertyName(context, property); diff --git a/packages/typespec-ts/src/modular/serialization/serializeUtils.ts b/packages/typespec-ts/src/modular/serialization/serializeUtils.ts index 52dacbef17..b7bdf158f9 100644 --- a/packages/typespec-ts/src/modular/serialization/serializeUtils.ts +++ b/packages/typespec-ts/src/modular/serialization/serializeUtils.ts @@ -206,6 +206,8 @@ export interface ModelOverrideOptions { // If true (default), enable flattening for nested flatten properties when generating samples. // When false, nested flatten properties are not further flattened to match the TypeScript interface structure. enableFlatten?: boolean; + + propertyFilter?: (property: SdkModelPropertyType) => boolean; } export function getPropertyWithOverrides( diff --git a/packages/typespec-ts/test/azureModularIntegration/clientNaming.spec.ts b/packages/typespec-ts/test/azureModularIntegration/clientNaming.spec.ts index 3a41609444..9a3b28009f 100644 --- a/packages/typespec-ts/test/azureModularIntegration/clientNaming.spec.ts +++ b/packages/typespec-ts/test/azureModularIntegration/clientNaming.spec.ts @@ -51,7 +51,7 @@ describe("NameAndEncodedName Client", () => { assert.strictEqual(res.headers.get("default-name"), "true"); } }); - assert.isUndefined(result); + assert.equal(result.clientName, "true"); }); it("should work with model client", async () => { diff --git a/packages/typespec-ts/test/azureModularIntegration/encodeDatetime.spec.ts b/packages/typespec-ts/test/azureModularIntegration/encodeDatetime.spec.ts index b7dabef79c..3f521de060 100644 --- a/packages/typespec-ts/test/azureModularIntegration/encodeDatetime.spec.ts +++ b/packages/typespec-ts/test/azureModularIntegration/encodeDatetime.spec.ts @@ -142,7 +142,10 @@ describe("EncodeDatetimeClient Rest Client", () => { ); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("Fri, 26 Aug 2022 14:38:00 GMT").toISOString() + ); }); it(`should get rfc3339 header`, async () => { @@ -154,7 +157,10 @@ describe("EncodeDatetimeClient Rest Client", () => { ); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("2022-08-26T18:38:00.000Z").toISOString() + ); }); it(`should get rfc7231 header`, async () => { @@ -166,7 +172,10 @@ describe("EncodeDatetimeClient Rest Client", () => { ); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("Fri, 26 Aug 2022 14:38:00 GMT").toISOString() + ); }); it(`should get unix-timestamp header`, async () => { @@ -175,7 +184,10 @@ describe("EncodeDatetimeClient Rest Client", () => { assert.strictEqual(res.headers.get("value"), "1686566864"); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("2023-06-12T10:47:44.000Z").toISOString() + ); }); }); }); diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/operation-templates/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/operation-templates/src/index.d.ts index 96672eff65..2259c1956a 100644 --- a/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/operation-templates/src/index.d.ts +++ b/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/operation-templates/src/index.d.ts @@ -65,6 +65,11 @@ export declare type ContinuablePage = TPage & { export declare type CreatedByType = string; +export declare interface DeleteResponse { + location?: string; + retryAfter?: number; +} + export declare interface ErrorAdditionalInfo { readonly type?: string; readonly info?: any; diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/resources/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/resources/src/index.d.ts index ce8a7ee146..625ad6bad8 100644 --- a/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/resources/src/index.d.ts +++ b/packages/typespec-ts/test/azureModularIntegration/generated/azure/resource-manager/resources/src/index.d.ts @@ -20,6 +20,11 @@ export declare type ContinuablePage = TPage & { export declare type CreatedByType = string; +export declare interface DeleteResponse { + location?: string; + retryAfter?: number; +} + export declare interface ErrorAdditionalInfo { readonly type?: string; readonly info?: any; diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/client/naming/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/client/naming/src/index.d.ts index 7a9df17558..f05f72b282 100644 --- a/packages/typespec-ts/test/azureModularIntegration/generated/client/naming/src/index.d.ts +++ b/packages/typespec-ts/test/azureModularIntegration/generated/client/naming/src/index.d.ts @@ -49,7 +49,7 @@ export declare class NamingClient { private _client; readonly pipeline: Pipeline; constructor(options?: NamingClientOptionalParams); - response(options?: ResponseOptionalParams): Promise; + response(options?: ResponseOptionalParams): Promise; request(clientName: string, options?: RequestOptionalParams): Promise; compatibleWithEncodedName(body: ClientNameAndJsonEncodedNameModel, options?: CompatibleWithEncodedNameOptionalParams): Promise; language(body: LanguageClientNameModel, options?: LanguageOptionalParams): Promise; @@ -72,6 +72,10 @@ export declare interface RequestOptionalParams extends OperationOptions { export declare interface ResponseOptionalParams extends OperationOptions { } +export declare interface ResponseResponse { + clientName: string; +} + export declare interface TSModel { defaultName: boolean; } diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/encode/datetime/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/encode/datetime/src/index.d.ts index 8ed5a8c89a..b1642019fe 100644 --- a/packages/typespec-ts/test/azureModularIntegration/generated/encode/datetime/src/index.d.ts +++ b/packages/typespec-ts/test/azureModularIntegration/generated/encode/datetime/src/index.d.ts @@ -19,6 +19,10 @@ export declare interface DefaultDatetimeProperty { value: Date; } +export declare interface DefaultResponse { + value: Date; +} + export declare interface HeaderDefaultOptionalParams extends OperationOptions { } @@ -92,10 +96,10 @@ export declare interface ResponseHeaderDefaultOptionalParams extends OperationOp } export declare interface ResponseHeaderOperations { - unixTimestamp: (options?: ResponseHeaderUnixTimestampOptionalParams) => Promise; - rfc7231: (options?: ResponseHeaderRfc7231OptionalParams) => Promise; - rfc3339: (options?: ResponseHeaderRfc3339OptionalParams) => Promise; - default: (options?: ResponseHeaderDefaultOptionalParams) => Promise; + unixTimestamp: (options?: ResponseHeaderUnixTimestampOptionalParams) => Promise; + rfc7231: (options?: ResponseHeaderRfc7231OptionalParams) => Promise; + rfc3339: (options?: ResponseHeaderRfc3339OptionalParams) => Promise; + default: (options?: ResponseHeaderDefaultOptionalParams) => Promise; } export declare interface ResponseHeaderRfc3339OptionalParams extends OperationOptions { @@ -111,10 +115,18 @@ export declare interface Rfc3339DatetimeProperty { value: Date; } +export declare interface Rfc3339Response { + value: Date; +} + export declare interface Rfc7231DatetimeProperty { value: Date; } +export declare interface Rfc7231Response { + value: Date; +} + export declare interface UnixTimestampArrayDatetimeProperty { value: Date[]; } @@ -123,4 +135,8 @@ export declare interface UnixTimestampDatetimeProperty { value: Date; } +export declare interface UnixTimestampResponse { + value: Date; +} + export { } diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/payload/content-negotiation/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/payload/content-negotiation/src/index.d.ts index a1bac61e87..53ee8cf35c 100644 --- a/packages/typespec-ts/test/azureModularIntegration/generated/payload/content-negotiation/src/index.d.ts +++ b/packages/typespec-ts/test/azureModularIntegration/generated/payload/content-negotiation/src/index.d.ts @@ -25,6 +25,7 @@ export declare interface DifferentBodyOperations { } export declare interface PngImageAsJson { + contentType: "application/json"; content: Uint8Array; } diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/special-headers/repeatability/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/special-headers/repeatability/src/index.d.ts index 21e9bdb2f7..6e8f3a996b 100644 --- a/packages/typespec-ts/test/azureModularIntegration/generated/special-headers/repeatability/src/index.d.ts +++ b/packages/typespec-ts/test/azureModularIntegration/generated/special-headers/repeatability/src/index.d.ts @@ -5,11 +5,15 @@ import { Pipeline } from '@azure/core-rest-pipeline'; export declare interface ImmediateSuccessOptionalParams extends OperationOptions { } +export declare interface ImmediateSuccessResponse { + repeatabilityResult?: "accepted" | "rejected"; +} + export declare class RepeatabilityClient { private _client; readonly pipeline: Pipeline; constructor(options?: RepeatabilityClientOptionalParams); - immediateSuccess(repeatabilityRequestID: string, repeatabilityFirstSent: Date, options?: ImmediateSuccessOptionalParams): Promise; + immediateSuccess(repeatabilityRequestID: string, repeatabilityFirstSent: Date, options?: ImmediateSuccessOptionalParams): Promise; } export declare interface RepeatabilityClientOptionalParams extends ClientOptions { diff --git a/packages/typespec-ts/test/azureModularIntegration/headersRepeatability.spec.ts b/packages/typespec-ts/test/azureModularIntegration/headersRepeatability.spec.ts index cc0ab0c5da..bb442d3060 100644 --- a/packages/typespec-ts/test/azureModularIntegration/headersRepeatability.spec.ts +++ b/packages/typespec-ts/test/azureModularIntegration/headersRepeatability.spec.ts @@ -17,6 +17,6 @@ describe("Repeatability Client", () => { requestID, new Date("Mon, 13 Nov 2023 14:38:00 GMT") ); - assert.isUndefined(result); + assert.equal(result.repeatabilityResult, "accepted"); }); }); diff --git a/packages/typespec-ts/test/azureModularIntegration/payloadContentNegotiation.spec.ts b/packages/typespec-ts/test/azureModularIntegration/payloadContentNegotiation.spec.ts index ab702afc04..1a05c8b225 100644 --- a/packages/typespec-ts/test/azureModularIntegration/payloadContentNegotiation.spec.ts +++ b/packages/typespec-ts/test/azureModularIntegration/payloadContentNegotiation.spec.ts @@ -44,5 +44,6 @@ describe("Payload Content Negotiation Client", () => { uint8ArrayToString(result.content, "utf-8"), pngFile.toString() ); + assert.strictEqual(result.contentType, "application/json; charset=utf-8"); }); }); diff --git a/packages/typespec-ts/test/modularIntegration/encodeDatetime.spec.ts b/packages/typespec-ts/test/modularIntegration/encodeDatetime.spec.ts index b7dabef79c..ab83966e7b 100644 --- a/packages/typespec-ts/test/modularIntegration/encodeDatetime.spec.ts +++ b/packages/typespec-ts/test/modularIntegration/encodeDatetime.spec.ts @@ -142,7 +142,10 @@ describe("EncodeDatetimeClient Rest Client", () => { ); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("Fri, 26 Aug 2022 14:38:00 GMT").toISOString() + ); }); it(`should get rfc3339 header`, async () => { @@ -154,7 +157,10 @@ describe("EncodeDatetimeClient Rest Client", () => { ); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("2022-08-26T18:38:00.000Z").toISOString() + ); }); it(`should get rfc7231 header`, async () => { @@ -166,7 +172,10 @@ describe("EncodeDatetimeClient Rest Client", () => { ); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date("Fri, 26 Aug 2022 14:38:00 GMT").toISOString() + ); }); it(`should get unix-timestamp header`, async () => { @@ -175,7 +184,10 @@ describe("EncodeDatetimeClient Rest Client", () => { assert.strictEqual(res.headers.get("value"), "1686566864"); } }); - assert.isUndefined(result); + assert.equal( + result.value.toISOString(), + new Date(1686566864 * 1000).toISOString() + ); }); }); }); diff --git a/packages/typespec-ts/test/modularIntegration/generated/encode/datetime/src/index.d.ts b/packages/typespec-ts/test/modularIntegration/generated/encode/datetime/src/index.d.ts index 86d9569fe3..0f023da4f9 100644 --- a/packages/typespec-ts/test/modularIntegration/generated/encode/datetime/src/index.d.ts +++ b/packages/typespec-ts/test/modularIntegration/generated/encode/datetime/src/index.d.ts @@ -19,6 +19,10 @@ export declare interface DefaultDatetimeProperty { value: Date; } +export declare interface DefaultResponse { + value: Date; +} + export declare interface HeaderDefaultOptionalParams extends OperationOptions { } @@ -92,10 +96,10 @@ export declare interface ResponseHeaderDefaultOptionalParams extends OperationOp } export declare interface ResponseHeaderOperations { - unixTimestamp: (options?: ResponseHeaderUnixTimestampOptionalParams) => Promise; - rfc7231: (options?: ResponseHeaderRfc7231OptionalParams) => Promise; - rfc3339: (options?: ResponseHeaderRfc3339OptionalParams) => Promise; - default: (options?: ResponseHeaderDefaultOptionalParams) => Promise; + unixTimestamp: (options?: ResponseHeaderUnixTimestampOptionalParams) => Promise; + rfc7231: (options?: ResponseHeaderRfc7231OptionalParams) => Promise; + rfc3339: (options?: ResponseHeaderRfc3339OptionalParams) => Promise; + default: (options?: ResponseHeaderDefaultOptionalParams) => Promise; } export declare interface ResponseHeaderRfc3339OptionalParams extends OperationOptions { @@ -111,10 +115,18 @@ export declare interface Rfc3339DatetimeProperty { value: Date; } +export declare interface Rfc3339Response { + value: Date; +} + export declare interface Rfc7231DatetimeProperty { value: Date; } +export declare interface Rfc7231Response { + value: Date; +} + export declare interface UnixTimestampArrayDatetimeProperty { value: Date[]; } @@ -123,4 +135,8 @@ export declare interface UnixTimestampDatetimeProperty { value: Date; } +export declare interface UnixTimestampResponse { + value: Date; +} + export { } diff --git a/packages/typespec-ts/test/modularIntegration/generated/payload/content-negotiation/src/index.d.ts b/packages/typespec-ts/test/modularIntegration/generated/payload/content-negotiation/src/index.d.ts index b5b7e0f221..a69b7f48b0 100644 --- a/packages/typespec-ts/test/modularIntegration/generated/payload/content-negotiation/src/index.d.ts +++ b/packages/typespec-ts/test/modularIntegration/generated/payload/content-negotiation/src/index.d.ts @@ -25,6 +25,7 @@ export declare interface DifferentBodyOperations { } export declare interface PngImageAsJson { + contentType: "application/json"; content: Uint8Array; } diff --git a/packages/typespec-ts/test/modularIntegration/generated/special-headers/repeatability/src/index.d.ts b/packages/typespec-ts/test/modularIntegration/generated/special-headers/repeatability/src/index.d.ts index 498e18f0f9..69d3efd1a6 100644 --- a/packages/typespec-ts/test/modularIntegration/generated/special-headers/repeatability/src/index.d.ts +++ b/packages/typespec-ts/test/modularIntegration/generated/special-headers/repeatability/src/index.d.ts @@ -5,11 +5,15 @@ import { Pipeline } from '@typespec/ts-http-runtime'; export declare interface ImmediateSuccessOptionalParams extends OperationOptions { } +export declare interface ImmediateSuccessResponse { + repeatabilityResult?: "accepted" | "rejected"; +} + export declare class RepeatabilityClient { private _client; readonly pipeline: Pipeline; constructor(options?: RepeatabilityClientOptionalParams); - immediateSuccess(repeatabilityRequestID: string, repeatabilityFirstSent: Date, options?: ImmediateSuccessOptionalParams): Promise; + immediateSuccess(repeatabilityRequestID: string, repeatabilityFirstSent: Date, options?: ImmediateSuccessOptionalParams): Promise; } export declare interface RepeatabilityClientOptionalParams extends ClientOptions { diff --git a/packages/typespec-ts/test/modularIntegration/headersRepeatability.spec.ts b/packages/typespec-ts/test/modularIntegration/headersRepeatability.spec.ts index cc0ab0c5da..bb442d3060 100644 --- a/packages/typespec-ts/test/modularIntegration/headersRepeatability.spec.ts +++ b/packages/typespec-ts/test/modularIntegration/headersRepeatability.spec.ts @@ -17,6 +17,6 @@ describe("Repeatability Client", () => { requestID, new Date("Mon, 13 Nov 2023 14:38:00 GMT") ); - assert.isUndefined(result); + assert.equal(result.repeatabilityResult, "accepted"); }); }); diff --git a/packages/typespec-ts/test/modularUnit/scenarios/anonymous/anonymous.md b/packages/typespec-ts/test/modularUnit/scenarios/anonymous/anonymous.md index 20edf67881..e6cdd41cff 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/anonymous/anonymous.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/anonymous/anonymous.md @@ -54,7 +54,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( @@ -66,34 +66,34 @@ export function _readSend( prop3: Date, prop4: string, prop5: Bar, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{pathParam}{?queryParam}", { pathParam: pathParam, - queryParam: queryParam, + queryParam: queryParam }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: { - prop1: prop1, - prop2: prop2, - prop3: prop3.toISOString(), - prop4: prop4, - prop5: barSerializer(prop5), - }, - }); -} - -export async function _readDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: { + prop1: prop1, + prop2: prop2, + prop3: prop3.toISOString(), + prop4: prop4, + prop5: barSerializer(prop5) + } + }); +} + +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -111,7 +111,7 @@ export async function read( prop3: Date, prop4: string, prop5: Bar, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { const result = await _readSend( context, @@ -122,7 +122,7 @@ export async function read( prop3, prop4, prop5, - options, + options ); return _readDeserialize(result); } @@ -195,7 +195,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( @@ -205,34 +205,34 @@ export function _readSend( prop1: string, prop2: number, prop4: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{pathParam}{?queryParam}", { pathParam: pathParam, - queryParam: queryParam, + queryParam: queryParam }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: { - prop1: prop1, - prop2: prop2, - prop3: !options?.prop3 ? options?.prop3 : options?.prop3.toISOString(), - prop4: prop4, - prop5: !options?.prop5 ? options?.prop5 : barSerializer(options?.prop5), - }, - }); -} - -export async function _readDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: { + prop1: prop1, + prop2: prop2, + prop3: !options?.prop3 ? options?.prop3 : options?.prop3.toISOString(), + prop4: prop4, + prop5: !options?.prop5 ? options?.prop5 : barSerializer(options?.prop5) + } + }); +} + +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -248,9 +248,17 @@ export async function read( prop1: string, prop2: number, prop4: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { - const result = await _readSend(context, pathParam, queryParam, prop1, prop2, prop4, options); + const result = await _readSend( + context, + pathParam, + queryParam, + prop1, + prop2, + prop4, + options + ); return _readDeserialize(result); } ``` @@ -324,7 +332,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( @@ -334,7 +342,7 @@ export function _readSend( prop2: number, prop4: string, queryParam: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{pathParam}/{prop1}{?prop4,queryParam}", @@ -342,26 +350,26 @@ export function _readSend( pathParam: pathParam, prop1: prop1, prop4: prop4, - queryParam: queryParam, + queryParam: queryParam }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: { - prop2: prop2, - prop3: !options?.prop3 ? options?.prop3 : options?.prop3.toISOString(), - prop5: !options?.prop5 ? options?.prop5 : barSerializer(options?.prop5), - }, - }); -} - -export async function _readDeserialize(result: PathUncheckedResponse): Promise { + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: { + prop2: prop2, + prop3: !options?.prop3 ? options?.prop3 : options?.prop3.toISOString(), + prop5: !options?.prop5 ? options?.prop5 : barSerializer(options?.prop5) + } + }); +} + +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -377,9 +385,17 @@ export async function read( prop2: number, prop4: string, queryParam: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { - const result = await _readSend(context, pathParam, prop1, prop2, prop4, queryParam, options); + const result = await _readSend( + context, + pathParam, + prop1, + prop2, + prop4, + queryParam, + options + ); return _readDeserialize(result); } ``` @@ -449,7 +465,7 @@ export function fooSerializer(item: Foo): any { prop2: item["prop2"], prop3: item["prop3"].toISOString(), prop4: item["prop4"], - prop5: barSerializer(item["prop5"]), + prop5: barSerializer(item["prop5"]) }; } ``` @@ -465,7 +481,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( @@ -473,28 +489,28 @@ export function _readSend( pathParam: string, queryParam: string, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{pathParam}{?queryParam}", { pathParam: pathParam, - queryParam: queryParam, + queryParam: queryParam }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: fooSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -508,7 +524,7 @@ export async function read( pathParam: string, queryParam: string, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { const result = await _readSend(context, pathParam, queryParam, body, options); return _readDeserialize(result); @@ -551,7 +567,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( @@ -559,28 +575,28 @@ export function _readSend( pathParam: string, queryParam: string, body: Record, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{pathParam}{?queryParam}", { pathParam: pathParam, - queryParam: queryParam, + queryParam: queryParam }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: _readRequestSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: _readRequestSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -594,7 +610,7 @@ export async function read( pathParam: string, queryParam: string, body: Record, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { const result = await _readSend(context, pathParam, queryParam, body, options); return _readDeserialize(result); @@ -645,7 +661,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( @@ -656,28 +672,28 @@ export function _readSend( prop1: string; prop2: Bar; }, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{pathParam}{?queryParam}", { pathParam: pathParam, - queryParam: queryParam, + queryParam: queryParam }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: _readRequestSerializer(test), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: _readRequestSerializer(test) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -694,7 +710,7 @@ export async function read( prop1: string; prop2: Bar; }, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { const result = await _readSend(context, pathParam, queryParam, test, options); return _readDeserialize(result); @@ -745,24 +761,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Test, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: testSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: testSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -774,7 +790,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -829,24 +845,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Test, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: testSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: testSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -858,7 +874,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -900,23 +916,21 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _readDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -928,7 +942,7 @@ export async function _readDeserialize( export async function read( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise> { const result = await _readSend(context, options); return _readDeserialize(result); @@ -972,22 +986,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -998,7 +1012,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise

{ const result = await _readSend(context, options); return _readDeserialize(result); @@ -1033,7 +1047,7 @@ export interface _ReadResponse { export function _readResponseDeserializer(item: any): _ReadResponse { return { - foo: !item["foo"] ? item["foo"] : _readResponseFooDeserializer(item["foo"]), + foo: !item["foo"] ? item["foo"] : _readResponseFooDeserializer(item["foo"]) }; } @@ -1044,7 +1058,7 @@ export interface _ReadResponseFoo { export function _readResponseFooDeserializer(item: any): _ReadResponseFoo { return { - bar: item["bar"], + bar: item["bar"] }; } ``` @@ -1059,19 +1073,17 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _readDeserialize(result: PathUncheckedResponse): Promise<{ @@ -1089,7 +1101,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise<{ export async function read( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise<{ foo?: { bar: string | null; @@ -1140,23 +1152,29 @@ export interface ReturnBody { export function returnBodyDeserializer(item: any): ReturnBody { return { emptyAnomyous: _returnBodyEmptyAnomyousDeserializer(item["emptyAnomyous"]), - emptyAnomyousArray: _returnBodyEmptyAnomyousArrayArrayDeserializer(item["emptyAnomyousArray"]), - emptyAnomyousDict: _returnBodyEmptyAnomyousDictRecordDeserializer(item["emptyAnomyousDict"]), + emptyAnomyousArray: _returnBodyEmptyAnomyousArrayArrayDeserializer( + item["emptyAnomyousArray"] + ), + emptyAnomyousDict: _returnBodyEmptyAnomyousDictRecordDeserializer( + item["emptyAnomyousDict"] + ), emptyModel: emptyModelDeserializer(item["emptyModel"]), emptyModelArray: emptyModelArrayDeserializer(item["emptyModelArray"]), - emptyModelDict: emptyModelRecordDeserializer(item["emptyModelDict"]), + emptyModelDict: emptyModelRecordDeserializer(item["emptyModelDict"]) }; } /** model interface _ReturnBodyEmptyAnomyous */ export interface _ReturnBodyEmptyAnomyous {} -export function _returnBodyEmptyAnomyousDeserializer(item: any): _ReturnBodyEmptyAnomyous { +export function _returnBodyEmptyAnomyousDeserializer( + item: any +): _ReturnBodyEmptyAnomyous { return item; } export function _returnBodyEmptyAnomyousArrayArrayDeserializer( - result: Array<_ReturnBodyEmptyAnomyousArray>, + result: Array<_ReturnBodyEmptyAnomyousArray> ): any[] { return result.map((item) => { return _returnBodyEmptyAnomyousArrayDeserializer(item); @@ -1167,17 +1185,19 @@ export function _returnBodyEmptyAnomyousArrayArrayDeserializer( export interface _ReturnBodyEmptyAnomyousArray {} export function _returnBodyEmptyAnomyousArrayDeserializer( - item: any, + item: any ): _ReturnBodyEmptyAnomyousArray { return item; } export function _returnBodyEmptyAnomyousDictRecordDeserializer( - item: Record, + item: Record ): Record { const result: Record = {}; Object.keys(item).map((key) => { - result[key] = !item[key] ? item[key] : _returnBodyEmptyAnomyousDictDeserializer(item[key]); + result[key] = !item[key] + ? item[key] + : _returnBodyEmptyAnomyousDictDeserializer(item[key]); }); return result; } @@ -1185,7 +1205,9 @@ export function _returnBodyEmptyAnomyousDictRecordDeserializer( /** model interface _ReturnBodyEmptyAnomyousDict */ export interface _ReturnBodyEmptyAnomyousDict {} -export function _returnBodyEmptyAnomyousDictDeserializer(item: any): _ReturnBodyEmptyAnomyousDict { +export function _returnBodyEmptyAnomyousDictDeserializer( + item: any +): _ReturnBodyEmptyAnomyousDict { return item; } @@ -1203,7 +1225,7 @@ export function emptyModelArrayDeserializer(result: Array): any[] { } export function emptyModelRecordDeserializer( - item: Record, + item: Record ): Record { const result: Record = {}; Object.keys(item).map((key) => { @@ -1223,22 +1245,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1249,7 +1271,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -1310,7 +1332,7 @@ export interface Foz { export function fozDeserializer(item: any): Foz { return { - baz: _fozBazDeserializer(item["baz"]), + baz: _fozBazDeserializer(item["baz"]) }; } @@ -1339,18 +1361,24 @@ export function _fozBazDeserializer(item: any): _FozBaz { return p; }), bas: item["bas"], - bar: !item["test"] ? item["test"] : simpleModelArrayDeserializer(item["test"]), - nonemptyAnomyous: _fozBazNonemptyAnomyousDeserializer(item["nonemptyAnomyous"]), + bar: !item["test"] + ? item["test"] + : simpleModelArrayDeserializer(item["test"]), + nonemptyAnomyous: _fozBazNonemptyAnomyousDeserializer( + item["nonemptyAnomyous"] + ), nonemptyAnomyousArray: _fozBazNonemptyAnomyousArrayArrayDeserializer( - item["nonemptyAnomyousArray"], + item["nonemptyAnomyousArray"] ), nonemptyAnomyousDict: _fozBazNonemptyAnomyousDictRecordDeserializer( - item["nonemptyAnomyousDict"], - ), + item["nonemptyAnomyousDict"] + ) }; } -export function simpleModelArrayDeserializer(result: Array): any[] { +export function simpleModelArrayDeserializer( + result: Array +): any[] { return result.map((item) => { return simpleModelDeserializer(item); }); @@ -1363,7 +1391,7 @@ export interface SimpleModel { export function simpleModelDeserializer(item: any): SimpleModel { return { - test: item["test"], + test: item["test"] }; } @@ -1372,14 +1400,16 @@ export interface _FozBazNonemptyAnomyous { a: string; } -export function _fozBazNonemptyAnomyousDeserializer(item: any): _FozBazNonemptyAnomyous { +export function _fozBazNonemptyAnomyousDeserializer( + item: any +): _FozBazNonemptyAnomyous { return { - a: item["a"], + a: item["a"] }; } export function _fozBazNonemptyAnomyousArrayArrayDeserializer( - result: Array<_FozBazNonemptyAnomyousArray>, + result: Array<_FozBazNonemptyAnomyousArray> ): any[] { return result.map((item) => { return _fozBazNonemptyAnomyousArrayDeserializer(item); @@ -1391,20 +1421,26 @@ export interface _FozBazNonemptyAnomyousArray { b?: Record; } -export function _fozBazNonemptyAnomyousArrayDeserializer(item: any): _FozBazNonemptyAnomyousArray { +export function _fozBazNonemptyAnomyousArrayDeserializer( + item: any +): _FozBazNonemptyAnomyousArray { return { b: !item["b"] ? item["b"] - : Object.fromEntries(Object.entries(item["b"]).map(([k, p]: [string, any]) => [k, p])), + : Object.fromEntries( + Object.entries(item["b"]).map(([k, p]: [string, any]) => [k, p]) + ) }; } export function _fozBazNonemptyAnomyousDictRecordDeserializer( - item: Record, + item: Record ): Record { const result: Record = {}; Object.keys(item).map((key) => { - result[key] = !item[key] ? item[key] : _fozBazNonemptyAnomyousDictDeserializer(item[key]); + result[key] = !item[key] + ? item[key] + : _fozBazNonemptyAnomyousDictDeserializer(item[key]); }); return result; } @@ -1414,11 +1450,13 @@ export interface _FozBazNonemptyAnomyousDict { c: number[]; } -export function _fozBazNonemptyAnomyousDictDeserializer(item: any): _FozBazNonemptyAnomyousDict { +export function _fozBazNonemptyAnomyousDictDeserializer( + item: any +): _FozBazNonemptyAnomyousDict { return { c: item["c"].map((p: any) => { return p; - }), + }) }; } ``` @@ -1433,22 +1471,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1459,7 +1497,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); diff --git a/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/apiOperations.md b/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/apiOperations.md index df689d09e0..42c53cff17 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/apiOperations.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/apiOperations.md @@ -21,24 +21,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _uploadFileViaBodySend( context: Client, body: Uint8Array, - options: UploadFileViaBodyOptionalParams = { requestOptions: {} }, + options: UploadFileViaBodyOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/uploadFileViaBody") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/octet-stream", - body: body, - }); + return context.path("/uploadFileViaBody").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/octet-stream", + body: body + }); } -export async function _uploadFileViaBodyDeserialize(result: PathUncheckedResponse): Promise { +export async function _uploadFileViaBodyDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -50,7 +50,7 @@ export async function _uploadFileViaBodyDeserialize(result: PathUncheckedRespons export async function uploadFileViaBody( context: Client, body: Uint8Array, - options: UploadFileViaBodyOptionalParams = { requestOptions: {} }, + options: UploadFileViaBodyOptionalParams = { requestOptions: {} } ): Promise { const result = await _uploadFileViaBodySend(context, body, options); return _uploadFileViaBodyDeserialize(result); @@ -81,24 +81,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _uploadFileViaBodySend( context: Client, body: Uint8Array, - options: UploadFileViaBodyOptionalParams = { requestOptions: {} }, + options: UploadFileViaBodyOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/uploadFileViaBody") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/octet-stream", - body: body, - }); + return context.path("/uploadFileViaBody").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/octet-stream", + body: body + }); } -export async function _uploadFileViaBodyDeserialize(result: PathUncheckedResponse): Promise { +export async function _uploadFileViaBodyDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -110,7 +110,7 @@ export async function _uploadFileViaBodyDeserialize(result: PathUncheckedRespons export async function uploadFileViaBody( context: Client, body: Uint8Array, - options: UploadFileViaBodyOptionalParams = { requestOptions: {} }, + options: UploadFileViaBodyOptionalParams = { requestOptions: {} } ): Promise { const result = await _uploadFileViaBodySend(context, body, options); return _uploadFileViaBodyDeserialize(result); @@ -145,7 +145,9 @@ op uploadFile( /** model interface _UploadFileRequest */ export interface _UploadFileRequest { name: string; - file: FileContents | { contents: FileContents; contentType?: string; filename?: string }; + file: + | FileContents + | { contents: FileContents; contentType?: string; filename?: string }; } ``` @@ -155,7 +157,7 @@ export interface _UploadFileRequest { export function _uploadFileRequestSerializer(item: _UploadFileRequest): any { return [ { name: "name", body: item["name"] }, - createFilePartDescriptor("file", item["file"], "application/octet-stream"), + createFilePartDescriptor("file", item["file"], "application/octet-stream") ]; } ``` @@ -170,7 +172,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _uploadFileSend( @@ -179,18 +181,18 @@ export function _uploadFileSend( name: string; file: Uint8Array; }, - options: UploadFileOptionalParams = { requestOptions: {} }, + options: UploadFileOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/uploadFile") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "multipart/form-data", - body: _uploadFileRequestSerializer(body), - }); + return context.path("/uploadFile").post({ + ...operationOptionsToRequestParameters(options), + contentType: "multipart/form-data", + body: _uploadFileRequestSerializer(body) + }); } -export async function _uploadFileDeserialize(result: PathUncheckedResponse): Promise { +export async function _uploadFileDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -205,7 +207,7 @@ export async function uploadFile( name: string; file: Uint8Array; }, - options: UploadFileOptionalParams = { requestOptions: {} }, + options: UploadFileOptionalParams = { requestOptions: {} } ): Promise { const result = await _uploadFileSend(context, body, options); return _uploadFileDeserialize(result); @@ -232,7 +234,10 @@ op uploadFiles( ## Models ```ts models -import { FileContents, createFilePartDescriptor } from "../static-helpers/multipartHelpers.js"; +import { + FileContents, + createFilePartDescriptor +} from "../static-helpers/multipartHelpers.js"; /** * This file contains only generated model types and their (de)serializers. @@ -242,14 +247,17 @@ import { FileContents, createFilePartDescriptor } from "../static-helpers/multip /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /** model interface _UploadFilesRequest */ export interface _UploadFilesRequest { - files: Array; + files: Array< + | FileContents + | { contents: FileContents; contentType?: string; filename?: string } + >; } export function _uploadFilesRequestSerializer(item: _UploadFilesRequest): any { return [ ...item["files"].map((x: unknown) => - createFilePartDescriptor("files", x, "application/octet-stream"), - ), + createFilePartDescriptor("files", x, "application/octet-stream") + ) ]; } ``` @@ -264,7 +272,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _uploadFilesSend( @@ -272,18 +280,18 @@ export function _uploadFilesSend( body: { files: Uint8Array[]; }, - options: UploadFilesOptionalParams = { requestOptions: {} }, + options: UploadFilesOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/uploadFiles") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "multipart/form-data", - body: _uploadFilesRequestSerializer(body), - }); + return context.path("/uploadFiles").post({ + ...operationOptionsToRequestParameters(options), + contentType: "multipart/form-data", + body: _uploadFilesRequestSerializer(body) + }); } -export async function _uploadFilesDeserialize(result: PathUncheckedResponse): Promise { +export async function _uploadFilesDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -297,7 +305,7 @@ export async function uploadFiles( body: { files: Uint8Array[]; }, - options: UploadFilesOptionalParams = { requestOptions: {} }, + options: UploadFilesOptionalParams = { requestOptions: {} } ): Promise { const result = await _uploadFilesSend(context, body, options); return _uploadFilesDeserialize(result); @@ -327,22 +335,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _downloadFileSend( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/downloadFile") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/octet-stream", ...options.requestOptions?.headers }, - }); + return context.path("/downloadFile").post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/octet-stream", + ...options.requestOptions?.headers + } + }); } -export async function _downloadFileDeserialize(result: PathUncheckedResponse): Promise { +export async function _downloadFileDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -353,7 +364,7 @@ export async function _downloadFileDeserialize(result: PathUncheckedResponse): P export async function downloadFile( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): Promise { const streamableMethod = _downloadFileSend(context, options); const result = await getBinaryResponse(streamableMethod); @@ -387,22 +398,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _downloadFileSend( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/downloadFile") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/octet-stream", ...options.requestOptions?.headers }, - }); + return context.path("/downloadFile").post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/octet-stream", + ...options.requestOptions?.headers + } + }); } -export async function _downloadFileDeserialize(result: PathUncheckedResponse): Promise { +export async function _downloadFileDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -413,7 +427,7 @@ export async function _downloadFileDeserialize(result: PathUncheckedResponse): P export async function downloadFile( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): Promise { const streamableMethod = _downloadFileSend(context, options); const result = await getBinaryResponse(streamableMethod); @@ -452,15 +466,20 @@ import { stringToUint8Array } from "@azure/core-util"; /** model interface _DownloadFileResponse */ export interface _DownloadFileResponse { name: string; - file: Array; + file: Array< + | FileContents + | { contents: FileContents; contentType?: string; filename?: string } + >; } -export function _downloadFileResponseDeserializer(item: any): _DownloadFileResponse { +export function _downloadFileResponseDeserializer( + item: any +): _DownloadFileResponse { return { name: item["name"], file: item["file"].map((p: any) => { return typeof p === "string" ? stringToUint8Array(p, "base64") : p; - }), + }) }; } ``` @@ -475,24 +494,28 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _downloadFileSend( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/downloadFile") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "multipart/form-data", ...options.requestOptions?.headers }, - }); + return context.path("/downloadFile").post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "multipart/form-data", + ...options.requestOptions?.headers + } + }); } -export async function _downloadFileDeserialize(result: PathUncheckedResponse): Promise<{ +export async function _downloadFileDeserialize( + result: PathUncheckedResponse +): Promise<{ name: string; file: Uint8Array[]; + contentType: "multipart/form-data"; }> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -504,10 +527,11 @@ export async function _downloadFileDeserialize(result: PathUncheckedResponse): P export async function downloadFile( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): Promise<{ name: string; file: Uint8Array[]; + contentType: "multipart/form-data"; }> { const result = await _downloadFileSend(context, options); return _downloadFileDeserialize(result); @@ -547,16 +571,22 @@ import { stringToUint8Array } from "@azure/core-util"; /** model interface _DownloadFileResponse */ export interface _DownloadFileResponse { name: string[]; - file: FileContents | { contents: FileContents; contentType?: string; filename?: string }; + file: + | FileContents + | { contents: FileContents; contentType?: string; filename?: string }; } -export function _downloadFileResponseDeserializer(item: any): _DownloadFileResponse { +export function _downloadFileResponseDeserializer( + item: any +): _DownloadFileResponse { return { name: item["name"].map((p: any) => { return p; }), file: - typeof item["file"] === "string" ? stringToUint8Array(item["file"], "base64") : item["file"], + typeof item["file"] === "string" + ? stringToUint8Array(item["file"], "base64") + : item["file"] }; } ``` @@ -571,24 +601,28 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _downloadFileSend( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/downloadFile") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "multipart/form-data", ...options.requestOptions?.headers }, - }); + return context.path("/downloadFile").post({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "multipart/form-data", + ...options.requestOptions?.headers + } + }); } -export async function _downloadFileDeserialize(result: PathUncheckedResponse): Promise<{ +export async function _downloadFileDeserialize( + result: PathUncheckedResponse +): Promise<{ name: string[]; file: Uint8Array; + contentType: "multipart/form-data"; }> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -600,10 +634,11 @@ export async function _downloadFileDeserialize(result: PathUncheckedResponse): P export async function downloadFile( context: Client, - options: DownloadFileOptionalParams = { requestOptions: {} }, + options: DownloadFileOptionalParams = { requestOptions: {} } ): Promise<{ name: string[]; file: Uint8Array; + contentType: "multipart/form-data"; }> { const result = await _downloadFileSend(context, options); return _downloadFileDeserialize(result); @@ -633,25 +668,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _uploadFileViaBodySend( context: Client, contentType: string, body: Uint8Array, - options: UploadFileViaBodyOptionalParams = { requestOptions: {} }, + options: UploadFileViaBodyOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/uploadFileViaBody") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: contentType, - body: body, - }); + return context.path("/uploadFileViaBody").post({ + ...operationOptionsToRequestParameters(options), + contentType: contentType, + body: body + }); } -export async function _uploadFileViaBodyDeserialize(result: PathUncheckedResponse): Promise { +export async function _uploadFileViaBodyDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -664,9 +699,14 @@ export async function uploadFileViaBody( context: Client, contentType: string, body: Uint8Array, - options: UploadFileViaBodyOptionalParams = { requestOptions: {} }, + options: UploadFileViaBodyOptionalParams = { requestOptions: {} } ): Promise { - const result = await _uploadFileViaBodySend(context, contentType, body, options); + const result = await _uploadFileViaBodySend( + context, + contentType, + body, + options + ); return _uploadFileViaBodyDeserialize(result); } ``` @@ -693,32 +733,32 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _testSend( context: Client, apiVersion: string, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{?api%2Dversion}", { - "api%2Dversion": apiVersion, + "api%2Dversion": apiVersion }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "text/plain", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "text/plain", ...options.requestOptions?.headers } + }); } -export async function _testDeserialize(result: PathUncheckedResponse): Promise { +export async function _testDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -730,7 +770,7 @@ export async function _testDeserialize(result: PathUncheckedResponse): Promise { const result = await _testSend(context, apiVersion, options); return _testDeserialize(result); @@ -750,21 +790,23 @@ export interface TestingClientOptionalParams extends ClientOptions {} export function createTesting( endpointParam: string, - options: TestingClientOptionalParams = {}, + options: TestingClientOptionalParams = {} ): TestingContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return clientContext; @@ -785,19 +827,25 @@ export class TestingClient { /** The pipeline used by this client to make requests */ public readonly pipeline: Pipeline; - constructor(endpointParam: string, options: TestingClientOptionalParams = {}) { + constructor( + endpointParam: string, + options: TestingClientOptionalParams = {} + ) { const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-client` : `azsdk-js-client`; this._client = createTesting(endpointParam, { ...options, - userAgentOptions: { userAgentPrefix }, + userAgentOptions: { userAgentPrefix } }); this.pipeline = this._client.pipeline; } - test(apiVersion: string, options: TestOptionalParams = { requestOptions: {} }): Promise { + test( + apiVersion: string, + options: TestOptionalParams = { requestOptions: {} } + ): Promise { return test(this._client, apiVersion, options); } } @@ -834,32 +882,32 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _testSend( context: Client, apiVersion: string, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{?api%2Dversion}", { - "api%2Dversion": apiVersion, + "api%2Dversion": apiVersion }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "text/plain", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "text/plain", ...options.requestOptions?.headers } + }); } -export async function _testDeserialize(result: PathUncheckedResponse): Promise { +export async function _testDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -871,7 +919,7 @@ export async function _testDeserialize(result: PathUncheckedResponse): Promise { const result = await _testSend(context, apiVersion, options); return _testDeserialize(result); @@ -891,21 +939,23 @@ export interface TestingClientOptionalParams extends ClientOptions {} export function createTesting( endpointParam: string, - options: TestingClientOptionalParams = {}, + options: TestingClientOptionalParams = {} ): TestingContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return clientContext; @@ -926,19 +976,25 @@ export class TestingClient { /** The pipeline used by this client to make requests */ public readonly pipeline: Pipeline; - constructor(endpointParam: string, options: TestingClientOptionalParams = {}) { + constructor( + endpointParam: string, + options: TestingClientOptionalParams = {} + ) { const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-client` : `azsdk-js-client`; this._client = createTesting(endpointParam, { ...options, - userAgentOptions: { userAgentPrefix }, + userAgentOptions: { userAgentPrefix } }); this.pipeline = this._client.pipeline; } - test(apiVersion: string, options: TestOptionalParams = { requestOptions: {} }): Promise { + test( + apiVersion: string, + options: TestOptionalParams = { requestOptions: {} } + ): Promise { return test(this._client, apiVersion, options); } } @@ -969,22 +1025,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _test1Send( context: Client, - options: Test1OptionalParams = { requestOptions: {} }, + options: Test1OptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/test1") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "text/plain", ...options.requestOptions?.headers }, - }); + return context.path("/test1").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "text/plain", ...options.requestOptions?.headers } + }); } -export async function _test1Deserialize(result: PathUncheckedResponse): Promise { +export async function _test1Deserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -995,7 +1051,7 @@ export async function _test1Deserialize(result: PathUncheckedResponse): Promise< export async function test1( context: Client, - options: Test1OptionalParams = { requestOptions: {} }, + options: Test1OptionalParams = { requestOptions: {} } ): Promise { const result = await _test1Send(context, options); return _test1Deserialize(result); @@ -1004,26 +1060,26 @@ export async function test1( export function _testSend( context: Client, apiVersion: string, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/test{?api%2Dversion}", { - "api%2Dversion": apiVersion, + "api%2Dversion": apiVersion }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "text/plain", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "text/plain", ...options.requestOptions?.headers } + }); } -export async function _testDeserialize(result: PathUncheckedResponse): Promise { +export async function _testDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1035,7 +1091,7 @@ export async function _testDeserialize(result: PathUncheckedResponse): Promise { const result = await _testSend(context, apiVersion, options); return _testDeserialize(result); @@ -1055,21 +1111,23 @@ export interface TestingClientOptionalParams extends ClientOptions {} export function createTesting( endpointParam: string, - options: TestingClientOptionalParams = {}, + options: TestingClientOptionalParams = {} ): TestingContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return clientContext; @@ -1090,23 +1148,31 @@ export class TestingClient { /** The pipeline used by this client to make requests */ public readonly pipeline: Pipeline; - constructor(endpointParam: string, options: TestingClientOptionalParams = {}) { + constructor( + endpointParam: string, + options: TestingClientOptionalParams = {} + ) { const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-client` : `azsdk-js-client`; this._client = createTesting(endpointParam, { ...options, - userAgentOptions: { userAgentPrefix }, + userAgentOptions: { userAgentPrefix } }); this.pipeline = this._client.pipeline; } - test1(options: Test1OptionalParams = { requestOptions: {} }): Promise { + test1( + options: Test1OptionalParams = { requestOptions: {} } + ): Promise { return test1(this._client, options); } - test(apiVersion: string, options: TestOptionalParams = { requestOptions: {} }): Promise { + test( + apiVersion: string, + options: TestOptionalParams = { requestOptions: {} } + ): Promise { return test(this._client, apiVersion, options); } } @@ -1215,20 +1281,23 @@ import { FileShareSnapshotUpdate, fileShareSnapshotUpdateSerializer, FileShareSnapshot, - fileShareSnapshotDeserializer, + fileShareSnapshotDeserializer } from "../models/models.js"; import { PagedAsyncIterableIterator, - buildPagedAsyncIterator, + buildPagedAsyncIterator } from "../static-helpers/pagingHelpers.js"; import { getLongRunningPoller } from "../static-helpers/pollingHelpers.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; -import { UpdateFileShareSnapshotOptionalParams, ListOptionalParams } from "./options.js"; +import { + UpdateFileShareSnapshotOptionalParams, + ListOptionalParams +} from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; import { PollerLike, OperationState } from "@azure/core-lro"; @@ -1238,7 +1307,7 @@ export function _updateFileShareSnapshotSend( resourceName: string, name: string, properties: FileShareSnapshotUpdate, - options: UpdateFileShareSnapshotOptionalParams = { requestOptions: {} }, + options: UpdateFileShareSnapshotOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/fileShares/{resourceName}/fileShareSnapshots/{name}{?api%2Dversion}", @@ -1247,23 +1316,21 @@ export function _updateFileShareSnapshotSend( resourceGroupName: resourceGroupName, resourceName: resourceName, name: name, - "api%2Dversion": context.apiVersion ?? "2021-10-01-preview", + "api%2Dversion": context.apiVersion ?? "2021-10-01-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .patch({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: fileShareSnapshotUpdateSerializer(properties), - }); + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: fileShareSnapshotUpdateSerializer(properties) + }); } export async function _updateFileShareSnapshotDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise { const expectedStatuses = ["202", "200", "201"]; if (!expectedStatuses.includes(result.status)) { @@ -1282,48 +1349,51 @@ export function updateFileShareSnapshot( resourceName: string, name: string, properties: FileShareSnapshotUpdate, - options: UpdateFileShareSnapshotOptionalParams = { requestOptions: {} }, + options: UpdateFileShareSnapshotOptionalParams = { requestOptions: {} } ): PollerLike, FileShareSnapshot> { - return getLongRunningPoller(context, _updateFileShareSnapshotDeserialize, ["202", "200", "201"], { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _updateFileShareSnapshotSend( - context, - resourceGroupName, - resourceName, - name, - properties, - options, - ), - resourceLocationConfig: "location", - apiVersion: context.apiVersion ?? "2021-10-01-preview", - }) as PollerLike, FileShareSnapshot>; + return getLongRunningPoller( + context, + _updateFileShareSnapshotDeserialize, + ["202", "200", "201"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _updateFileShareSnapshotSend( + context, + resourceGroupName, + resourceName, + name, + properties, + options + ), + resourceLocationConfig: "location", + apiVersion: context.apiVersion ?? "2021-10-01-preview" + } + ) as PollerLike, FileShareSnapshot>; } export function _listSend( context: Client, - options: ListOptionalParams = { requestOptions: {} }, + options: ListOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/providers/Microsoft.Contoso/operations{?api%2Dversion}", { - "api%2Dversion": context.apiVersion ?? "2021-10-01-preview", + "api%2Dversion": context.apiVersion ?? "2021-10-01-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _listDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise<_OperationListResult> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -1338,7 +1408,7 @@ export async function _listDeserialize( /** List the operations for the provider */ export function list( context: Client, - options: ListOptionalParams = { requestOptions: {} }, + options: ListOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, @@ -1348,8 +1418,8 @@ export function list( { itemName: "value", nextLinkName: "nextLink", - apiVersion: context.apiVersion ?? "2021-10-01-preview", - }, + apiVersion: context.apiVersion ?? "2021-10-01-preview" + } ); } ``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/azureCoreOperations.md b/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/azureCoreOperations.md index 67419fd692..e2717bd9c6 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/azureCoreOperations.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/azureCoreOperations.md @@ -54,7 +54,7 @@ needAzureCore: true import { TestingContext as Client } from "./index.js"; import { ResourceOperationStatusWidgetSuiteWidgetSuiteError, - resourceOperationStatusWidgetSuiteWidgetSuiteErrorDeserializer, + resourceOperationStatusWidgetSuiteWidgetSuiteErrorDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { GetWidgetOperationStatusOptionalParams } from "./options.js"; @@ -62,7 +62,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getWidgetOperationStatusSend( @@ -70,36 +70,36 @@ export function _getWidgetOperationStatusSend( apiVersion: string, name: string, operationId: string, - options: GetWidgetOperationStatusOptionalParams = { requestOptions: {} }, + options: GetWidgetOperationStatusOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/widgets/{name}/operations/{operationId}{?api%2Dversion}", { name: name, operationId: operationId, - "api%2Dversion": apiVersion, + "api%2Dversion": apiVersion }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _getWidgetOperationStatusDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return resourceOperationStatusWidgetSuiteWidgetSuiteErrorDeserializer(result.body); + return resourceOperationStatusWidgetSuiteWidgetSuiteErrorDeserializer( + result.body + ); } /** Get the status of a long-running operation on widgets. */ @@ -108,14 +108,14 @@ export async function getWidgetOperationStatus( apiVersion: string, name: string, operationId: string, - options: GetWidgetOperationStatusOptionalParams = { requestOptions: {} }, + options: GetWidgetOperationStatusOptionalParams = { requestOptions: {} } ): Promise { const result = await _getWidgetOperationStatusSend( context, apiVersion, name, operationId, - options, + options ); return _getWidgetOperationStatusDeserialize(result); } @@ -145,18 +145,25 @@ export interface ResourceOperationStatusWidgetSuiteWidgetSuiteError { } export function resourceOperationStatusWidgetSuiteWidgetSuiteErrorDeserializer( - item: any, + item: any ): ResourceOperationStatusWidgetSuiteWidgetSuiteError { return { id: item["id"], status: item["status"], error: !item["error"] ? item["error"] : item["error"], - result: !item["result"] ? item["result"] : widgetSuiteDeserializer(item["result"]), + result: !item["result"] + ? item["result"] + : widgetSuiteDeserializer(item["result"]) }; } /** Enum describing allowed operation states. */ -export type OperationState = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Canceled"; +export type OperationState = + | "NotStarted" + | "Running" + | "Succeeded" + | "Failed" + | "Canceled"; /** A widget. */ export interface WidgetSuite { @@ -174,7 +181,7 @@ export function widgetSuiteDeserializer(item: any): WidgetSuite { manufacturerId: item["manufacturerId"], sharedModel: !item["sharedModel"] ? item["sharedModel"] - : fakedSharedModelDeserializer(item["sharedModel"]), + : fakedSharedModelDeserializer(item["sharedModel"]) }; } @@ -189,7 +196,7 @@ export interface FakedSharedModel { export function fakedSharedModelDeserializer(item: any): FakedSharedModel { return { tag: item["tag"], - createdAt: item["createdAt"], + createdAt: item["createdAt"] }; } ``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/reservedWordOperations.md b/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/reservedWordOperations.md index 854848e9b6..18987d7097 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/reservedWordOperations.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/apiOperations/reservedWordOperations.md @@ -19,22 +19,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _$continueSend( context: Client, - options: ContinueOptionalParams = { requestOptions: {} }, + options: ContinueOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _$continueDeserialize(result: PathUncheckedResponse): Promise { +export async function _$continueDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -50,7 +50,7 @@ export async function _$continueDeserialize(result: PathUncheckedResponse): Prom */ export async function $continue( context: Client, - options: ContinueOptionalParams = { requestOptions: {} }, + options: ContinueOptionalParams = { requestOptions: {} } ): Promise { const result = await _$continueSend(context, options); return _$continueDeserialize(result); @@ -78,22 +78,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _$returnSend( context: Client, - options: ReturnOptionalParams = { requestOptions: {} }, + options: ReturnOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _$returnDeserialize(result: PathUncheckedResponse): Promise { +export async function _$returnDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -109,7 +109,7 @@ export async function _$returnDeserialize(result: PathUncheckedResponse): Promis */ export async function $return( context: Client, - options: ReturnOptionalParams = { requestOptions: {} }, + options: ReturnOptionalParams = { requestOptions: {} } ): Promise { const result = await _$returnSend(context, options); return _$returnDeserialize(result); @@ -137,22 +137,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _globalSend( context: Client, - options: GlobalOptionalParams = { requestOptions: {} }, + options: GlobalOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _globalDeserialize(result: PathUncheckedResponse): Promise { +export async function _globalDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -163,7 +163,7 @@ export async function _globalDeserialize(result: PathUncheckedResponse): Promise export async function global( context: Client, - options: GlobalOptionalParams = { requestOptions: {} }, + options: GlobalOptionalParams = { requestOptions: {} } ): Promise { const result = await _globalSend(context, options); return _globalDeserialize(result); diff --git a/packages/typespec-ts/test/modularUnit/scenarios/enumUnion/enumUnion.md b/packages/typespec-ts/test/modularUnit/scenarios/enumUnion/enumUnion.md index 8826814504..9e09a807da 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/enumUnion/enumUnion.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/enumUnion/enumUnion.md @@ -62,25 +62,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, contentType: SchemaContentTypeValues, body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: contentType, - body: body, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: contentType, + body: body + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -93,7 +93,7 @@ export async function get( context: Client, contentType: SchemaContentTypeValues, body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): Promise { const result = await _getSend(context, contentType, body, options); return _getDeserialize(result); @@ -150,6 +150,11 @@ export type SchemaContentTypeValues = | "application/json; serialization=json" | "text/plain; charset=utf-8" | "text/vnd.ms.protobuf"; + +/** Defines headers for operation response. */ +export interface GetResponse { + testHeader: SchemaContentTypeValues; +} ``` # union with string as extensible enum is exhaustive @@ -196,7 +201,9 @@ withRawContent: true /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /** Type of SchemaContentTypeValues */ -export type SchemaContentTypeValues = "text/plain; charset=utf-8" | "text/vnd.ms.protobuf"; +export type SchemaContentTypeValues = + | "text/plain; charset=utf-8" + | "text/vnd.ms.protobuf"; ``` # union contains union with string element @@ -255,7 +262,9 @@ export type SchemaContentTypeValues = | "text/vnd.ms.protobuf" | string; -export function schemaContentTypeValuesSerializer(item: SchemaContentTypeValues): any { +export function schemaContentTypeValuesSerializer( + item: SchemaContentTypeValues +): any { return item; } @@ -321,7 +330,9 @@ export type SchemaContentTypeValues = | "text/vnd.ms.protobuf" | string; -export function schemaContentTypeValuesSerializer(item: SchemaContentTypeValues): any { +export function schemaContentTypeValuesSerializer( + item: SchemaContentTypeValues +): any { return item; } @@ -375,7 +386,9 @@ withRawContent: true /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /** Type of SchemaContentTypeValues */ -export type SchemaContentTypeValues = "text/plain; charset=utf-8" | "text/vnd.ms.protobuf"; +export type SchemaContentTypeValues = + | "text/plain; charset=utf-8" + | "text/vnd.ms.protobuf"; ``` # union contains union with string element @@ -434,7 +447,9 @@ export type SchemaContentTypeValues = | "text/vnd.ms.protobuf" | string; -export function schemaContentTypeValuesSerializer(item: SchemaContentTypeValues): any { +export function schemaContentTypeValuesSerializer( + item: SchemaContentTypeValues +): any { return item; } @@ -500,7 +515,9 @@ export type SchemaContentTypeValues = | "text/vnd.ms.protobuf" | string; -export function schemaContentTypeValuesSerializer(item: SchemaContentTypeValues): any { +export function schemaContentTypeValuesSerializer( + item: SchemaContentTypeValues +): any { return item; } @@ -544,52 +561,62 @@ needOptions: false ## schemaOutput ```ts models -// (file was not generated) +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface GetResponse { + testHeader: "A" | "B"; +} ``` ## Operations ```ts operations import { DemoServiceContext as Client } from "./index.js"; +import { GetResponse } from "../models/models.js"; import { GetOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, testHeader: "A" | "B", body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "text/plain", - headers: { "test-header": testHeader, ...options.requestOptions?.headers }, - body: body, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "text/plain", + headers: { "test-header": testHeader, ...options.requestOptions?.headers }, + body: body + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise<{ testHeader: "A" | "B" }> { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { testHeader: result.headers["test-header"]! } as GetResponse; } export async function get( context: Client, testHeader: "A" | "B", body: string, - options: GetOptionalParams = { requestOptions: {} }, -): Promise { + options: GetOptionalParams = { requestOptions: {} } +): Promise<{ testHeader: "A" | "B" }> { const result = await _getSend(context, testHeader, body, options); return _getDeserialize(result); } @@ -630,52 +657,62 @@ experimental-extensible-enums: true ## schemaOutput ```ts models -// (file was not generated) +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface GetResponse { + testHeader: string; +} ``` ## Operations ```ts operations import { DemoServiceContext as Client } from "./index.js"; +import { GetResponse } from "../models/models.js"; import { GetOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, testHeader: string, body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "text/plain", - headers: { "test-header": testHeader, ...options.requestOptions?.headers }, - body: body, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "text/plain", + headers: { "test-header": testHeader, ...options.requestOptions?.headers }, + body: body + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise<{ testHeader: string }> { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { testHeader: result.headers["test-header"]! } as GetResponse; } export async function get( context: Client, testHeader: string, body: string, - options: GetOptionalParams = { requestOptions: {} }, -): Promise { + options: GetOptionalParams = { requestOptions: {} } +): Promise<{ testHeader: string }> { const result = await _getSend(context, testHeader, body, options); return _getDeserialize(result); } @@ -1303,7 +1340,7 @@ export enum KnownImageSize { * A taller image size of 1792x1024 pixels. * Only supported with dall-e-3 models. */ - Size1024X1792 = "1024x1792", + Size1024X1792 = "1024x1792" } ``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/example/example.md b/packages/typespec-ts/test/modularUnit/scenarios/example/example.md index f0595c3a3f..e38038d11c 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/example/example.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/example/example.md @@ -51,7 +51,7 @@ export interface Example { export function exampleDeserializer(item: any): Example { return { - id: item["id"], + id: item["id"] }; } ``` @@ -99,32 +99,32 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, id: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{id}", { - id: id, + id: id }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -136,7 +136,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, id, options); return _readDeserialize(result); @@ -149,7 +149,7 @@ Or you can extract a specific operation using `ts operations function { const result = await _readSend(context, id, options); return _readDeserialize(result); diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/azureCoreErrorModels.md b/packages/typespec-ts/test/modularUnit/scenarios/models/azureCoreErrorModels.md index d65441dae5..b25b0557b6 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/models/azureCoreErrorModels.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/azureCoreErrorModels.md @@ -79,10 +79,12 @@ export interface _OperationListResult { nextLink?: string; } -export function _operationListResultDeserializer(item: any): _OperationListResult { +export function _operationListResultDeserializer( + item: any +): _OperationListResult { return { value: operationArrayDeserializer(item["value"]), - nextLink: item["nextLink"], + nextLink: item["nextLink"] }; } @@ -110,9 +112,11 @@ export function operationDeserializer(item: any): Operation { return { name: item["name"], isDataAction: item["isDataAction"], - display: !item["display"] ? item["display"] : operationDisplayDeserializer(item["display"]), + display: !item["display"] + ? item["display"] + : operationDisplayDeserializer(item["display"]), origin: item["origin"], - actionType: item["actionType"], + actionType: item["actionType"] }; } @@ -133,7 +137,7 @@ export function operationDisplayDeserializer(item: any): OperationDisplay { provider: item["provider"], resource: item["resource"], operation: item["operation"], - description: item["description"], + description: item["description"] }; } @@ -150,7 +154,9 @@ export interface ErrorResponse { export function errorResponseDeserializer(item: any): ErrorResponse { return { - error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + error: !item["error"] + ? item["error"] + : errorDetailDeserializer(item["error"]) }; } @@ -173,20 +179,26 @@ export function errorDetailDeserializer(item: any): ErrorDetail { code: item["code"], message: item["message"], target: item["target"], - details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + details: !item["details"] + ? item["details"] + : errorDetailArrayDeserializer(item["details"]), additionalInfo: !item["additionalInfo"] ? item["additionalInfo"] - : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]) }; } -export function errorDetailArrayDeserializer(result: Array): any[] { +export function errorDetailArrayDeserializer( + result: Array +): any[] { return result.map((item) => { return errorDetailDeserializer(item); }); } -export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { +export function errorAdditionalInfoArrayDeserializer( + result: Array +): any[] { return result.map((item) => { return errorAdditionalInfoDeserializer(item); }); @@ -200,10 +212,12 @@ export interface ErrorAdditionalInfo { readonly info?: any; } -export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { +export function errorAdditionalInfoDeserializer( + item: any +): ErrorAdditionalInfo { return { type: item["type"], - info: item["info"], + info: item["info"] }; } @@ -217,7 +231,7 @@ export function avsSummarySerializer(item: AvsSummary): any { return { properties: !item["properties"] ? item["properties"] - : avsSummaryPropertiesSerializer(item["properties"]), + : avsSummaryPropertiesSerializer(item["properties"]) }; } @@ -231,7 +245,7 @@ export function avsSummaryDeserializer(item: any): AvsSummary { : systemDataDeserializer(item["systemData"]), properties: !item["properties"] ? item["properties"] - : avsSummaryPropertiesDeserializer(item["properties"]), + : avsSummaryPropertiesDeserializer(item["properties"]) }; } @@ -240,13 +254,17 @@ export interface AvsSummaryProperties { error: ErrorDetail_1; } -export function avsSummaryPropertiesSerializer(item: AvsSummaryProperties): any { +export function avsSummaryPropertiesSerializer( + item: AvsSummaryProperties +): any { return { error: errorDetailSerializer(item["error"]) }; } -export function avsSummaryPropertiesDeserializer(item: any): AvsSummaryProperties { +export function avsSummaryPropertiesDeserializer( + item: any +): AvsSummaryProperties { return { - error: errorDetailDeserializer_1(item["error"]), + error: errorDetailDeserializer_1(item["error"]) }; } @@ -258,14 +276,18 @@ export interface ErrorDetail_1 { } export function errorDetailSerializer(item: ErrorDetail_1): any { - return { code: item["code"], message: item["message"], details: item["details"] }; + return { + code: item["code"], + message: item["message"], + details: item["details"] + }; } export function errorDetailDeserializer_1(item: any): ErrorDetail_1 { return { code: item["code"], message: item["message"], - details: item["details"], + details: item["details"] }; } @@ -283,7 +305,7 @@ export function proxyResourceDeserializer(item: any): ProxyResource { type: item["type"], systemData: !item["systemData"] ? item["systemData"] - : systemDataDeserializer(item["systemData"]), + : systemDataDeserializer(item["systemData"]) }; } @@ -310,7 +332,7 @@ export function resourceDeserializer(item: any): Resource { type: item["type"], systemData: !item["systemData"] ? item["systemData"] - : systemDataDeserializer(item["systemData"]), + : systemDataDeserializer(item["systemData"]) }; } @@ -334,12 +356,14 @@ export function systemDataDeserializer(item: any): SystemData { return { createdBy: item["createdBy"], createdByType: item["createdByType"], - createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + createdAt: !item["createdAt"] + ? item["createdAt"] + : new Date(item["createdAt"]), lastModifiedBy: item["lastModifiedBy"], lastModifiedByType: item["lastModifiedByType"], lastModifiedAt: !item["lastModifiedAt"] ? item["lastModifiedAt"] - : new Date(item["lastModifiedAt"]), + : new Date(item["lastModifiedAt"]) }; } @@ -349,7 +373,7 @@ export type CreatedByType = "User" | "Application" | "ManagedIdentity" | "Key"; /** The available API versions. */ export enum KnownVersions { /** 2021-10-01-preview version */ - V20211001Preview = "2021-10-01-preview", + V20211001Preview = "2021-10-01-preview" } ``` @@ -364,11 +388,11 @@ import { errorResponseDeserializer, AvsSummary, avsSummarySerializer, - avsSummaryDeserializer, + avsSummaryDeserializer } from "../models/models.js"; import { PagedAsyncIterableIterator, - buildPagedAsyncIterator, + buildPagedAsyncIterator } from "../static-helpers/pagingHelpers.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { CreateOrUpdateOptionalParams, ListOptionalParams } from "./options.js"; @@ -376,7 +400,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _createOrUpdateSend( @@ -384,7 +408,7 @@ export function _createOrUpdateSend( resourceGroupName: string, avsSummaryName: string, resource: AvsSummary, - options: CreateOrUpdateOptionalParams = { requestOptions: {} }, + options: CreateOrUpdateOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/avsSummaries/{avsSummaryName}{?api%2Dversion}", @@ -392,24 +416,22 @@ export function _createOrUpdateSend( subscriptionId: context.subscriptionId, resourceGroupName: resourceGroupName, avsSummaryName: avsSummaryName, - "api%2Dversion": context.apiVersion ?? "2021-10-01-preview", + "api%2Dversion": context.apiVersion ?? "2021-10-01-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .put({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: avsSummarySerializer(resource), - }); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: avsSummarySerializer(resource) + }); } export async function _createOrUpdateDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise { const expectedStatuses = ["200", "201"]; if (!expectedStatuses.includes(result.status)) { @@ -427,41 +449,39 @@ export async function createOrUpdate( resourceGroupName: string, avsSummaryName: string, resource: AvsSummary, - options: CreateOrUpdateOptionalParams = { requestOptions: {} }, + options: CreateOrUpdateOptionalParams = { requestOptions: {} } ): Promise { const result = await _createOrUpdateSend( context, resourceGroupName, avsSummaryName, resource, - options, + options ); return _createOrUpdateDeserialize(result); } export function _listSend( context: Client, - options: ListOptionalParams = { requestOptions: {} }, + options: ListOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/providers/Microsoft.Contoso/operations{?api%2Dversion}", { - "api%2Dversion": context.apiVersion ?? "2021-10-01-preview", + "api%2Dversion": context.apiVersion ?? "2021-10-01-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _listDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise<_OperationListResult> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -476,7 +496,7 @@ export async function _listDeserialize( /** List the operations for the provider */ export function list( context: Client, - options: ListOptionalParams = { requestOptions: {} }, + options: ListOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, @@ -486,8 +506,8 @@ export function list( { itemName: "value", nextLinkName: "nextLink", - apiVersion: context.apiVersion ?? "2021-10-01-preview", - }, + apiVersion: context.apiVersion ?? "2021-10-01-preview" + } ); } ``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/missingErrorResponseModel.md b/packages/typespec-ts/test/modularUnit/scenarios/models/missingErrorResponseModel.md index 69f78b22d0..d511b87bf3 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/models/missingErrorResponseModel.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/missingErrorResponseModel.md @@ -80,20 +80,22 @@ export interface AssetChainSummaryResult { errors?: ErrorResponse[]; } -export function assetChainSummaryResultDeserializer(item: any): AssetChainSummaryResult { +export function assetChainSummaryResultDeserializer( + item: any +): AssetChainSummaryResult { return { errors: !item["errors"] ? item["errors"] : item["errors"].map((p: any) => { return p; - }), + }) }; } /** Known values of {@link Versions} that the service accepts. */ export enum KnownVersions { /** Version 2023-03-01-preview */ - V20230301Preview = "2023-03-01-preview", + V20230301Preview = "2023-03-01-preview" } ``` @@ -101,29 +103,30 @@ export enum KnownVersions { ```ts operations import { TestServiceContext as Client } from "./index.js"; -import { AssetChainSummaryResult, assetChainSummaryResultDeserializer } from "../models/models.js"; +import { + AssetChainSummaryResult, + assetChainSummaryResultDeserializer +} from "../models/models.js"; import { GetAssetChainSummaryOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getAssetChainSummarySend( context: Client, - options: GetAssetChainSummaryOptionalParams = { requestOptions: {} }, + options: GetAssetChainSummaryOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/assetChainSummary") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/assetChainSummary").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _getAssetChainSummaryDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -135,9 +138,9 @@ export async function _getAssetChainSummaryDeserialize( export async function getAssetChainSummary( context: Client, - options: GetAssetChainSummaryOptionalParams = { requestOptions: {} }, + options: GetAssetChainSummaryOptionalParams = { requestOptions: {} } ): Promise { const result = await _getAssetChainSummarySend(context, options); return _getAssetChainSummaryDeserialize(result); } -``` \ No newline at end of file +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/models.md b/packages/typespec-ts/test/modularUnit/scenarios/models/models.md index 288af0ae65..24d321ef0a 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/models/models.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/models.md @@ -30,18 +30,22 @@ export interface StreamingChatCompletionOptions { } export function streamingChatCompletionOptionsSerializer( - item: StreamingChatCompletionOptions, + item: StreamingChatCompletionOptions ): any { - return { stream: item["stream"], messages: item["messages"], index: item["index"] }; + return { + stream: item["stream"], + messages: item["messages"], + index: item["index"] + }; } export function streamingChatCompletionOptionsDeserializer( - item: any, + item: any ): StreamingChatCompletionOptions { return { stream: item["stream"], messages: item["messages"], - index: item["index"], + index: item["index"] }; } ``` @@ -53,7 +57,7 @@ import { TestingContext as Client } from "./index.js"; import { StreamingChatCompletionOptions, streamingChatCompletionOptionsSerializer, - streamingChatCompletionOptionsDeserializer, + streamingChatCompletionOptionsDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { ReadOptionalParams } from "./options.js"; @@ -61,36 +65,34 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, id: string, body: StreamingChatCompletionOptions, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{id}", { - id: id, + id: id }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: streamingChatCompletionOptionsSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: streamingChatCompletionOptionsSerializer(body) + }); } export async function _readDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -104,7 +106,7 @@ export async function read( context: Client, id: string, body: StreamingChatCompletionOptions, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { const result = await _readSend(context, id, body, options); return _readDeserialize(result); @@ -141,24 +143,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "text/plain", ...options.requestOptions?.headers }, - body: { stream: true, messages: "aaaaa", index: 123 }, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "text/plain", ...options.requestOptions?.headers }, + body: { stream: true, messages: "aaaaa", index: 123 } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -169,7 +171,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -177,6 +179,7 @@ export async function read( ``` // We need to skip this case due to tcgc issue: https://github.com/Azure/typespec-azure/issues/3088 + # skip: Should get the effective model name ## TypeSpec @@ -255,9 +258,9 @@ export function _tryRequestSerializer(item: _TryRequest): any { : options?.labels.map((p: any) => { return p; }), - dummy: options?.dummy, - }, - }, + dummy: options?.dummy + } + } ]; } -``` \ No newline at end of file +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelInResponse.md b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelInResponse.md new file mode 100644 index 0000000000..303563fb07 --- /dev/null +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelInResponse.md @@ -0,0 +1,40 @@ +# Intersection of model and header in response + +This scenario tests that metadata properties like headers are included in the generated TypeScript model interface by default. + +## TypeSpec + +```tsp +model User { + name: string; + email: string; +} + +op getUser(): User & {@header requestId: string}; +``` + +## Models + +```ts models interface User +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** model interface User */ +export interface User { + name: string; + email: string; +} +``` + +```ts operations function getUser +export async function getUser( + context: Client, + options: GetUserOptionalParams = { requestOptions: {} } +): Promise<{ name: string; email: string; requestId: string }> { + const result = await _getUserSend(context, options); + return _getUserDeserialize(result); +} +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelSpread.md b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelSpread.md new file mode 100644 index 0000000000..563afc0ce8 --- /dev/null +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerAndModelSpread.md @@ -0,0 +1,40 @@ +# Intersection of model and header in response + +This scenario tests that metadata properties like headers are included in the generated TypeScript model interface by default. + +## TypeSpec + +```tsp +model User { + name: string; + email: string; +} + +op getUser(): {@header requestId: string, ...User}; +``` + +## Models + +```ts models interface User +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** model interface User */ +export interface User { + name: string; + email: string; +} +``` + +```ts operations function getUser +export async function getUser( + context: Client, + options: GetUserOptionalParams = { requestOptions: {} } +): Promise<{ name: string; email: string; requestId: string }> { + const result = await _getUserSend(context, options); + return _getUserDeserialize(result); +} +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerInResponse.md b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerInResponse.md new file mode 100644 index 0000000000..15c253922e --- /dev/null +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerInResponse.md @@ -0,0 +1,195 @@ +# Header properties included in the response model interface by default + +This scenario tests that metadata properties like headers are included in the generated TypeScript model interface by default. + +## TypeSpec + +```tsp +model User { + name: string; + email: string; + + @header("x-user-id") + userId?: string; + + @header + @encode("rfc7231") + createdAt?: utcDateTime; +} + +op getUser(): User; +``` + +## Models + +```ts models interface User +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** model interface User */ +export interface User { + name: string; + email: string; + userId?: string; + createdAt?: Date; +} +``` + +```ts operations function getUser +export async function getUser( + context: Client, + options: GetUserOptionalParams = { requestOptions: {} } +): Promise { + const result = await _getUserSend(context, options); + return _getUserDeserialize(result); +} +``` + +```ts models function userDeserializer +export function userDeserializer(item: any, headers?: any): User { + return { + name: item["name"], + email: item["email"], + userId: headers?.["x-user-id"], + createdAt: !headers?.["created-at"] + ? headers?.["created-at"] + : new Date(headers?.["created-at"]) + }; +} +``` + +```ts operations function _getUserDeserialize +export async function _getUserDeserialize( + result: PathUncheckedResponse +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return userDeserializer(result.body, result.headers); +} +``` + +# [void] Header properties included in the response model when there is no response body + +## TypeSpec + +```tsp + +@delete op deleteUser(): { @header("x-request-id") requestId: string, @header("x-optional-header") optionalHeader?: string}; +``` + +## Models + +```ts models interface DeleteUserResponse +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface DeleteUserResponse { + requestId: string; + optionalHeader?: string; +} +``` + +```ts operations function deleteUser +export async function deleteUser( + context: Client, + options: DeleteUserOptionalParams = { requestOptions: {} } +): Promise<{ requestId: string; optionalHeader?: string }> { + const result = await _deleteUserSend(context, options); + return _deleteUserDeserialize(result); +} +``` + +```ts operations function _deleteUserDeserialize +export async function _deleteUserDeserialize( + result: PathUncheckedResponse +): Promise<{ requestId: string; optionalHeader?: string }> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return { + requestId: result.headers["x-request-id"]!, + optionalHeader: result.headers?.["x-optional-header"] + } as DeleteUserResponse; +} +``` + +# Header-only response with typed properties (boolean, date, bytes) + +## TypeSpec + +```tsp +@get op getAccountInfo(): { + @header("date") date: utcDateTime; + @header("x-ms-legal-hold") legalHold: boolean; + @header("content-md5") contentMd5: bytes; + @header("x-ms-request-id") requestId?: string; +}; +``` + +## Models + +```ts models interface GetAccountInfoResponse +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface GetAccountInfoResponse { + date: Date; + legalHold: boolean; + contentMd5: Uint8Array; + requestId?: string; +} +``` + +```ts operations function getAccountInfo +export async function getAccountInfo( + context: Client, + options: GetAccountInfoOptionalParams = { requestOptions: {} } +): Promise<{ + date: Date; + legalHold: boolean; + contentMd5: Uint8Array; + requestId?: string; +}> { + const result = await _getAccountInfoSend(context, options); + return _getAccountInfoDeserialize(result); +} +``` + +```ts operations function _getAccountInfoDeserialize +export async function _getAccountInfoDeserialize( + result: PathUncheckedResponse +): Promise<{ + date: Date; + legalHold: boolean; + contentMd5: Uint8Array; + requestId?: string; +}> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return { + date: new Date(result.headers["date"]!), + legalHold: result.headers["x-ms-legal-hold"]! === "true", + contentMd5: stringToUint8Array(result.headers["content-md5"]!, "base64"), + requestId: result.headers?.["x-ms-request-id"] + } as GetAccountInfoResponse; +} +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerInXmlResponse.md b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerInXmlResponse.md new file mode 100644 index 0000000000..77e62f3da5 --- /dev/null +++ b/packages/typespec-ts/test/modularUnit/scenarios/models/response/headerInXmlResponse.md @@ -0,0 +1,197 @@ +# Header properties included in the response model interface by default + +This scenario tests that metadata properties like headers are included in the generated TypeScript model interface by default. + +## TypeSpec + +```tsp +model User { + name: string; + email: string; +} + +op getUser(): {...User, @header("content-type") + contentType: "application/xml"; + @header("x-user-id") + userId?: string; + + @header + @encode("rfc7231") + createdAt?: utcDateTime;}; +``` + +## Models + +```ts models interface User +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** model interface User */ +export interface User { + name: string; + email: string; +} +``` + +```ts operations function getUser +export async function getUser( + context: Client, + options: GetUserOptionalParams = { requestOptions: {} } +): Promise { + const result = await _getUserSend(context, options); + return _getUserDeserialize(result); +} +``` + +```ts models function userXmlDeserializer +export function userXmlDeserializer(item: any, headers?: any): User { + return { + name: item["name"], + email: item["email"], + userId: headers?.["x-user-id"], + createdAt: !headers?.["created-at"] + ? headers?.["created-at"] + : new Date(headers?.["created-at"]) + }; +} +``` + +```ts operations function _getUserDeserialize +export async function _getUserDeserialize( + result: PathUncheckedResponse +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return userXmlDeserializer(result.body, result.headers); +} +``` + +# [void] Header properties included in the response model when there is no response body + +## TypeSpec + +```tsp + +@delete op deleteUser(): { @header("x-request-id") requestId: string, @header("x-optional-header") optionalHeader?: string}; +``` + +## Models + +```ts models interface DeleteUserResponse +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface DeleteUserResponse { + requestId: string; + optionalHeader?: string; +} +``` + +```ts operations function deleteUser +export async function deleteUser( + context: Client, + options: DeleteUserOptionalParams = { requestOptions: {} } +): Promise<{ requestId: string; optionalHeader?: string }> { + const result = await _deleteUserSend(context, options); + return _deleteUserDeserialize(result); +} +``` + +```ts operations function _deleteUserDeserialize +export async function _deleteUserDeserialize( + result: PathUncheckedResponse +): Promise<{ requestId: string; optionalHeader?: string }> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return { + requestId: result.headers["x-request-id"]!, + optionalHeader: result.headers?.["x-optional-header"] + } as DeleteUserResponse; +} +``` + +# Header-only response with typed properties (boolean, date, bytes) + +## TypeSpec + +```tsp +@get op getAccountInfo(): { + @header("date") date: utcDateTime; + @header("x-ms-legal-hold") legalHold: boolean; + @header("content-md5") contentMd5: bytes; + @header("x-ms-request-id") requestId?: string; +}; +``` + +## Models + +```ts models interface GetAccountInfoResponse +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface GetAccountInfoResponse { + date: Date; + legalHold: boolean; + contentMd5: Uint8Array; + requestId?: string; +} +``` + +```ts operations function getAccountInfo +export async function getAccountInfo( + context: Client, + options: GetAccountInfoOptionalParams = { requestOptions: {} } +): Promise<{ + date: Date; + legalHold: boolean; + contentMd5: Uint8Array; + requestId?: string; +}> { + const result = await _getAccountInfoSend(context, options); + return _getAccountInfoDeserialize(result); +} +``` + +```ts operations function _getAccountInfoDeserialize +export async function _getAccountInfoDeserialize( + result: PathUncheckedResponse +): Promise<{ + date: Date; + legalHold: boolean; + contentMd5: Uint8Array; + requestId?: string; +}> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return { + date: new Date(result.headers["date"]!), + legalHold: result.headers["x-ms-legal-hold"]! === "true", + contentMd5: stringToUint8Array(result.headers["content-md5"]!, "base64"), + requestId: result.headers?.["x-ms-request-id"] + } as GetAccountInfoResponse; +} +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/modelsGenerator/modelsGenerator.md b/packages/typespec-ts/test/modularUnit/scenarios/modelsGenerator/modelsGenerator.md index 86f3bf704c..e4ec57d087 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/modelsGenerator/modelsGenerator.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/modelsGenerator/modelsGenerator.md @@ -17,6 +17,7 @@ model Test { Shouldn't be included in root index file ```ts root index + ``` # should generate models with `@usage` added for model-only case @@ -53,7 +54,7 @@ export interface Test { export function testDeserializer(item: any): Test { return { - prop: item["prop"], + prop: item["prop"] }; } ``` @@ -122,7 +123,7 @@ export function inputOutputModelSerializer(item: InputOutputModel): any { export function inputOutputModelDeserializer(item: any): InputOutputModel { return { - prop: item["prop"], + prop: item["prop"] }; } ``` @@ -186,7 +187,7 @@ export function inputOutputModelSerializer(item: InputOutputModel): any { export function inputOutputModelDeserializer(item: any): InputOutputModel { return { - prop: item["prop"], + prop: item["prop"] }; } ``` @@ -249,7 +250,7 @@ export function inputOutputModelSerializer(item: InputOutputModel): any { export function inputOutputModelDeserializer(item: any): InputOutputModel { return { - prop: item["prop"], + prop: item["prop"] }; } ``` @@ -319,7 +320,7 @@ export function inputOutputModelSerializer(item: InputOutputModel): any { export function inputOutputModelDeserializer(item: any): InputOutputModel { return { - prop: item["prop"], + prop: item["prop"] }; } @@ -352,23 +353,23 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _createStreamingSend( context: Client, - options: CreateStreamingOptionalParams = { requestOptions: {} }, + options: CreateStreamingOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/createStreaming") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: { stream: true }, - }); + return context.path("/createStreaming").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: { stream: true } + }); } -export async function _createStreamingDeserialize(result: PathUncheckedResponse): Promise { +export async function _createStreamingDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -379,7 +380,7 @@ export async function _createStreamingDeserialize(result: PathUncheckedResponse) export async function createStreaming( context: Client, - options: CreateStreamingOptionalParams = { requestOptions: {} }, + options: CreateStreamingOptionalParams = { requestOptions: {} } ): Promise { const result = await _createStreamingSend(context, options); return _createStreamingDeserialize(result); @@ -423,10 +424,10 @@ export interface Foo { ```ts models function fooSerializer export function fooSerializer(item: Foo): any { return { - prop1: item["prop1"].toISOString().split('T')[0], + prop1: item["prop1"].toISOString().split("T")[0], prop2: item["prop2"], prop3: item["prop3"].toISOString(), - prop4: item["prop4"], + prop4: item["prop4"] }; } ``` @@ -439,7 +440,7 @@ export function fooDeserializer(item: any): Foo { prop1: new Date(item["prop1"]), prop2: item["prop2"], prop3: new Date(item["prop3"]), - prop4: item["prop4"], + prop4: item["prop4"] }; } ``` @@ -454,25 +455,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -484,7 +485,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -508,23 +509,23 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, prop: Date, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { prop: prop.toUTCString(), ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { prop: prop.toUTCString(), ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -536,7 +537,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, prop, options); return _readDeserialize(result); @@ -591,25 +592,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -621,7 +622,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -676,25 +677,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -706,7 +707,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -758,25 +759,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -788,7 +789,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -831,25 +832,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -861,7 +862,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -905,25 +906,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -935,7 +936,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -982,25 +983,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1012,7 +1013,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -1061,7 +1062,7 @@ export function fooDeserializer(item: any): Foo { prop1: typeof item["prop1"] === "string" ? stringToUint8Array(item["prop1"], "base64") - : item["prop1"], + : item["prop1"] }; } ``` @@ -1076,25 +1077,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1106,7 +1107,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -1156,7 +1157,7 @@ export function fooDeserializer(item: any): Foo { prop1: typeof item["prop1"] === "string" ? stringToUint8Array(item["prop1"], "base64") - : item["prop1"], + : item["prop1"] }; } ``` @@ -1171,25 +1172,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1201,7 +1202,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -1251,7 +1252,7 @@ export function fooDeserializer(item: any): Foo { prop1: typeof item["prop1"] === "string" ? stringToUint8Array(item["prop1"], "base64url") - : item["prop1"], + : item["prop1"] }; } ``` @@ -1266,25 +1267,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1296,7 +1297,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -1343,7 +1344,7 @@ export function catDeserializer(item: any): Cat { name: item["name"], weight: item["weight"], kind: item["kind"], - meow: item["meow"], + meow: item["meow"] }; } @@ -1356,7 +1357,7 @@ export interface Pet { export function petDeserializer(item: any): Pet { return { name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } @@ -1371,7 +1372,7 @@ export function dogDeserializer(item: any): Dog { name: item["name"], weight: item["weight"], kind: item["kind"], - bark: item["bark"], + bark: item["bark"] }; } @@ -1423,7 +1424,7 @@ export function catDeserializer(item: any): Cat { name: item["name"], weight: item["weight"], kind: item["kind"], - meow: item["meow"], + meow: item["meow"] }; } @@ -1436,7 +1437,7 @@ export interface Pet { export function petDeserializer(item: any): Pet { return { name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } ``` @@ -1451,22 +1452,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1477,7 +1478,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -1522,7 +1523,7 @@ export function catDeserializer(item: any): Cat { weight: item["weight"], name: item["name"], kind: item["kind"], - meow: item["meow"], + meow: item["meow"] }; } @@ -1534,7 +1535,7 @@ export interface Pet extends Animal { export function petDeserializer(item: any): Pet { return { name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } @@ -1545,7 +1546,7 @@ export interface Animal { export function animalDeserializer(item: any): Animal { return { - name: item["name"], + name: item["name"] }; } ``` @@ -1560,22 +1561,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1586,7 +1587,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -1631,7 +1632,12 @@ export interface PSDog extends Pet { } export function psDogSerializer(item: PSDog): any { - return { kind: item["kind"], name: item["name"], weight: item["weight"], bark: item["bark"] }; + return { + kind: item["kind"], + name: item["name"], + weight: item["weight"], + bark: item["bark"] + }; } export function psDogDeserializer(item: any): PSDog { @@ -1639,7 +1645,7 @@ export function psDogDeserializer(item: any): PSDog { kind: item["kind"], name: item["name"], weight: item["weight"], - bark: item["bark"], + bark: item["bark"] }; } @@ -1658,7 +1664,7 @@ export function petDeserializer(item: any): Pet { return { kind: item["kind"], name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } @@ -1696,25 +1702,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: PSDog, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: psDogSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: psDogSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1726,7 +1732,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise

{ const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -1775,7 +1781,7 @@ export function petDeserializer(item: any): Pet { return { kind: item["kind"], name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } @@ -1806,7 +1812,7 @@ export function catDeserializer(item: any): Cat { kind: item["kind"], name: item["name"], weight: item["weight"], - meow: item["meow"], + meow: item["meow"] }; } @@ -1821,7 +1827,7 @@ export function dogDeserializer(item: any): Dog { kind: item["kind"], name: item["name"], weight: item["weight"], - bark: item["bark"], + bark: item["bark"] }; } ``` @@ -1836,22 +1842,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1862,7 +1868,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise

{ const result = await _readSend(context, options); return _readDeserialize(result); @@ -1917,7 +1923,7 @@ export function petDeserializer(item: any): Pet { return { kind: item["kind"], name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } @@ -1948,7 +1954,7 @@ export function catDeserializer(item: any): Cat { kind: item["kind"], name: item["name"], weight: item["weight"], - meow: item["meow"], + meow: item["meow"] }; } @@ -1965,7 +1971,7 @@ export function dogDeserializer(item: any): Dog { name: item["name"], weight: item["weight"], type: item["type"], - bark: item["bark"], + bark: item["bark"] }; } @@ -1995,7 +2001,7 @@ export function goldDeserializer(item: any): Gold { bark: item["bark"], name: item["name"], weight: item["weight"], - friends: petUnionArrayDeserializer(item["friends"]), + friends: petUnionArrayDeserializer(item["friends"]) }; } @@ -2016,22 +2022,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -2042,7 +2048,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise

{ const result = await _readSend(context, options); return _readDeserialize(result); @@ -2085,7 +2091,7 @@ export function fooDeserializer(item: any): Foo { return { name: item["name"], weight: item["weight"], - bar: barDeserializer(item["bar"]), + bar: barDeserializer(item["bar"]) }; } @@ -2096,7 +2102,7 @@ export interface Bar { export function barDeserializer(item: any): Bar { return { - foo: fooDeserializer(item["foo"]), + foo: fooDeserializer(item["foo"]) }; } ``` @@ -2111,22 +2117,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -2137,7 +2143,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -2208,25 +2214,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, contentType: SchemaContentTypeValues, body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: contentType, - body: body, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: contentType, + body: body + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -2239,7 +2245,7 @@ export async function get( context: Client, contentType: SchemaContentTypeValues, body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): Promise { const result = await _getSend(context, contentType, body, options); return _getDeserialize(result); @@ -2297,6 +2303,11 @@ export type SchemaContentTypeValues = | "application/json; serialization=json" | "text/plain; charset=utf-8" | "text/vnd.ms.protobuf"; + +/** Defines headers for operation response. */ +export interface GetResponse { + testHeader: SchemaContentTypeValues; +} ``` # anonymous union with string literals being used in regular headers @@ -2334,52 +2345,62 @@ needAzureCore: false ## Models ```ts models -// (file was not generated) +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Defines headers for operation response. */ +export interface GetResponse { + testHeader: "A" | "B"; +} ``` ## Operations ```ts operations import { DemoServiceContext as Client } from "./index.js"; +import { GetResponse } from "../models/models.js"; import { GetOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, testHeader: "A" | "B", body: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "text/plain", - headers: { "test-header": testHeader, ...options.requestOptions?.headers }, - body: body, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "text/plain", + headers: { "test-header": testHeader, ...options.requestOptions?.headers }, + body: body + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise<{ testHeader: "A" | "B" }> { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return; + return { testHeader: result.headers["test-header"]! } as GetResponse; } export async function get( context: Client, testHeader: "A" | "B", body: string, - options: GetOptionalParams = { requestOptions: {} }, -): Promise { + options: GetOptionalParams = { requestOptions: {} } +): Promise<{ testHeader: "A" | "B" }> { const result = await _getSend(context, testHeader, body, options); return _getDeserialize(result); } @@ -2632,10 +2653,10 @@ export function vegetablesSerializer(item: Vegetables): any { ...serializeRecord( item.additionalProperties ?? {}, undefined, - _vegetablesAdditionalPropertySerializer, + _vegetablesAdditionalPropertySerializer ), carrots: item["carrots"], - beans: item["beans"], + beans: item["beans"] }; } @@ -2644,22 +2665,24 @@ export function vegetablesDeserializer(item: any): Vegetables { additionalProperties: serializeRecord( item, ["carrots", "beans"], - _vegetablesAdditionalPropertyDeserializer, + _vegetablesAdditionalPropertyDeserializer ), carrots: item["carrots"], - beans: item["beans"], + beans: item["beans"] }; } /** Alias for _VegetablesAdditionalProperty */ export type _VegetablesAdditionalProperty = number | string; -export function _vegetablesAdditionalPropertySerializer(item: _VegetablesAdditionalProperty): any { +export function _vegetablesAdditionalPropertySerializer( + item: _VegetablesAdditionalProperty +): any { return item; } export function _vegetablesAdditionalPropertyDeserializer( - item: any, + item: any ): _VegetablesAdditionalProperty { return item; } @@ -2768,24 +2791,32 @@ export interface ServiceResourceProperties { servicePlacementPolicies?: ServicePlacementPolicyDescription[]; } -export function serviceResourcePropertiesSerializer(item: ServiceResourceProperties): any { +export function serviceResourcePropertiesSerializer( + item: ServiceResourceProperties +): any { return { servicePlacementPolicies: !item["servicePlacementPolicies"] ? item["servicePlacementPolicies"] - : servicePlacementPolicyDescriptionArraySerializer(item["servicePlacementPolicies"]), + : servicePlacementPolicyDescriptionArraySerializer( + item["servicePlacementPolicies"] + ) }; } -export function serviceResourcePropertiesDeserializer(item: any): ServiceResourceProperties { +export function serviceResourcePropertiesDeserializer( + item: any +): ServiceResourceProperties { return { servicePlacementPolicies: !item["servicePlacementPolicies"] ? item["servicePlacementPolicies"] - : servicePlacementPolicyDescriptionArrayDeserializer(item["servicePlacementPolicies"]), + : servicePlacementPolicyDescriptionArrayDeserializer( + item["servicePlacementPolicies"] + ) }; } export function servicePlacementPolicyDescriptionArraySerializer( - result: Array, + result: Array ): any[] { return result.map((item) => { return servicePlacementPolicyDescriptionSerializer(item); @@ -2793,7 +2824,7 @@ export function servicePlacementPolicyDescriptionArraySerializer( } export function servicePlacementPolicyDescriptionArrayDeserializer( - result: Array, + result: Array ): any[] { return result.map((item) => { return servicePlacementPolicyDescriptionDeserializer(item); @@ -2807,19 +2838,24 @@ export interface ServicePlacementPolicyDescription extends Pet { } export function servicePlacementPolicyDescriptionSerializer( - item: ServicePlacementPolicyDescription, + item: ServicePlacementPolicyDescription ): any { - return { kind: item["kind"], name: item["name"], weight: item["weight"], type: item["type"] }; + return { + kind: item["kind"], + name: item["name"], + weight: item["weight"], + type: item["type"] + }; } export function servicePlacementPolicyDescriptionDeserializer( - item: any, + item: any ): ServicePlacementPolicyDescription { return { kind: item["kind"], name: item["name"], weight: item["weight"], - type: item["type"], + type: item["type"] }; } @@ -2838,7 +2874,7 @@ export function petDeserializer(item: any): Pet { return { kind: item["kind"], name: item["name"], - weight: item["weight"], + weight: item["weight"] }; } @@ -2848,7 +2884,9 @@ export type PetUnion = ServicePlacementPolicyDescription | Pet; export function petUnionSerializer(item: PetUnion): any { switch (item.kind) { case "dog": - return servicePlacementPolicyDescriptionSerializer(item as ServicePlacementPolicyDescription); + return servicePlacementPolicyDescriptionSerializer( + item as ServicePlacementPolicyDescription + ); default: return petSerializer(item); @@ -2859,7 +2897,7 @@ export function petUnionDeserializer(item: any): PetUnion { switch (item.kind) { case "dog": return servicePlacementPolicyDescriptionDeserializer( - item as ServicePlacementPolicyDescription, + item as ServicePlacementPolicyDescription ); default: diff --git a/packages/typespec-ts/test/modularUnit/scenarios/operations/headerParam/headerParamWithClientInitialization.md b/packages/typespec-ts/test/modularUnit/scenarios/operations/headerParam/headerParamWithClientInitialization.md index 7d70dab9b2..8c9f900cf2 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/operations/headerParam/headerParamWithClientInitialization.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/operations/headerParam/headerParamWithClientInitialization.md @@ -61,7 +61,7 @@ model SavingsPlanModel extends Azure.ResourceManager.Foundations.ProxyResource { >; sku: ResourceSku; - + @doc("The resource-specific properties for this resource.") properties?: SavingsPlanModelProperties; } @@ -125,21 +125,23 @@ export interface BillingBenefitsClientOptionalParams extends ClientOptions { export function createBillingBenefits( endpointParam: string, - options: BillingBenefitsClientOptionalParams = {}, + options: BillingBenefitsClientOptionalParams = {} ): BillingBenefitsContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return { ...clientContext, expand: options.expand } as BillingBenefitsContext; @@ -153,7 +155,7 @@ import { BillingBenefitsContext as Client } from "./index.js"; import { SavingsPlanModel, savingsPlanModelDeserializer, - errorResponseDeserializer, + errorResponseDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { GetOptionalParams } from "./options.js"; @@ -161,7 +163,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( @@ -171,7 +173,7 @@ export function _getSend( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ThisWillBeReplaced/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}{?api%2Dversion}", @@ -180,25 +182,25 @@ export function _getSend( resourceGroupName: resourceGroupName, savingsPlanOrderId: savingsPlanOrderId, savingsPlanId: savingsPlanId, - "api%2Dversion": apiVersion, + "api%2Dversion": apiVersion }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.expand !== undefined ? { $expand: context.expand } : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.expand !== undefined ? { $expand: context.expand } : {}), + accept: "application/json", + ...options.requestOptions?.headers + } + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -217,7 +219,7 @@ export async function get( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): Promise { const result = await _getSend( context, @@ -226,11 +228,12 @@ export async function get( resourceGroupName, savingsPlanOrderId, savingsPlanId, - options, + options ); return _getDeserialize(result); } ``` + # Required header parameter with clientInitialization This scenario tests the generation of TypeScript code for an Azure Resource Manager resource read operation with header parameters, specifically the `$expand` parameter for the SavingsPlanModel. @@ -294,7 +297,7 @@ model SavingsPlanModel extends Azure.ResourceManager.Foundations.ProxyResource { >; sku: ResourceSku; - + @doc("The resource-specific properties for this resource.") properties?: SavingsPlanModelProperties; } @@ -356,21 +359,23 @@ export interface BillingBenefitsClientOptionalParams extends ClientOptions {} export function createBillingBenefits( endpointParam: string, expand: string, - options: BillingBenefitsClientOptionalParams = {}, + options: BillingBenefitsClientOptionalParams = {} ): BillingBenefitsContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return { ...clientContext, expand } as BillingBenefitsContext; @@ -384,7 +389,7 @@ import { BillingBenefitsContext as Client } from "./index.js"; import { SavingsPlanModel, savingsPlanModelDeserializer, - errorResponseDeserializer, + errorResponseDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { GetOptionalParams } from "./options.js"; @@ -392,7 +397,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( @@ -402,7 +407,7 @@ export function _getSend( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ThisWillBeReplaced/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}{?api%2Dversion}", @@ -411,25 +416,25 @@ export function _getSend( resourceGroupName: resourceGroupName, savingsPlanOrderId: savingsPlanOrderId, savingsPlanId: savingsPlanId, - "api%2Dversion": apiVersion, + "api%2Dversion": apiVersion }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - ...(options?.expand !== undefined ? { $expand: context.expand } : {}), - accept: "application/json", - ...options.requestOptions?.headers, - }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.expand !== undefined ? { $expand: context.expand } : {}), + accept: "application/json", + ...options.requestOptions?.headers + } + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -448,7 +453,7 @@ export async function get( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): Promise { const result = await _getSend( context, @@ -457,8 +462,8 @@ export async function get( resourceGroupName, savingsPlanOrderId, savingsPlanId, - options, + options ); return _getDeserialize(result); } -``` \ No newline at end of file +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/operations/lroPaging.md b/packages/typespec-ts/test/modularUnit/scenarios/operations/lroPaging.md index 381e8d3eac..508920be2c 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/operations/lroPaging.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/operations/lroPaging.md @@ -74,7 +74,7 @@ export interface _WebAppCollection { export function _webAppCollectionDeserializer(item: any): _WebAppCollection { return { value: siteArrayDeserializer(item["value"]), - nextLink: item["nextLink"], + nextLink: item["nextLink"] }; } @@ -94,7 +94,9 @@ export function siteDeserializer(item: any): Site { return { tags: !item["tags"] ? item["tags"] - : Object.fromEntries(Object.entries(item["tags"]).map(([k, p]: [string, any]) => [k, p])), + : Object.fromEntries( + Object.entries(item["tags"]).map(([k, p]: [string, any]) => [k, p]) + ), location: item["location"], id: item["id"], name: item["name"], @@ -104,7 +106,7 @@ export function siteDeserializer(item: any): Site { : systemDataDeserializer(item["systemData"]), properties: !item["properties"] ? item["properties"] - : sitePropertiesDeserializer(item["properties"]), + : sitePropertiesDeserializer(item["properties"]) }; } @@ -116,7 +118,7 @@ export interface SiteProperties { export function sitePropertiesDeserializer(item: any): SiteProperties { return { - state: item["state"], + state: item["state"] }; } @@ -138,8 +140,10 @@ export function trackedResourceDeserializer(item: any): TrackedResource { : systemDataDeserializer(item["systemData"]), tags: !item["tags"] ? item["tags"] - : Object.fromEntries(Object.entries(item["tags"]).map(([k, p]: [string, any]) => [k, p])), - location: item["location"], + : Object.fromEntries( + Object.entries(item["tags"]).map(([k, p]: [string, any]) => [k, p]) + ), + location: item["location"] }; } @@ -162,7 +166,7 @@ export function resourceDeserializer(item: any): Resource { type: item["type"], systemData: !item["systemData"] ? item["systemData"] - : systemDataDeserializer(item["systemData"]), + : systemDataDeserializer(item["systemData"]) }; } @@ -186,12 +190,14 @@ export function systemDataDeserializer(item: any): SystemData { return { createdBy: item["createdBy"], createdByType: item["createdByType"], - createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + createdAt: !item["createdAt"] + ? item["createdAt"] + : new Date(item["createdAt"]), lastModifiedBy: item["lastModifiedBy"], lastModifiedByType: item["lastModifiedByType"], lastModifiedAt: !item["lastModifiedAt"] ? item["lastModifiedAt"] - : new Date(item["lastModifiedAt"]), + : new Date(item["lastModifiedAt"]) }; } @@ -206,7 +212,9 @@ export interface ErrorResponse { export function errorResponseDeserializer(item: any): ErrorResponse { return { - error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + error: !item["error"] + ? item["error"] + : errorDetailDeserializer(item["error"]) }; } @@ -229,20 +237,26 @@ export function errorDetailDeserializer(item: any): ErrorDetail { code: item["code"], message: item["message"], target: item["target"], - details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + details: !item["details"] + ? item["details"] + : errorDetailArrayDeserializer(item["details"]), additionalInfo: !item["additionalInfo"] ? item["additionalInfo"] - : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]) }; } -export function errorDetailArrayDeserializer(result: Array): any[] { +export function errorDetailArrayDeserializer( + result: Array +): any[] { return result.map((item) => { return errorDetailDeserializer(item); }); } -export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { +export function errorAdditionalInfoArrayDeserializer( + result: Array +): any[] { return result.map((item) => { return errorAdditionalInfoDeserializer(item); }); @@ -256,17 +270,19 @@ export interface ErrorAdditionalInfo { readonly info?: any; } -export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { +export function errorAdditionalInfoDeserializer( + item: any +): ErrorAdditionalInfo { return { type: item["type"], - info: item["info"], + info: item["info"] }; } /** Known values of {@link Versions} that the service accepts. */ export enum KnownVersions { /** 2023-12-01 */ - V20231201 = "2023-12-01", + V20231201 = "2023-12-01" } ``` @@ -278,11 +294,11 @@ import { _WebAppCollection, _webAppCollectionDeserializer, Site, - errorResponseDeserializer, + errorResponseDeserializer } from "../models/models.js"; import { PagedAsyncIterableIterator, - buildPagedAsyncIterator, + buildPagedAsyncIterator } from "../static-helpers/pagingHelpers.js"; import { getLongRunningPoller } from "../static-helpers/pollingHelpers.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; @@ -291,7 +307,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; import { PollerLike, OperationState } from "@azure/core-lro"; @@ -299,7 +315,7 @@ export function _suspendSend( context: Client, resourceGroupName: string, name: string, - options: SuspendOptionalParams = { requestOptions: {} }, + options: SuspendOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/suspend{?api%2Dversion}", @@ -307,22 +323,20 @@ export function _suspendSend( subscriptionId: context.subscriptionId, resourceGroupName: resourceGroupName, name: name, - "api%2Dversion": context.apiVersion ?? "2023-12-01", + "api%2Dversion": context.apiVersion ?? "2023-12-01" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _suspendDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise<_WebAppCollection> { const expectedStatuses = ["200", "201", "202"]; if (!expectedStatuses.includes(result.status)) { @@ -339,7 +353,7 @@ export function suspend( context: Client, resourceGroupName: string, name: string, - options: SuspendOptionalParams = { requestOptions: {} }, + options: SuspendOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { const initialPagingPoller = getLongRunningPoller( context, @@ -348,10 +362,11 @@ export function suspend( { updateIntervalInMs: options?.updateIntervalInMs, abortSignal: options?.abortSignal, - getInitialResponse: () => _suspendSend(context, resourceGroupName, name, options), + getInitialResponse: () => + _suspendSend(context, resourceGroupName, name, options), resourceLocationConfig: "location", - apiVersion: context.apiVersion ?? "2023-12-01", - }, + apiVersion: context.apiVersion ?? "2023-12-01" + } ) as PollerLike, PathUncheckedResponse>; return buildPagedAsyncIterator( @@ -359,7 +374,11 @@ export function suspend( async () => await initialPagingPoller, _suspendDeserialize, ["200", "201", "202"], - { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2023-12-01" }, + { + itemName: "value", + nextLinkName: "nextLink", + apiVersion: context.apiVersion ?? "2023-12-01" + } ); } -``` \ No newline at end of file +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/operations/operations.md b/packages/typespec-ts/test/modularUnit/scenarios/operations/operations.md index 826a733961..07aa6a4284 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/operations/operations.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/operations/operations.md @@ -17,17 +17,21 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context.path("/").post({ ...operationOptionsToRequestParameters(options) }); + return context + .path("/") + .post({ ...operationOptionsToRequestParameters(options) }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["204"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -38,7 +42,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -62,17 +66,21 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context.path("/").get({ ...operationOptionsToRequestParameters(options) }); + return context + .path("/") + .get({ ...operationOptionsToRequestParameters(options) }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -83,7 +91,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -133,7 +141,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; import { uint8ArrayToString } from "@azure/core-util"; @@ -146,7 +154,7 @@ export function _readSend( utcDateHeader: Date, prop1: string, prop2: number, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { return context.path("/").post({ ...operationOptionsToRequestParameters(options), @@ -156,7 +164,8 @@ export function _readSend( ...(options?.optionalHeader !== undefined ? { "optional-header": options?.optionalHeader } : {}), - ...(options?.nullableOptionalHeader !== undefined && options?.nullableOptionalHeader !== null + ...(options?.nullableOptionalHeader !== undefined && + options?.nullableOptionalHeader !== null ? { "nullable-optional-header": options?.nullableOptionalHeader } : {}), "bytes-header": uint8ArrayToString(bytesHeader, "base64"), @@ -164,7 +173,7 @@ export function _readSend( "csv-array-header": buildCsvCollection( csvArrayHeader.map((p: any) => { return uint8ArrayToString(p, "base64url"); - }), + }) ), ...(options?.optionalCsvArrayHeader !== undefined ? { @@ -173,8 +182,8 @@ export function _readSend( : buildCsvCollection( options?.optionalCsvArrayHeader.map((p: any) => { return p; - }), - ), + }) + ) } : {}), "utc-date-header": utcDateHeader.toUTCString(), @@ -182,23 +191,26 @@ export function _readSend( ? { "optional-date-header": !options?.optionalDateHeader ? options?.optionalDateHeader - : options?.optionalDateHeader.toUTCString(), + : options?.optionalDateHeader.toUTCString() } : {}), - ...(options?.nullableDateHeader !== undefined && options?.nullableDateHeader !== null + ...(options?.nullableDateHeader !== undefined && + options?.nullableDateHeader !== null ? { "nullable-date-header": !options?.nullableDateHeader ? options?.nullableDateHeader - : options?.nullableDateHeader.toUTCString(), + : options?.nullableDateHeader.toUTCString() } : {}), - ...options.requestOptions?.headers, + ...options.requestOptions?.headers }, - body: { prop1: prop1, prop2: prop2 }, + body: { prop1: prop1, prop2: prop2 } }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -216,7 +228,7 @@ export async function read( utcDateHeader: Date, prop1: string, prop2: number, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise { const result = await _readSend( context, @@ -227,7 +239,7 @@ export async function read( utcDateHeader, prop1, prop2, - options, + options ); return _readDeserialize(result); } @@ -256,26 +268,26 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, nullableRequiredHeader: string | null, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { - "nullable-required-header": nullableRequiredHeader, - ...options.requestOptions?.headers, - }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { + "nullable-required-header": nullableRequiredHeader, + ...options.requestOptions?.headers + } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -287,7 +299,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, nullableRequiredHeader, options); return _readDeserialize(result); @@ -316,23 +328,25 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: !options["bars"] ? options["bars"] : barArraySerializer(options["bars"]), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: !options["bars"] + ? options["bars"] + : barArraySerializer(options["bars"]) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -343,7 +357,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -372,24 +386,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, bars: Bar[], - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: barArraySerializer(bars), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: barArraySerializer(bars) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -401,7 +415,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, bars, options); return _readDeserialize(result); @@ -430,19 +444,17 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } export async function _readDeserialize(result: PathUncheckedResponse): Promise< @@ -460,7 +472,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise< export async function read( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise< { a: Bar; @@ -487,30 +499,36 @@ op read(@body bars?: Bar[]): Bar[] | null; ```ts operations import { TestingContext as Client } from "./index.js"; -import { Bar, barArraySerializer, barArrayDeserializer } from "../models/models.js"; +import { + Bar, + barArraySerializer, + barArrayDeserializer +} from "../models/models.js"; import { ReadOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: !options["bars"] ? options["bars"] : barArraySerializer(options["bars"]), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: !options["bars"] + ? options["bars"] + : barArraySerializer(options["bars"]) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -521,7 +539,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -556,24 +574,24 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, body: Foo, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - body: fooSerializer(body), - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + body: fooSerializer(body) + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -585,7 +603,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, body, options); return _readDeserialize(result); @@ -620,22 +638,22 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _readDeserialize(result: PathUncheckedResponse): Promise { +export async function _readDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -646,7 +664,7 @@ export async function _readDeserialize(result: PathUncheckedResponse): Promise { const result = await _readSend(context, options); return _readDeserialize(result); @@ -686,29 +704,29 @@ import { TestingContext as Client } from "./index.js"; import { errorDeserializer, _Bar, _barDeserializer } from "../models/models.js"; import { PagedAsyncIterableIterator, - buildPagedAsyncIterator, + buildPagedAsyncIterator } from "../static-helpers/pagingHelpers.js"; import { TestOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _testSend( context: Client, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _testDeserialize(result: PathUncheckedResponse): Promise<_Bar> { +export async function _testDeserialize( + result: PathUncheckedResponse +): Promise<_Bar> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -721,14 +739,14 @@ export async function _testDeserialize(result: PathUncheckedResponse): Promise<_ export function test( context: Client, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, () => _testSend(context, options), _testDeserialize, ["200"], - { itemName: "lists" }, + { itemName: "lists" } ); } ``` @@ -770,32 +788,36 @@ needAzureCore: true ```ts operations import { TestingContext as Client } from "./index.js"; -import { errorDeserializer, _Child, _childDeserializer } from "../models/models.js"; +import { + errorDeserializer, + _Child, + _childDeserializer +} from "../models/models.js"; import { PagedAsyncIterableIterator, - buildPagedAsyncIterator, + buildPagedAsyncIterator } from "../static-helpers/pagingHelpers.js"; import { TestOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _testSend( context: Client, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _testDeserialize(result: PathUncheckedResponse): Promise<_Child> { +export async function _testDeserialize( + result: PathUncheckedResponse +): Promise<_Child> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -808,14 +830,14 @@ export async function _testDeserialize(result: PathUncheckedResponse): Promise<_ export function test( context: Client, - options: TestOptionalParams = { requestOptions: {} }, + options: TestOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, () => _testSend(context, options), _testDeserialize, ["200"], - { itemName: "lists", nextLinkName: "nextLink" }, + { itemName: "lists", nextLinkName: "nextLink" } ); } ``` @@ -850,7 +872,7 @@ export interface TestArrayModel { export function testArrayModelDeserializer(item: any): TestArrayModel { return { - prop: testArrayDeserializer(item["prop"]), + prop: testArrayDeserializer(item["prop"]) }; } @@ -867,7 +889,7 @@ export interface Test { export function testDeserializer(item: any): Test { return { - prop: !item["prop"] ? item["prop"] : testArrayDeserializer(item["prop"]), + prop: !item["prop"] ? item["prop"] : testArrayDeserializer(item["prop"]) }; } ``` @@ -876,28 +898,31 @@ export function testDeserializer(item: any): Test { ```ts operations import { TestingContext as Client } from "./index.js"; -import { TestArrayModel, testArrayModelDeserializer } from "../models/models.js"; +import { + TestArrayModel, + testArrayModelDeserializer +} from "../models/models.js"; import { GetOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -908,7 +933,7 @@ export async function _getDeserialize(result: PathUncheckedResponse): Promise { const result = await _getSend(context, options); return _getDeserialize(result); @@ -946,11 +971,13 @@ export interface TestDictionary { export function testDictionaryDeserializer(item: any): TestDictionary { return { - prop: testRecordDeserializer(item["prop"]), + prop: testRecordDeserializer(item["prop"]) }; } -export function testRecordDeserializer(item: Record): Record { +export function testRecordDeserializer( + item: Record +): Record { const result: Record = {}; Object.keys(item).map((key) => { result[key] = !item[key] ? item[key] : testDeserializer(item[key]); @@ -965,7 +992,7 @@ export interface Test { export function testDeserializer(item: any): Test { return { - prop: !item["prop"] ? item["prop"] : testRecordDeserializer(item["prop"]), + prop: !item["prop"] ? item["prop"] : testRecordDeserializer(item["prop"]) }; } ``` @@ -974,28 +1001,31 @@ export function testDeserializer(item: any): Test { ```ts operations import { TestingContext as Client } from "./index.js"; -import { TestDictionary, testDictionaryDeserializer } from "../models/models.js"; +import { + TestDictionary, + testDictionaryDeserializer +} from "../models/models.js"; import { GetOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( context: Client, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/") - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/").get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1006,7 +1036,7 @@ export async function _getDeserialize(result: PathUncheckedResponse): Promise { const result = await _getSend(context, options); return _getDeserialize(result); @@ -1052,7 +1082,7 @@ export function endpointSerializer(item: Endpoint): any { export function endpointDeserializer(item: any): Endpoint { return { name: item["name"], - description: item["description"], + description: item["description"] }; } ``` @@ -1061,43 +1091,45 @@ export function endpointDeserializer(item: any): Endpoint { ```ts operations import { TestingContext as Client } from "./index.js"; -import { Endpoint, endpointSerializer, endpointDeserializer } from "../models/models.js"; +import { + Endpoint, + endpointSerializer, + endpointDeserializer +} from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { CreateOrUpdateEndpointOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _createOrUpdateEndpointSend( context: Client, endpointName: string, endpointParam: Endpoint, - options: CreateOrUpdateEndpointOptionalParams = { requestOptions: {} }, + options: CreateOrUpdateEndpointOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/endpoints/{endpointName}", { - endpointName: endpointName, + endpointName: endpointName }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: endpointSerializer(endpointParam), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: endpointSerializer(endpointParam) + }); } export async function _createOrUpdateEndpointDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -1111,9 +1143,14 @@ export async function createOrUpdateEndpoint( context: Client, endpointName: string, endpointParam: Endpoint, - options: CreateOrUpdateEndpointOptionalParams = { requestOptions: {} }, + options: CreateOrUpdateEndpointOptionalParams = { requestOptions: {} } ): Promise { - const result = await _createOrUpdateEndpointSend(context, endpointName, endpointParam, options); + const result = await _createOrUpdateEndpointSend( + context, + endpointName, + endpointParam, + options + ); return _createOrUpdateEndpointDeserialize(result); } ``` @@ -1181,7 +1218,7 @@ export interface _ListTestResult { export function _listTestResultDeserializer(item: any): _ListTestResult { return { tests: testArrayDeserializer(item["tests"]), - next: item["next"], + next: item["next"] }; } @@ -1198,7 +1235,7 @@ export interface Test { export function testDeserializer(item: any): Test { return { - id: item["id"], + id: item["id"] }; } ``` @@ -1207,32 +1244,36 @@ export function testDeserializer(item: any): Test { ```ts operations import { testServiceContext as Client } from "./index.js"; -import { _ListTestResult, _listTestResultDeserializer, Test } from "../models/models.js"; +import { + _ListTestResult, + _listTestResultDeserializer, + Test +} from "../models/models.js"; import { PagedAsyncIterableIterator, - buildPagedAsyncIterator, + buildPagedAsyncIterator } from "../static-helpers/pagingHelpers.js"; import { FooOptionalParams, BarOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _fooSend( context: Client, - options: FooOptionalParams = { requestOptions: {} }, + options: FooOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/list-post") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/list-post").post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _fooDeserialize(result: PathUncheckedResponse): Promise<_ListTestResult> { +export async function _fooDeserialize( + result: PathUncheckedResponse +): Promise<_ListTestResult> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1243,30 +1284,30 @@ export async function _fooDeserialize(result: PathUncheckedResponse): Promise<_L export function foo( context: Client, - options: FooOptionalParams = { requestOptions: {} }, + options: FooOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, () => _fooSend(context, options), _fooDeserialize, ["200"], - { itemName: "tests", nextLinkName: "next", nextLinkMethod: "POST" }, + { itemName: "tests", nextLinkName: "next", nextLinkMethod: "POST" } ); } export function _barSend( context: Client, - options: BarOptionalParams = { requestOptions: {} }, + options: BarOptionalParams = { requestOptions: {} } ): StreamableMethod { - return context - .path("/list-get") - .post({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path("/list-get").post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _barDeserialize(result: PathUncheckedResponse): Promise<_ListTestResult> { +export async function _barDeserialize( + result: PathUncheckedResponse +): Promise<_ListTestResult> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -1277,14 +1318,14 @@ export async function _barDeserialize(result: PathUncheckedResponse): Promise<_L export function bar( context: Client, - options: BarOptionalParams = { requestOptions: {} }, + options: BarOptionalParams = { requestOptions: {} } ): PagedAsyncIterableIterator { return buildPagedAsyncIterator( context, () => _barSend(context, options), _barDeserialize, ["200"], - { itemName: "tests", nextLinkName: "next" }, + { itemName: "tests", nextLinkName: "next" } ); } ``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/operations/pathParam/pathParamUrlTemplate.md b/packages/typespec-ts/test/modularUnit/scenarios/operations/pathParam/pathParamUrlTemplate.md index 970236fc09..f5364c5663 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/operations/pathParam/pathParamUrlTemplate.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/operations/pathParam/pathParamUrlTemplate.md @@ -58,7 +58,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _updateKeySend( @@ -66,30 +66,30 @@ export function _updateKeySend( keyName: string, keyVersion: string, parameters: string, - options: UpdateKeyOptionalParams = { requestOptions: {} }, + options: UpdateKeyOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/keys/{key-name}/{key-version}{?api%2Dversion}", { "key-name": keyName, "key-version": keyVersion, - "api%2Dversion": context.apiVersion ?? "2022-05-15-preview", + "api%2Dversion": context.apiVersion ?? "2022-05-15-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .patch({ - ...operationOptionsToRequestParameters(options), - contentType: "text/plain", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: parameters, - }); + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "text/plain", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: parameters + }); } -export async function _updateKeyDeserialize(result: PathUncheckedResponse): Promise { +export async function _updateKeyDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -104,9 +104,15 @@ export async function updateKey( keyName: string, keyVersion: string, parameters: string, - options: UpdateKeyOptionalParams = { requestOptions: {} }, + options: UpdateKeyOptionalParams = { requestOptions: {} } ): Promise { - const result = await _updateKeySend(context, keyName, keyVersion, parameters, options); + const result = await _updateKeySend( + context, + keyName, + keyVersion, + parameters, + options + ); return _updateKeyDeserialize(result); } ``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/operations/queryParam/queryParamWithClientInitialization.md b/packages/typespec-ts/test/modularUnit/scenarios/operations/queryParam/queryParamWithClientInitialization.md index fb1f38e206..6f4cbce61a 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/operations/queryParam/queryParamWithClientInitialization.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/operations/queryParam/queryParamWithClientInitialization.md @@ -61,7 +61,7 @@ model SavingsPlanModel extends Azure.ResourceManager.Foundations.ProxyResource { >; sku: ResourceSku; - + @doc("The resource-specific properties for this resource.") properties?: SavingsPlanModelProperties; } @@ -125,21 +125,23 @@ export interface BillingBenefitsClientOptionalParams extends ClientOptions { export function createBillingBenefits( endpointParam: string, - options: BillingBenefitsClientOptionalParams = {}, + options: BillingBenefitsClientOptionalParams = {} ): BillingBenefitsContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return { ...clientContext, expand: options.expand } as BillingBenefitsContext; @@ -153,7 +155,7 @@ import { BillingBenefitsContext as Client } from "./index.js"; import { SavingsPlanModel, savingsPlanModelDeserializer, - errorResponseDeserializer, + errorResponseDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { GetOptionalParams } from "./options.js"; @@ -161,7 +163,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( @@ -171,7 +173,7 @@ export function _getSend( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ThisWillBeReplaced/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}{?api%2Dversion,%24expand}", @@ -181,21 +183,21 @@ export function _getSend( savingsPlanOrderId: savingsPlanOrderId, savingsPlanId: savingsPlanId, "api%2Dversion": apiVersion, - "%24expand": context.expand, + "%24expand": context.expand }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -214,7 +216,7 @@ export async function get( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): Promise { const result = await _getSend( context, @@ -223,7 +225,7 @@ export async function get( resourceGroupName, savingsPlanOrderId, savingsPlanId, - options, + options ); return _getDeserialize(result); } @@ -292,7 +294,7 @@ model SavingsPlanModel extends Azure.ResourceManager.Foundations.ProxyResource { >; sku: ResourceSku; - + @doc("The resource-specific properties for this resource.") properties?: SavingsPlanModelProperties; } @@ -354,21 +356,23 @@ export interface BillingBenefitsClientOptionalParams extends ClientOptions {} export function createBillingBenefits( endpointParam: string, expand: string, - options: BillingBenefitsClientOptionalParams = {}, + options: BillingBenefitsClientOptionalParams = {} ): BillingBenefitsContext { const endpointUrl = options.endpoint ?? String(endpointParam); const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : `azsdk-js-api`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : `azsdk-js-api`; const { apiVersion: _, ...updatedOptions } = { ...options, userAgentOptions: { userAgentPrefix }, - loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info } }; const clientContext = getClient(endpointUrl, undefined, updatedOptions); if (options.apiVersion) { logger.warning( - "This client does not support client api-version, please change it at the operation level", + "This client does not support client api-version, please change it at the operation level" ); } return { ...clientContext, expand } as BillingBenefitsContext; @@ -382,7 +386,7 @@ import { BillingBenefitsContext as Client } from "./index.js"; import { SavingsPlanModel, savingsPlanModelDeserializer, - errorResponseDeserializer, + errorResponseDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { GetOptionalParams } from "./options.js"; @@ -390,7 +394,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _getSend( @@ -400,7 +404,7 @@ export function _getSend( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ThisWillBeReplaced/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}{?api%2Dversion,%24expand}", @@ -410,21 +414,21 @@ export function _getSend( savingsPlanOrderId: savingsPlanOrderId, savingsPlanId: savingsPlanId, "api%2Dversion": apiVersion, - "%24expand": context.expand, + "%24expand": context.expand }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .get({ - ...operationOptionsToRequestParameters(options), - headers: { accept: "application/json", ...options.requestOptions?.headers }, - }); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers } + }); } -export async function _getDeserialize(result: PathUncheckedResponse): Promise { +export async function _getDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -443,7 +447,7 @@ export async function get( resourceGroupName: string, savingsPlanOrderId: string, savingsPlanId: string, - options: GetOptionalParams = { requestOptions: {} }, + options: GetOptionalParams = { requestOptions: {} } ): Promise { const result = await _getSend( context, @@ -452,8 +456,8 @@ export async function get( resourceGroupName, savingsPlanOrderId, savingsPlanId, - options, + options ); return _getDeserialize(result); } -``` \ No newline at end of file +``` diff --git a/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalCheck.md b/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalCheck.md index 877a0ca177..17e0f3067e 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalCheck.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalCheck.md @@ -75,45 +75,48 @@ Should generate operations correctly: ```ts operations import { TestingContext as Client } from "./index.js"; -import { bodyParameterSerializer, _readResponseDeserializer } from "../models/models.js"; +import { + bodyParameterSerializer, + _readResponseDeserializer +} from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { ReadOptionalParams } from "./options.js"; import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _readSend( context: Client, name: string, requiredQuery: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/{name}{?requiredQuery,optionalQuery}", { name: name, requiredQuery: requiredQuery, - optionalQuery: options?.optionalQuery, + optionalQuery: options?.optionalQuery }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: !options["widget"] ? options["widget"] : bodyParameterSerializer(options["widget"]), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: !options["widget"] + ? options["widget"] + : bodyParameterSerializer(options["widget"]) + }); } export async function _readDeserialize( - result: PathUncheckedResponse, + result: PathUncheckedResponse ): Promise> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { @@ -128,7 +131,7 @@ export async function read( context: Client, name: string, requiredQuery: string, - options: ReadOptionalParams = { requestOptions: {} }, + options: ReadOptionalParams = { requestOptions: {} } ): Promise> { const result = await _readSend(context, name, requiredQuery, options); return _readDeserialize(result); @@ -154,7 +157,7 @@ async function read(): Promise { const client = new TestingClient(endpoint); const result = await client.read("required path param", "required query", { widget: { name: "body name" }, - optionalQuery: "renamed optional query", + optionalQuery: "renamed optional query" }); console.log(result); } diff --git a/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalParameterName.md b/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalParameterName.md index bc65b2fee3..3452f8e908 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalParameterName.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/bodyOptionalParameterName.md @@ -144,7 +144,7 @@ import { backupRequestPropertiesSerializer, BackupResult, backupResultDeserializer, - errorResponseDeserializer, + errorResponseDeserializer } from "../models/models.js"; import { getLongRunningPoller } from "../static-helpers/pollingHelpers.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; @@ -153,7 +153,7 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; import { PollerLike, OperationState } from "@azure/core-lro"; @@ -161,7 +161,7 @@ export function _backupSend( context: Client, resourceGroupName: string, cloudHsmClusterName: string, - options: BackupOptionalParams = { requestOptions: {} }, + options: BackupOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backup{?api%2Dversion}", @@ -169,25 +169,25 @@ export function _backupSend( subscriptionId: context.subscriptionId, resourceGroupName: resourceGroupName, cloudHsmClusterName: cloudHsmClusterName, - "api%2Dversion": context.apiVersion ?? "2021-10-01-preview", + "api%2Dversion": context.apiVersion ?? "2021-10-01-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { accept: "application/json", ...options.requestOptions?.headers }, - body: !options["backupRequestProperties"] - ? options["backupRequestProperties"] - : backupRequestPropertiesSerializer(options["backupRequestProperties"]), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: !options["backupRequestProperties"] + ? options["backupRequestProperties"] + : backupRequestPropertiesSerializer(options["backupRequestProperties"]) + }); } -export async function _backupDeserialize(result: PathUncheckedResponse): Promise { +export async function _backupDeserialize( + result: PathUncheckedResponse +): Promise { const expectedStatuses = ["202", "200", "201"]; if (!expectedStatuses.includes(result.status)) { const error = createRestError(result); @@ -203,15 +203,21 @@ export function backup( context: Client, resourceGroupName: string, cloudHsmClusterName: string, - options: BackupOptionalParams = { requestOptions: {} }, + options: BackupOptionalParams = { requestOptions: {} } ): PollerLike, BackupResult> { - return getLongRunningPoller(context, _backupDeserialize, ["202", "200", "201"], { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => _backupSend(context, resourceGroupName, cloudHsmClusterName, options), - resourceLocationConfig: "azure-async-operation", - apiVersion: context.apiVersion ?? "2021-10-01-preview", - }) as PollerLike, BackupResult>; + return getLongRunningPoller( + context, + _backupDeserialize, + ["202", "200", "201"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _backupSend(context, resourceGroupName, cloudHsmClusterName, options), + resourceLocationConfig: "azure-async-operation", + apiVersion: context.apiVersion ?? "2021-10-01-preview" + } + ) as PollerLike, BackupResult>; } ``` @@ -235,7 +241,10 @@ async function cloudHsmClustersBackup(): Promise { const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new HardwareSecurityModulesClient(credential, subscriptionId); const result = await client.backup("rgcloudhsm", "chsm1", { - backupRequestProperties: { azureStorageBlobContainerUri: "sss", token: "aaa" }, + backupRequestProperties: { + azureStorageBlobContainerUri: "sss", + token: "aaa" + } }); console.log(result); } @@ -262,7 +271,7 @@ model BodyParameter { } @doc("This is a model with all http request decorator.") model CompositeRequest { - + @path name: string; @@ -328,11 +337,16 @@ import { TestingClient } from "@azure/internal-test"; async function read(): Promise { const endpoint = process.env.TESTING_ENDPOINT || ""; const client = new TestingClient(endpoint); - const result = await client.read("required path param", "required header", "required query", { - widget: { name: "body name" }, - testHeader: "optional header", - optionalQuery: "renamed optional query", - }); + const result = await client.read( + "required path param", + "required header", + "required query", + { + widget: { name: "body name" }, + testHeader: "optional header", + optionalQuery: "renamed optional query" + } + ); console.log(result); } @@ -417,7 +431,7 @@ async function read(): Promise { const client = new TestingClient(endpoint); const result = await client.read("required path param", "required query", { widget: { name: "body name" }, - optionalQuery: "renamed optional query", + optionalQuery: "renamed optional query" }); console.log(result); } diff --git a/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/parameterOrdering.md b/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/parameterOrdering.md index 90f75fe92c..27a5f953ed 100644 --- a/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/parameterOrdering.md +++ b/packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/parameterOrdering.md @@ -60,7 +60,6 @@ The config would be like: ```yaml needAzureCore: true withVersionedApiVersion: true - ``` ## Operations @@ -70,8 +69,7 @@ import { TestingContext as Client } from "./index.js"; import { TestVerificationContent, testVerificationContentSerializer, - TestVerificationResult, - testVerificationResultDeserializer, + testVerificationResultDeserializer } from "../models/models.js"; import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; import { VerifyOptionalParams } from "./options.js"; @@ -79,44 +77,42 @@ import { StreamableMethod, PathUncheckedResponse, createRestError, - operationOptionsToRequestParameters, + operationOptionsToRequestParameters } from "@azure-rest/core-client"; export function _verifySend( context: Client, body: TestVerificationContent, apcGatewayId: string, - options: VerifyOptionalParams = { requestOptions: {} }, + options: VerifyOptionalParams = { requestOptions: {} } ): StreamableMethod { const path = expandUrlTemplate( "/device-location/location:verify{?api%2Dversion}", { - "api%2Dversion": context.apiVersion ?? "2022-05-15-preview", + "api%2Dversion": context.apiVersion ?? "2022-05-15-preview" }, { - allowReserved: options?.requestOptions?.skipUrlEncoding, - }, + allowReserved: options?.requestOptions?.skipUrlEncoding + } ); - return context - .path(path) - .post({ - ...operationOptionsToRequestParameters(options), - contentType: "application/json", - headers: { - ...(options?.clientRequestId !== undefined - ? { "x-ms-client-request-id": options?.clientRequestId } - : {}), - "apc-gateway-id": apcGatewayId, - accept: "application/json", - ...options.requestOptions?.headers, - }, - body: testVerificationContentSerializer(body), - }); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + "apc-gateway-id": apcGatewayId, + accept: "application/json", + ...options.requestOptions?.headers + }, + body: testVerificationContentSerializer(body) + }); } export async function _verifyDeserialize( - result: PathUncheckedResponse, -): Promise { + result: PathUncheckedResponse +): Promise<{ result: string; clientRequestId?: string }> { const expectedStatuses = ["200"]; if (!expectedStatuses.includes(result.status)) { throw createRestError(result); @@ -130,8 +126,8 @@ export async function verify( context: Client, body: TestVerificationContent, apcGatewayId: string, - options: VerifyOptionalParams = { requestOptions: {} }, -): Promise { + options: VerifyOptionalParams = { requestOptions: {} } +): Promise<{ result: string; clientRequestId?: string }> { const result = await _verifySend(context, body, apcGatewayId, options); return _verifyDeserialize(result); } @@ -176,7 +172,10 @@ import { TestingClient } from "@azure/internal-test"; async function verify(): Promise { const endpoint = process.env.TESTING_ENDPOINT || ""; const client = new TestingClient(endpoint); - const result = await client.verify({ message: "test message" }, "zdgrzzaxlodrvewbksn"); + const result = await client.verify( + { message: "test message" }, + "zdgrzzaxlodrvewbksn" + ); console.log(result); } @@ -185,4 +184,4 @@ async function main(): Promise { } main().catch(console.error); -``` \ No newline at end of file +``` diff --git a/packages/typespec-ts/test/util/testUtil.ts b/packages/typespec-ts/test/util/testUtil.ts index 826f233e7e..b92d769238 100644 --- a/packages/typespec-ts/test/util/testUtil.ts +++ b/packages/typespec-ts/test/util/testUtil.ts @@ -193,6 +193,7 @@ export async function createDpgContextTestHelper( provideContext("rlcMetaTree", new Map()); provideContext("symbolMap", new Map()); provideContext("outputProject", outputProject); + provideContext("headerOnlyResponses", new Map()); const context = await createContextWithDefaultOptions({ program,