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 billing/resource-manager] Corrected specs and examples for BillingRP #2335

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
2 changes: 1 addition & 1 deletion sdk/billing/arm-billing/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Microsoft
Copyright (c) 2019 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
21 changes: 10 additions & 11 deletions sdk/billing/arm-billing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ This package contains an isomorphic SDK for BillingManagementClient.

### How to Install

```
```bash
npm install @azure/arm-billing
```

### How to use

#### nodejs - Authentication, client creation and list enrollmentAccounts as an example written in TypeScript.
#### nodejs - Authentication, client creation and list billingAccounts as an example written in TypeScript.

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

```
```bash
npm install @azure/ms-rest-nodeauth
```

##### Sample code

```ts
```typescript
import * as msRest from "@azure/ms-rest-js";
import * as msRestAzure from "@azure/ms-rest-azure-js";
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
Expand All @@ -34,7 +34,8 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new BillingManagementClient(creds, subscriptionId);
client.enrollmentAccounts.list().then((result) => {
const expand = "testexpand";
client.billingAccounts.list(expand).then((result) => {
console.log("The result is:");
console.log(result);
});
Expand All @@ -43,11 +44,11 @@ msRestNodeAuth.interactiveLogin().then((creds) => {
});
```

#### browser - Authentication, client creation and list enrollmentAccounts as an example written in JavaScript.
#### browser - Authentication, client creation and list billingAccounts as an example written in JavaScript.

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

```
```bash
npm install @azure/ms-rest-browserauth
```

Expand Down Expand Up @@ -77,7 +78,8 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
authManager.login();
}
const client = new Azure.ArmBilling.BillingManagementClient(res.creds, subscriptionId);
client.enrollmentAccounts.list().then((result) => {
const expand = "testexpand";
client.billingAccounts.list(expand).then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
Expand All @@ -94,6 +96,3 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
## Related projects

- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)


![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/billing/arm-billing/README.png)
264 changes: 264 additions & 0 deletions sdk/billing/arm-billing/lib/billingManagementClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/

import * as msRest from "@azure/ms-rest-js";
import * as Models from "./models";
import * as Mappers from "./models/mappers";
import * as Parameters from "./models/parameters";
import * as operations from "./operations";
import { BillingManagementClientContext } from "./billingManagementClientContext";


class BillingManagementClient extends BillingManagementClientContext {
// Operation groups
billingAccounts: operations.BillingAccounts;
availableBalanceByBillingProfile: operations.AvailableBalanceByBillingProfile;
paymentMethodsByBillingProfile: operations.PaymentMethodsByBillingProfile;
billingProfilesByBillingAccountName: operations.BillingProfilesByBillingAccountName;
billingProfiles: operations.BillingProfiles;
invoiceSectionsByBillingAccountName: operations.InvoiceSectionsByBillingAccountName;
invoiceSections: operations.InvoiceSections;
invoiceSectionsWithCreateSubscriptionPermission: operations.InvoiceSectionsWithCreateSubscriptionPermission;
departmentsByBillingAccountName: operations.DepartmentsByBillingAccountName;
departments: operations.Departments;
enrollmentAccountsByBillingAccountName: operations.EnrollmentAccountsByBillingAccountName;
enrollmentAccounts: operations.EnrollmentAccounts;
invoicesByBillingAccount: operations.InvoicesByBillingAccount;
invoicePricesheet: operations.InvoicePricesheet;
invoicesByBillingProfile: operations.InvoicesByBillingProfile;
invoice: operations.Invoice;
productsByBillingSubscriptions: operations.ProductsByBillingSubscriptions;
billingSubscriptionsByBillingProfile: operations.BillingSubscriptionsByBillingProfile;
billingSubscriptionsByInvoiceSection: operations.BillingSubscriptionsByInvoiceSection;
billingSubscription: operations.BillingSubscription;
productsByBillingAccount: operations.ProductsByBillingAccount;
productsByInvoiceSection: operations.ProductsByInvoiceSection;
products: operations.Products;
transactionsByBillingAccount: operations.TransactionsByBillingAccount;
transactionsByBillingProfile: operations.TransactionsByBillingProfile;
transactionsByInvoiceSection: operations.TransactionsByInvoiceSection;
policy: operations.PolicyOperations;
billingProperty: operations.BillingPropertyOperations;
transfers: operations.Transfers;
recipientTransfers: operations.RecipientTransfers;
operations: operations.Operations;
billingAccountBillingPermissions: operations.BillingAccountBillingPermissions;
invoiceSectionsBillingPermissions: operations.InvoiceSectionsBillingPermissions;
billingProfileBillingPermissions: operations.BillingProfileBillingPermissions;
billingAccountBillingRoleDefinition: operations.BillingAccountBillingRoleDefinition;
invoiceSectionBillingRoleDefinition: operations.InvoiceSectionBillingRoleDefinition;
billingProfileBillingRoleDefinition: operations.BillingProfileBillingRoleDefinition;
billingAccountBillingRoleAssignment: operations.BillingAccountBillingRoleAssignment;
invoiceSectionBillingRoleAssignment: operations.InvoiceSectionBillingRoleAssignment;
billingProfileBillingRoleAssignment: operations.BillingProfileBillingRoleAssignment;
agreements: operations.Agreements;

/**
* Initializes a new instance of the BillingManagementClient class.
* @param credentials Credentials needed for the client to connect to Azure.
* @param subscriptionId Azure Subscription ID.
* @param [options] The parameter options
*/
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BillingManagementClientOptions) {
super(credentials, subscriptionId, options);
this.billingAccounts = new operations.BillingAccounts(this);
this.availableBalanceByBillingProfile = new operations.AvailableBalanceByBillingProfile(this);
this.paymentMethodsByBillingProfile = new operations.PaymentMethodsByBillingProfile(this);
this.billingProfilesByBillingAccountName = new operations.BillingProfilesByBillingAccountName(this);
this.billingProfiles = new operations.BillingProfiles(this);
this.invoiceSectionsByBillingAccountName = new operations.InvoiceSectionsByBillingAccountName(this);
this.invoiceSections = new operations.InvoiceSections(this);
this.invoiceSectionsWithCreateSubscriptionPermission = new operations.InvoiceSectionsWithCreateSubscriptionPermission(this);
this.departmentsByBillingAccountName = new operations.DepartmentsByBillingAccountName(this);
this.departments = new operations.Departments(this);
this.enrollmentAccountsByBillingAccountName = new operations.EnrollmentAccountsByBillingAccountName(this);
this.enrollmentAccounts = new operations.EnrollmentAccounts(this);
this.invoicesByBillingAccount = new operations.InvoicesByBillingAccount(this);
this.invoicePricesheet = new operations.InvoicePricesheet(this);
this.invoicesByBillingProfile = new operations.InvoicesByBillingProfile(this);
this.invoice = new operations.Invoice(this);
this.productsByBillingSubscriptions = new operations.ProductsByBillingSubscriptions(this);
this.billingSubscriptionsByBillingProfile = new operations.BillingSubscriptionsByBillingProfile(this);
this.billingSubscriptionsByInvoiceSection = new operations.BillingSubscriptionsByInvoiceSection(this);
this.billingSubscription = new operations.BillingSubscription(this);
this.productsByBillingAccount = new operations.ProductsByBillingAccount(this);
this.productsByInvoiceSection = new operations.ProductsByInvoiceSection(this);
this.products = new operations.Products(this);
this.transactionsByBillingAccount = new operations.TransactionsByBillingAccount(this);
this.transactionsByBillingProfile = new operations.TransactionsByBillingProfile(this);
this.transactionsByInvoiceSection = new operations.TransactionsByInvoiceSection(this);
this.policy = new operations.PolicyOperations(this);
this.billingProperty = new operations.BillingPropertyOperations(this);
this.transfers = new operations.Transfers(this);
this.recipientTransfers = new operations.RecipientTransfers(this);
this.operations = new operations.Operations(this);
this.billingAccountBillingPermissions = new operations.BillingAccountBillingPermissions(this);
this.invoiceSectionsBillingPermissions = new operations.InvoiceSectionsBillingPermissions(this);
this.billingProfileBillingPermissions = new operations.BillingProfileBillingPermissions(this);
this.billingAccountBillingRoleDefinition = new operations.BillingAccountBillingRoleDefinition(this);
this.invoiceSectionBillingRoleDefinition = new operations.InvoiceSectionBillingRoleDefinition(this);
this.billingProfileBillingRoleDefinition = new operations.BillingProfileBillingRoleDefinition(this);
this.billingAccountBillingRoleAssignment = new operations.BillingAccountBillingRoleAssignment(this);
this.invoiceSectionBillingRoleAssignment = new operations.InvoiceSectionBillingRoleAssignment(this);
this.billingProfileBillingRoleAssignment = new operations.BillingProfileBillingRoleAssignment(this);
this.agreements = new operations.Agreements(this);
}

/**
* Cancel product by product id
* @param billingAccountName billing Account Id.
* @param productName Invoice Id.
* @param [options] The optional parameters
* @returns Promise<Models.UpdateAutoRenewForBillingAccountResponse>
*/
updateAutoRenewForBillingAccount(billingAccountName: string, productName: string, options?: Models.BillingManagementClientUpdateAutoRenewForBillingAccountOptionalParams): Promise<Models.UpdateAutoRenewForBillingAccountResponse>;
/**
* @param billingAccountName billing Account Id.
* @param productName Invoice Id.
* @param callback The callback
*/
updateAutoRenewForBillingAccount(billingAccountName: string, productName: string, callback: msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>): void;
/**
* @param billingAccountName billing Account Id.
* @param productName Invoice Id.
* @param options The optional parameters
* @param callback The callback
*/
updateAutoRenewForBillingAccount(billingAccountName: string, productName: string, options: Models.BillingManagementClientUpdateAutoRenewForBillingAccountOptionalParams, callback: msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>): void;
updateAutoRenewForBillingAccount(billingAccountName: string, productName: string, options?: Models.BillingManagementClientUpdateAutoRenewForBillingAccountOptionalParams | msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>, callback?: msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>): Promise<Models.UpdateAutoRenewForBillingAccountResponse> {
return this.sendOperationRequest(
{
billingAccountName,
productName,
options
},
updateAutoRenewForBillingAccountOperationSpec,
callback) as Promise<Models.UpdateAutoRenewForBillingAccountResponse>;
}

/**
* Cancel auto renew for product by product id
* @param billingAccountName billing Account Id.
* @param invoiceSectionName InvoiceSection Id.
* @param productName Invoice Id.
* @param [options] The optional parameters
* @returns Promise<Models.UpdateAutoRenewForInvoiceSectionResponse>
*/
updateAutoRenewForInvoiceSection(billingAccountName: string, invoiceSectionName: string, productName: string, options?: Models.BillingManagementClientUpdateAutoRenewForInvoiceSectionOptionalParams): Promise<Models.UpdateAutoRenewForInvoiceSectionResponse>;
/**
* @param billingAccountName billing Account Id.
* @param invoiceSectionName InvoiceSection Id.
* @param productName Invoice Id.
* @param callback The callback
*/
updateAutoRenewForInvoiceSection(billingAccountName: string, invoiceSectionName: string, productName: string, callback: msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>): void;
/**
* @param billingAccountName billing Account Id.
* @param invoiceSectionName InvoiceSection Id.
* @param productName Invoice Id.
* @param options The optional parameters
* @param callback The callback
*/
updateAutoRenewForInvoiceSection(billingAccountName: string, invoiceSectionName: string, productName: string, options: Models.BillingManagementClientUpdateAutoRenewForInvoiceSectionOptionalParams, callback: msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>): void;
updateAutoRenewForInvoiceSection(billingAccountName: string, invoiceSectionName: string, productName: string, options?: Models.BillingManagementClientUpdateAutoRenewForInvoiceSectionOptionalParams | msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>, callback?: msRest.ServiceCallback<Models.UpdateAutoRenewOperationSummary>): Promise<Models.UpdateAutoRenewForInvoiceSectionResponse> {
return this.sendOperationRequest(
{
billingAccountName,
invoiceSectionName,
productName,
options
},
updateAutoRenewForInvoiceSectionOperationSpec,
callback) as Promise<Models.UpdateAutoRenewForInvoiceSectionResponse>;
}
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const updateAutoRenewForBillingAccountOperationSpec: msRest.OperationSpec = {
httpMethod: "POST",
path: "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/updateAutoRenew",
urlParameters: [
Parameters.billingAccountName,
Parameters.productName
],
queryParameters: [
Parameters.apiVersion
],
headerParameters: [
Parameters.acceptLanguage
],
requestBody: {
parameterPath: {
autoRenew: [
"options",
"autoRenew"
]
},
mapper: {
...Mappers.UpdateAutoRenewRequest,
required: true
}
},
responses: {
200: {
bodyMapper: Mappers.UpdateAutoRenewOperationSummary
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};

const updateAutoRenewForInvoiceSectionOperationSpec: msRest.OperationSpec = {
httpMethod: "POST",
path: "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/updateAutoRenew",
urlParameters: [
Parameters.billingAccountName,
Parameters.invoiceSectionName,
Parameters.productName
],
queryParameters: [
Parameters.apiVersion
],
headerParameters: [
Parameters.acceptLanguage
],
requestBody: {
parameterPath: {
autoRenew: [
"options",
"autoRenew"
]
},
mapper: {
...Mappers.UpdateAutoRenewRequest,
required: true
}
},
responses: {
200: {
bodyMapper: Mappers.UpdateAutoRenewOperationSummary
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};

export {
BillingManagementClient,
BillingManagementClientContext,
Models as BillingManagementModels,
Mappers as BillingManagementMappers
};
export * from "./operations";
Loading