Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR @azure/arm-reservations] reservation readme t2 config #4073

Closed
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
33 changes: 15 additions & 18 deletions sdk/reservations/arm-reservations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm install @azure/arm-reservations

### How to use

#### nodejs - Authentication, client creation and get quota as an example written in TypeScript.
#### nodejs - client creation and list reservation as an example written in TypeScript.

##### Install @azure/ms-rest-nodeauth

Expand All @@ -26,17 +26,16 @@ npm install @azure/ms-rest-nodeauth@"^3.0.0"

##### Sample code

```javascript
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 { AzureReservationAPI } = require("@azure/arm-reservations");
const { interactiveLogin } = require("@azure/ms-rest-nodeauth");

interactiveLogin().then((creds) => {
const client = new AzureReservationAPI(creds);
const subscriptionId = "testsubscriptionId";
const providerId = "testproviderId";
const location = "westus";
const resourceName = "testresourceName";
client.quota.get(subscriptionId, providerId, location, resourceName).then((result) => {
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new AzureReservationAPI(creds, subscriptionId);
const reservationOrderId = "testreservationOrderId";
client.reservation.list(reservationOrderId).then((result) => {
console.log("The result is:");
console.log(result);
});
Expand All @@ -45,7 +44,7 @@ interactiveLogin().then((creds) => {
});
```

#### browser - Authentication, client creation and get quota as an example written in JavaScript.
#### browser - Authentication, client creation and list reservation as an example written in JavaScript.

##### Install @azure/ms-rest-browserauth

Expand All @@ -68,6 +67,7 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
<script src="node_modules/@azure/arm-reservations/dist/arm-reservations.js"></script>
<script type="text/javascript">
const subscriptionId = "<Subscription_Id>";
const authManager = new msAuth.AuthManager({
clientId: "<client id for your Azure AD app>",
tenant: "<optional tenant for your organization>"
Expand All @@ -77,12 +77,9 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
// may cause redirects
authManager.login();
}
const client = new Azure.ArmReservations.AzureReservationAPI(res.creds);
const subscriptionId = "testsubscriptionId";
const providerId = "testproviderId";
const location = "westus";
const resourceName = "testresourceName";
client.quota.get(subscriptionId, providerId, location, resourceName).then((result) => {
const client = new Azure.ArmReservations.AzureReservationAPI(res.creds, subscriptionId);
const reservationOrderId = "testreservationOrderId";
client.reservation.list(reservationOrderId).then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AzureReservationAPIContext extends msRestAzure.AzureServiceClient {
if (!options) {
options = {};
}
if (!options.userAgent) {
if(!options.userAgent) {
const defaultUserAgent = msRestAzure.getDefaultUserAgentValue();
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
}
Expand All @@ -43,10 +43,10 @@ export class AzureReservationAPIContext extends msRestAzure.AzureServiceClient {
this.requestContentType = "application/json; charset=utf-8";
this.credentials = credentials;

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