Skip to content

Commit 87ff3b9

Browse files
author
awstools
committed
feat(client-amp): Added support for UpdateScraper API, to enable updating collector configuration in-place
1 parent 410614c commit 87ff3b9

File tree

12 files changed

+527
-70
lines changed

12 files changed

+527
-70
lines changed

clients/client-amp/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ workspace.</p>
2727

2828
## Installing
2929

30-
To install the this package, simply type add or install @aws-sdk/client-amp
30+
To install this package, simply type add or install @aws-sdk/client-amp
3131
using your favorite package manager:
3232

3333
- `npm install @aws-sdk/client-amp`
@@ -419,6 +419,14 @@ UpdateLoggingConfiguration
419419

420420
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/amp/command/UpdateLoggingConfigurationCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-amp/Interface/UpdateLoggingConfigurationCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-amp/Interface/UpdateLoggingConfigurationCommandOutput/)
421421

422+
</details>
423+
<details>
424+
<summary>
425+
UpdateScraper
426+
</summary>
427+
428+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/amp/command/UpdateScraperCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-amp/Interface/UpdateScraperCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-amp/Interface/UpdateScraperCommandOutput/)
429+
422430
</details>
423431
<details>
424432
<summary>

clients/client-amp/src/Amp.ts

+17
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ import {
124124
UpdateLoggingConfigurationCommandInput,
125125
UpdateLoggingConfigurationCommandOutput,
126126
} from "./commands/UpdateLoggingConfigurationCommand";
127+
import {
128+
UpdateScraperCommand,
129+
UpdateScraperCommandInput,
130+
UpdateScraperCommandOutput,
131+
} from "./commands/UpdateScraperCommand";
127132
import {
128133
UpdateWorkspaceAliasCommand,
129134
UpdateWorkspaceAliasCommandInput,
@@ -156,6 +161,7 @@ const commands = {
156161
TagResourceCommand,
157162
UntagResourceCommand,
158163
UpdateLoggingConfigurationCommand,
164+
UpdateScraperCommand,
159165
UpdateWorkspaceAliasCommand,
160166
};
161167

@@ -547,6 +553,17 @@ export interface Amp {
547553
cb: (err: any, data?: UpdateLoggingConfigurationCommandOutput) => void
548554
): void;
549555

556+
/**
557+
* @see {@link UpdateScraperCommand}
558+
*/
559+
updateScraper(args: UpdateScraperCommandInput, options?: __HttpHandlerOptions): Promise<UpdateScraperCommandOutput>;
560+
updateScraper(args: UpdateScraperCommandInput, cb: (err: any, data?: UpdateScraperCommandOutput) => void): void;
561+
updateScraper(
562+
args: UpdateScraperCommandInput,
563+
options: __HttpHandlerOptions,
564+
cb: (err: any, data?: UpdateScraperCommandOutput) => void
565+
): void;
566+
550567
/**
551568
* @see {@link UpdateWorkspaceAliasCommand}
552569
*/

clients/client-amp/src/AmpClient.ts

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ import {
123123
UpdateLoggingConfigurationCommandInput,
124124
UpdateLoggingConfigurationCommandOutput,
125125
} from "./commands/UpdateLoggingConfigurationCommand";
126+
import { UpdateScraperCommandInput, UpdateScraperCommandOutput } from "./commands/UpdateScraperCommand";
126127
import {
127128
UpdateWorkspaceAliasCommandInput,
128129
UpdateWorkspaceAliasCommandOutput,
@@ -167,6 +168,7 @@ export type ServiceInputTypes =
167168
| TagResourceCommandInput
168169
| UntagResourceCommandInput
169170
| UpdateLoggingConfigurationCommandInput
171+
| UpdateScraperCommandInput
170172
| UpdateWorkspaceAliasCommandInput;
171173

172174
/**
@@ -198,6 +200,7 @@ export type ServiceOutputTypes =
198200
| TagResourceCommandOutput
199201
| UntagResourceCommandOutput
200202
| UpdateLoggingConfigurationCommandOutput
203+
| UpdateScraperCommandOutput
201204
| UpdateWorkspaceAliasCommandOutput;
202205

203206
/**

clients/client-amp/src/commands/CreateScraperCommand.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ export interface CreateScraperCommandOutput extends CreateScraperResponse, __Met
3030
/**
3131
* <p>The <code>CreateScraper</code> operation creates a scraper to collect metrics. A
3232
* scraper pulls metrics from Prometheus-compatible sources within an Amazon EKS
33-
* cluster, and sends them to your Amazon Managed Service for Prometheus workspace. You can configure the
34-
* scraper to control what metrics are collected, and what transformations are applied
35-
* prior to sending them to your workspace.</p>
36-
* <p>If needed, an IAM role will be created for you that gives Amazon Managed Service for Prometheus access to the metrics in your cluster. For more information, see
37-
* <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/using-service-linked-roles.html#using-service-linked-roles-prom-scraper">Using roles for scraping metrics from EKS</a> in the <i>Amazon Managed Service for Prometheus User
38-
* Guide</i>.</p>
39-
* <p>You cannot update a scraper. If you want to change the configuration of the scraper,
40-
* create a new scraper and delete the old one.</p>
41-
* <p>The <code>scrapeConfiguration</code> parameter contains the base64-encoded version of
42-
* the YAML configuration file.</p>
33+
* cluster, and sends them to your Amazon Managed Service for Prometheus workspace. Scrapers are
34+
* flexible, and can be configured to control what metrics are collected, the
35+
* frequency of collection, what transformations are applied to the metrics, and more.</p>
36+
* <p>An IAM role will be created for you that Amazon Managed Service for Prometheus uses
37+
* to access the metrics in your cluster. You must configure this role with a policy that
38+
* allows it to scrape metrics from your cluster. For more information, see
39+
* <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-eks-setup">Configuring your Amazon EKS cluster</a> in the <i>Amazon Managed Service for Prometheus User Guide</i>.</p>
40+
* <p>The <code>scrapeConfiguration</code> parameter contains the base-64 encoded YAML
41+
* configuration for the scraper.</p>
4342
* <note>
4443
* <p>For more information about collectors, including what metrics are collected, and
45-
* how to configure the scraper, see <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector.html">Amazon Web Services managed
46-
* collectors</a> in the <i>Amazon Managed Service for Prometheus User
44+
* how to configure the scraper, see <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html">Using an
45+
* Amazon Web Services managed
46+
* collector</a> in the <i>Amazon Managed Service for Prometheus User
4747
* Guide</i>.</p>
4848
* </note>
4949
* @example

clients/client-amp/src/commands/ListTagsForResourceCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface ListTagsForResourceCommandOutput extends ListTagsForResourceRes
3030
/**
3131
* <p>The <code>ListTagsForResource</code> operation returns the tags that are associated
3232
* with an Amazon Managed Service for Prometheus resource. Currently, the only resources that can be
33-
* tagged are workspaces and rule groups namespaces. </p>
33+
* tagged are scrapers, workspaces, and rule groups namespaces. </p>
3434
* @example
3535
* Use a bare-bones client and the command you need to make an API call.
3636
* ```javascript

clients/client-amp/src/commands/TagResourceCommand.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export interface TagResourceCommandOutput extends TagResourceResponse, __Metadat
2929

3030
/**
3131
* <p>The <code>TagResource</code> operation associates tags with an Amazon Managed Service for Prometheus
32-
* resource. The only resources that can be tagged are workspaces and rule groups
33-
* namespaces. </p>
32+
* resource. The only resources that can be tagged are rule groups namespaces, scrapers,
33+
* and workspaces.</p>
3434
* <p>If you specify a new tag key for the resource, this tag is appended to the list of
3535
* tags associated with the resource. If you specify a tag key that is already associated
3636
* with the resource, the new tag value that you specify replaces the previous value for
37-
* that tag.</p>
37+
* that tag. To remove a tag, use <code>UntagResource</code>.</p>
3838
* @example
3939
* Use a bare-bones client and the command you need to make an API call.
4040
* ```javascript

clients/client-amp/src/commands/UntagResourceCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface UntagResourceCommandOutput extends UntagResourceResponse, __Met
2929

3030
/**
3131
* <p>Removes the specified tags from an Amazon Managed Service for Prometheus resource. The only resources
32-
* that can be tagged are workspaces and rule groups namespaces. </p>
32+
* that can be tagged are rule groups namespaces, scrapers, and workspaces. </p>
3333
* @example
3434
* Use a bare-bones client and the command you need to make an API call.
3535
* ```javascript
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { AmpClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../AmpClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { UpdateScraperRequest, UpdateScraperResponse } from "../models/models_0";
10+
import { de_UpdateScraperCommand, se_UpdateScraperCommand } from "../protocols/Aws_restJson1";
11+
12+
/**
13+
* @public
14+
*/
15+
export type { __MetadataBearer };
16+
export { $Command };
17+
/**
18+
* @public
19+
*
20+
* The input for {@link UpdateScraperCommand}.
21+
*/
22+
export interface UpdateScraperCommandInput extends UpdateScraperRequest {}
23+
/**
24+
* @public
25+
*
26+
* The output of {@link UpdateScraperCommand}.
27+
*/
28+
export interface UpdateScraperCommandOutput extends UpdateScraperResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>Updates an existing scraper.</p>
32+
* <p>You can't use this function to update the source from which the scraper is
33+
* collecting metrics. To change the source, delete the scraper and create a new
34+
* one.</p>
35+
* @example
36+
* Use a bare-bones client and the command you need to make an API call.
37+
* ```javascript
38+
* import { AmpClient, UpdateScraperCommand } from "@aws-sdk/client-amp"; // ES Modules import
39+
* // const { AmpClient, UpdateScraperCommand } = require("@aws-sdk/client-amp"); // CommonJS import
40+
* const client = new AmpClient(config);
41+
* const input = { // UpdateScraperRequest
42+
* scraperId: "STRING_VALUE", // required
43+
* alias: "STRING_VALUE",
44+
* scrapeConfiguration: { // ScrapeConfiguration Union: only one key present
45+
* configurationBlob: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
46+
* },
47+
* destination: { // Destination Union: only one key present
48+
* ampConfiguration: { // AmpConfiguration
49+
* workspaceArn: "STRING_VALUE", // required
50+
* },
51+
* },
52+
* clientToken: "STRING_VALUE",
53+
* };
54+
* const command = new UpdateScraperCommand(input);
55+
* const response = await client.send(command);
56+
* // { // UpdateScraperResponse
57+
* // scraperId: "STRING_VALUE", // required
58+
* // arn: "STRING_VALUE", // required
59+
* // status: { // ScraperStatus
60+
* // statusCode: "STRING_VALUE", // required
61+
* // },
62+
* // tags: { // TagMap
63+
* // "<keys>": "STRING_VALUE",
64+
* // },
65+
* // };
66+
*
67+
* ```
68+
*
69+
* @param UpdateScraperCommandInput - {@link UpdateScraperCommandInput}
70+
* @returns {@link UpdateScraperCommandOutput}
71+
* @see {@link UpdateScraperCommandInput} for command's `input` shape.
72+
* @see {@link UpdateScraperCommandOutput} for command's `response` shape.
73+
* @see {@link AmpClientResolvedConfig | config} for AmpClient's `config` shape.
74+
*
75+
* @throws {@link AccessDeniedException} (client fault)
76+
* <p>You do not have sufficient access to perform this action.</p>
77+
*
78+
* @throws {@link ConflictException} (client fault)
79+
* <p>The request would cause an inconsistent state.</p>
80+
*
81+
* @throws {@link InternalServerException} (server fault)
82+
* <p>An unexpected error occurred during the processing of the request.</p>
83+
*
84+
* @throws {@link ResourceNotFoundException} (client fault)
85+
* <p>The request references a resources that doesn't exist.</p>
86+
*
87+
* @throws {@link ServiceQuotaExceededException} (client fault)
88+
* <p>Completing the request would cause a service quota to be exceeded.</p>
89+
*
90+
* @throws {@link ThrottlingException} (client fault)
91+
* <p>The request was denied due to request throttling.</p>
92+
*
93+
* @throws {@link ValidationException} (client fault)
94+
* <p>The input fails to satisfy the constraints specified by an Amazon Web Services
95+
* service.</p>
96+
*
97+
* @throws {@link AmpServiceException}
98+
* <p>Base exception class for all service exceptions from Amp service.</p>
99+
*
100+
* @public
101+
*/
102+
export class UpdateScraperCommand extends $Command
103+
.classBuilder<
104+
UpdateScraperCommandInput,
105+
UpdateScraperCommandOutput,
106+
AmpClientResolvedConfig,
107+
ServiceInputTypes,
108+
ServiceOutputTypes
109+
>()
110+
.ep(commonParams)
111+
.m(function (this: any, Command: any, cs: any, config: AmpClientResolvedConfig, o: any) {
112+
return [
113+
getSerdePlugin(config, this.serialize, this.deserialize),
114+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
115+
];
116+
})
117+
.s("AmazonPrometheusService", "UpdateScraper", {})
118+
.n("AmpClient", "UpdateScraperCommand")
119+
.f(void 0, void 0)
120+
.ser(se_UpdateScraperCommand)
121+
.de(de_UpdateScraperCommand)
122+
.build() {
123+
/** @internal type navigation helper, not in runtime. */
124+
protected declare static __types: {
125+
api: {
126+
input: UpdateScraperRequest;
127+
output: UpdateScraperResponse;
128+
};
129+
sdk: {
130+
input: UpdateScraperCommandInput;
131+
output: UpdateScraperCommandOutput;
132+
};
133+
};
134+
}

clients/client-amp/src/commands/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ export * from "./PutRuleGroupsNamespaceCommand";
2424
export * from "./TagResourceCommand";
2525
export * from "./UntagResourceCommand";
2626
export * from "./UpdateLoggingConfigurationCommand";
27+
export * from "./UpdateScraperCommand";
2728
export * from "./UpdateWorkspaceAliasCommand";

0 commit comments

Comments
 (0)