Skip to content

Commit fdc8747

Browse files
author
awstools
committed
feat(client-sns): Amazon SNS introduces the Data Protection Policy APIs, which enable customers to attach a data protection policy to an SNS topic. This allows topic owners to enable the new message data protection feature to audit and block sensitive data that is exchanged through their topics.
1 parent b794a32 commit fdc8747

File tree

8 files changed

+688
-0
lines changed

8 files changed

+688
-0
lines changed

clients/client-sns/src/SNS.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ import {
4848
DeleteSMSSandboxPhoneNumberCommandOutput,
4949
} from "./commands/DeleteSMSSandboxPhoneNumberCommand";
5050
import { DeleteTopicCommand, DeleteTopicCommandInput, DeleteTopicCommandOutput } from "./commands/DeleteTopicCommand";
51+
import {
52+
GetDataProtectionPolicyCommand,
53+
GetDataProtectionPolicyCommandInput,
54+
GetDataProtectionPolicyCommandOutput,
55+
} from "./commands/GetDataProtectionPolicyCommand";
5156
import {
5257
GetEndpointAttributesCommand,
5358
GetEndpointAttributesCommandInput,
@@ -130,6 +135,11 @@ import {
130135
PublishBatchCommandOutput,
131136
} from "./commands/PublishBatchCommand";
132137
import { PublishCommand, PublishCommandInput, PublishCommandOutput } from "./commands/PublishCommand";
138+
import {
139+
PutDataProtectionPolicyCommand,
140+
PutDataProtectionPolicyCommandInput,
141+
PutDataProtectionPolicyCommandOutput,
142+
} from "./commands/PutDataProtectionPolicyCommand";
133143
import {
134144
RemovePermissionCommand,
135145
RemovePermissionCommandInput,
@@ -628,6 +638,38 @@ export class SNS extends SNSClient {
628638
}
629639
}
630640

641+
/**
642+
* <p>Retrieves the specified inline <code>DataProtectionPolicy</code> document that is stored in the specified Amazon SNS topic. </p>
643+
*/
644+
public getDataProtectionPolicy(
645+
args: GetDataProtectionPolicyCommandInput,
646+
options?: __HttpHandlerOptions
647+
): Promise<GetDataProtectionPolicyCommandOutput>;
648+
public getDataProtectionPolicy(
649+
args: GetDataProtectionPolicyCommandInput,
650+
cb: (err: any, data?: GetDataProtectionPolicyCommandOutput) => void
651+
): void;
652+
public getDataProtectionPolicy(
653+
args: GetDataProtectionPolicyCommandInput,
654+
options: __HttpHandlerOptions,
655+
cb: (err: any, data?: GetDataProtectionPolicyCommandOutput) => void
656+
): void;
657+
public getDataProtectionPolicy(
658+
args: GetDataProtectionPolicyCommandInput,
659+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetDataProtectionPolicyCommandOutput) => void),
660+
cb?: (err: any, data?: GetDataProtectionPolicyCommandOutput) => void
661+
): Promise<GetDataProtectionPolicyCommandOutput> | void {
662+
const command = new GetDataProtectionPolicyCommand(args);
663+
if (typeof optionsOrCb === "function") {
664+
this.send(command, optionsOrCb);
665+
} else if (typeof cb === "function") {
666+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
667+
this.send(command, optionsOrCb || {}, cb);
668+
} else {
669+
return this.send(command, optionsOrCb);
670+
}
671+
}
672+
631673
/**
632674
* <p>Retrieves the endpoint attributes for a device on one of the supported push
633675
* notification services, such as GCM (Firebase Cloud Messaging) and APNS. For more
@@ -1279,6 +1321,38 @@ export class SNS extends SNSClient {
12791321
}
12801322
}
12811323

1324+
/**
1325+
* <p>Adds or updates an inline policy document that is stored in the specified Amazon SNS topic.</p>
1326+
*/
1327+
public putDataProtectionPolicy(
1328+
args: PutDataProtectionPolicyCommandInput,
1329+
options?: __HttpHandlerOptions
1330+
): Promise<PutDataProtectionPolicyCommandOutput>;
1331+
public putDataProtectionPolicy(
1332+
args: PutDataProtectionPolicyCommandInput,
1333+
cb: (err: any, data?: PutDataProtectionPolicyCommandOutput) => void
1334+
): void;
1335+
public putDataProtectionPolicy(
1336+
args: PutDataProtectionPolicyCommandInput,
1337+
options: __HttpHandlerOptions,
1338+
cb: (err: any, data?: PutDataProtectionPolicyCommandOutput) => void
1339+
): void;
1340+
public putDataProtectionPolicy(
1341+
args: PutDataProtectionPolicyCommandInput,
1342+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: PutDataProtectionPolicyCommandOutput) => void),
1343+
cb?: (err: any, data?: PutDataProtectionPolicyCommandOutput) => void
1344+
): Promise<PutDataProtectionPolicyCommandOutput> | void {
1345+
const command = new PutDataProtectionPolicyCommand(args);
1346+
if (typeof optionsOrCb === "function") {
1347+
this.send(command, optionsOrCb);
1348+
} else if (typeof cb === "function") {
1349+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
1350+
this.send(command, optionsOrCb || {}, cb);
1351+
} else {
1352+
return this.send(command, optionsOrCb);
1353+
}
1354+
}
1355+
12821356
/**
12831357
* <p>Removes a statement from a topic's access control policy.</p>
12841358
*/

clients/client-sns/src/SNSClient.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ import {
8585
DeleteSMSSandboxPhoneNumberCommandOutput,
8686
} from "./commands/DeleteSMSSandboxPhoneNumberCommand";
8787
import { DeleteTopicCommandInput, DeleteTopicCommandOutput } from "./commands/DeleteTopicCommand";
88+
import {
89+
GetDataProtectionPolicyCommandInput,
90+
GetDataProtectionPolicyCommandOutput,
91+
} from "./commands/GetDataProtectionPolicyCommand";
8892
import {
8993
GetEndpointAttributesCommandInput,
9094
GetEndpointAttributesCommandOutput,
@@ -136,6 +140,10 @@ import { ListTopicsCommandInput, ListTopicsCommandOutput } from "./commands/List
136140
import { OptInPhoneNumberCommandInput, OptInPhoneNumberCommandOutput } from "./commands/OptInPhoneNumberCommand";
137141
import { PublishBatchCommandInput, PublishBatchCommandOutput } from "./commands/PublishBatchCommand";
138142
import { PublishCommandInput, PublishCommandOutput } from "./commands/PublishCommand";
143+
import {
144+
PutDataProtectionPolicyCommandInput,
145+
PutDataProtectionPolicyCommandOutput,
146+
} from "./commands/PutDataProtectionPolicyCommand";
139147
import { RemovePermissionCommandInput, RemovePermissionCommandOutput } from "./commands/RemovePermissionCommand";
140148
import {
141149
SetEndpointAttributesCommandInput,
@@ -173,6 +181,7 @@ export type ServiceInputTypes =
173181
| DeletePlatformApplicationCommandInput
174182
| DeleteSMSSandboxPhoneNumberCommandInput
175183
| DeleteTopicCommandInput
184+
| GetDataProtectionPolicyCommandInput
176185
| GetEndpointAttributesCommandInput
177186
| GetPlatformApplicationAttributesCommandInput
178187
| GetSMSAttributesCommandInput
@@ -191,6 +200,7 @@ export type ServiceInputTypes =
191200
| OptInPhoneNumberCommandInput
192201
| PublishBatchCommandInput
193202
| PublishCommandInput
203+
| PutDataProtectionPolicyCommandInput
194204
| RemovePermissionCommandInput
195205
| SetEndpointAttributesCommandInput
196206
| SetPlatformApplicationAttributesCommandInput
@@ -215,6 +225,7 @@ export type ServiceOutputTypes =
215225
| DeletePlatformApplicationCommandOutput
216226
| DeleteSMSSandboxPhoneNumberCommandOutput
217227
| DeleteTopicCommandOutput
228+
| GetDataProtectionPolicyCommandOutput
218229
| GetEndpointAttributesCommandOutput
219230
| GetPlatformApplicationAttributesCommandOutput
220231
| GetSMSAttributesCommandOutput
@@ -233,6 +244,7 @@ export type ServiceOutputTypes =
233244
| OptInPhoneNumberCommandOutput
234245
| PublishBatchCommandOutput
235246
| PublishCommandOutput
247+
| PutDataProtectionPolicyCommandOutput
236248
| RemovePermissionCommandOutput
237249
| SetEndpointAttributesCommandOutput
238250
| SetPlatformApplicationAttributesCommandOutput
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import {
16+
GetDataProtectionPolicyInput,
17+
GetDataProtectionPolicyInputFilterSensitiveLog,
18+
GetDataProtectionPolicyResponse,
19+
GetDataProtectionPolicyResponseFilterSensitiveLog,
20+
} from "../models/models_0";
21+
import {
22+
deserializeAws_queryGetDataProtectionPolicyCommand,
23+
serializeAws_queryGetDataProtectionPolicyCommand,
24+
} from "../protocols/Aws_query";
25+
import { ServiceInputTypes, ServiceOutputTypes, SNSClientResolvedConfig } from "../SNSClient";
26+
27+
export interface GetDataProtectionPolicyCommandInput extends GetDataProtectionPolicyInput {}
28+
export interface GetDataProtectionPolicyCommandOutput extends GetDataProtectionPolicyResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>Retrieves the specified inline <code>DataProtectionPolicy</code> document that is stored in the specified Amazon SNS topic. </p>
32+
* @example
33+
* Use a bare-bones client and the command you need to make an API call.
34+
* ```javascript
35+
* import { SNSClient, GetDataProtectionPolicyCommand } from "@aws-sdk/client-sns"; // ES Modules import
36+
* // const { SNSClient, GetDataProtectionPolicyCommand } = require("@aws-sdk/client-sns"); // CommonJS import
37+
* const client = new SNSClient(config);
38+
* const command = new GetDataProtectionPolicyCommand(input);
39+
* const response = await client.send(command);
40+
* ```
41+
*
42+
* @see {@link GetDataProtectionPolicyCommandInput} for command's `input` shape.
43+
* @see {@link GetDataProtectionPolicyCommandOutput} for command's `response` shape.
44+
* @see {@link SNSClientResolvedConfig | config} for SNSClient's `config` shape.
45+
*
46+
*/
47+
export class GetDataProtectionPolicyCommand extends $Command<
48+
GetDataProtectionPolicyCommandInput,
49+
GetDataProtectionPolicyCommandOutput,
50+
SNSClientResolvedConfig
51+
> {
52+
// Start section: command_properties
53+
// End section: command_properties
54+
55+
constructor(readonly input: GetDataProtectionPolicyCommandInput) {
56+
// Start section: command_constructor
57+
super();
58+
// End section: command_constructor
59+
}
60+
61+
/**
62+
* @internal
63+
*/
64+
resolveMiddleware(
65+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
66+
configuration: SNSClientResolvedConfig,
67+
options?: __HttpHandlerOptions
68+
): Handler<GetDataProtectionPolicyCommandInput, GetDataProtectionPolicyCommandOutput> {
69+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
70+
71+
const stack = clientStack.concat(this.middlewareStack);
72+
73+
const { logger } = configuration;
74+
const clientName = "SNSClient";
75+
const commandName = "GetDataProtectionPolicyCommand";
76+
const handlerExecutionContext: HandlerExecutionContext = {
77+
logger,
78+
clientName,
79+
commandName,
80+
inputFilterSensitiveLog: GetDataProtectionPolicyInputFilterSensitiveLog,
81+
outputFilterSensitiveLog: GetDataProtectionPolicyResponseFilterSensitiveLog,
82+
};
83+
const { requestHandler } = configuration;
84+
return stack.resolve(
85+
(request: FinalizeHandlerArguments<any>) =>
86+
requestHandler.handle(request.request as __HttpRequest, options || {}),
87+
handlerExecutionContext
88+
);
89+
}
90+
91+
private serialize(input: GetDataProtectionPolicyCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
92+
return serializeAws_queryGetDataProtectionPolicyCommand(input, context);
93+
}
94+
95+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetDataProtectionPolicyCommandOutput> {
96+
return deserializeAws_queryGetDataProtectionPolicyCommand(output, context);
97+
}
98+
99+
// Start section: command_body_extra
100+
// End section: command_body_extra
101+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { PutDataProtectionPolicyInput, PutDataProtectionPolicyInputFilterSensitiveLog } from "../models/models_0";
16+
import {
17+
deserializeAws_queryPutDataProtectionPolicyCommand,
18+
serializeAws_queryPutDataProtectionPolicyCommand,
19+
} from "../protocols/Aws_query";
20+
import { ServiceInputTypes, ServiceOutputTypes, SNSClientResolvedConfig } from "../SNSClient";
21+
22+
export interface PutDataProtectionPolicyCommandInput extends PutDataProtectionPolicyInput {}
23+
export interface PutDataProtectionPolicyCommandOutput extends __MetadataBearer {}
24+
25+
/**
26+
* <p>Adds or updates an inline policy document that is stored in the specified Amazon SNS topic.</p>
27+
* @example
28+
* Use a bare-bones client and the command you need to make an API call.
29+
* ```javascript
30+
* import { SNSClient, PutDataProtectionPolicyCommand } from "@aws-sdk/client-sns"; // ES Modules import
31+
* // const { SNSClient, PutDataProtectionPolicyCommand } = require("@aws-sdk/client-sns"); // CommonJS import
32+
* const client = new SNSClient(config);
33+
* const command = new PutDataProtectionPolicyCommand(input);
34+
* const response = await client.send(command);
35+
* ```
36+
*
37+
* @see {@link PutDataProtectionPolicyCommandInput} for command's `input` shape.
38+
* @see {@link PutDataProtectionPolicyCommandOutput} for command's `response` shape.
39+
* @see {@link SNSClientResolvedConfig | config} for SNSClient's `config` shape.
40+
*
41+
*/
42+
export class PutDataProtectionPolicyCommand extends $Command<
43+
PutDataProtectionPolicyCommandInput,
44+
PutDataProtectionPolicyCommandOutput,
45+
SNSClientResolvedConfig
46+
> {
47+
// Start section: command_properties
48+
// End section: command_properties
49+
50+
constructor(readonly input: PutDataProtectionPolicyCommandInput) {
51+
// Start section: command_constructor
52+
super();
53+
// End section: command_constructor
54+
}
55+
56+
/**
57+
* @internal
58+
*/
59+
resolveMiddleware(
60+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
61+
configuration: SNSClientResolvedConfig,
62+
options?: __HttpHandlerOptions
63+
): Handler<PutDataProtectionPolicyCommandInput, PutDataProtectionPolicyCommandOutput> {
64+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
65+
66+
const stack = clientStack.concat(this.middlewareStack);
67+
68+
const { logger } = configuration;
69+
const clientName = "SNSClient";
70+
const commandName = "PutDataProtectionPolicyCommand";
71+
const handlerExecutionContext: HandlerExecutionContext = {
72+
logger,
73+
clientName,
74+
commandName,
75+
inputFilterSensitiveLog: PutDataProtectionPolicyInputFilterSensitiveLog,
76+
outputFilterSensitiveLog: (output: any) => output,
77+
};
78+
const { requestHandler } = configuration;
79+
return stack.resolve(
80+
(request: FinalizeHandlerArguments<any>) =>
81+
requestHandler.handle(request.request as __HttpRequest, options || {}),
82+
handlerExecutionContext
83+
);
84+
}
85+
86+
private serialize(input: PutDataProtectionPolicyCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
87+
return serializeAws_queryPutDataProtectionPolicyCommand(input, context);
88+
}
89+
90+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<PutDataProtectionPolicyCommandOutput> {
91+
return deserializeAws_queryPutDataProtectionPolicyCommand(output, context);
92+
}
93+
94+
// Start section: command_body_extra
95+
// End section: command_body_extra
96+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from "./DeleteEndpointCommand";
1010
export * from "./DeletePlatformApplicationCommand";
1111
export * from "./DeleteSMSSandboxPhoneNumberCommand";
1212
export * from "./DeleteTopicCommand";
13+
export * from "./GetDataProtectionPolicyCommand";
1314
export * from "./GetEndpointAttributesCommand";
1415
export * from "./GetPlatformApplicationAttributesCommand";
1516
export * from "./GetSMSAttributesCommand";
@@ -28,6 +29,7 @@ export * from "./ListTopicsCommand";
2829
export * from "./OptInPhoneNumberCommand";
2930
export * from "./PublishBatchCommand";
3031
export * from "./PublishCommand";
32+
export * from "./PutDataProtectionPolicyCommand";
3133
export * from "./RemovePermissionCommand";
3234
export * from "./SetEndpointAttributesCommand";
3335
export * from "./SetPlatformApplicationAttributesCommand";

0 commit comments

Comments
 (0)