- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
ListLocationsCommand
Returns a list of source and destination locations.
If you have more locations than are returned in a response (that is, the response returns only a truncated list of your agents), the response contains a token that you can specify in your next request to fetch the next page of locations.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { DataSyncClient, ListLocationsCommand } from "@aws-sdk/client-datasync"; // ES Modules import
// const { DataSyncClient, ListLocationsCommand } = require("@aws-sdk/client-datasync"); // CommonJS import
const client = new DataSyncClient(config);
const input = { // ListLocationsRequest
MaxResults: Number("int"),
NextToken: "STRING_VALUE",
Filters: [ // LocationFilters
{ // LocationFilter
Name: "LocationUri" || "LocationType" || "CreationTime", // required
Values: [ // FilterValues // required
"STRING_VALUE",
],
Operator: "Equals" || "NotEquals" || "In" || "LessThanOrEqual" || "LessThan" || "GreaterThanOrEqual" || "GreaterThan" || "Contains" || "NotContains" || "BeginsWith", // required
},
],
};
const command = new ListLocationsCommand(input);
const response = await client.send(command);
// { // ListLocationsResponse
// Locations: [ // LocationList
// { // LocationListEntry
// LocationArn: "STRING_VALUE",
// LocationUri: "STRING_VALUE",
// },
// ],
// NextToken: "STRING_VALUE",
// };
ListLocationsCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Filters | LocationFilter[] | undefined | You can use API filters to narrow down the list of resources returned by |
MaxResults | number | undefined | The maximum number of locations to return. |
NextToken | string | undefined | An opaque string that indicates the position at which to begin the next list of locations. |
ListLocationsCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Locations | LocationListEntry[] | undefined | An array that contains a list of locations. |
NextToken | string | undefined | An opaque string that indicates the position at which to begin returning the next list of locations. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InternalException | server | This exception is thrown when an error occurs in the DataSync service. |
InvalidRequestException | client | This exception is thrown when the client submits a malformed request. |
DataSyncServiceException | Base exception class for all service exceptions from DataSync service. |