Skip to content

Commit

Permalink
CodeGen from PR 14061 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
update (Azure#14061)
  • Loading branch information
SDKAuto committed Apr 22, 2021
1 parent 94a3973 commit 2562d62
Show file tree
Hide file tree
Showing 17 changed files with 1,462 additions and 2,384 deletions.
43 changes: 17 additions & 26 deletions sdk/kusto/arm-kusto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,29 @@ npm install @azure/arm-kusto
##### Install @azure/ms-rest-nodeauth

- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.

```bash
npm install @azure/ms-rest-nodeauth@"^3.0.0"
```

##### Sample code

While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package

```typescript
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
const { KustoManagementClient } = require("@azure/arm-kusto");
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth
.interactiveLogin()
.then((creds) => {
const client = new KustoManagementClient(creds, subscriptionId);
const resourceGroupName = "testresourceGroupName";
const clusterName = "testclusterName";
client.clusters.get(resourceGroupName, clusterName).then((result) => {
console.log("The result is:");
console.log(result);
});
})
.catch((err) => {
console.error(err);
msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new KustoManagementClient(creds, subscriptionId);
const resourceGroupName = "testresourceGroupName";
const clusterName = "testclusterName";
client.clusters.get(resourceGroupName, clusterName).then((result) => {
console.log("The result is:");
console.log(result);
});
}).catch((err) => {
console.error(err);
});
```

#### browser - Authentication, client creation and get clusters as an example written in JavaScript.
Expand All @@ -63,7 +58,6 @@ npm install @azure/ms-rest-browserauth
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.

- index.html

```html
<!DOCTYPE html>
<html lang="en">
Expand All @@ -87,16 +81,13 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
const client = new Azure.ArmKusto.KustoManagementClient(res.creds, subscriptionId);
const resourceGroupName = "testresourceGroupName";
const clusterName = "testclusterName";
client.clusters
.get(resourceGroupName, clusterName)
.then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
console.log("An error occurred:");
console.error(err);
});
client.clusters.get(resourceGroupName, clusterName).then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
});
});
</script>
</head>
Expand Down
10 changes: 8 additions & 2 deletions sdk/kusto/arm-kusto/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import sourcemaps from "rollup-plugin-sourcemaps";
*/
const config = {
input: "./esm/kustoManagementClient.js",
external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
external: [
"@azure/ms-rest-js",
"@azure/ms-rest-azure-js"
],
output: {
file: "./dist/arm-kusto.js",
format: "umd",
Expand All @@ -25,7 +28,10 @@ const config = {
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/`
},
plugins: [nodeResolve({ mainFields: ["module", "main"] }), sourcemaps()]
plugins: [
nodeResolve({ mainFields: ['module', 'main'] }),
sourcemaps()
]
};

export default config;
7 changes: 2 additions & 5 deletions sdk/kusto/arm-kusto/src/kustoManagementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as Mappers from "./models/mappers";
import * as operations from "./operations";
import { KustoManagementClientContext } from "./kustoManagementClientContext";


class KustoManagementClient extends KustoManagementClientContext {
// Operation groups
clusters: operations.Clusters;
Expand All @@ -32,11 +33,7 @@ class KustoManagementClient extends KustoManagementClientContext {
* subscription. The subscription ID forms part of the URI for every service call.
* @param [options] The parameter options
*/
constructor(
credentials: msRest.ServiceClientCredentials,
subscriptionId: string,
options?: Models.KustoManagementClientOptions
) {
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.KustoManagementClientOptions) {
super(credentials, subscriptionId, options);
this.clusters = new operations.Clusters(this);
this.clusterPrincipalAssignments = new operations.ClusterPrincipalAssignments(this);
Expand Down
23 changes: 8 additions & 15 deletions sdk/kusto/arm-kusto/src/kustoManagementClientContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,36 @@ export class KustoManagementClientContext extends msRestAzure.AzureServiceClient
* subscription. The subscription ID forms part of the URI for every service call.
* @param [options] The parameter options
*/
constructor(
credentials: msRest.ServiceClientCredentials,
subscriptionId: string,
options?: Models.KustoManagementClientOptions
) {
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.KustoManagementClientOptions) {
if (credentials == undefined) {
throw new Error("'credentials' cannot be null.");
throw new Error('\'credentials\' cannot be null.');
}
if (subscriptionId == undefined) {
throw new Error("'subscriptionId' cannot be null.");
throw new Error('\'subscriptionId\' cannot be null.');
}

if (!options) {
options = {};
}
if (!options.userAgent) {
if(!options.userAgent) {
const defaultUserAgent = msRestAzure.getDefaultUserAgentValue();
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
}

super(credentials, options);

this.apiVersion = "2021-01-01";
this.acceptLanguage = "en-US";
this.apiVersion = '2021-01-01';
this.acceptLanguage = 'en-US';
this.longRunningOperationRetryTimeout = 30;
this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com";
this.requestContentType = "application/json; charset=utf-8";
this.credentials = credentials;
this.subscriptionId = subscriptionId;

if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
this.acceptLanguage = options.acceptLanguage;
}
if (
options.longRunningOperationRetryTimeout !== null &&
options.longRunningOperationRetryTimeout !== undefined
) {
if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout;
}
}
Expand Down
Loading

0 comments on commit 2562d62

Please sign in to comment.