From b46415dd1dcbda84ab078a0903e892e1ad8a3e62 Mon Sep 17 00:00:00 2001 From: awstools Date: Wed, 13 Nov 2024 23:18:58 +0000 Subject: [PATCH] feat(client-billing): Today, AWS announces the general availability of ListBillingViews API in the AWS SDKs, to enable AWS Billing Conductor (ABC) users to create proforma Cost and Usage Reports (CUR) programmatically. --- clients/client-billing/.gitignore | 9 + clients/client-billing/LICENSE | 201 ++++ clients/client-billing/README.md | 219 +++++ clients/client-billing/api-extractor.json | 4 + clients/client-billing/package.json | 101 ++ clients/client-billing/src/Billing.ts | 46 + clients/client-billing/src/BillingClient.ts | 308 ++++++ .../auth/httpAuthExtensionConfiguration.ts | 72 ++ .../src/auth/httpAuthSchemeProvider.ts | 137 +++ .../src/commands/ListBillingViewsCommand.ts | 166 ++++ clients/client-billing/src/commands/index.ts | 2 + .../src/endpoint/EndpointParameters.ts | 37 + .../src/endpoint/endpointResolver.ts | 26 + .../client-billing/src/endpoint/ruleset.ts | 22 + .../src/extensionConfiguration.ts | 15 + clients/client-billing/src/index.ts | 23 + .../src/models/BillingServiceException.ts | 24 + clients/client-billing/src/models/index.ts | 2 + clients/client-billing/src/models/models_0.ts | 267 +++++ .../src/pagination/Interfaces.ts | 11 + .../pagination/ListBillingViewsPaginator.ts | 24 + .../client-billing/src/pagination/index.ts | 3 + .../src/protocols/Aws_json1_0.ts | 233 +++++ .../src/runtimeConfig.browser.ts | 44 + .../src/runtimeConfig.native.ts | 18 + .../src/runtimeConfig.shared.ts | 38 + clients/client-billing/src/runtimeConfig.ts | 60 ++ .../client-billing/src/runtimeExtensions.ts | 48 + clients/client-billing/tsconfig.cjs.json | 6 + clients/client-billing/tsconfig.es.json | 8 + clients/client-billing/tsconfig.json | 13 + clients/client-billing/tsconfig.types.json | 10 + codegen/sdk-codegen/aws-models/billing.json | 918 ++++++++++++++++++ 33 files changed, 3115 insertions(+) create mode 100644 clients/client-billing/.gitignore create mode 100644 clients/client-billing/LICENSE create mode 100644 clients/client-billing/README.md create mode 100644 clients/client-billing/api-extractor.json create mode 100644 clients/client-billing/package.json create mode 100644 clients/client-billing/src/Billing.ts create mode 100644 clients/client-billing/src/BillingClient.ts create mode 100644 clients/client-billing/src/auth/httpAuthExtensionConfiguration.ts create mode 100644 clients/client-billing/src/auth/httpAuthSchemeProvider.ts create mode 100644 clients/client-billing/src/commands/ListBillingViewsCommand.ts create mode 100644 clients/client-billing/src/commands/index.ts create mode 100644 clients/client-billing/src/endpoint/EndpointParameters.ts create mode 100644 clients/client-billing/src/endpoint/endpointResolver.ts create mode 100644 clients/client-billing/src/endpoint/ruleset.ts create mode 100644 clients/client-billing/src/extensionConfiguration.ts create mode 100644 clients/client-billing/src/index.ts create mode 100644 clients/client-billing/src/models/BillingServiceException.ts create mode 100644 clients/client-billing/src/models/index.ts create mode 100644 clients/client-billing/src/models/models_0.ts create mode 100644 clients/client-billing/src/pagination/Interfaces.ts create mode 100644 clients/client-billing/src/pagination/ListBillingViewsPaginator.ts create mode 100644 clients/client-billing/src/pagination/index.ts create mode 100644 clients/client-billing/src/protocols/Aws_json1_0.ts create mode 100644 clients/client-billing/src/runtimeConfig.browser.ts create mode 100644 clients/client-billing/src/runtimeConfig.native.ts create mode 100644 clients/client-billing/src/runtimeConfig.shared.ts create mode 100644 clients/client-billing/src/runtimeConfig.ts create mode 100644 clients/client-billing/src/runtimeExtensions.ts create mode 100644 clients/client-billing/tsconfig.cjs.json create mode 100644 clients/client-billing/tsconfig.es.json create mode 100644 clients/client-billing/tsconfig.json create mode 100644 clients/client-billing/tsconfig.types.json create mode 100644 codegen/sdk-codegen/aws-models/billing.json diff --git a/clients/client-billing/.gitignore b/clients/client-billing/.gitignore new file mode 100644 index 000000000000..54f14c9aef25 --- /dev/null +++ b/clients/client-billing/.gitignore @@ -0,0 +1,9 @@ +/node_modules/ +/build/ +/coverage/ +/docs/ +/dist-* +*.tsbuildinfo +*.tgz +*.log +package-lock.json diff --git a/clients/client-billing/LICENSE b/clients/client-billing/LICENSE new file mode 100644 index 000000000000..1349aa7c9923 --- /dev/null +++ b/clients/client-billing/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/clients/client-billing/README.md b/clients/client-billing/README.md new file mode 100644 index 000000000000..06673d4148e6 --- /dev/null +++ b/clients/client-billing/README.md @@ -0,0 +1,219 @@ + + +# @aws-sdk/client-billing + +## Description + +AWS SDK for JavaScript Billing Client for Node.js, Browser and React Native. + +

+You can use the Billing API to programatically list the billing views available to you for a given time period. A billing view represents a set of billing data. +

+

The Billing API provides the following endpoint:

+

+https://billing.us-east-1.api.aws +

+ +## Installing + +To install this package, simply type add or install @aws-sdk/client-billing +using your favorite package manager: + +- `npm install @aws-sdk/client-billing` +- `yarn add @aws-sdk/client-billing` +- `pnpm add @aws-sdk/client-billing` + +## Getting Started + +### Import + +The AWS SDK is modulized by clients and commands. +To send a request, you only need to import the `BillingClient` and +the commands you need, for example `ListBillingViewsCommand`: + +```js +// ES5 example +const { BillingClient, ListBillingViewsCommand } = require("@aws-sdk/client-billing"); +``` + +```ts +// ES6+ example +import { BillingClient, ListBillingViewsCommand } from "@aws-sdk/client-billing"; +``` + +### Usage + +To send a request, you: + +- Initiate client with configuration (e.g. credentials, region). +- Initiate command with input parameters. +- Call `send` operation on client with command object as input. +- If you are using a custom http handler, you may call `destroy()` to close open connections. + +```js +// a client can be shared by different commands. +const client = new BillingClient({ region: "REGION" }); + +const params = { + /** input parameters */ +}; +const command = new ListBillingViewsCommand(params); +``` + +#### Async/await + +We recommend using [await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await) +operator to wait for the promise returned by send operation as follows: + +```js +// async/await. +try { + const data = await client.send(command); + // process data. +} catch (error) { + // error handling. +} finally { + // finally. +} +``` + +Async-await is clean, concise, intuitive, easy to debug and has better error handling +as compared to using Promise chains or callbacks. + +#### Promises + +You can also use [Promise chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#chaining) +to execute send operation. + +```js +client.send(command).then( + (data) => { + // process data. + }, + (error) => { + // error handling. + } +); +``` + +Promises can also be called using `.catch()` and `.finally()` as follows: + +```js +client + .send(command) + .then((data) => { + // process data. + }) + .catch((error) => { + // error handling. + }) + .finally(() => { + // finally. + }); +``` + +#### Callbacks + +We do not recommend using callbacks because of [callback hell](http://callbackhell.com/), +but they are supported by the send operation. + +```js +// callbacks. +client.send(command, (err, data) => { + // process err and data. +}); +``` + +#### v2 compatible style + +The client can also send requests using v2 compatible style. +However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post +on [modular packages in AWS SDK for JavaScript](https://aws.amazon.com/blogs/developer/modular-packages-in-aws-sdk-for-javascript/) + +```ts +import * as AWS from "@aws-sdk/client-billing"; +const client = new AWS.Billing({ region: "REGION" }); + +// async/await. +try { + const data = await client.listBillingViews(params); + // process data. +} catch (error) { + // error handling. +} + +// Promises. +client + .listBillingViews(params) + .then((data) => { + // process data. + }) + .catch((error) => { + // error handling. + }); + +// callbacks. +client.listBillingViews(params, (err, data) => { + // process err and data. +}); +``` + +### Troubleshooting + +When the service returns an exception, the error will include the exception information, +as well as response metadata (e.g. request id). + +```js +try { + const data = await client.send(command); + // process data. +} catch (error) { + const { requestId, cfId, extendedRequestId } = error.$metadata; + console.log({ requestId, cfId, extendedRequestId }); + /** + * The keys within exceptions are also parsed. + * You can access them by specifying exception names: + * if (error.name === 'SomeServiceException') { + * const value = error.specialKeyInException; + * } + */ +} +``` + +## Getting Help + +Please use these community resources for getting help. +We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them. + +- Visit [Developer Guide](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html) + or [API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html). +- Check out the blog posts tagged with [`aws-sdk-js`](https://aws.amazon.com/blogs/developer/tag/aws-sdk-js/) + on AWS Developer Blog. +- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/aws-sdk-js) and tag it with `aws-sdk-js`. +- Join the AWS JavaScript community on [gitter](https://gitter.im/aws/aws-sdk-js-v3). +- If it turns out that you may have found a bug, please [open an issue](https://github.com/aws/aws-sdk-js-v3/issues/new/choose). + +To test your universal JavaScript code in Node.js, browser and react-native environments, +visit our [code samples repo](https://github.com/aws-samples/aws-sdk-js-tests). + +## Contributing + +This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/client-billing` package is updated. +To contribute to client you can check our [generate clients scripts](https://github.com/aws/aws-sdk-js-v3/tree/main/scripts/generate-clients). + +## License + +This SDK is distributed under the +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), +see LICENSE for more information. + +## Client Commands (Operations List) + +
+ +ListBillingViews + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/billing/command/ListBillingViewsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-billing/Interface/ListBillingViewsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-billing/Interface/ListBillingViewsCommandOutput/) + +
diff --git a/clients/client-billing/api-extractor.json b/clients/client-billing/api-extractor.json new file mode 100644 index 000000000000..d5bf5ffeee85 --- /dev/null +++ b/clients/client-billing/api-extractor.json @@ -0,0 +1,4 @@ +{ + "extends": "../../api-extractor.json", + "mainEntryPointFilePath": "/dist-types/index.d.ts" +} diff --git a/clients/client-billing/package.json b/clients/client-billing/package.json new file mode 100644 index 000000000000..b6b535e69504 --- /dev/null +++ b/clients/client-billing/package.json @@ -0,0 +1,101 @@ +{ + "name": "@aws-sdk/client-billing", + "description": "AWS SDK for JavaScript Billing Client for Node.js, Browser and React Native", + "version": "3.0.0", + "scripts": { + "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build:es": "tsc -p tsconfig.es.json", + "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build", + "build:types": "tsc -p tsconfig.types.json", + "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4", + "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0", + "extract:docs": "api-extractor run --local", + "generate:client": "node ../../scripts/generate-clients/single-service --solo billing" + }, + "main": "./dist-cjs/index.js", + "types": "./dist-types/index.d.ts", + "module": "./dist-es/index.js", + "sideEffects": false, + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/client-sso-oidc": "*", + "@aws-sdk/client-sts": "*", + "@aws-sdk/core": "*", + "@aws-sdk/credential-provider-node": "*", + "@aws-sdk/middleware-host-header": "*", + "@aws-sdk/middleware-logger": "*", + "@aws-sdk/middleware-recursion-detection": "*", + "@aws-sdk/middleware-user-agent": "*", + "@aws-sdk/region-config-resolver": "*", + "@aws-sdk/types": "*", + "@aws-sdk/util-endpoints": "*", + "@aws-sdk/util-user-agent-browser": "*", + "@aws-sdk/util-user-agent-node": "*", + "@smithy/config-resolver": "^3.0.10", + "@smithy/core": "^2.5.1", + "@smithy/fetch-http-handler": "^4.0.0", + "@smithy/hash-node": "^3.0.8", + "@smithy/invalid-dependency": "^3.0.8", + "@smithy/middleware-content-length": "^3.0.10", + "@smithy/middleware-endpoint": "^3.2.1", + "@smithy/middleware-retry": "^3.0.25", + "@smithy/middleware-serde": "^3.0.8", + "@smithy/middleware-stack": "^3.0.8", + "@smithy/node-config-provider": "^3.1.9", + "@smithy/node-http-handler": "^3.2.5", + "@smithy/protocol-http": "^4.1.5", + "@smithy/smithy-client": "^3.4.2", + "@smithy/types": "^3.6.0", + "@smithy/url-parser": "^3.0.8", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.25", + "@smithy/util-defaults-mode-node": "^3.0.25", + "@smithy/util-endpoints": "^2.1.4", + "@smithy/util-middleware": "^3.0.8", + "@smithy/util-retry": "^3.0.8", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2" + }, + "devDependencies": { + "@tsconfig/node16": "16.1.3", + "@types/node": "^16.18.96", + "concurrently": "7.0.0", + "downlevel-dts": "0.10.1", + "rimraf": "3.0.2", + "typescript": "~4.9.5" + }, + "engines": { + "node": ">=16.0.0" + }, + "typesVersions": { + "<4.0": { + "dist-types/*": [ + "dist-types/ts3.4/*" + ] + } + }, + "files": [ + "dist-*/**" + ], + "author": { + "name": "AWS SDK for JavaScript Team", + "url": "https://aws.amazon.com/javascript/" + }, + "license": "Apache-2.0", + "browser": { + "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser" + }, + "react-native": { + "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.native" + }, + "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-billing", + "repository": { + "type": "git", + "url": "https://github.com/aws/aws-sdk-js-v3.git", + "directory": "clients/client-billing" + } +} diff --git a/clients/client-billing/src/Billing.ts b/clients/client-billing/src/Billing.ts new file mode 100644 index 000000000000..1ad84ad2f1db --- /dev/null +++ b/clients/client-billing/src/Billing.ts @@ -0,0 +1,46 @@ +// smithy-typescript generated code +import { createAggregatedClient } from "@smithy/smithy-client"; +import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types"; + +import { BillingClient, BillingClientConfig } from "./BillingClient"; +import { + ListBillingViewsCommand, + ListBillingViewsCommandInput, + ListBillingViewsCommandOutput, +} from "./commands/ListBillingViewsCommand"; + +const commands = { + ListBillingViewsCommand, +}; + +export interface Billing { + /** + * @see {@link ListBillingViewsCommand} + */ + listBillingViews( + args: ListBillingViewsCommandInput, + options?: __HttpHandlerOptions + ): Promise; + listBillingViews( + args: ListBillingViewsCommandInput, + cb: (err: any, data?: ListBillingViewsCommandOutput) => void + ): void; + listBillingViews( + args: ListBillingViewsCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: ListBillingViewsCommandOutput) => void + ): void; +} + +/** + *

+ * You can use the Billing API to programatically list the billing views available to you for a given time period. A billing view represents a set of billing data. + *

+ *

The Billing API provides the following endpoint:

+ *

+ * https://billing.us-east-1.api.aws + *

+ * @public + */ +export class Billing extends BillingClient implements Billing {} +createAggregatedClient(commands, Billing); diff --git a/clients/client-billing/src/BillingClient.ts b/clients/client-billing/src/BillingClient.ts new file mode 100644 index 000000000000..051cb172c636 --- /dev/null +++ b/clients/client-billing/src/BillingClient.ts @@ -0,0 +1,308 @@ +// smithy-typescript generated code +import { + getHostHeaderPlugin, + HostHeaderInputConfig, + HostHeaderResolvedConfig, + resolveHostHeaderConfig, +} from "@aws-sdk/middleware-host-header"; +import { getLoggerPlugin } from "@aws-sdk/middleware-logger"; +import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection"; +import { + getUserAgentPlugin, + resolveUserAgentConfig, + UserAgentInputConfig, + UserAgentResolvedConfig, +} from "@aws-sdk/middleware-user-agent"; +import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver"; +import { + DefaultIdentityProviderConfig, + getHttpAuthSchemeEndpointRuleSetPlugin, + getHttpSigningPlugin, +} from "@smithy/core"; +import { getContentLengthPlugin } from "@smithy/middleware-content-length"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; +import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; +import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; +import { + Client as __Client, + DefaultsMode as __DefaultsMode, + SmithyConfiguration as __SmithyConfiguration, + SmithyResolvedConfiguration as __SmithyResolvedConfiguration, +} from "@smithy/smithy-client"; +import { + AwsCredentialIdentityProvider, + BodyLengthCalculator as __BodyLengthCalculator, + CheckOptionalClientConfig as __CheckOptionalClientConfig, + ChecksumConstructor as __ChecksumConstructor, + Decoder as __Decoder, + Encoder as __Encoder, + EndpointV2 as __EndpointV2, + HashConstructor as __HashConstructor, + HttpHandlerOptions as __HttpHandlerOptions, + Logger as __Logger, + Provider as __Provider, + Provider, + StreamCollector as __StreamCollector, + UrlParser as __UrlParser, + UserAgent as __UserAgent, +} from "@smithy/types"; + +import { + defaultBillingHttpAuthSchemeParametersProvider, + HttpAuthSchemeInputConfig, + HttpAuthSchemeResolvedConfig, + resolveHttpAuthSchemeConfig, +} from "./auth/httpAuthSchemeProvider"; +import { ListBillingViewsCommandInput, ListBillingViewsCommandOutput } from "./commands/ListBillingViewsCommand"; +import { + ClientInputEndpointParameters, + ClientResolvedEndpointParameters, + EndpointParameters, + resolveClientEndpointParameters, +} from "./endpoint/EndpointParameters"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; +import { resolveRuntimeExtensions, RuntimeExtension, RuntimeExtensionsConfig } from "./runtimeExtensions"; + +export { __Client }; + +/** + * @public + */ +export type ServiceInputTypes = ListBillingViewsCommandInput; + +/** + * @public + */ +export type ServiceOutputTypes = ListBillingViewsCommandOutput; + +/** + * @public + */ +export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHandlerOptions>> { + /** + * The HTTP handler to use or its constructor options. Fetch in browser and Https in Nodejs. + */ + requestHandler?: __HttpHandlerUserInput; + + /** + * A constructor for a class implementing the {@link @smithy/types#ChecksumConstructor} interface + * that computes the SHA-256 HMAC or checksum of a string or binary buffer. + * @internal + */ + sha256?: __ChecksumConstructor | __HashConstructor; + + /** + * The function that will be used to convert strings into HTTP endpoints. + * @internal + */ + urlParser?: __UrlParser; + + /** + * A function that can calculate the length of a request body. + * @internal + */ + bodyLengthChecker?: __BodyLengthCalculator; + + /** + * A function that converts a stream into an array of bytes. + * @internal + */ + streamCollector?: __StreamCollector; + + /** + * The function that will be used to convert a base64-encoded string to a byte array. + * @internal + */ + base64Decoder?: __Decoder; + + /** + * The function that will be used to convert binary data to a base64-encoded string. + * @internal + */ + base64Encoder?: __Encoder; + + /** + * The function that will be used to convert a UTF8-encoded string to a byte array. + * @internal + */ + utf8Decoder?: __Decoder; + + /** + * The function that will be used to convert binary data to a UTF-8 encoded string. + * @internal + */ + utf8Encoder?: __Encoder; + + /** + * The runtime environment. + * @internal + */ + runtime?: string; + + /** + * Disable dynamically changing the endpoint of the client based on the hostPrefix + * trait of an operation. + */ + disableHostPrefix?: boolean; + + /** + * Unique service identifier. + * @internal + */ + serviceId?: string; + + /** + * Enables IPv6/IPv4 dualstack endpoint. + */ + useDualstackEndpoint?: boolean | __Provider; + + /** + * Enables FIPS compatible endpoints. + */ + useFipsEndpoint?: boolean | __Provider; + + /** + * The AWS region to which this client will send requests + */ + region?: string | __Provider; + + /** + * The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header + * @internal + */ + defaultUserAgentProvider?: Provider<__UserAgent>; + + /** + * Default credentials provider; Not available in browser runtime. + * @deprecated + * @internal + */ + credentialDefaultProvider?: (input: any) => AwsCredentialIdentityProvider; + + /** + * Value for how many times a request will be made at most in case of retry. + */ + maxAttempts?: number | __Provider; + + /** + * Specifies which retry algorithm to use. + * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-util-retry/Enum/RETRY_MODES/ + * + */ + retryMode?: string | __Provider; + + /** + * Optional logger for logging debug/info/warn/error. + */ + logger?: __Logger; + + /** + * Optional extensions + */ + extensions?: RuntimeExtension[]; + + /** + * The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. + */ + defaultsMode?: __DefaultsMode | __Provider<__DefaultsMode>; +} + +/** + * @public + */ +export type BillingClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & + ClientDefaults & + UserAgentInputConfig & + RetryInputConfig & + RegionInputConfig & + HostHeaderInputConfig & + EndpointInputConfig & + HttpAuthSchemeInputConfig & + ClientInputEndpointParameters; +/** + * @public + * + * The configuration interface of BillingClient class constructor that set the region, credentials and other options. + */ +export interface BillingClientConfig extends BillingClientConfigType {} + +/** + * @public + */ +export type BillingClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> & + Required & + RuntimeExtensionsConfig & + UserAgentResolvedConfig & + RetryResolvedConfig & + RegionResolvedConfig & + HostHeaderResolvedConfig & + EndpointResolvedConfig & + HttpAuthSchemeResolvedConfig & + ClientResolvedEndpointParameters; +/** + * @public + * + * The resolved configuration interface of BillingClient class. This is resolved and normalized from the {@link BillingClientConfig | constructor configuration interface}. + */ +export interface BillingClientResolvedConfig extends BillingClientResolvedConfigType {} + +/** + *

+ * You can use the Billing API to programatically list the billing views available to you for a given time period. A billing view represents a set of billing data. + *

+ *

The Billing API provides the following endpoint:

+ *

+ * https://billing.us-east-1.api.aws + *

+ * @public + */ +export class BillingClient extends __Client< + __HttpHandlerOptions, + ServiceInputTypes, + ServiceOutputTypes, + BillingClientResolvedConfig +> { + /** + * The resolved configuration of BillingClient class. This is resolved and normalized from the {@link BillingClientConfig | constructor configuration interface}. + */ + readonly config: BillingClientResolvedConfig; + + constructor(...[configuration]: __CheckOptionalClientConfig) { + const _config_0 = __getRuntimeConfig(configuration || {}); + const _config_1 = resolveClientEndpointParameters(_config_0); + const _config_2 = resolveUserAgentConfig(_config_1); + const _config_3 = resolveRetryConfig(_config_2); + const _config_4 = resolveRegionConfig(_config_3); + const _config_5 = resolveHostHeaderConfig(_config_4); + const _config_6 = resolveEndpointConfig(_config_5); + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []); + super(_config_8); + this.config = _config_8; + this.middlewareStack.use(getUserAgentPlugin(this.config)); + this.middlewareStack.use(getRetryPlugin(this.config)); + this.middlewareStack.use(getContentLengthPlugin(this.config)); + this.middlewareStack.use(getHostHeaderPlugin(this.config)); + this.middlewareStack.use(getLoggerPlugin(this.config)); + this.middlewareStack.use(getRecursionDetectionPlugin(this.config)); + this.middlewareStack.use( + getHttpAuthSchemeEndpointRuleSetPlugin(this.config, { + httpAuthSchemeParametersProvider: defaultBillingHttpAuthSchemeParametersProvider, + identityProviderConfigProvider: async (config: BillingClientResolvedConfig) => + new DefaultIdentityProviderConfig({ + "aws.auth#sigv4": config.credentials, + }), + }) + ); + this.middlewareStack.use(getHttpSigningPlugin(this.config)); + } + + /** + * Destroy underlying resources, like sockets. It's usually not necessary to do this. + * However in Node.js, it's best to explicitly shut down the client's agent when it is no longer needed. + * Otherwise, sockets might stay open for quite a long time before the server terminates them. + */ + destroy(): void { + super.destroy(); + } +} diff --git a/clients/client-billing/src/auth/httpAuthExtensionConfiguration.ts b/clients/client-billing/src/auth/httpAuthExtensionConfiguration.ts new file mode 100644 index 000000000000..00fd87c198d8 --- /dev/null +++ b/clients/client-billing/src/auth/httpAuthExtensionConfiguration.ts @@ -0,0 +1,72 @@ +// smithy-typescript generated code +import { AwsCredentialIdentity, AwsCredentialIdentityProvider, HttpAuthScheme } from "@smithy/types"; + +import { BillingHttpAuthSchemeProvider } from "./httpAuthSchemeProvider"; + +/** + * @internal + */ +export interface HttpAuthExtensionConfiguration { + setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void; + httpAuthSchemes(): HttpAuthScheme[]; + setHttpAuthSchemeProvider(httpAuthSchemeProvider: BillingHttpAuthSchemeProvider): void; + httpAuthSchemeProvider(): BillingHttpAuthSchemeProvider; + setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void; + credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined; +} + +/** + * @internal + */ +export type HttpAuthRuntimeConfig = Partial<{ + httpAuthSchemes: HttpAuthScheme[]; + httpAuthSchemeProvider: BillingHttpAuthSchemeProvider; + credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider; +}>; + +/** + * @internal + */ +export const getHttpAuthExtensionConfiguration = ( + runtimeConfig: HttpAuthRuntimeConfig +): HttpAuthExtensionConfiguration => { + const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!; + let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!; + let _credentials = runtimeConfig.credentials; + return { + setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void { + const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId); + if (index === -1) { + _httpAuthSchemes.push(httpAuthScheme); + } else { + _httpAuthSchemes.splice(index, 1, httpAuthScheme); + } + }, + httpAuthSchemes(): HttpAuthScheme[] { + return _httpAuthSchemes; + }, + setHttpAuthSchemeProvider(httpAuthSchemeProvider: BillingHttpAuthSchemeProvider): void { + _httpAuthSchemeProvider = httpAuthSchemeProvider; + }, + httpAuthSchemeProvider(): BillingHttpAuthSchemeProvider { + return _httpAuthSchemeProvider; + }, + setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void { + _credentials = credentials; + }, + credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined { + return _credentials; + }, + }; +}; + +/** + * @internal + */ +export const resolveHttpAuthRuntimeConfig = (config: HttpAuthExtensionConfiguration): HttpAuthRuntimeConfig => { + return { + httpAuthSchemes: config.httpAuthSchemes(), + httpAuthSchemeProvider: config.httpAuthSchemeProvider(), + credentials: config.credentials(), + }; +}; diff --git a/clients/client-billing/src/auth/httpAuthSchemeProvider.ts b/clients/client-billing/src/auth/httpAuthSchemeProvider.ts new file mode 100644 index 000000000000..d88ca6c3481e --- /dev/null +++ b/clients/client-billing/src/auth/httpAuthSchemeProvider.ts @@ -0,0 +1,137 @@ +// smithy-typescript generated code +import { + AwsSdkSigV4AuthInputConfig, + AwsSdkSigV4AuthResolvedConfig, + AwsSdkSigV4PreviouslyResolved, + resolveAwsSdkSigV4Config, +} from "@aws-sdk/core"; +import { + HandlerExecutionContext, + HttpAuthOption, + HttpAuthScheme, + HttpAuthSchemeParameters, + HttpAuthSchemeParametersProvider, + HttpAuthSchemeProvider, +} from "@smithy/types"; +import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware"; + +import { BillingClientConfig, BillingClientResolvedConfig } from "../BillingClient"; + +/** + * @internal + */ +export interface BillingHttpAuthSchemeParameters extends HttpAuthSchemeParameters { + region?: string; +} + +/** + * @internal + */ +export interface BillingHttpAuthSchemeParametersProvider + extends HttpAuthSchemeParametersProvider< + BillingClientResolvedConfig, + HandlerExecutionContext, + BillingHttpAuthSchemeParameters, + object + > {} + +/** + * @internal + */ +export const defaultBillingHttpAuthSchemeParametersProvider = async ( + config: BillingClientResolvedConfig, + context: HandlerExecutionContext, + input: object +): Promise => { + return { + operation: getSmithyContext(context).operation as string, + region: + (await normalizeProvider(config.region)()) || + (() => { + throw new Error("expected `region` to be configured for `aws.auth#sigv4`"); + })(), + }; +}; + +function createAwsAuthSigv4HttpAuthOption(authParameters: BillingHttpAuthSchemeParameters): HttpAuthOption { + return { + schemeId: "aws.auth#sigv4", + signingProperties: { + name: "billing", + region: authParameters.region, + }, + propertiesExtractor: (config: Partial, context) => ({ + /** + * @internal + */ + signingProperties: { + config, + context, + }, + }), + }; +} + +/** + * @internal + */ +export interface BillingHttpAuthSchemeProvider extends HttpAuthSchemeProvider {} + +/** + * @internal + */ +export const defaultBillingHttpAuthSchemeProvider: BillingHttpAuthSchemeProvider = (authParameters) => { + const options: HttpAuthOption[] = []; + switch (authParameters.operation) { + default: { + options.push(createAwsAuthSigv4HttpAuthOption(authParameters)); + } + } + return options; +}; + +/** + * @internal + */ +export interface HttpAuthSchemeInputConfig extends AwsSdkSigV4AuthInputConfig { + /** + * Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme. + * @internal + */ + httpAuthSchemes?: HttpAuthScheme[]; + + /** + * Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use. + * @internal + */ + httpAuthSchemeProvider?: BillingHttpAuthSchemeProvider; +} + +/** + * @internal + */ +export interface HttpAuthSchemeResolvedConfig extends AwsSdkSigV4AuthResolvedConfig { + /** + * Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme. + * @internal + */ + readonly httpAuthSchemes: HttpAuthScheme[]; + + /** + * Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use. + * @internal + */ + readonly httpAuthSchemeProvider: BillingHttpAuthSchemeProvider; +} + +/** + * @internal + */ +export const resolveHttpAuthSchemeConfig = ( + config: T & HttpAuthSchemeInputConfig & AwsSdkSigV4PreviouslyResolved +): T & HttpAuthSchemeResolvedConfig => { + const config_0 = resolveAwsSdkSigV4Config(config); + return { + ...config_0, + } as T & HttpAuthSchemeResolvedConfig; +}; diff --git a/clients/client-billing/src/commands/ListBillingViewsCommand.ts b/clients/client-billing/src/commands/ListBillingViewsCommand.ts new file mode 100644 index 000000000000..b3a3858ec108 --- /dev/null +++ b/clients/client-billing/src/commands/ListBillingViewsCommand.ts @@ -0,0 +1,166 @@ +// smithy-typescript generated code +import { getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { Command as $Command } from "@smithy/smithy-client"; +import { MetadataBearer as __MetadataBearer } from "@smithy/types"; + +import { BillingClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BillingClient"; +import { commonParams } from "../endpoint/EndpointParameters"; +import { + ListBillingViewsRequest, + ListBillingViewsResponse, + ListBillingViewsResponseFilterSensitiveLog, +} from "../models/models_0"; +import { de_ListBillingViewsCommand, se_ListBillingViewsCommand } from "../protocols/Aws_json1_0"; + +/** + * @public + */ +export type { __MetadataBearer }; +export { $Command }; +/** + * @public + * + * The input for {@link ListBillingViewsCommand}. + */ +export interface ListBillingViewsCommandInput extends ListBillingViewsRequest {} +/** + * @public + * + * The output of {@link ListBillingViewsCommand}. + */ +export interface ListBillingViewsCommandOutput extends ListBillingViewsResponse, __MetadataBearer {} + +/** + *

Lists the billing views available for a given time period. + *

+ *

Every Amazon Web Services account has a unique PRIMARY billing view that represents the billing data available by default. Accounts that use Billing Conductor also have BILLING_GROUP billing views representing pro forma costs associated with each created billing group.

+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { BillingClient, ListBillingViewsCommand } from "@aws-sdk/client-billing"; // ES Modules import + * // const { BillingClient, ListBillingViewsCommand } = require("@aws-sdk/client-billing"); // CommonJS import + * const client = new BillingClient(config); + * const input = { // ListBillingViewsRequest + * activeTimeRange: { // ActiveTimeRange + * activeAfterInclusive: new Date("TIMESTAMP"), // required + * activeBeforeInclusive: new Date("TIMESTAMP"), // required + * }, + * maxResults: Number("int"), + * nextToken: "STRING_VALUE", + * }; + * const command = new ListBillingViewsCommand(input); + * const response = await client.send(command); + * // { // ListBillingViewsResponse + * // billingViews: [ // BillingViewList // required + * // { // BillingViewListElement + * // arn: "STRING_VALUE", + * // name: "STRING_VALUE", + * // ownerAccountId: "STRING_VALUE", + * // billingViewType: "PRIMARY" || "BILLING_GROUP", + * // }, + * // ], + * // nextToken: "STRING_VALUE", + * // }; + * + * ``` + * + * @param ListBillingViewsCommandInput - {@link ListBillingViewsCommandInput} + * @returns {@link ListBillingViewsCommandOutput} + * @see {@link ListBillingViewsCommandInput} for command's `input` shape. + * @see {@link ListBillingViewsCommandOutput} for command's `response` shape. + * @see {@link BillingClientResolvedConfig | config} for BillingClient's `config` shape. + * + * @throws {@link AccessDeniedException} (client fault) + *

You don't have sufficient access to perform this action.

+ * + * @throws {@link InternalServerException} (server fault) + *

The request processing failed because of an unknown error, exception, or failure. + *

+ * + * @throws {@link ThrottlingException} (client fault) + *

The request was denied due to request throttling. + *

+ * + * @throws {@link ValidationException} (client fault) + *

The input fails to satisfy the constraints specified by an Amazon Web Services service. + *

+ * + * @throws {@link BillingServiceException} + *

Base exception class for all service exceptions from Billing service.

+ * + * @public + * @example Invoke ListBillingViews + * ```javascript + * // + * const input = { + * "activeTimeRange": { + * "activeAfterInclusive": 1719792000, + * "activeBeforeInclusive": 1722470399.999 + * } + * }; + * const command = new ListBillingViewsCommand(input); + * const response = await client.send(command); + * /* response == + * { + * "billingViews": [ + * { + * "name": "Primary Billing View Account 123456789101", + * "arn": "arn:aws:billing::123456789101:billingview/primary", + * "billingViewType": "PRIMARY", + * "ownerAccountId": "123456789101" + * } + * ] + * } + * *\/ + * // example id: example-1 + * ``` + * + * @example Error example for ListBillingViews + * ```javascript + * // + * const input = { + * "activeTimeRange": { + * "activeAfterInclusive": 1719792001, + * "activeBeforeInclusive": 1719792000 + * } + * }; + * const command = new ListBillingViewsCommand(input); + * await client.send(command); + * // example id: example-2 + * ``` + * + */ +export class ListBillingViewsCommand extends $Command + .classBuilder< + ListBillingViewsCommandInput, + ListBillingViewsCommandOutput, + BillingClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes + >() + .ep(commonParams) + .m(function (this: any, Command: any, cs: any, config: BillingClientResolvedConfig, o: any) { + return [ + getSerdePlugin(config, this.serialize, this.deserialize), + getEndpointPlugin(config, Command.getEndpointParameterInstructions()), + ]; + }) + .s("AWSBilling", "ListBillingViews", {}) + .n("BillingClient", "ListBillingViewsCommand") + .f(void 0, ListBillingViewsResponseFilterSensitiveLog) + .ser(se_ListBillingViewsCommand) + .de(de_ListBillingViewsCommand) + .build() { + /** @internal type navigation helper, not in runtime. */ + protected declare static __types: { + api: { + input: ListBillingViewsRequest; + output: ListBillingViewsResponse; + }; + sdk: { + input: ListBillingViewsCommandInput; + output: ListBillingViewsCommandOutput; + }; + }; +} diff --git a/clients/client-billing/src/commands/index.ts b/clients/client-billing/src/commands/index.ts new file mode 100644 index 000000000000..853515c0fc64 --- /dev/null +++ b/clients/client-billing/src/commands/index.ts @@ -0,0 +1,2 @@ +// smithy-typescript generated code +export * from "./ListBillingViewsCommand"; diff --git a/clients/client-billing/src/endpoint/EndpointParameters.ts b/clients/client-billing/src/endpoint/EndpointParameters.ts new file mode 100644 index 000000000000..b7b7b1be8bd6 --- /dev/null +++ b/clients/client-billing/src/endpoint/EndpointParameters.ts @@ -0,0 +1,37 @@ +// smithy-typescript generated code +import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types"; + +/** + * @public + */ +export interface ClientInputEndpointParameters { + useFipsEndpoint?: boolean | Provider; + endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; + region?: string | Provider; +} + +export type ClientResolvedEndpointParameters = ClientInputEndpointParameters & { + defaultSigningName: string; +}; + +export const resolveClientEndpointParameters = ( + options: T & ClientInputEndpointParameters +): T & ClientResolvedEndpointParameters => { + return { + ...options, + useFipsEndpoint: options.useFipsEndpoint ?? false, + defaultSigningName: "billing", + }; +}; + +export const commonParams = { + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, +} as const; + +export interface EndpointParameters extends __EndpointParameters { + UseFIPS?: boolean; + Endpoint?: string; + Region?: string; +} diff --git a/clients/client-billing/src/endpoint/endpointResolver.ts b/clients/client-billing/src/endpoint/endpointResolver.ts new file mode 100644 index 000000000000..b08a72482ca0 --- /dev/null +++ b/clients/client-billing/src/endpoint/endpointResolver.ts @@ -0,0 +1,26 @@ +// smithy-typescript generated code +import { awsEndpointFunctions } from "@aws-sdk/util-endpoints"; +import { EndpointV2, Logger } from "@smithy/types"; +import { customEndpointFunctions, EndpointCache, EndpointParams, resolveEndpoint } from "@smithy/util-endpoints"; + +import { EndpointParameters } from "./EndpointParameters"; +import { ruleSet } from "./ruleset"; + +const cache = new EndpointCache({ + size: 50, + params: ["Endpoint", "Region", "UseFIPS"], +}); + +export const defaultEndpointResolver = ( + endpointParams: EndpointParameters, + context: { logger?: Logger } = {} +): EndpointV2 => { + return cache.get(endpointParams as EndpointParams, () => + resolveEndpoint(ruleSet, { + endpointParams: endpointParams as EndpointParams, + logger: context.logger, + }) + ); +}; + +customEndpointFunctions.aws = awsEndpointFunctions; diff --git a/clients/client-billing/src/endpoint/ruleset.ts b/clients/client-billing/src/endpoint/ruleset.ts new file mode 100644 index 000000000000..c36119adb9fb --- /dev/null +++ b/clients/client-billing/src/endpoint/ruleset.ts @@ -0,0 +1,22 @@ +// @ts-nocheck +// generated code, do not edit +import { RuleSetObject } from "@smithy/types"; + +/* This file is compressed. Log this object + or see "smithy.rules#endpointRuleSet" + in codegen/sdk-codegen/aws-models/billing.json */ + +const l="ref"; +const a=true, +b=false, +c="isSet", +d="error", +e="endpoint", +f="tree", +g={"required":false,"type":"String"}, +h={[l]:"Endpoint"}, +i={"authSchemes":[{"name":"sigv4","signingRegion":"{PartitionResult#implicitGlobalRegion}"}]}, +j=[{"fn":"booleanEquals","argv":[{[l]:"UseFIPS"},true]}], +k=[{[l]:"Region"}]; +const _data={version:"1.0",parameters:{UseFIPS:{required:a,default:b,type:"Boolean"},Endpoint:g,Region:g},rules:[{conditions:[{fn:c,argv:[h]}],rules:[{conditions:j,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:d},{endpoint:{url:h,properties:{},headers:{}},type:e}],type:f},{rules:[{conditions:[{fn:c,argv:k}],rules:[{conditions:[{fn:"aws.partition",argv:k,assign:"PartitionResult"}],rules:[{conditions:j,endpoint:{url:"https://billing-fips.{PartitionResult#implicitGlobalRegion}.{PartitionResult#dualStackDnsSuffix}",properties:i,headers:{}},type:e},{endpoint:{url:"https://billing.{PartitionResult#implicitGlobalRegion}.{PartitionResult#dualStackDnsSuffix}",properties:i,headers:{}},type:e}],type:f}],type:f},{error:"Invalid Configuration: Missing Region",type:d}],type:f}]}; +export const ruleSet: RuleSetObject = _data; diff --git a/clients/client-billing/src/extensionConfiguration.ts b/clients/client-billing/src/extensionConfiguration.ts new file mode 100644 index 000000000000..9c0d625e6e44 --- /dev/null +++ b/clients/client-billing/src/extensionConfiguration.ts @@ -0,0 +1,15 @@ +// smithy-typescript generated code +import { AwsRegionExtensionConfiguration } from "@aws-sdk/types"; +import { HttpHandlerExtensionConfiguration } from "@smithy/protocol-http"; +import { DefaultExtensionConfiguration } from "@smithy/types"; + +import { HttpAuthExtensionConfiguration } from "./auth/httpAuthExtensionConfiguration"; + +/** + * @internal + */ +export interface BillingExtensionConfiguration + extends HttpHandlerExtensionConfiguration, + DefaultExtensionConfiguration, + AwsRegionExtensionConfiguration, + HttpAuthExtensionConfiguration {} diff --git a/clients/client-billing/src/index.ts b/clients/client-billing/src/index.ts new file mode 100644 index 000000000000..f01475037868 --- /dev/null +++ b/clients/client-billing/src/index.ts @@ -0,0 +1,23 @@ +// smithy-typescript generated code +/* eslint-disable */ +/** + *

+ * You can use the Billing API to programatically list the billing views available to you for a given time period. A billing view represents a set of billing data. + *

+ *

The Billing API provides the following endpoint:

+ *

+ * https://billing.us-east-1.api.aws + *

+ * + * @packageDocumentation + */ +export * from "./BillingClient"; +export * from "./Billing"; +export { ClientInputEndpointParameters } from "./endpoint/EndpointParameters"; +export type { RuntimeExtension } from "./runtimeExtensions"; +export type { BillingExtensionConfiguration } from "./extensionConfiguration"; +export * from "./commands"; +export * from "./pagination"; +export * from "./models"; + +export { BillingServiceException } from "./models/BillingServiceException"; diff --git a/clients/client-billing/src/models/BillingServiceException.ts b/clients/client-billing/src/models/BillingServiceException.ts new file mode 100644 index 000000000000..546741f72890 --- /dev/null +++ b/clients/client-billing/src/models/BillingServiceException.ts @@ -0,0 +1,24 @@ +// smithy-typescript generated code +import { + ServiceException as __ServiceException, + ServiceExceptionOptions as __ServiceExceptionOptions, +} from "@smithy/smithy-client"; + +export type { __ServiceExceptionOptions }; + +export { __ServiceException }; + +/** + * @public + * + * Base exception class for all service exceptions from Billing service. + */ +export class BillingServiceException extends __ServiceException { + /** + * @internal + */ + constructor(options: __ServiceExceptionOptions) { + super(options); + Object.setPrototypeOf(this, BillingServiceException.prototype); + } +} diff --git a/clients/client-billing/src/models/index.ts b/clients/client-billing/src/models/index.ts new file mode 100644 index 000000000000..9eaceb12865f --- /dev/null +++ b/clients/client-billing/src/models/index.ts @@ -0,0 +1,2 @@ +// smithy-typescript generated code +export * from "./models_0"; diff --git a/clients/client-billing/src/models/models_0.ts b/clients/client-billing/src/models/models_0.ts new file mode 100644 index 000000000000..07776857a243 --- /dev/null +++ b/clients/client-billing/src/models/models_0.ts @@ -0,0 +1,267 @@ +// smithy-typescript generated code +import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client"; + +import { BillingServiceException as __BaseException } from "./BillingServiceException"; + +/** + *

You don't have sufficient access to perform this action.

+ * @public + */ +export class AccessDeniedException extends __BaseException { + readonly name: "AccessDeniedException" = "AccessDeniedException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "AccessDeniedException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, AccessDeniedException.prototype); + } +} + +/** + *

A time range with a start and end time.

+ * @public + */ +export interface ActiveTimeRange { + /** + *

The inclusive time range start date.

+ * @public + */ + activeAfterInclusive: Date | undefined; + + /** + *

+ * The inclusive time range end date. + *

+ * @public + */ + activeBeforeInclusive: Date | undefined; +} + +/** + *

The request processing failed because of an unknown error, exception, or failure. + *

+ * @public + */ +export class InternalServerException extends __BaseException { + readonly name: "InternalServerException" = "InternalServerException"; + readonly $fault: "server" = "server"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "InternalServerException", + $fault: "server", + ...opts, + }); + Object.setPrototypeOf(this, InternalServerException.prototype); + } +} + +/** + * @public + */ +export interface ListBillingViewsRequest { + /** + *

+ * The time range for the billing views listed. PRIMARY billing view is always listed. BILLING_GROUP billing views are listed for time ranges when the associated billing group resource in Billing Conductor is active. The time range must be within one calendar month. + *

+ * @public + */ + activeTimeRange: ActiveTimeRange | undefined; + + /** + *

The maximum number of billing views to retrieve. Default is 100. + *

+ * @public + */ + maxResults?: number | undefined; + + /** + *

The pagination token that is used on subsequent calls to list billing views.

+ * @public + */ + nextToken?: string | undefined; +} + +/** + * @public + * @enum + */ +export const BillingViewType = { + BILLING_GROUP: "BILLING_GROUP", + PRIMARY: "PRIMARY", +} as const; + +/** + * @public + */ +export type BillingViewType = (typeof BillingViewType)[keyof typeof BillingViewType]; + +/** + *

A representation of a billing view.

+ * @public + */ +export interface BillingViewListElement { + /** + *

The Amazon Resource Name (ARN) that can be used to uniquely identify the billing view. + *

+ * @public + */ + arn?: string | undefined; + + /** + *

+ * A list of names of the Billing view. + *

+ * @public + */ + name?: string | undefined; + + /** + *

+ * The list of owners of the Billing view. + *

+ * @public + */ + ownerAccountId?: string | undefined; + + /** + *

The type of billing view.

+ * @public + */ + billingViewType?: BillingViewType | undefined; +} + +/** + * @public + */ +export interface ListBillingViewsResponse { + /** + *

A list of BillingViewListElement retrieved.

+ * @public + */ + billingViews: BillingViewListElement[] | undefined; + + /** + *

The pagination token to use on subsequent calls to list billing views. + *

+ * @public + */ + nextToken?: string | undefined; +} + +/** + *

The request was denied due to request throttling. + *

+ * @public + */ +export class ThrottlingException extends __BaseException { + readonly name: "ThrottlingException" = "ThrottlingException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ThrottlingException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ThrottlingException.prototype); + } +} + +/** + *

The field's information of a request that resulted in an exception. + *

+ * @public + */ +export interface ValidationExceptionField { + /** + *

The name of the field.

+ * @public + */ + name: string | undefined; + + /** + *

The message describing why the field failed validation.

+ * @public + */ + message: string | undefined; +} + +/** + * @public + * @enum + */ +export const ValidationExceptionReason = { + CANNOT_PARSE: "cannotParse", + FIELD_VALIDATION_FAILED: "fieldValidationFailed", + OTHER: "other", + UNKNOWN_OPERATION: "unknownOperation", +} as const; + +/** + * @public + */ +export type ValidationExceptionReason = (typeof ValidationExceptionReason)[keyof typeof ValidationExceptionReason]; + +/** + *

The input fails to satisfy the constraints specified by an Amazon Web Services service. + *

+ * @public + */ +export class ValidationException extends __BaseException { + readonly name: "ValidationException" = "ValidationException"; + readonly $fault: "client" = "client"; + /** + *

The input fails to satisfy the constraints specified by an Amazon Web Services service.

+ * @public + */ + reason: ValidationExceptionReason | undefined; + + /** + *

The input fails to satisfy the constraints specified by an Amazon Web Services service.

+ * @public + */ + fieldList?: ValidationExceptionField[] | undefined; + + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + super({ + name: "ValidationException", + $fault: "client", + ...opts, + }); + Object.setPrototypeOf(this, ValidationException.prototype); + this.reason = opts.reason; + this.fieldList = opts.fieldList; + } +} + +/** + * @internal + */ +export const BillingViewListElementFilterSensitiveLog = (obj: BillingViewListElement): any => ({ + ...obj, + ...(obj.name && { name: SENSITIVE_STRING }), +}); + +/** + * @internal + */ +export const ListBillingViewsResponseFilterSensitiveLog = (obj: ListBillingViewsResponse): any => ({ + ...obj, + ...(obj.billingViews && { + billingViews: obj.billingViews.map((item) => BillingViewListElementFilterSensitiveLog(item)), + }), +}); diff --git a/clients/client-billing/src/pagination/Interfaces.ts b/clients/client-billing/src/pagination/Interfaces.ts new file mode 100644 index 000000000000..bfdb4991ccfc --- /dev/null +++ b/clients/client-billing/src/pagination/Interfaces.ts @@ -0,0 +1,11 @@ +// smithy-typescript generated code +import { PaginationConfiguration } from "@smithy/types"; + +import { BillingClient } from "../BillingClient"; + +/** + * @public + */ +export interface BillingPaginationConfiguration extends PaginationConfiguration { + client: BillingClient; +} diff --git a/clients/client-billing/src/pagination/ListBillingViewsPaginator.ts b/clients/client-billing/src/pagination/ListBillingViewsPaginator.ts new file mode 100644 index 000000000000..b924479a9824 --- /dev/null +++ b/clients/client-billing/src/pagination/ListBillingViewsPaginator.ts @@ -0,0 +1,24 @@ +// smithy-typescript generated code +import { createPaginator } from "@smithy/core"; +import { Paginator } from "@smithy/types"; + +import { BillingClient } from "../BillingClient"; +import { + ListBillingViewsCommand, + ListBillingViewsCommandInput, + ListBillingViewsCommandOutput, +} from "../commands/ListBillingViewsCommand"; +import { BillingPaginationConfiguration } from "./Interfaces"; + +/** + * @public + */ +export const paginateListBillingViews: ( + config: BillingPaginationConfiguration, + input: ListBillingViewsCommandInput, + ...rest: any[] +) => Paginator = createPaginator< + BillingPaginationConfiguration, + ListBillingViewsCommandInput, + ListBillingViewsCommandOutput +>(BillingClient, ListBillingViewsCommand, "nextToken", "nextToken", "maxResults"); diff --git a/clients/client-billing/src/pagination/index.ts b/clients/client-billing/src/pagination/index.ts new file mode 100644 index 000000000000..d1f711072390 --- /dev/null +++ b/clients/client-billing/src/pagination/index.ts @@ -0,0 +1,3 @@ +// smithy-typescript generated code +export * from "./Interfaces"; +export * from "./ListBillingViewsPaginator"; diff --git a/clients/client-billing/src/protocols/Aws_json1_0.ts b/clients/client-billing/src/protocols/Aws_json1_0.ts new file mode 100644 index 000000000000..4f57ca022dc8 --- /dev/null +++ b/clients/client-billing/src/protocols/Aws_json1_0.ts @@ -0,0 +1,233 @@ +// smithy-typescript generated code +import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { + _json, + collectBody, + decorateServiceException as __decorateServiceException, + take, + withBaseException, +} from "@smithy/smithy-client"; +import { + Endpoint as __Endpoint, + HeaderBag as __HeaderBag, + ResponseMetadata as __ResponseMetadata, + SerdeContext as __SerdeContext, +} from "@smithy/types"; + +import { ListBillingViewsCommandInput, ListBillingViewsCommandOutput } from "../commands/ListBillingViewsCommand"; +import { BillingServiceException as __BaseException } from "../models/BillingServiceException"; +import { + AccessDeniedException, + ActiveTimeRange, + InternalServerException, + ListBillingViewsRequest, + ThrottlingException, + ValidationException, +} from "../models/models_0"; + +/** + * serializeAws_json1_0ListBillingViewsCommand + */ +export const se_ListBillingViewsCommand = async ( + input: ListBillingViewsCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const headers: __HeaderBag = sharedHeaders("ListBillingViews"); + let body: any; + body = JSON.stringify(se_ListBillingViewsRequest(input, context)); + return buildHttpRpcRequest(context, headers, "/", undefined, body); +}; + +/** + * deserializeAws_json1_0ListBillingViewsCommand + */ +export const de_ListBillingViewsCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode >= 300) { + return de_CommandError(output, context); + } + const data: any = await parseBody(output.body, context); + let contents: any = {}; + contents = _json(data); + const response: ListBillingViewsCommandOutput = { + $metadata: deserializeMetadata(output), + ...contents, + }; + return response; +}; + +/** + * deserialize_Aws_json1_0CommandError + */ +const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseErrorBody(output.body, context), + }; + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "AccessDeniedException": + case "com.amazonaws.billing#AccessDeniedException": + throw await de_AccessDeniedExceptionRes(parsedOutput, context); + case "InternalServerException": + case "com.amazonaws.billing#InternalServerException": + throw await de_InternalServerExceptionRes(parsedOutput, context); + case "ThrottlingException": + case "com.amazonaws.billing#ThrottlingException": + throw await de_ThrottlingExceptionRes(parsedOutput, context); + case "ValidationException": + case "com.amazonaws.billing#ValidationException": + throw await de_ValidationExceptionRes(parsedOutput, context); + default: + const parsedBody = parsedOutput.body; + return throwDefaultError({ + output, + parsedBody, + errorCode, + }) as never; + } +}; + +/** + * deserializeAws_json1_0AccessDeniedExceptionRes + */ +const de_AccessDeniedExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const body = parsedOutput.body; + const deserialized: any = _json(body); + const exception = new AccessDeniedException({ + $metadata: deserializeMetadata(parsedOutput), + ...deserialized, + }); + return __decorateServiceException(exception, body); +}; + +/** + * deserializeAws_json1_0InternalServerExceptionRes + */ +const de_InternalServerExceptionRes = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const body = parsedOutput.body; + const deserialized: any = _json(body); + const exception = new InternalServerException({ + $metadata: deserializeMetadata(parsedOutput), + ...deserialized, + }); + return __decorateServiceException(exception, body); +}; + +/** + * deserializeAws_json1_0ThrottlingExceptionRes + */ +const de_ThrottlingExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { + const body = parsedOutput.body; + const deserialized: any = _json(body); + const exception = new ThrottlingException({ + $metadata: deserializeMetadata(parsedOutput), + ...deserialized, + }); + return __decorateServiceException(exception, body); +}; + +/** + * deserializeAws_json1_0ValidationExceptionRes + */ +const de_ValidationExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { + const body = parsedOutput.body; + const deserialized: any = _json(body); + const exception = new ValidationException({ + $metadata: deserializeMetadata(parsedOutput), + ...deserialized, + }); + return __decorateServiceException(exception, body); +}; + +/** + * serializeAws_json1_0ActiveTimeRange + */ +const se_ActiveTimeRange = (input: ActiveTimeRange, context: __SerdeContext): any => { + return take(input, { + activeAfterInclusive: (_) => _.getTime() / 1_000, + activeBeforeInclusive: (_) => _.getTime() / 1_000, + }); +}; + +/** + * serializeAws_json1_0ListBillingViewsRequest + */ +const se_ListBillingViewsRequest = (input: ListBillingViewsRequest, context: __SerdeContext): any => { + return take(input, { + activeTimeRange: (_) => se_ActiveTimeRange(_, context), + maxResults: [], + nextToken: [], + }); +}; + +// de_AccessDeniedException omitted. + +// de_BillingViewList omitted. + +// de_BillingViewListElement omitted. + +// de_InternalServerException omitted. + +// de_ListBillingViewsResponse omitted. + +// de_ThrottlingException omitted. + +// de_ValidationException omitted. + +// de_ValidationExceptionField omitted. + +// de_ValidationExceptionFieldList omitted. + +const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({ + httpStatusCode: output.statusCode, + requestId: + output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"], + extendedRequestId: output.headers["x-amz-id-2"], + cfId: output.headers["x-amz-cf-id"], +}); + +// Encode Uint8Array data into string with utf-8. +const collectBodyString = (streamBody: any, context: __SerdeContext): Promise => + collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); + +const throwDefaultError = withBaseException(__BaseException); +const buildHttpRpcRequest = async ( + context: __SerdeContext, + headers: __HeaderBag, + path: string, + resolvedHostname: string | undefined, + body: any +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const contents: any = { + protocol, + hostname, + port, + method: "POST", + path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path, + headers, + }; + if (resolvedHostname !== undefined) { + contents.hostname = resolvedHostname; + } + if (body !== undefined) { + contents.body = body; + } + return new __HttpRequest(contents); +}; +function sharedHeaders(operation: string): __HeaderBag { + return { + "content-type": "application/x-amz-json-1.0", + "x-amz-target": `AWSBilling.${operation}`, + }; +} diff --git a/clients/client-billing/src/runtimeConfig.browser.ts b/clients/client-billing/src/runtimeConfig.browser.ts new file mode 100644 index 000000000000..c7030c5ddfa1 --- /dev/null +++ b/clients/client-billing/src/runtimeConfig.browser.ts @@ -0,0 +1,44 @@ +// smithy-typescript generated code +// @ts-ignore: package.json will be imported from dist folders +import packageInfo from "../package.json"; // eslint-disable-line + +import { Sha256 } from "@aws-crypto/sha256-browser"; +import { createDefaultUserAgentProvider } from "@aws-sdk/util-user-agent-browser"; +import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver"; +import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler"; +import { invalidProvider } from "@smithy/invalid-dependency"; +import { calculateBodyLength } from "@smithy/util-body-length-browser"; +import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry"; +import { BillingClientConfig } from "./BillingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; +import { loadConfigsForDefaultMode } from "@smithy/smithy-client"; +import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-browser"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BillingClientConfig) => { + const defaultsMode = resolveDefaultsModeConfig(config); + const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode); + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + defaultsMode, + bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config?.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config?.defaultUserAgentProvider ?? + createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config?.region ?? invalidProvider("Region is missing"), + requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider), + retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sha256: config?.sha256 ?? Sha256, + streamCollector: config?.streamCollector ?? streamCollector, + useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), + useFipsEndpoint: config?.useFipsEndpoint ?? (() => Promise.resolve(DEFAULT_USE_FIPS_ENDPOINT)), + }; +}; diff --git a/clients/client-billing/src/runtimeConfig.native.ts b/clients/client-billing/src/runtimeConfig.native.ts new file mode 100644 index 000000000000..28df9fcf46e8 --- /dev/null +++ b/clients/client-billing/src/runtimeConfig.native.ts @@ -0,0 +1,18 @@ +// smithy-typescript generated code +import { Sha256 } from "@aws-crypto/sha256-js"; + +import { BillingClientConfig } from "./BillingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BillingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config?.sha256 ?? Sha256, + }; +}; diff --git a/clients/client-billing/src/runtimeConfig.shared.ts b/clients/client-billing/src/runtimeConfig.shared.ts new file mode 100644 index 000000000000..c6cf9f2d8cdf --- /dev/null +++ b/clients/client-billing/src/runtimeConfig.shared.ts @@ -0,0 +1,38 @@ +// smithy-typescript generated code +import { AwsSdkSigV4Signer } from "@aws-sdk/core"; +import { NoOpLogger } from "@smithy/smithy-client"; +import { IdentityProviderConfig } from "@smithy/types"; +import { parseUrl } from "@smithy/url-parser"; +import { fromBase64, toBase64 } from "@smithy/util-base64"; +import { fromUtf8, toUtf8 } from "@smithy/util-utf8"; + +import { defaultBillingHttpAuthSchemeProvider } from "./auth/httpAuthSchemeProvider"; +import { BillingClientConfig } from "./BillingClient"; +import { defaultEndpointResolver } from "./endpoint/endpointResolver"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BillingClientConfig) => { + return { + apiVersion: "2023-09-07", + base64Decoder: config?.base64Decoder ?? fromBase64, + base64Encoder: config?.base64Encoder ?? toBase64, + disableHostPrefix: config?.disableHostPrefix ?? false, + endpointProvider: config?.endpointProvider ?? defaultEndpointResolver, + extensions: config?.extensions ?? [], + httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultBillingHttpAuthSchemeProvider, + httpAuthSchemes: config?.httpAuthSchemes ?? [ + { + schemeId: "aws.auth#sigv4", + identityProvider: (ipc: IdentityProviderConfig) => ipc.getIdentityProvider("aws.auth#sigv4"), + signer: new AwsSdkSigV4Signer(), + }, + ], + logger: config?.logger ?? new NoOpLogger(), + serviceId: config?.serviceId ?? "Billing", + urlParser: config?.urlParser ?? parseUrl, + utf8Decoder: config?.utf8Decoder ?? fromUtf8, + utf8Encoder: config?.utf8Encoder ?? toUtf8, + }; +}; diff --git a/clients/client-billing/src/runtimeConfig.ts b/clients/client-billing/src/runtimeConfig.ts new file mode 100644 index 000000000000..ecad54238bb5 --- /dev/null +++ b/clients/client-billing/src/runtimeConfig.ts @@ -0,0 +1,60 @@ +// smithy-typescript generated code +// @ts-ignore: package.json will be imported from dist folders +import packageInfo from "../package.json"; // eslint-disable-line + +import { emitWarningIfUnsupportedVersion as awsCheckVersion } from "@aws-sdk/core"; +import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node"; +import { NODE_APP_ID_CONFIG_OPTIONS, createDefaultUserAgentProvider } from "@aws-sdk/util-user-agent-node"; +import { + NODE_REGION_CONFIG_FILE_OPTIONS, + NODE_REGION_CONFIG_OPTIONS, + NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, + NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, +} from "@smithy/config-resolver"; +import { Hash } from "@smithy/hash-node"; +import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry"; +import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider"; +import { NodeHttpHandler as RequestHandler, streamCollector } from "@smithy/node-http-handler"; +import { calculateBodyLength } from "@smithy/util-body-length-node"; +import { DEFAULT_RETRY_MODE } from "@smithy/util-retry"; +import { BillingClientConfig } from "./BillingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; +import { loadConfigsForDefaultMode } from "@smithy/smithy-client"; +import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-node"; +import { emitWarningIfUnsupportedVersion } from "@smithy/smithy-client"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: BillingClientConfig) => { + emitWarningIfUnsupportedVersion(process.version); + const defaultsMode = resolveDefaultsModeConfig(config); + const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode); + const clientSharedValues = getSharedRuntimeConfig(config); + awsCheckVersion(process.version); + return { + ...clientSharedValues, + ...config, + runtime: "node", + defaultsMode, + bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: config?.credentialDefaultProvider ?? credentialDefaultProvider, + defaultUserAgentProvider: + config?.defaultUserAgentProvider ?? + createDefaultUserAgentProvider({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider), + retryMode: + config?.retryMode ?? + loadNodeConfig({ + ...NODE_RETRY_MODE_CONFIG_OPTIONS, + default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, + }), + sha256: config?.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config?.streamCollector ?? streamCollector, + useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), + useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS), + userAgentAppId: config?.userAgentAppId ?? loadNodeConfig(NODE_APP_ID_CONFIG_OPTIONS), + }; +}; diff --git a/clients/client-billing/src/runtimeExtensions.ts b/clients/client-billing/src/runtimeExtensions.ts new file mode 100644 index 000000000000..c6d822c2aae4 --- /dev/null +++ b/clients/client-billing/src/runtimeExtensions.ts @@ -0,0 +1,48 @@ +// smithy-typescript generated code +import { + getAwsRegionExtensionConfiguration, + resolveAwsRegionExtensionConfiguration, +} from "@aws-sdk/region-config-resolver"; +import { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig } from "@smithy/protocol-http"; +import { getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig } from "@smithy/smithy-client"; + +import { getHttpAuthExtensionConfiguration, resolveHttpAuthRuntimeConfig } from "./auth/httpAuthExtensionConfiguration"; +import { BillingExtensionConfiguration } from "./extensionConfiguration"; + +/** + * @public + */ +export interface RuntimeExtension { + configure(extensionConfiguration: BillingExtensionConfiguration): void; +} + +/** + * @public + */ +export interface RuntimeExtensionsConfig { + extensions: RuntimeExtension[]; +} + +const asPartial = >(t: T) => t; + +/** + * @internal + */ +export const resolveRuntimeExtensions = (runtimeConfig: any, extensions: RuntimeExtension[]) => { + const extensionConfiguration: BillingExtensionConfiguration = { + ...asPartial(getAwsRegionExtensionConfiguration(runtimeConfig)), + ...asPartial(getDefaultExtensionConfiguration(runtimeConfig)), + ...asPartial(getHttpHandlerExtensionConfiguration(runtimeConfig)), + ...asPartial(getHttpAuthExtensionConfiguration(runtimeConfig)), + }; + + extensions.forEach((extension) => extension.configure(extensionConfiguration)); + + return { + ...runtimeConfig, + ...resolveAwsRegionExtensionConfiguration(extensionConfiguration), + ...resolveDefaultRuntimeConfig(extensionConfiguration), + ...resolveHttpHandlerRuntimeConfig(extensionConfiguration), + ...resolveHttpAuthRuntimeConfig(extensionConfiguration), + }; +}; diff --git a/clients/client-billing/tsconfig.cjs.json b/clients/client-billing/tsconfig.cjs.json new file mode 100644 index 000000000000..3567d85ba846 --- /dev/null +++ b/clients/client-billing/tsconfig.cjs.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "outDir": "dist-cjs" + } +} diff --git a/clients/client-billing/tsconfig.es.json b/clients/client-billing/tsconfig.es.json new file mode 100644 index 000000000000..809f57bde65e --- /dev/null +++ b/clients/client-billing/tsconfig.es.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "lib": ["dom"], + "module": "esnext", + "outDir": "dist-es" + } +} diff --git a/clients/client-billing/tsconfig.json b/clients/client-billing/tsconfig.json new file mode 100644 index 000000000000..e7f5ec56b742 --- /dev/null +++ b/clients/client-billing/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "@tsconfig/node16/tsconfig.json", + "compilerOptions": { + "downlevelIteration": true, + "importHelpers": true, + "incremental": true, + "removeComments": true, + "resolveJsonModule": true, + "rootDir": "src", + "useUnknownInCatchVariables": false + }, + "exclude": ["test/"] +} diff --git a/clients/client-billing/tsconfig.types.json b/clients/client-billing/tsconfig.types.json new file mode 100644 index 000000000000..4c3dfa7b3d25 --- /dev/null +++ b/clients/client-billing/tsconfig.types.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "removeComments": false, + "declaration": true, + "declarationDir": "dist-types", + "emitDeclarationOnly": true + }, + "exclude": ["test/**/*", "dist-types/**/*"] +} diff --git a/codegen/sdk-codegen/aws-models/billing.json b/codegen/sdk-codegen/aws-models/billing.json new file mode 100644 index 000000000000..be21ab25ef2a --- /dev/null +++ b/codegen/sdk-codegen/aws-models/billing.json @@ -0,0 +1,918 @@ +{ + "smithy": "2.0", + "shapes": { + "com.amazonaws.billing#AWSBilling": { + "type": "service", + "version": "2023-09-07", + "operations": [ + { + "target": "com.amazonaws.billing#ListBillingViews" + } + ], + "traits": { + "aws.api#service": { + "sdkId": "Billing", + "endpointPrefix": "billing", + "arnNamespace": "billing", + "cloudTrailEventSource": "billing.amazonaws.com" + }, + "aws.auth#sigv4": { + "name": "billing" + }, + "aws.endpoints#dualStackOnlyEndpoints": {}, + "aws.endpoints#standardPartitionalEndpoints": { + "endpointPatternType": "service_region_dnsSuffix" + }, + "aws.protocols#awsJson1_0": {}, + "smithy.api#documentation": "

\n You can use the Billing API to programatically list the billing views available to you for a given time period. A billing view represents a set of billing data.\n

\n

The Billing API provides the following endpoint:

\n

\n https://billing.us-east-1.api.aws\n

", + "smithy.api#title": "AWS Billing", + "smithy.rules#endpointRuleSet": { + "version": "1.0", + "parameters": { + "UseFIPS": { + "builtIn": "AWS::UseFIPS", + "required": true, + "default": false, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "Boolean" + }, + "Endpoint": { + "builtIn": "SDK::Endpoint", + "required": false, + "documentation": "Override the endpoint used to send this request", + "type": "String" + }, + "Region": { + "builtIn": "AWS::Region", + "required": false, + "documentation": "The AWS region used to dispatch the request.", + "type": "String" + } + }, + "rules": [ + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Endpoint" + } + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "error": "Invalid Configuration: FIPS and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [], + "endpoint": { + "url": { + "ref": "Endpoint" + }, + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + }, + { + "conditions": [], + "rules": [ + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Region" + } + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "aws.partition", + "argv": [ + { + "ref": "Region" + } + ], + "assign": "PartitionResult" + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "endpoint": { + "url": "https://billing-fips.{PartitionResult#implicitGlobalRegion}.{PartitionResult#dualStackDnsSuffix}", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{PartitionResult#implicitGlobalRegion}" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + }, + { + "conditions": [], + "endpoint": { + "url": "https://billing.{PartitionResult#implicitGlobalRegion}.{PartitionResult#dualStackDnsSuffix}", + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "{PartitionResult#implicitGlobalRegion}" + } + ] + }, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "Invalid Configuration: Missing Region", + "type": "error" + } + ], + "type": "tree" + } + ] + }, + "smithy.rules#endpointTests": { + "testCases": [ + { + "documentation": "For custom endpoint with region not set and fips disabled", + "expect": { + "endpoint": { + "url": "https://example.com" + } + }, + "params": { + "Endpoint": "https://example.com", + "UseFIPS": false + } + }, + { + "documentation": "For custom endpoint with fips enabled", + "expect": { + "error": "Invalid Configuration: FIPS and custom endpoint are not supported" + }, + "params": { + "Endpoint": "https://example.com", + "UseFIPS": true + } + }, + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-east-1" + } + ] + }, + "url": "https://billing-fips.us-east-1.api.aws" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true + } + }, + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-east-1" + } + ] + }, + "url": "https://billing.us-east-1.api.aws" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false + } + }, + { + "documentation": "For region cn-northwest-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "cn-northwest-1" + } + ] + }, + "url": "https://billing-fips.cn-northwest-1.api.amazonwebservices.com.cn" + } + }, + "params": { + "Region": "cn-northwest-1", + "UseFIPS": true + } + }, + { + "documentation": "For region cn-northwest-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "cn-northwest-1" + } + ] + }, + "url": "https://billing.cn-northwest-1.api.amazonwebservices.com.cn" + } + }, + "params": { + "Region": "cn-northwest-1", + "UseFIPS": false + } + }, + { + "documentation": "For region us-gov-west-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-gov-west-1" + } + ] + }, + "url": "https://billing-fips.us-gov-west-1.api.aws" + } + }, + "params": { + "Region": "us-gov-west-1", + "UseFIPS": true + } + }, + { + "documentation": "For region us-gov-west-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-gov-west-1" + } + ] + }, + "url": "https://billing.us-gov-west-1.api.aws" + } + }, + "params": { + "Region": "us-gov-west-1", + "UseFIPS": false + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-iso-east-1" + } + ] + }, + "url": "https://billing-fips.us-iso-east-1.c2s.ic.gov" + } + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": true + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-iso-east-1" + } + ] + }, + "url": "https://billing.us-iso-east-1.c2s.ic.gov" + } + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": false + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-isob-east-1" + } + ] + }, + "url": "https://billing-fips.us-isob-east-1.sc2s.sgov.gov" + } + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": true + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-isob-east-1" + } + ] + }, + "url": "https://billing.us-isob-east-1.sc2s.sgov.gov" + } + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": false + } + }, + { + "documentation": "For region eu-isoe-west-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "eu-isoe-west-1" + } + ] + }, + "url": "https://billing-fips.eu-isoe-west-1.cloud.adc-e.uk" + } + }, + "params": { + "Region": "eu-isoe-west-1", + "UseFIPS": true + } + }, + { + "documentation": "For region eu-isoe-west-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "eu-isoe-west-1" + } + ] + }, + "url": "https://billing.eu-isoe-west-1.cloud.adc-e.uk" + } + }, + "params": { + "Region": "eu-isoe-west-1", + "UseFIPS": false + } + }, + { + "documentation": "For region us-isof-south-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-isof-south-1" + } + ] + }, + "url": "https://billing-fips.us-isof-south-1.csp.hci.ic.gov" + } + }, + "params": { + "Region": "us-isof-south-1", + "UseFIPS": true + } + }, + { + "documentation": "For region us-isof-south-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "properties": { + "authSchemes": [ + { + "name": "sigv4", + "signingRegion": "us-isof-south-1" + } + ] + }, + "url": "https://billing.us-isof-south-1.csp.hci.ic.gov" + } + }, + "params": { + "Region": "us-isof-south-1", + "UseFIPS": false + } + }, + { + "documentation": "Missing region", + "expect": { + "error": "Invalid Configuration: Missing Region" + } + } + ], + "version": "1.0" + } + } + }, + "com.amazonaws.billing#AccessDeniedException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.billing#ErrorMessage", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "aws.protocols#awsQueryError": { + "code": "BillingAccessDenied", + "httpResponseCode": 403 + }, + "smithy.api#documentation": "

You don't have sufficient access to perform this action.

", + "smithy.api#error": "client", + "smithy.api#httpError": 403 + } + }, + "com.amazonaws.billing#AccountId": { + "type": "string", + "traits": { + "smithy.api#pattern": "^[0-9]{12}$" + } + }, + "com.amazonaws.billing#ActiveTimeRange": { + "type": "structure", + "members": { + "activeAfterInclusive": { + "target": "smithy.api#Timestamp", + "traits": { + "smithy.api#documentation": "

The inclusive time range start date.

", + "smithy.api#required": {} + } + }, + "activeBeforeInclusive": { + "target": "smithy.api#Timestamp", + "traits": { + "smithy.api#documentation": "

\n The inclusive time range end date.\n

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

A time range with a start and end time.

" + } + }, + "com.amazonaws.billing#BillingViewArn": { + "type": "string", + "traits": { + "smithy.api#pattern": "^arn:aws[a-z-]*:(billing)::[0-9]{12}:billingview/[a-zA-Z0-9_\\+=\\.\\-@]{1,43}$" + } + }, + "com.amazonaws.billing#BillingViewList": { + "type": "list", + "member": { + "target": "com.amazonaws.billing#BillingViewListElement" + } + }, + "com.amazonaws.billing#BillingViewListElement": { + "type": "structure", + "members": { + "arn": { + "target": "com.amazonaws.billing#BillingViewArn", + "traits": { + "smithy.api#documentation": "

The Amazon Resource Name (ARN) that can be used to uniquely identify the billing view.\n

" + } + }, + "name": { + "target": "com.amazonaws.billing#BillingViewName", + "traits": { + "smithy.api#documentation": "

\n A list of names of the Billing view.\n

" + } + }, + "ownerAccountId": { + "target": "com.amazonaws.billing#AccountId", + "traits": { + "smithy.api#documentation": "

\n The list of owners of the Billing view.\n

" + } + }, + "billingViewType": { + "target": "com.amazonaws.billing#BillingViewType", + "traits": { + "smithy.api#documentation": "

The type of billing view.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

A representation of a billing view.

" + } + }, + "com.amazonaws.billing#BillingViewName": { + "type": "string", + "traits": { + "smithy.api#pattern": "^[ a-zA-Z0-9_\\+=\\.\\-@]+$", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.billing#BillingViewType": { + "type": "enum", + "members": { + "PRIMARY": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "PRIMARY" + } + }, + "BILLING_GROUP": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "BILLING_GROUP" + } + } + } + }, + "com.amazonaws.billing#BillingViewsMaxResults": { + "type": "integer", + "traits": { + "smithy.api#range": { + "min": 1, + "max": 100 + } + } + }, + "com.amazonaws.billing#ErrorMessage": { + "type": "string", + "traits": { + "smithy.api#length": { + "max": 1024 + } + } + }, + "com.amazonaws.billing#FieldName": { + "type": "string", + "traits": { + "smithy.api#length": { + "max": 100 + } + } + }, + "com.amazonaws.billing#InternalServerException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.billing#ErrorMessage", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "aws.protocols#awsQueryError": { + "code": "BillingInternalServer", + "httpResponseCode": 500 + }, + "smithy.api#documentation": "

The request processing failed because of an unknown error, exception, or failure.\n

", + "smithy.api#error": "server", + "smithy.api#httpError": 500 + } + }, + "com.amazonaws.billing#ListBillingViews": { + "type": "operation", + "input": { + "target": "com.amazonaws.billing#ListBillingViewsRequest" + }, + "output": { + "target": "com.amazonaws.billing#ListBillingViewsResponse" + }, + "errors": [ + { + "target": "com.amazonaws.billing#AccessDeniedException" + }, + { + "target": "com.amazonaws.billing#InternalServerException" + }, + { + "target": "com.amazonaws.billing#ThrottlingException" + }, + { + "target": "com.amazonaws.billing#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

Lists the billing views available for a given time period.\n

\n

Every Amazon Web Services account has a unique PRIMARY billing view that represents the billing data available by default. Accounts that use Billing Conductor also have BILLING_GROUP billing views representing pro forma costs associated with each created billing group.

", + "smithy.api#examples": [ + { + "title": "Invoke ListBillingViews", + "input": { + "activeTimeRange": { + "activeAfterInclusive": 1719792000, + "activeBeforeInclusive": 1.722470399999e9 + } + }, + "output": { + "billingViews": [ + { + "arn": "arn:aws:billing::123456789101:billingview/primary", + "billingViewType": "PRIMARY", + "name": "Primary Billing View Account 123456789101", + "ownerAccountId": "123456789101" + } + ] + } + }, + { + "title": "Error example for ListBillingViews", + "input": { + "activeTimeRange": { + "activeAfterInclusive": 1719792001, + "activeBeforeInclusive": 1719792000 + } + }, + "error": { + "shapeId": "com.amazonaws.billing#ValidationException", + "content": { + "message": "Failed to get billing view data for an invalid time range.", + "reason": "other" + } + }, + "allowConstraintErrors": true + } + ], + "smithy.api#http": { + "method": "POST", + "uri": "/", + "code": 200 + }, + "smithy.api#paginated": { + "inputToken": "nextToken", + "outputToken": "nextToken", + "pageSize": "maxResults", + "items": "billingViews" + }, + "smithy.api#readonly": {}, + "smithy.test#smokeTests": [ + { + "id": "ListBillingViewsSuccess", + "params": { + "activeTimeRange": { + "activeAfterInclusive": 1719792000, + "activeBeforeInclusive": 1.722470399999e9 + } + }, + "expect": { + "success": {} + }, + "vendorParamsShape": "aws.test#AwsVendorParams", + "vendorParams": { + "region": "us-east-1" + } + } + ] + } + }, + "com.amazonaws.billing#ListBillingViewsRequest": { + "type": "structure", + "members": { + "activeTimeRange": { + "target": "com.amazonaws.billing#ActiveTimeRange", + "traits": { + "smithy.api#documentation": "

\n The time range for the billing views listed. PRIMARY billing view is always listed. BILLING_GROUP billing views are listed for time ranges when the associated billing group resource in Billing Conductor is active. The time range must be within one calendar month.\n

", + "smithy.api#required": {} + } + }, + "maxResults": { + "target": "com.amazonaws.billing#BillingViewsMaxResults", + "traits": { + "smithy.api#documentation": "

The maximum number of billing views to retrieve. Default is 100.\n

" + } + }, + "nextToken": { + "target": "com.amazonaws.billing#PageToken", + "traits": { + "smithy.api#documentation": "

The pagination token that is used on subsequent calls to list billing views.

" + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.billing#ListBillingViewsResponse": { + "type": "structure", + "members": { + "billingViews": { + "target": "com.amazonaws.billing#BillingViewList", + "traits": { + "smithy.api#documentation": "

A list of BillingViewListElement retrieved.

", + "smithy.api#required": {} + } + }, + "nextToken": { + "target": "com.amazonaws.billing#PageToken", + "traits": { + "smithy.api#documentation": "

The pagination token to use on subsequent calls to list billing views.\n

" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.billing#PageToken": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 2047 + } + } + }, + "com.amazonaws.billing#ThrottlingException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.billing#ErrorMessage", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "aws.protocols#awsQueryError": { + "code": "BillingThrottling", + "httpResponseCode": 429 + }, + "smithy.api#documentation": "

The request was denied due to request throttling.\n

", + "smithy.api#error": "client", + "smithy.api#httpError": 429 + } + }, + "com.amazonaws.billing#ValidationException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.billing#ErrorMessage", + "traits": { + "smithy.api#required": {} + } + }, + "reason": { + "target": "com.amazonaws.billing#ValidationExceptionReason", + "traits": { + "smithy.api#documentation": "

The input fails to satisfy the constraints specified by an Amazon Web Services service.

", + "smithy.api#required": {} + } + }, + "fieldList": { + "target": "com.amazonaws.billing#ValidationExceptionFieldList", + "traits": { + "smithy.api#documentation": "

The input fails to satisfy the constraints specified by an Amazon Web Services service.

" + } + } + }, + "traits": { + "aws.protocols#awsQueryError": { + "code": "BillingValidation", + "httpResponseCode": 400 + }, + "smithy.api#documentation": "

The input fails to satisfy the constraints specified by an Amazon Web Services service.\n

", + "smithy.api#error": "client", + "smithy.api#httpError": 400 + } + }, + "com.amazonaws.billing#ValidationExceptionField": { + "type": "structure", + "members": { + "name": { + "target": "com.amazonaws.billing#FieldName", + "traits": { + "smithy.api#documentation": "

The name of the field.

", + "smithy.api#required": {} + } + }, + "message": { + "target": "com.amazonaws.billing#ErrorMessage", + "traits": { + "smithy.api#documentation": "

The message describing why the field failed validation.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

The field's information of a request that resulted in an exception.\n

" + } + }, + "com.amazonaws.billing#ValidationExceptionFieldList": { + "type": "list", + "member": { + "target": "com.amazonaws.billing#ValidationExceptionField" + } + }, + "com.amazonaws.billing#ValidationExceptionReason": { + "type": "enum", + "members": { + "UNKNOWN_OPERATION": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "unknownOperation" + } + }, + "CANNOT_PARSE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "cannotParse" + } + }, + "FIELD_VALIDATION_FAILED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "fieldValidationFailed" + } + }, + "OTHER": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "other" + } + } + } + } + } +}