Skip to content

Commit

Permalink
Sample generation for MPG for cliassical client (#2770)
Browse files Browse the repository at this point in the history
* Upgrade to the latest tcgc

* Update the fixes

* Init sample generation

* Fix testing issues

* Init sample gen

* Init sample gen

* Upgrade tcgc to v44.3

* Generate the first sample gen

* Update the dependencies

* Update the samples

* Update the sample gen for network anayltisc

* Build samples with multiple examples for one operations

* Update the samples

* Update the comments in sample gen

* Generate models from TCGC and use binder

* Fix subscription id issue

* update the example summary

* Update the paging operations

* Add import for default credential

* Update the package name dependencies

* update the package.json file

* Update the property name

* generic serializers

* Update the sample gen based on binder pr

* Generate samples for hierachy client

* Handle property renaming

* update uts

* add example client test case

* update the samples

* update the sample generations

* update the sample cases

* update the sample cases

* update the test cases

* update the test cases

* update md files

* update to latest main

* update to latest main

* update to latest main

* update to the latest main

* update to the latest main

* update to the latest main

* Update the samples with cases for operation level parameters

* Update the hierarchyClientOperations

* Update the hierachyClientOperations cases

* update the samples

* Update the test cases and refactor code a little

* Remove useless samples in smoke test

* Update the samples and filter out constant values

* Refactor the code a little

* Refactor the code a little

* Squash the commit hashes for sample gen

* smoke test and remove example client rlc

* remove example client rlc

* update tspconfig

* update tspconfig

* Fix the spread issues

* Update the optional body cases

* Revert changes

* Rename methods

* Refactor a little the example code

* Update the enablement for arm

* Update the default logic

* Fix build issues

* Update the sample with multipleClient

* Update the name

* update

* update

* Refactor with client and method parameters

* Update the samples and skip console void result

* Update the required body cases

* fix ci

* update the deduplicateProperties

* Resolve conflicts

* Update packages/autorest.typescript/src/generators/modelsGenerator.ts

* Resolve comments

* Update date and time cases

* Update the sample with sperated file and json pair

* Updated cases for hierachy and operation groups

* Just renamings

* Merge to main

* Update the test cases

* update the descriptions

* Skip optional body test cases

---------

Co-authored-by: Jiao Di (MSFT) <[email protected]>
Co-authored-by: Jose Manuel Heredia Hidalgo <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2024
1 parent 854466f commit 2d85b98
Show file tree
Hide file tree
Showing 47 changed files with 3,589 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to assign role to the data product.
*
* @summary assign role to the data product.
* x-ms-original-file: 2023-11-15/DataProducts_AddUserRole_MaximumSet_Gen.json
*/
async function dataProductsAddUserRoleMaximumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
const result = await client.dataProducts.addUserRole(
"aoiresourceGroupName",
"dataproduct01",
{
roleId: "00000000-0000-0000-0000-00000000000",
principalId: "00000000-0000-0000-0000-00000000000",
userName: "UserName",
dataTypeScope: ["scope"],
principalType: "User",
role: "Reader",
},
);
console.log(result);
}

async function main() {
dataProductsAddUserRoleMaximumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to create data product resource.
*
* @summary create data product resource.
* x-ms-original-file: 2023-11-15/DataProducts_Create_MaximumSet_Gen.json
*/
async function dataProductsCreateMaximumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
const result = await client.dataProducts.create(
"aoiresourceGroupName",
"dataproduct01",
{
properties: {
provisioningState: "Succeeded",
publisher: "Microsoft",
product: "MCC",
majorVersion: "1.0.0",
owners: ["[email protected]"],
redundancy: "Disabled",
purviewAccount: "testpurview",
purviewCollection: "134567890",
privateLinksEnabled: "Disabled",
publicNetworkAccess: "Enabled",
customerManagedKeyEncryptionEnabled: "Enabled",
customerEncryptionKey: {
keyVaultUri: "https://KeyVault.vault.azure.net",
keyName: "keyName",
keyVersion: "keyVersion",
},
networkacls: {
virtualNetworkRule: [
{
id: "/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName",
action: "Allow",
state: "",
},
],
ipRules: [{ value: "1.1.1.1", action: "Allow" }],
allowedQueryIpRangeList: ["1.1.1.1"],
defaultAction: "Allow",
},
managedResourceGroupConfiguration: {
name: "managedResourceGroupName",
location: "eastus",
},
currentMinorVersion: "1.0.1",
consumptionEndpoints: {},
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1":
{},
},
},
tags: { userSpecifiedKeyName: "userSpecifiedKeyValue" },
location: "eastus",
},
);
console.log(result);
}

async function main() {
dataProductsCreateMaximumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to delete data product resource.
*
* @summary delete data product resource.
* x-ms-original-file: 2023-11-15/DataProducts_Delete_MaximumSet_Gen.json
*/
async function dataProductsDeleteMaximumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
await client.dataProducts.delete("aoiresourceGroupName", "dataproduct01");
}

async function main() {
dataProductsDeleteMaximumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to generate sas token for storage account.
*
* @summary generate sas token for storage account.
* x-ms-original-file: 2023-11-15/DataProducts_GenerateStorageAccountSasToken_MaximumSet_Gen.json
*/
async function dataProductsGenerateStorageAccountSasTokenMaximumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
const result = await client.dataProducts.generateStorageAccountSasToken(
"aoiresourceGroupName",
"dataproduct01",
{
startTimeStamp: new Date("2023-08-24T05:34:58.151Z"),
expiryTimeStamp: new Date("2023-08-24T05:34:58.151Z"),
ipAddress: "1.1.1.1",
},
);
console.log(result);
}

async function main() {
dataProductsGenerateStorageAccountSasTokenMaximumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to list data products by resource group.
*
* @summary list data products by resource group.
* x-ms-original-file: 2023-11-15/DataProducts_ListByResourceGroup_MinimumSet_Gen.json
*/
async function dataProductsListByResourceGroupMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.dataProducts.listByResourceGroup(
"aoiresourceGroupName",
)) {
resArray.push(item);
}

console.log(resArray);
}

async function main() {
dataProductsListByResourceGroupMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to initiate key rotation on Data Product.
*
* @summary initiate key rotation on Data Product.
* x-ms-original-file: 2023-11-15/DataProducts_RotateKey_MaximumSet_Gen.json
*/
async function dataProductsRotateKeyMaximumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
await client.dataProducts.rotateKey("aoiresourceGroupName", "dataproduct01", {
keyVaultUrl: "https://myKeyVault.vault.azure.net",
});
}

async function main() {
dataProductsRotateKeyMaximumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NetworkAnalyticsClient } from "@azure/arm-networkanalytics";
import { DefaultAzureCredential } from "@azure/identity";

/**
* This sample demonstrates how to update data product resource.
*
* @summary update data product resource.
* x-ms-original-file: 2023-11-15/DataProducts_Update_MaximumSet_Gen.json
*/
async function dataProductsUpdateMaximumSetGen() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new NetworkAnalyticsClient(credential, subscriptionId);
const result = await client.dataProducts.update(
"aoiresourceGroupName",
"dataproduct01",
{
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1":
{},
},
},
tags: { userSpecifiedKeyName: "userSpecifiedKeyValue" },
properties: {
owners: ["[email protected]", "[email protected]"],
purviewAccount: "testpurview",
purviewCollection: "134567890",
privateLinksEnabled: "Disabled",
currentMinorVersion: "1.0.1",
},
},
);
console.log(result);
}

async function main() {
dataProductsUpdateMaximumSetGen();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"forceConsistentCasingInFileNames": true,
"moduleResolution": "NodeNext",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
"esModuleInterop": true,
"paths": { "@azure/arm-networkanalytics": ["./src/index"] }
},
"include": ["./src/**/*.ts", "./test/**/*.ts"]
"include": ["./src/**/*.ts", "./test/**/*.ts", "samples-dev/**/*.ts"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"title": "DataProducts_AddUserRole_MaximumSet_Gen",
"operationId": "DataProducts_AddUserRole",
"parameters": {
"api-version": "2023-11-15",
"subscriptionId": "00000000-0000-0000-0000-00000000000",
"resourceGroupName": "aoiresourceGroupName",
"dataProductName": "dataproduct01",
"body": {
"roleId": "00000000-0000-0000-0000-00000000000",
"principalId": "00000000-0000-0000-0000-00000000000",
"userName": "UserName",
"dataTypeScope": [
"scope"
],
"principalType": "User",
"role": "Reader"
}
},
"responses": {
"200": {
"body": {
"roleId": "00000000-0000-0000-0000-00000000000",
"principalId": "00000000-0000-0000-0000-00000000000",
"userName": "UserName",
"dataTypeScope": [
"scope"
],
"principalType": "User",
"role": "Reader",
"roleAssignmentId": "00000000-0000-0000-0000-00000000000"
}
}
}
}
Loading

0 comments on commit 2d85b98

Please sign in to comment.