From 48cba72387fae6ff5c27a2dab9e6d58cfd8264b8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 18 Oct 2022 04:07:40 +0000 Subject: [PATCH] CodeGen from PR 20792 in Azure/azure-rest-api-specs [Hub Generated] Review request for Microsoft.ResourceGraph to add version stable/2022-10-01 (#20792) * Adds base for updating Microsoft.ResourceGraph from version preview/2021-06-01-preview to version 2022-10-01 * Updates readme * Updates API version in new specs and examples * Add ResourceHistoryRequestResponse type * Spell check fix * Remove resourcehistory.json. Update readme. * Update readme * Revert "Update readme" This reverts commit d8c5ee2a7b6fa1606cf0398b7dc8f3b33305ff9c. * Update readme * Update readme --- common/config/rush/pnpm-lock.yaml | 19 +- .../arm-resourcegraph/CHANGELOG.md | 16 +- sdk/resourcegraph/arm-resourcegraph/README.md | 2 +- .../arm-resourcegraph/_meta.json | 12 +- .../arm-resourcegraph/package.json | 29 +- .../review/arm-resourcegraph.api.md | 104 ++++++- .../arm-resourcegraph/src/models/index.ts | 127 +++++++- .../arm-resourcegraph/src/models/mappers.ts | 285 ++++++++++++++++++ .../src/models/parameters.ts | 40 ++- .../src/resourceGraphClient.ts | 85 +++++- .../arm-resourcegraph/test/sampleTest.ts | 39 ++- .../arm-resourcegraph/tsconfig.json | 10 +- 12 files changed, 670 insertions(+), 98 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 8fb1dffd174e..b66675a7587c 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3961,7 +3961,7 @@ packages: dependencies: semver: 7.3.7 shelljs: 0.8.5 - typescript: 4.9.0-dev.20221016 + typescript: 4.9.0-dev.20221017 dev: false /downlevel-dts/0.8.0: @@ -8958,8 +8958,8 @@ packages: hasBin: true dev: false - /typescript/4.9.0-dev.20221016: - resolution: {integrity: sha512-5ewJzFqYCUKUku9SdWIURLJW3PlkthY8C+HDu7kfWggpUJj3Ei7XrvMa32tMdl4a4H7k90m0xHRyoiCAH7wO2A==} + /typescript/4.9.0-dev.20221017: + resolution: {integrity: sha512-Aae7UmEtGS1U+pAvYpx8a466hlcXBX3moIdQ93lEAwriqrjidTeEP4JZ7UblTJWYZAlLu9g6LKfSe9X+6XR6GA==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -14201,17 +14201,19 @@ packages: dev: false file:projects/arm-resourcegraph.tgz: - resolution: {integrity: sha512-gyMQAJ6GPIZv1lpo2HPSuCzwKumbSp2+6V50vX2mwO/kQbP4t01D6t3+8jGWDfQgXt3ttb+DTJ2OzlAuKPNYzA==, tarball: file:projects/arm-resourcegraph.tgz} + resolution: {integrity: sha512-H0rA1aTQzhuvVa7hIQbq0Mra5C1y0HaQh17wvVp1KDi5ClQ5qYiFNzp6b8nvuxi9qbMzrMsvgjB6U/b8hu+UfQ==, tarball: file:projects/arm-resourcegraph.tgz} name: '@rush-temp/arm-resourcegraph' version: 0.0.0 dependencies: '@azure-tools/test-recorder': 1.0.2 '@azure/identity': 2.1.0 - '@microsoft/api-extractor': 7.32.0 + '@microsoft/api-extractor': 7.18.11 '@rollup/plugin-commonjs': 21.1.0_rollup@2.79.1 '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.3 + chai: 4.3.6 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 @@ -14223,7 +14225,6 @@ packages: uglify-js: 3.17.2 transitivePeerDependencies: - '@types/node' - - encoding - supports-color dev: false @@ -17420,7 +17421,7 @@ packages: dev: false file:projects/keyvault-secrets.tgz: - resolution: {integrity: sha512-naBuklZ7AHmeVLo/R/ej1xsyI0Re5E6eQKusaUVJQtnZ9aazrtLeVDI6kVdT+oYtk2eS/injmQzwzx68yLDjUg==, tarball: file:projects/keyvault-secrets.tgz} + resolution: {integrity: sha512-glu2elfF+vMdKRUZllcVwLZrRooMSgc17x12lcYQZkksNvDvlXOJAbFP3sVdp77S6VhH5U4FBG2aSNRIwHV9CA==, tarball: file:projects/keyvault-secrets.tgz} name: '@rush-temp/keyvault-secrets' version: 0.0.0 dependencies: @@ -17622,7 +17623,7 @@ packages: dev: false file:projects/mixed-reality-remote-rendering.tgz: - resolution: {integrity: sha512-KLnDms6nk+EnBMcLlr3nwdhzi9NBLHo8NLR/J0pzEMJG1JtxkozXvku2pLsUf78oYUwlCzbAtJIH1j1O7FbH1Q==, tarball: file:projects/mixed-reality-remote-rendering.tgz} + resolution: {integrity: sha512-c+DeluRNwjQYq5UZMvSO/87WTaN/FjPKt77w4m64+5NStzY4sa8ock8tyfNEDWPts8V7mLarnIMiVDSS1JfOCA==, tarball: file:projects/mixed-reality-remote-rendering.tgz} name: '@rush-temp/mixed-reality-remote-rendering' version: 0.0.0 dependencies: @@ -19598,7 +19599,7 @@ packages: dev: false file:projects/video-analyzer-edge.tgz: - resolution: {integrity: sha512-khmGlWMF87TB6iTydsWU2lJr6mQb/nlRjYJBPZKVHl1NxGjd7bO9KYXXkLm3smdUy1zHKLAG0+8Imc483bc9zg==, tarball: file:projects/video-analyzer-edge.tgz} + resolution: {integrity: sha512-ev9PjvfbH+H1BE1EQYL/+kTzu/utd8oJTuXQ3s1g/eN5ArVxEEmt5UXz2fbkgUsSAEo4n4llhnPVZEOBKn0mHA==, tarball: file:projects/video-analyzer-edge.tgz} name: '@rush-temp/video-analyzer-edge' version: 0.0.0 dependencies: diff --git a/sdk/resourcegraph/arm-resourcegraph/CHANGELOG.md b/sdk/resourcegraph/arm-resourcegraph/CHANGELOG.md index 9dc293952bcd..5b712e693006 100644 --- a/sdk/resourcegraph/arm-resourcegraph/CHANGELOG.md +++ b/sdk/resourcegraph/arm-resourcegraph/CHANGELOG.md @@ -1,18 +1,8 @@ # Release History + +## 5.0.0-beta.3 (2022-10-18) -## 5.0.0-beta.3 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 5.0.0-beta.2 (2022-04-28) - -The package of @azure/arm-resourcegraph is using our next generation design principles since version 5.0.0-beta.2, which contains breaking changes. +The package of @azure/arm-resourcegraph is using our next generation design principles since version 5.0.0-beta.3, which contains breaking changes. To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog). diff --git a/sdk/resourcegraph/arm-resourcegraph/README.md b/sdk/resourcegraph/arm-resourcegraph/README.md index 44daec8ba36c..0997e65a63f4 100644 --- a/sdk/resourcegraph/arm-resourcegraph/README.md +++ b/sdk/resourcegraph/arm-resourcegraph/README.md @@ -13,7 +13,7 @@ Azure Resource Graph API Reference ### Currently supported environments -- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- [LTS versions of Node.js](https://nodejs.org/about/releases/) - Latest versions of Safari, Chrome, Edge and Firefox. See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. diff --git a/sdk/resourcegraph/arm-resourcegraph/_meta.json b/sdk/resourcegraph/arm-resourcegraph/_meta.json index 4be4af390502..733ce25cd09c 100644 --- a/sdk/resourcegraph/arm-resourcegraph/_meta.json +++ b/sdk/resourcegraph/arm-resourcegraph/_meta.json @@ -1,8 +1,8 @@ { - "commit": "0cd7b3e83d5e7e21222dcc4bdde4565562da0cdf", - "readme": "specification\\resourcegraph\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resourcegraph\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", + "commit": "68847d6ae901f0cb2efa62ae2c523ad8cf5c2ea3", + "readme": "specification/resourcegraph/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=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/resourcegraph/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.3.0", - "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.4.4", + "use": "@autorest/typescript@6.0.0-rc.1" +} \ No newline at end of file diff --git a/sdk/resourcegraph/arm-resourcegraph/package.json b/sdk/resourcegraph/arm-resourcegraph/package.json index ec990223b24f..ad942c0a3a03 100644 --- a/sdk/resourcegraph/arm-resourcegraph/package.json +++ b/sdk/resourcegraph/arm-resourcegraph/package.json @@ -5,7 +5,7 @@ "description": "A generated SDK for ResourceGraphClient.", "version": "5.0.0-beta.3", "engines": { - "node": ">=14.0.0" + "node": ">=12.0.0" }, "dependencies": { "@azure/core-paging": "^1.2.0", @@ -26,7 +26,7 @@ "module": "./dist-esm/src/index.js", "types": "./types/arm-resourcegraph.d.ts", "devDependencies": { - "@microsoft/api-extractor": "^7.31.1", + "@microsoft/api-extractor": "7.18.11", "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-multi-entry": "^4.1.0", @@ -38,9 +38,13 @@ "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resourcegraph/arm-resourcegraph", "repository": { @@ -91,9 +95,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -104,13 +107,5 @@ } ] }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-resourcegraph?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/resourcegraph/arm-resourcegraph/review/arm-resourcegraph.api.md b/sdk/resourcegraph/arm-resourcegraph/review/arm-resourcegraph.api.md index 4c7e197e4cd2..e237078e5f57 100644 --- a/sdk/resourcegraph/arm-resourcegraph/review/arm-resourcegraph.api.md +++ b/sdk/resourcegraph/arm-resourcegraph/review/arm-resourcegraph.api.md @@ -11,6 +11,12 @@ import { PagedAsyncIterableIterator } from '@azure/core-paging'; // @public export type AuthorizationScopeFilter = "AtScopeAndBelow" | "AtScopeAndAbove" | "AtScopeExact" | "AtScopeAboveAndBelow"; +// @public +export type ChangeCategory = "User" | "System"; + +// @public +export type ChangeType = "Create" | "Update" | "Delete"; + // @public export interface Column { name: string; @@ -52,10 +58,10 @@ export interface Facet { } // @public -export type FacetError = Facet & { - resultType: "FacetError"; +export interface FacetError extends Facet { errors: ErrorDetails[]; -}; + resultType: "FacetError"; +} // @public export interface FacetRequest { @@ -72,12 +78,12 @@ export interface FacetRequestOptions { } // @public -export type FacetResult = Facet & { - resultType: "FacetResult"; - totalRecords: number; +export interface FacetResult extends Facet { count: number; data: Record; -}; + resultType: "FacetResult"; + totalRecords: number; +} // @public export type FacetSortOrder = "asc" | "desc"; @@ -117,6 +123,9 @@ export interface OperationsListOptionalParams extends coreClient.OperationOption // @public export type OperationsListResponse = OperationListResult; +// @public +export type PropertyChangeType = "Insert" | "Update" | "Remove"; + // @public export interface QueryRequest { facets?: FacetRequest[]; @@ -146,15 +155,75 @@ export interface QueryResponse { totalRecords: number; } +// @public +export interface ResourceChangeData { + afterSnapshot: ResourceChangeDataAfterSnapshot; + beforeSnapshot: ResourceChangeDataBeforeSnapshot; + changeId: string; + changeType?: ChangeType; + propertyChanges?: ResourcePropertyChange[]; + resourceId?: string; +} + +// @public +export interface ResourceChangeDataAfterSnapshot extends ResourceSnapshotData { +} + +// @public +export interface ResourceChangeDataBeforeSnapshot extends ResourceSnapshotData { +} + +// @public +export interface ResourceChangeDetailsOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface ResourceChangeDetailsRequestParameters { + changeIds: string[]; + resourceIds: string[]; +} + +// @public +export type ResourceChangeDetailsResponse = ResourceChangeData[]; + +// @public +export interface ResourceChangeList { + changes?: ResourceChangeData[]; + skipToken?: any; +} + +// @public +export interface ResourceChangesOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface ResourceChangesRequestParameters { + fetchPropertyChanges?: boolean; + fetchSnapshots?: boolean; + interval: ResourceChangesRequestParametersInterval; + resourceIds?: string[]; + skipToken?: string; + subscriptionId?: string; + table?: string; + top?: number; +} + +// @public +export interface ResourceChangesRequestParametersInterval extends DateTimeInterval { +} + +// @public +export type ResourceChangesResponse = ResourceChangeList; + // @public (undocumented) export class ResourceGraphClient extends coreClient.ServiceClient { // (undocumented) $host: string; constructor(credentials: coreAuth.TokenCredential, options?: ResourceGraphClientOptionalParams); // (undocumented) - apiVersion: string; - // (undocumented) operations: Operations; + resourceChangeDetails(parameters: ResourceChangeDetailsRequestParameters, options?: ResourceChangeDetailsOptionalParams): Promise; + resourceChanges(parameters: ResourceChangesRequestParameters, options?: ResourceChangesOptionalParams): Promise; resources(query: QueryRequest, options?: ResourcesOptionalParams): Promise; resourcesHistory(request: ResourcesHistoryRequest, options?: ResourcesHistoryOptionalParams): Promise; } @@ -162,10 +231,18 @@ export class ResourceGraphClient extends coreClient.ServiceClient { // @public export interface ResourceGraphClientOptionalParams extends coreClient.ServiceClientOptions { $host?: string; - apiVersion?: string; endpoint?: string; } +// @public +export interface ResourcePropertyChange { + afterValue?: string; + beforeValue?: string; + changeCategory: ChangeCategory; + propertyChangeType: PropertyChangeType; + propertyName: string; +} + // @public export interface ResourcesHistoryOptionalParams extends coreClient.OperationOptions { } @@ -190,6 +267,13 @@ export interface ResourcesHistoryRequestOptions { // @public export type ResourcesHistoryResponse = Record; +// @public +export interface ResourceSnapshotData { + content?: Record; + snapshotId?: string; + timestamp: Date; +} + // @public export interface ResourcesOptionalParams extends coreClient.OperationOptions { } diff --git a/sdk/resourcegraph/arm-resourcegraph/src/models/index.ts b/sdk/resourcegraph/arm-resourcegraph/src/models/index.ts index a1a27f63a861..b76f23202cf3 100644 --- a/sdk/resourcegraph/arm-resourcegraph/src/models/index.ts +++ b/sdk/resourcegraph/arm-resourcegraph/src/models/index.ts @@ -172,6 +172,91 @@ export interface DateTimeInterval { end: Date; } +/** The parameters for a specific changes request. */ +export interface ResourceChangesRequestParameters { + /** Specifies the list of resources for a changes request. */ + resourceIds?: string[]; + /** The subscription id of resources to query the changes from. */ + subscriptionId?: string; + /** Specifies the date and time interval for a changes request. */ + interval: ResourceChangesRequestParametersInterval; + /** Acts as the continuation token for paged responses. */ + skipToken?: string; + /** The maximum number of changes the client can accept in a paged response. */ + top?: number; + /** The table name to query resources from. */ + table?: string; + /** The flag if set to true will fetch property changes */ + fetchPropertyChanges?: boolean; + /** The flag if set to true will fetch change snapshots */ + fetchSnapshots?: boolean; +} + +/** A list of changes associated with a resource over a specific time interval. */ +export interface ResourceChangeList { + /** + * The pageable value returned by the operation, i.e. a list of changes to the resource. + * + * - The list is ordered from the most recent changes to the least recent changes. + * - This list will be empty if there were no changes during the requested interval. + * - The `Before` snapshot timestamp value of the oldest change can be outside of the specified time interval. + */ + changes?: ResourceChangeData[]; + /** Skip token that encodes the skip information while executing the current request */ + skipToken?: any; +} + +/** Data on a specific change, represented by a pair of before and after resource snapshots. */ +export interface ResourceChangeData { + /** The resource for a change. */ + resourceId?: string; + /** The change ID. Valid and unique within the specified resource only. */ + changeId: string; + /** The snapshot before the change. */ + beforeSnapshot: ResourceChangeDataBeforeSnapshot; + /** The snapshot after the change. */ + afterSnapshot: ResourceChangeDataAfterSnapshot; + /** The change type for snapshot. PropertyChanges will be provided in case of Update change type */ + changeType?: ChangeType; + /** An array of resource property change */ + propertyChanges?: ResourcePropertyChange[]; +} + +/** Data on a specific resource snapshot. */ +export interface ResourceSnapshotData { + /** The ID of the snapshot. */ + snapshotId?: string; + /** + * The time when the snapshot was created. + * The snapshot timestamp provides an approximation as to when a modification to a resource was detected. There can be a difference between the actual modification time and the detection time. This is due to differences in how operations that modify a resource are processed, versus how operation that record resource snapshots are processed. + */ + timestamp: Date; + /** The resource snapshot content (in resourceChangeDetails response only). */ + content?: Record; +} + +/** The resource property change */ +export interface ResourcePropertyChange { + /** The property name */ + propertyName: string; + /** The property value in before snapshot */ + beforeValue?: string; + /** The property value in after snapshot */ + afterValue?: string; + /** The change category. */ + changeCategory: ChangeCategory; + /** The property change Type */ + propertyChangeType: PropertyChangeType; +} + +/** The parameters for a specific change details request. */ +export interface ResourceChangeDetailsRequestParameters { + /** Specifies the list of resources for a change details request. */ + resourceIds: string[]; + /** Specifies the list of change IDs for a change details request. */ + changeIds: string[]; +} + /** Query output in tabular format. */ export interface Table { /** Query result column descriptors. */ @@ -189,7 +274,7 @@ export interface Column { } /** Successfully executed facet containing additional statistics on the response of a query. */ -export type FacetResult = Facet & { +export interface FacetResult extends Facet { /** Polymorphic discriminator, which specifies the different types this object can be */ resultType: "FacetResult"; /** Number of total records in the facet results. */ @@ -198,15 +283,27 @@ export type FacetResult = Facet & { count: number; /** A JObject array or Table containing the desired facets. Only present if the facet is valid. */ data: Record; -}; +} /** A facet whose execution resulted in an error. */ -export type FacetError = Facet & { +export interface FacetError extends Facet { /** Polymorphic discriminator, which specifies the different types this object can be */ resultType: "FacetError"; /** An array containing detected facet errors with details. */ errors: ErrorDetails[]; -}; +} + +/** Specifies the date and time interval for a changes request. */ +export interface ResourceChangesRequestParametersInterval + extends DateTimeInterval {} + +/** The snapshot before the change. */ +export interface ResourceChangeDataBeforeSnapshot + extends ResourceSnapshotData {} + +/** The snapshot after the change. */ +export interface ResourceChangeDataAfterSnapshot extends ResourceSnapshotData {} + /** Defines values for ResultFormat. */ export type ResultFormat = "table" | "objectArray"; /** Defines values for AuthorizationScopeFilter. */ @@ -219,6 +316,12 @@ export type AuthorizationScopeFilter = export type FacetSortOrder = "asc" | "desc"; /** Defines values for ResultTruncated. */ export type ResultTruncated = "true" | "false"; +/** Defines values for ChangeType. */ +export type ChangeType = "Create" | "Update" | "Delete"; +/** Defines values for ChangeCategory. */ +export type ChangeCategory = "User" | "System"; +/** Defines values for PropertyChangeType. */ +export type PropertyChangeType = "Insert" | "Update" | "Remove"; /** Defines values for ColumnDataType. */ export type ColumnDataType = | "string" @@ -241,6 +344,20 @@ export interface ResourcesHistoryOptionalParams /** Contains response data for the resourcesHistory operation. */ export type ResourcesHistoryResponse = Record; +/** Optional parameters. */ +export interface ResourceChangesOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the resourceChanges operation. */ +export type ResourceChangesResponse = ResourceChangeList; + +/** Optional parameters. */ +export interface ResourceChangeDetailsOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the resourceChangeDetails operation. */ +export type ResourceChangeDetailsResponse = ResourceChangeData[]; + /** Optional parameters. */ export interface OperationsListOptionalParams extends coreClient.OperationOptions {} @@ -253,8 +370,6 @@ export interface ResourceGraphClientOptionalParams extends coreClient.ServiceClientOptions { /** server parameter */ $host?: string; - /** Api Version */ - apiVersion?: string; /** Overrides client endpoint. */ endpoint?: string; } diff --git a/sdk/resourcegraph/arm-resourcegraph/src/models/mappers.ts b/sdk/resourcegraph/arm-resourcegraph/src/models/mappers.ts index 1d45b2a7e03a..43b5088171a3 100644 --- a/sdk/resourcegraph/arm-resourcegraph/src/models/mappers.ts +++ b/sdk/resourcegraph/arm-resourcegraph/src/models/mappers.ts @@ -545,6 +545,261 @@ export const DateTimeInterval: coreClient.CompositeMapper = { } }; +export const ResourceChangesRequestParameters: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangesRequestParameters", + modelProperties: { + resourceIds: { + serializedName: "resourceIds", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + interval: { + serializedName: "interval", + type: { + name: "Composite", + className: "ResourceChangesRequestParametersInterval" + } + }, + skipToken: { + serializedName: "$skipToken", + type: { + name: "String" + } + }, + top: { + constraints: { + InclusiveMaximum: 1000, + InclusiveMinimum: 1 + }, + serializedName: "$top", + type: { + name: "Number" + } + }, + table: { + serializedName: "table", + type: { + name: "String" + } + }, + fetchPropertyChanges: { + serializedName: "fetchPropertyChanges", + type: { + name: "Boolean" + } + }, + fetchSnapshots: { + serializedName: "fetchSnapshots", + type: { + name: "Boolean" + } + } + } + } +}; + +export const ResourceChangeList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangeList", + modelProperties: { + changes: { + serializedName: "changes", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ResourceChangeData" + } + } + } + }, + skipToken: { + serializedName: "$skipToken", + type: { + name: "any" + } + } + } + } +}; + +export const ResourceChangeData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangeData", + modelProperties: { + resourceId: { + serializedName: "resourceId", + type: { + name: "String" + } + }, + changeId: { + serializedName: "changeId", + required: true, + type: { + name: "String" + } + }, + beforeSnapshot: { + serializedName: "beforeSnapshot", + type: { + name: "Composite", + className: "ResourceChangeDataBeforeSnapshot" + } + }, + afterSnapshot: { + serializedName: "afterSnapshot", + type: { + name: "Composite", + className: "ResourceChangeDataAfterSnapshot" + } + }, + changeType: { + serializedName: "changeType", + type: { + name: "Enum", + allowedValues: ["Create", "Update", "Delete"] + } + }, + propertyChanges: { + serializedName: "propertyChanges", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ResourcePropertyChange" + } + } + } + } + } + } +}; + +export const ResourceSnapshotData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceSnapshotData", + modelProperties: { + snapshotId: { + serializedName: "snapshotId", + type: { + name: "String" + } + }, + timestamp: { + serializedName: "timestamp", + required: true, + type: { + name: "DateTime" + } + }, + content: { + serializedName: "content", + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const ResourcePropertyChange: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourcePropertyChange", + modelProperties: { + propertyName: { + serializedName: "propertyName", + required: true, + type: { + name: "String" + } + }, + beforeValue: { + serializedName: "beforeValue", + type: { + name: "String" + } + }, + afterValue: { + serializedName: "afterValue", + type: { + name: "String" + } + }, + changeCategory: { + serializedName: "changeCategory", + required: true, + type: { + name: "Enum", + allowedValues: ["User", "System"] + } + }, + propertyChangeType: { + serializedName: "propertyChangeType", + required: true, + type: { + name: "Enum", + allowedValues: ["Insert", "Update", "Remove"] + } + } + } + } +}; + +export const ResourceChangeDetailsRequestParameters: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangeDetailsRequestParameters", + modelProperties: { + resourceIds: { + serializedName: "resourceIds", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + changeIds: { + serializedName: "changeIds", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + export const Table: coreClient.CompositeMapper = { type: { name: "Composite", @@ -677,6 +932,36 @@ export const FacetError: coreClient.CompositeMapper = { } }; +export const ResourceChangesRequestParametersInterval: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangesRequestParametersInterval", + modelProperties: { + ...DateTimeInterval.type.modelProperties + } + } +}; + +export const ResourceChangeDataBeforeSnapshot: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangeDataBeforeSnapshot", + modelProperties: { + ...ResourceSnapshotData.type.modelProperties + } + } +}; + +export const ResourceChangeDataAfterSnapshot: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceChangeDataAfterSnapshot", + modelProperties: { + ...ResourceSnapshotData.type.modelProperties + } + } +}; + export let discriminators = { Facet: Facet, "Facet.FacetResult": FacetResult, diff --git a/sdk/resourcegraph/arm-resourcegraph/src/models/parameters.ts b/sdk/resourcegraph/arm-resourcegraph/src/models/parameters.ts index 1a4e73d15e5c..f2309c7e22ff 100644 --- a/sdk/resourcegraph/arm-resourcegraph/src/models/parameters.ts +++ b/sdk/resourcegraph/arm-resourcegraph/src/models/parameters.ts @@ -13,7 +13,9 @@ import { } from "@azure/core-client"; import { QueryRequest as QueryRequestMapper, - ResourcesHistoryRequest as ResourcesHistoryRequestMapper + ResourcesHistoryRequest as ResourcesHistoryRequestMapper, + ResourceChangesRequestParameters as ResourceChangesRequestParametersMapper, + ResourceChangeDetailsRequestParameters as ResourceChangeDetailsRequestParametersMapper } from "../models/mappers"; export const contentType: OperationParameter = { @@ -60,7 +62,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-06-01-preview", + defaultValue: "2022-10-01", isConstant: true, serializedName: "api-version", type: { @@ -73,3 +75,37 @@ export const request: OperationParameter = { parameterPath: "request", mapper: ResourcesHistoryRequestMapper }; + +export const apiVersion1: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2021-06-01-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const parameters: OperationParameter = { + parameterPath: "parameters", + mapper: ResourceChangesRequestParametersMapper +}; + +export const apiVersion2: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2020-09-01-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const parameters1: OperationParameter = { + parameterPath: "parameters", + mapper: ResourceChangeDetailsRequestParametersMapper +}; diff --git a/sdk/resourcegraph/arm-resourcegraph/src/resourceGraphClient.ts b/sdk/resourcegraph/arm-resourcegraph/src/resourceGraphClient.ts index fa3699cd65f4..881437ee70df 100644 --- a/sdk/resourcegraph/arm-resourcegraph/src/resourceGraphClient.ts +++ b/sdk/resourcegraph/arm-resourcegraph/src/resourceGraphClient.ts @@ -20,12 +20,17 @@ import { ResourcesResponse, ResourcesHistoryRequest, ResourcesHistoryOptionalParams, - ResourcesHistoryResponse + ResourcesHistoryResponse, + ResourceChangesRequestParameters, + ResourceChangesOptionalParams, + ResourceChangesResponse, + ResourceChangeDetailsRequestParameters, + ResourceChangeDetailsOptionalParams, + ResourceChangeDetailsResponse } from "./models"; export class ResourceGraphClient extends coreClient.ServiceClient { $host: string; - apiVersion: string; /** * Initializes a new instance of the ResourceGraphClient class. @@ -94,7 +99,6 @@ export class ResourceGraphClient extends coreClient.ServiceClient { // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-06-01-preview"; this.operations = new OperationsImpl(this); } @@ -128,6 +132,36 @@ export class ResourceGraphClient extends coreClient.ServiceClient { ); } + /** + * List changes to a resource for a given time interval. + * @param parameters the parameters for this request for changes. + * @param options The options parameters. + */ + resourceChanges( + parameters: ResourceChangesRequestParameters, + options?: ResourceChangesOptionalParams + ): Promise { + return this.sendOperationRequest( + { parameters, options }, + resourceChangesOperationSpec + ); + } + + /** + * Get resource change details. + * @param parameters The parameters for this request for resource change details. + * @param options The options parameters. + */ + resourceChangeDetails( + parameters: ResourceChangeDetailsRequestParameters, + options?: ResourceChangeDetailsOptionalParams + ): Promise { + return this.sendOperationRequest( + { parameters, options }, + resourceChangeDetailsOperationSpec + ); + } + operations: Operations; } // Operation Specifications @@ -165,7 +199,50 @@ const resourcesHistoryOperationSpec: coreClient.OperationSpec = { } }, requestBody: Parameters.request, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const resourceChangesOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.ResourceGraph/resourceChanges", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.ResourceChangeList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.parameters, + queryParameters: [Parameters.apiVersion2], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const resourceChangeDetailsOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.ResourceGraph/resourceChangeDetails", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: { + type: { + name: "Sequence", + element: { + type: { name: "Composite", className: "ResourceChangeData" } + } + } + } + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.parameters1, + queryParameters: [Parameters.apiVersion2], urlParameters: [Parameters.$host], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", diff --git a/sdk/resourcegraph/arm-resourcegraph/test/sampleTest.ts b/sdk/resourcegraph/arm-resourcegraph/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/resourcegraph/arm-resourcegraph/test/sampleTest.ts +++ b/sdk/resourcegraph/arm-resourcegraph/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/resourcegraph/arm-resourcegraph/tsconfig.json b/sdk/resourcegraph/arm-resourcegraph/tsconfig.json index a3decb7f3969..3e6ae96443f3 100644 --- a/sdk/resourcegraph/arm-resourcegraph/tsconfig.json +++ b/sdk/resourcegraph/arm-resourcegraph/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-resourcegraph": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"