Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/subscription/arm-subscriptions/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022 Microsoft
Copyright (c) 2023 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions sdk/subscription/arm-subscriptions/_meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"commit": "52a770004c3019a067e9dcdbb2e95b4992d42728",
"commit": "9eba6eb27c98106f70168a7a8842f30c308fa81a",
"readme": "specification/subscription/resource-manager/readme.md",
"autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\subscription\\resource-manager\\readme.md --use=@autorest/[email protected].3.20221108.1 --generate-sample=true",
"autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/subscription/resource-manager/readme.md --use=@autorest/[email protected].10",
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
"release_tool": "@azure-tools/js-sdk-release-tools@2.4.2",
"use": "@autorest/[email protected].3.20221108.1"
"release_tool": "@azure-tools/js-sdk-release-tools@2.7.0",
"use": "@autorest/[email protected].10"
}
21 changes: 7 additions & 14 deletions sdk/subscription/arm-subscriptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"node": ">=14.0.0"
},
"dependencies": {
"@azure/core-lro": "^2.2.0",
"@azure/core-lro": "^2.5.0",
"@azure/abort-controller": "^1.0.0",
"@azure/core-paging": "^1.2.0",
"@azure/core-client": "^1.6.1",
"@azure/core-client": "^1.7.0",
"@azure/core-auth": "^1.3.0",
"@azure/core-rest-pipeline": "^1.8.0",
"tslib": "^2.2.0"
Expand All @@ -33,12 +33,13 @@
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-multi-entry": "^6.0.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"mkdirp": "^1.0.4",
"mkdirp": "^2.1.2",
"rollup": "^2.66.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"typescript": "~5.0.0",
"typescript": "~4.8.0",
"uglify-js": "^3.4.9",
"rimraf": "^3.0.0",
"dotenv": "^16.0.0",
"@azure/identity": "^2.0.1",
"@azure-tools/test-recorder": "^3.0.0",
"@azure-tools/test-credential": "^1.0.0",
Expand All @@ -49,7 +50,6 @@
"@types/node": "^14.0.0",
"@azure/dev-tool": "^1.0.0"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions",
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
Expand Down Expand Up @@ -111,12 +111,5 @@
]
},
"autoPublish": true,
"//sampleConfiguration": {
"productName": "",
"productSlugs": [
"azure"
],
"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-subscriptions?view=azure-node-preview"
}
}
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import * as coreAuth from '@azure/core-auth';
import * as coreClient from '@azure/core-client';
import { OperationState } from '@azure/core-lro';
import { PagedAsyncIterableIterator } from '@azure/core-paging';
import { PollerLike } from '@azure/core-lro';
import { PollOperationState } from '@azure/core-lro';
import { SimplePollerLike } from '@azure/core-lro';

// @public
export type AcceptOwnership = string;
Expand Down Expand Up @@ -42,7 +42,7 @@ export interface AcceptOwnershipStatusResponse {

// @public
export interface Alias {
beginCreate(aliasName: string, body: PutAliasRequest, options?: AliasCreateOptionalParams): Promise<PollerLike<PollOperationState<AliasCreateResponse>, AliasCreateResponse>>;
beginCreate(aliasName: string, body: PutAliasRequest, options?: AliasCreateOptionalParams): Promise<SimplePollerLike<OperationState<AliasCreateResponse>, AliasCreateResponse>>;
beginCreateAndWait(aliasName: string, body: PutAliasRequest, options?: AliasCreateOptionalParams): Promise<AliasCreateResponse>;
delete(aliasName: string, options?: AliasDeleteOptionalParams): Promise<void>;
get(aliasName: string, options?: AliasGetOptionalParams): Promise<AliasGetResponse>;
Expand Down Expand Up @@ -414,7 +414,7 @@ export interface SubscriptionName {
// @public
export interface SubscriptionOperations {
acceptOwnershipStatus(subscriptionId: string, options?: SubscriptionAcceptOwnershipStatusOptionalParams): Promise<SubscriptionAcceptOwnershipStatusResponse>;
beginAcceptOwnership(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise<PollerLike<PollOperationState<SubscriptionAcceptOwnershipResponse>, SubscriptionAcceptOwnershipResponse>>;
beginAcceptOwnership(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise<SimplePollerLike<OperationState<SubscriptionAcceptOwnershipResponse>, SubscriptionAcceptOwnershipResponse>>;
beginAcceptOwnershipAndWait(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise<SubscriptionAcceptOwnershipResponse>;
cancel(subscriptionId: string, options?: SubscriptionCancelOptionalParams): Promise<SubscriptionCancelResponse>;
enable(subscriptionId: string, options?: SubscriptionEnableOptionalParams): Promise<SubscriptionEnableResponse>;
Expand Down
54 changes: 31 additions & 23 deletions sdk/subscription/arm-subscriptions/src/lroImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,37 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { AbortSignalLike } from "@azure/abort-controller";
import { LongRunningOperation, LroResponse } from "@azure/core-lro";

export class LroImpl<T> implements LongRunningOperation<T> {
constructor(
private sendOperationFn: (args: any, spec: any) => Promise<LroResponse<T>>,
private args: Record<string, unknown>,
private spec: {
readonly requestBody?: unknown;
readonly path?: string;
readonly httpMethod: string;
} & Record<string, any>,
public requestPath: string = spec.path!,
public requestMethod: string = spec.httpMethod
) {}
public async sendInitialRequest(): Promise<LroResponse<T>> {
return this.sendOperationFn(this.args, this.spec);
}
public async sendPollRequest(path: string): Promise<LroResponse<T>> {
const { requestBody, ...restSpec } = this.spec;
return this.sendOperationFn(this.args, {
...restSpec,
path,
httpMethod: "GET"
});
}
export function createLroSpec<T>(inputs: {
sendOperationFn: (args: any, spec: any) => Promise<LroResponse<T>>;
args: Record<string, unknown>;
spec: {
readonly requestBody?: unknown;
readonly path?: string;
readonly httpMethod: string;
} & Record<string, any>;
}): LongRunningOperation<T> {
const { args, spec, sendOperationFn } = inputs;
return {
requestMethod: spec.httpMethod,
requestPath: spec.path!,
sendInitialRequest: () => sendOperationFn(args, spec),
sendPollRequest: (
path: string,
options?: { abortSignal?: AbortSignalLike }
) => {
const { requestBody, ...restSpec } = spec;
return sendOperationFn(args, {
...restSpec,
httpMethod: "GET",
path,
abortSignal: options?.abortSignal
});
}
};
}
29 changes: 18 additions & 11 deletions sdk/subscription/arm-subscriptions/src/operations/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SubscriptionClient } from "../subscriptionClient";
import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro";
import { LroImpl } from "../lroImpl";
import {
SimplePollerLike,
OperationState,
createHttpPoller
} from "@azure/core-lro";
import { createLroSpec } from "../lroImpl";
import {
PutAliasRequest,
AliasCreateOptionalParams,
Expand Down Expand Up @@ -49,15 +53,15 @@ export class AliasImpl implements Alias {
body: PutAliasRequest,
options?: AliasCreateOptionalParams
): Promise<
PollerLike<PollOperationState<AliasCreateResponse>, AliasCreateResponse>
SimplePollerLike<OperationState<AliasCreateResponse>, AliasCreateResponse>
> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise<AliasCreateResponse> => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperation = async (
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
Expand Down Expand Up @@ -90,13 +94,16 @@ export class AliasImpl implements Alias {
};
};

const lro = new LroImpl(
sendOperation,
{ aliasName, body, options },
createOperationSpec
);
const poller = new LroEngine(lro, {
resumeFrom: options?.resumeFrom,
const lro = createLroSpec({
sendOperationFn,
args: { aliasName, body, options },
spec: createOperationSpec
});
const poller = await createHttpPoller<
AliasCreateResponse,
OperationState<AliasCreateResponse>
>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SubscriptionClient } from "../subscriptionClient";
import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro";
import { LroImpl } from "../lroImpl";
import {
SimplePollerLike,
OperationState,
createHttpPoller
} from "@azure/core-lro";
import { createLroSpec } from "../lroImpl";
import {
SubscriptionCancelOptionalParams,
SubscriptionCancelResponse,
Expand Down Expand Up @@ -98,8 +102,8 @@ export class SubscriptionOperationsImpl implements SubscriptionOperations {
body: AcceptOwnershipRequest,
options?: SubscriptionAcceptOwnershipOptionalParams
): Promise<
PollerLike<
PollOperationState<SubscriptionAcceptOwnershipResponse>,
SimplePollerLike<
OperationState<SubscriptionAcceptOwnershipResponse>,
SubscriptionAcceptOwnershipResponse
>
> {
Expand All @@ -109,7 +113,7 @@ export class SubscriptionOperationsImpl implements SubscriptionOperations {
): Promise<SubscriptionAcceptOwnershipResponse> => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperation = async (
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
Expand Down Expand Up @@ -142,13 +146,16 @@ export class SubscriptionOperationsImpl implements SubscriptionOperations {
};
};

const lro = new LroImpl(
sendOperation,
{ subscriptionId, body, options },
acceptOwnershipOperationSpec
);
const poller = new LroEngine(lro, {
resumeFrom: options?.resumeFrom,
const lro = createLroSpec({
sendOperationFn,
args: { subscriptionId, body, options },
spec: acceptOwnershipOperationSpec
});
const poller = await createHttpPoller<
SubscriptionAcceptOwnershipResponse,
OperationState<SubscriptionAcceptOwnershipResponse>
>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ const listPolicyForTenantNextOperationSpec: coreClient.OperationSpec = {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
bodyMapper: Mappers.SubscriptionListResult
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.$host, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
bodyMapper: Mappers.TenantListResult
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.$host, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import { PollerLike, PollOperationState } from "@azure/core-lro";
import { SimplePollerLike, OperationState } from "@azure/core-lro";
import {
PutAliasRequest,
AliasCreateOptionalParams,
Expand All @@ -33,7 +33,7 @@ export interface Alias {
body: PutAliasRequest,
options?: AliasCreateOptionalParams
): Promise<
PollerLike<PollOperationState<AliasCreateResponse>, AliasCreateResponse>
SimplePollerLike<OperationState<AliasCreateResponse>, AliasCreateResponse>
>;
/**
* Create Alias Subscription.
Expand Down
Loading