clients/client-detective/README.md
AWS SDK for JavaScript Detective Client for Node.js, Browser and React Native.
<p>Detective uses machine learning and purpose-built visualizations to help you to analyze and investigate security issues across your Amazon Web Services (Amazon Web Services) workloads. Detective automatically extracts time-based events such as login attempts, API calls, and network traffic from CloudTrail and Amazon Virtual Private Cloud (Amazon VPC) flow logs. It also extracts findings detected by Amazon GuardDuty.</p> <p>The Detective API primarily supports the creation and management of behavior graphs. A behavior graph contains the extracted data from a set of member accounts, and is created and managed by an administrator account.</p> <p>To add a member account to the behavior graph, the administrator account sends an invitation to the account. When the account accepts the invitation, it becomes a member account in the behavior graph.</p> <p>Detective is also integrated with Organizations. The organization management account designates the Detective administrator account for the organization. That account becomes the administrator account for the organization behavior graph. The Detective administrator account is also the delegated administrator account for Detective in Organizations.</p> <p>The Detective administrator account can enable any organization account as a member account in the organization behavior graph. The organization accounts do not receive invitations. The Detective administrator account can also invite other accounts to the organization behavior graph.</p> <p>Every behavior graph is specific to a Region. You can only use the API to manage behavior graphs that belong to the Region that is associated with the currently selected endpoint.</p> <p>The administrator account for a behavior graph can use the Detective API to do the following:</p> <ul> <li> <p>Enable and disable Detective. Enabling Detective creates a new behavior graph.</p> </li> <li> <p>View the list of member accounts in a behavior graph.</p> </li> <li> <p>Add member accounts to a behavior graph.</p> </li> <li> <p>Remove member accounts from a behavior graph.</p> </li> <li> <p>Apply tags to a behavior graph.</p> </li> </ul> <p>The organization management account can use the Detective API to select the delegated administrator for Detective.</p> <p>The Detective administrator account for an organization can use the Detective API to do the following:</p> <ul> <li> <p>Perform all of the functions of an administrator account.</p> </li> <li> <p>Determine whether to automatically enable new organization accounts as member accounts in the organization behavior graph.</p> </li> </ul> <p>An invited member account can use the Detective API to do the following:</p> <ul> <li> <p>View the list of behavior graphs that they are invited to.</p> </li> <li> <p>Accept an invitation to contribute to a behavior graph.</p> </li> <li> <p>Decline an invitation to contribute to a behavior graph.</p> </li> <li> <p>Remove their account from a behavior graph.</p> </li> </ul> <p>All API actions are logged as CloudTrail events. See <a href="https://docs.aws.amazon.com/detective/latest/userguide/logging-using-cloudtrail.html">Logging Detective API Calls with CloudTrail</a>.</p> <note> <p>We replaced the term "master account" with the term "administrator account". An administrator account is used to centrally manage multiple accounts. In the case of Detective, the administrator account manages the accounts in their behavior graph.</p> </note>To install this package, use the CLI of your favorite package manager:
npm install @aws-sdk/client-detectiveyarn add @aws-sdk/client-detectivepnpm add @aws-sdk/client-detectiveThe AWS SDK is modulized by clients and commands.
To send a request, you only need to import the DetectiveClient and
the commands you need, for example ListGraphsCommand:
// ES5 example
const { DetectiveClient, ListGraphsCommand } = require("@aws-sdk/client-detective");
// ES6+ example
import { DetectiveClient, ListGraphsCommand } from "@aws-sdk/client-detective";
To send a request:
send operation on the client, providing the command object as input.const client = new DetectiveClient({ region: "REGION" });
const params = { /** input parameters */ };
const command = new ListGraphsCommand(params);
We recommend using the await operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
You can also use Promise chaining.
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
The aggregated client class is exported from the same package, but without the "Client" suffix.
Detective extends DetectiveClient 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 (DetectiveClient).
More details are in the blog post on
modular packages in AWS SDK for JavaScript.
import { Detective } from "@aws-sdk/client-detective";
const client = new Detective({ region: "REGION" });
// async/await.
try {
const data = await client.listGraphs(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listGraphs(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks (not recommended).
client.listGraphs(params, (err, data) => {
// process err and data.
});
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
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.
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.
aws-sdk-js
on AWS Developer Blog.aws-sdk-js.To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-detective package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
Command API Reference / Input / Output
</details> <details> <summary> BatchGetGraphMemberDatasources </summary>Command API Reference / Input / Output
</details> <details> <summary> BatchGetMembershipDatasources </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateGraph </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateMembers </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteGraph </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteMembers </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeOrganizationConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DisableOrganizationAdminAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> DisassociateMembership </summary>Command API Reference / Input / Output
</details> <details> <summary> EnableOrganizationAdminAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> GetInvestigation </summary>Command API Reference / Input / Output
</details> <details> <summary> GetMembers </summary>Command API Reference / Input / Output
</details> <details> <summary> ListDatasourcePackages </summary>Command API Reference / Input / Output
</details> <details> <summary> ListGraphs </summary>Command API Reference / Input / Output
</details> <details> <summary> ListIndicators </summary>Command API Reference / Input / Output
</details> <details> <summary> ListInvestigations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListInvitations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListMembers </summary>Command API Reference / Input / Output
</details> <details> <summary> ListOrganizationAdminAccounts </summary>Command API Reference / Input / Output
</details> <details> <summary> ListTagsForResource </summary>Command API Reference / Input / Output
</details> <details> <summary> RejectInvitation </summary>Command API Reference / Input / Output
</details> <details> <summary> StartInvestigation </summary>Command API Reference / Input / Output
</details> <details> <summary> StartMonitoringMember </summary>Command API Reference / Input / Output
</details> <details> <summary> TagResource </summary>Command API Reference / Input / Output
</details> <details> <summary> UntagResource </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateDatasourcePackages </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateInvestigationState </summary> </details> <details> <summary> UpdateOrganizationConfiguration </summary> </details>