Skip to content

Commit

Permalink
feat(client-servicediscovery): Adds a new DiscoverInstancesRevision A…
Browse files Browse the repository at this point in the history
…PI and also adds InstanceRevision field to the DiscoverInstances API response.
  • Loading branch information
awstools committed Sep 20, 2023
1 parent f2b4b67 commit 5bfe554
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 45 deletions.
8 changes: 8 additions & 0 deletions clients/client-servicediscovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ DiscoverInstances

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-servicediscovery/classes/discoverinstancescommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-servicediscovery/interfaces/discoverinstancescommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-servicediscovery/interfaces/discoverinstancescommandoutput.html)

</details>
<details>
<summary>
DiscoverInstancesRevision
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-servicediscovery/classes/discoverinstancesrevisioncommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-servicediscovery/interfaces/discoverinstancesrevisioncommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-servicediscovery/interfaces/discoverinstancesrevisioncommandoutput.html)

</details>
<details>
<summary>
Expand Down
23 changes: 23 additions & 0 deletions clients/client-servicediscovery/src/ServiceDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ import {
DiscoverInstancesCommandInput,
DiscoverInstancesCommandOutput,
} from "./commands/DiscoverInstancesCommand";
import {
DiscoverInstancesRevisionCommand,
DiscoverInstancesRevisionCommandInput,
DiscoverInstancesRevisionCommandOutput,
} from "./commands/DiscoverInstancesRevisionCommand";
import { GetInstanceCommand, GetInstanceCommandInput, GetInstanceCommandOutput } from "./commands/GetInstanceCommand";
import {
GetInstancesHealthStatusCommand,
Expand Down Expand Up @@ -131,6 +136,7 @@ const commands = {
DeleteServiceCommand,
DeregisterInstanceCommand,
DiscoverInstancesCommand,
DiscoverInstancesRevisionCommand,
GetInstanceCommand,
GetInstancesHealthStatusCommand,
GetNamespaceCommand,
Expand Down Expand Up @@ -273,6 +279,23 @@ export interface ServiceDiscovery {
cb: (err: any, data?: DiscoverInstancesCommandOutput) => void
): void;

/**
* @see {@link DiscoverInstancesRevisionCommand}
*/
discoverInstancesRevision(
args: DiscoverInstancesRevisionCommandInput,
options?: __HttpHandlerOptions
): Promise<DiscoverInstancesRevisionCommandOutput>;
discoverInstancesRevision(
args: DiscoverInstancesRevisionCommandInput,
cb: (err: any, data?: DiscoverInstancesRevisionCommandOutput) => void
): void;
discoverInstancesRevision(
args: DiscoverInstancesRevisionCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: DiscoverInstancesRevisionCommandOutput) => void
): void;

/**
* @see {@link GetInstanceCommand}
*/
Expand Down
6 changes: 6 additions & 0 deletions clients/client-servicediscovery/src/ServiceDiscoveryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ import { DeleteNamespaceCommandInput, DeleteNamespaceCommandOutput } from "./com
import { DeleteServiceCommandInput, DeleteServiceCommandOutput } from "./commands/DeleteServiceCommand";
import { DeregisterInstanceCommandInput, DeregisterInstanceCommandOutput } from "./commands/DeregisterInstanceCommand";
import { DiscoverInstancesCommandInput, DiscoverInstancesCommandOutput } from "./commands/DiscoverInstancesCommand";
import {
DiscoverInstancesRevisionCommandInput,
DiscoverInstancesRevisionCommandOutput,
} from "./commands/DiscoverInstancesRevisionCommand";
import { GetInstanceCommandInput, GetInstanceCommandOutput } from "./commands/GetInstanceCommand";
import {
GetInstancesHealthStatusCommandInput,
Expand Down Expand Up @@ -126,6 +130,7 @@ export type ServiceInputTypes =
| DeleteServiceCommandInput
| DeregisterInstanceCommandInput
| DiscoverInstancesCommandInput
| DiscoverInstancesRevisionCommandInput
| GetInstanceCommandInput
| GetInstancesHealthStatusCommandInput
| GetNamespaceCommandInput
Expand Down Expand Up @@ -157,6 +162,7 @@ export type ServiceOutputTypes =
| DeleteServiceCommandOutput
| DeregisterInstanceCommandOutput
| DiscoverInstancesCommandOutput
| DiscoverInstancesRevisionCommandOutput
| GetInstanceCommandOutput
| GetInstancesHealthStatusCommandOutput
| GetNamespaceCommandOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export interface DiscoverInstancesCommandOutput extends DiscoverInstancesRespons
/**
* @public
* <p>Discovers registered instances for a specified namespace and service. You can use
* <code>DiscoverInstances</code> to discover instances for any type of namespace. For public and
* private DNS namespaces, you can also use DNS queries to discover instances.</p>
* <code>DiscoverInstances</code> to discover instances for any type of namespace.
* <code>DiscoverInstances</code> returns a randomized list of instances allowing customers to
* distribute traffic evenly across instances. For public and private DNS namespaces, you can also
* use DNS queries to discover instances.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down Expand Up @@ -71,6 +73,7 @@ export interface DiscoverInstancesCommandOutput extends DiscoverInstancesRespons
* // },
* // },
* // ],
* // InstancesRevision: Number("long"),
* // };
*
* ```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// smithy-typescript generated code
import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
import { Command as $Command } from "@smithy/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@smithy/types";

import { DiscoverInstancesRevisionRequest, DiscoverInstancesRevisionResponse } from "../models/models_0";
import { de_DiscoverInstancesRevisionCommand, se_DiscoverInstancesRevisionCommand } from "../protocols/Aws_json1_1";
import { ServiceDiscoveryClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../ServiceDiscoveryClient";

/**
* @public
*/
export { __MetadataBearer, $Command };
/**
* @public
*
* The input for {@link DiscoverInstancesRevisionCommand}.
*/
export interface DiscoverInstancesRevisionCommandInput extends DiscoverInstancesRevisionRequest {}
/**
* @public
*
* The output of {@link DiscoverInstancesRevisionCommand}.
*/
export interface DiscoverInstancesRevisionCommandOutput extends DiscoverInstancesRevisionResponse, __MetadataBearer {}

/**
* @public
* <p>Discovers the increasing revision associated with an instance.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { ServiceDiscoveryClient, DiscoverInstancesRevisionCommand } from "@aws-sdk/client-servicediscovery"; // ES Modules import
* // const { ServiceDiscoveryClient, DiscoverInstancesRevisionCommand } = require("@aws-sdk/client-servicediscovery"); // CommonJS import
* const client = new ServiceDiscoveryClient(config);
* const input = { // DiscoverInstancesRevisionRequest
* NamespaceName: "STRING_VALUE", // required
* ServiceName: "STRING_VALUE", // required
* };
* const command = new DiscoverInstancesRevisionCommand(input);
* const response = await client.send(command);
* // { // DiscoverInstancesRevisionResponse
* // InstancesRevision: Number("long"),
* // };
*
* ```
*
* @param DiscoverInstancesRevisionCommandInput - {@link DiscoverInstancesRevisionCommandInput}
* @returns {@link DiscoverInstancesRevisionCommandOutput}
* @see {@link DiscoverInstancesRevisionCommandInput} for command's `input` shape.
* @see {@link DiscoverInstancesRevisionCommandOutput} for command's `response` shape.
* @see {@link ServiceDiscoveryClientResolvedConfig | config} for ServiceDiscoveryClient's `config` shape.
*
* @throws {@link InvalidInput} (client fault)
* <p>One or more specified values aren't valid. For example, a required value might be missing, a
* numeric value might be outside the allowed range, or a string value might exceed length
* constraints.</p>
*
* @throws {@link NamespaceNotFound} (client fault)
* <p>No namespace exists with the specified ID.</p>
*
* @throws {@link RequestLimitExceeded} (client fault)
* <p>The operation can't be completed because you've reached the quota for the number of
* requests. For more information, see <a href="https://docs.aws.amazon.com/cloud-map/latest/dg/throttling.html">Cloud Map API request throttling quota</a> in the
* <i>Cloud Map Developer Guide</i>.</p>
*
* @throws {@link ServiceNotFound} (client fault)
* <p>No service exists with the specified ID.</p>
*
* @throws {@link ServiceDiscoveryServiceException}
* <p>Base exception class for all service exceptions from ServiceDiscovery service.</p>
*
*/
export class DiscoverInstancesRevisionCommand extends $Command<
DiscoverInstancesRevisionCommandInput,
DiscoverInstancesRevisionCommandOutput,
ServiceDiscoveryClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

public static getEndpointParameterInstructions(): EndpointParameterInstructions {
return {
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
Endpoint: { type: "builtInParams", name: "endpoint" },
Region: { type: "builtInParams", name: "region" },
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
};
}

/**
* @public
*/
constructor(readonly input: DiscoverInstancesRevisionCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: ServiceDiscoveryClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<DiscoverInstancesRevisionCommandInput, DiscoverInstancesRevisionCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(
getEndpointPlugin(configuration, DiscoverInstancesRevisionCommand.getEndpointParameterInstructions())
);

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "ServiceDiscoveryClient";
const commandName = "DiscoverInstancesRevisionCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: (_: any) => _,
outputFilterSensitiveLog: (_: any) => _,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

/**
* @internal
*/
private serialize(input: DiscoverInstancesRevisionCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return se_DiscoverInstancesRevisionCommand(input, context);
}

/**
* @internal
*/
private deserialize(
output: __HttpResponse,
context: __SerdeContext
): Promise<DiscoverInstancesRevisionCommandOutput> {
return de_DiscoverInstancesRevisionCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface GetOperationCommandOutput extends GetOperationResponse, __Metad
/**
* @public
* <p>Gets information about any operation that returns an operation ID in the response, such as a
* <code>CreateService</code> request.</p>
* <code>CreateHttpNamespace</code> request.</p>
* <note>
* <p>To get a list of operations that match specified criteria, see <a href="https://docs.aws.amazon.com/cloud-map/latest/api/API_ListOperations.html">ListOperations</a>.</p>
* </note>
Expand Down
1 change: 1 addition & 0 deletions clients/client-servicediscovery/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from "./DeleteNamespaceCommand";
export * from "./DeleteServiceCommand";
export * from "./DeregisterInstanceCommand";
export * from "./DiscoverInstancesCommand";
export * from "./DiscoverInstancesRevisionCommand";
export * from "./GetInstanceCommand";
export * from "./GetInstancesHealthStatusCommand";
export * from "./GetNamespaceCommand";
Expand Down
Loading

0 comments on commit 5bfe554

Please sign in to comment.