Back to Aws Sdk Js V3

@aws-sdk/client-marketplace-reporting

clients/client-marketplace-reporting/README.md

3.1044.09.7 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-marketplace-reporting

Description

AWS SDK for JavaScript MarketplaceReporting Client for Node.js, Browser and React Native.

<p>The Amazon Web Services Marketplace <code>GetBuyerDashboard</code> API enables you to get a procurement insights dashboard programmatically. The API gets the agreement and cost analysis dashboards with data for all of the Amazon Web Services accounts in your Amazon Web Services Organization. </p> <p>To use the Amazon Web Services Marketplace Reporting API, you must complete the following prerequisites:</p> <ul> <li> <p>Enable all features for your organization. For more information, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html">Enabling all features for an organization with Organizations</a>, in the <i>Organizations User Guide</i>.</p> </li> <li> <p>Call the service as the Organizations management account or an account registered as a delegated administrator for the procurement insights service.</p> <p>For more information about management accounts, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_tutorials_basic.html">Tutorial: Creating and configuring an organization</a> and <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs-manage_accounts_management.html">Managing the management account with Organizations</a>, both in the <i>Organizations User Guide</i>.</p> <p>For more information about delegated administrators, see <a href="https://docs.aws.amazon.com/marketplace/latest/buyerguide/management-delegates.html">Using delegated administrators</a>, in the <i>Amazon Web Services Marketplace Buyer Guide</i>.</p> </li> <li> <p>Create an IAM policy that enables the <code>aws-marketplace:GetBuyerDashboard</code> and <code>organizations:DescribeOrganization</code> permissions. In addition, the management account requires the <code>organizations:EnableAWSServiceAccess</code> and <code>iam:CreateServiceLinkedRole</code> permissions to create. For more information about creating the policy, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html">Policies and permissions in Identity and Access Management</a>, in the <i>IAM User Guide</i>.</p> <note> <p>Access can be shared only by registering the desired linked account as a delegated administrator. That requires <code>organizations:RegisterDelegatedAdministrator</code> <code>organizations:ListDelegatedAdministrators</code> and <code>organizations:DeregisterDelegatedAdministrator</code> permissions.</p> </note> </li> <li> <p>Use the Amazon Web Services Marketplace console to create the <code>AWSServiceRoleForProcurementInsightsPolicy</code> service-linked role. The role enables Amazon Web Services Marketplace procurement visibility integration. The management account requires an IAM policy with the <code>organizations:EnableAWSServiceAccess</code> and <code>iam:CreateServiceLinkedRole</code> permissions to create the service-linked role and enable the service access. For more information, see <a href="https://docs.aws.amazon.com/marketplace/latest/buyerguide/orgs-access-slr.html">Granting access to Organizations</a> and <a href="https://docs.aws.amazon.com/marketplace/latest/buyerguide/buyer-service-linked-role-procurement.html">Service-linked role to share procurement data</a> in the <i>Amazon Web Services Marketplace Buyer Guide</i>.</p> </li> <li> <p>After creating the service-linked role, you must enable trusted access that grants Amazon Web Services Marketplace permission to access data from your Organizations. For more information, see <a href="https://docs.aws.amazon.com/marketplace/latest/buyerguide/orgs-access-slr.html">Granting access to Organizations</a> in the <i>Amazon Web Services Marketplace Buyer Guide</i>.</p> </li> </ul>

Installing

To install this package, use the CLI of your favorite package manager:

  • npm install @aws-sdk/client-marketplace-reporting
  • yarn add @aws-sdk/client-marketplace-reporting
  • pnpm add @aws-sdk/client-marketplace-reporting

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the MarketplaceReportingClient and the commands you need, for example GetBuyerDashboardCommand:

js
// ES5 example
const { MarketplaceReportingClient, GetBuyerDashboardCommand } = require("@aws-sdk/client-marketplace-reporting");
ts
// ES6+ example
import { MarketplaceReportingClient, GetBuyerDashboardCommand } from "@aws-sdk/client-marketplace-reporting";

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new MarketplaceReportingClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new GetBuyerDashboardCommand(params);

Async/await

We recommend using the 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.
}

Promises

You can also use Promise chaining.

js
client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

MarketplaceReporting extends MarketplaceReportingClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (MarketplaceReportingClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { MarketplaceReporting } from "@aws-sdk/client-marketplace-reporting";

const client = new MarketplaceReporting({ region: "REGION" });

// async/await.
try {
  const data = await client.getBuyerDashboard(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .getBuyerDashboard(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks (not recommended).
client.getBuyerDashboard(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;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-marketplace-reporting package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

<details> <summary> GetBuyerDashboard </summary>

Command API Reference / Input / Output

</details>