Skip to content

Commit

Permalink
feat(client-ssm-incidents): Adding support for dynamic SSM Runbook pa…
Browse files Browse the repository at this point in the history
…rameter values. Updating validation pattern for engagements. Adding ConflictException to UpdateReplicationSet API contract.
  • Loading branch information
awstools committed May 12, 2022
1 parent 796d6f4 commit 67fcba1
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 61 deletions.
5 changes: 4 additions & 1 deletion clients/client-ssm-incidents/src/SSMIncidents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,10 @@ export class SSMIncidents extends SSMIncidentsClient {
}

/**
* <p>Adds a resource policy to the specified response plan.</p>
* <p>Adds a resource policy to the specified response plan. The resource policy is used to
* share the response plan using Resource Access Manager (RAM). For more
* information about cross-account sharing, see <a href="https://docs.aws.amazon.com/incident-manager/latest/userguide/xa.html">Setting up
* cross-account functionality</a>.</p>
*/
public putResourcePolicy(
args: PutResourcePolicyCommandInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export interface PutResourcePolicyCommandInput extends PutResourcePolicyInput {}
export interface PutResourcePolicyCommandOutput extends PutResourcePolicyOutput, __MetadataBearer {}

/**
* <p>Adds a resource policy to the specified response plan.</p>
* <p>Adds a resource policy to the specified response plan. The resource policy is used to
* share the response plan using Resource Access Manager (RAM). For more
* information about cross-account sharing, see <a href="https://docs.aws.amazon.com/incident-manager/latest/userguide/xa.html">Setting up
* cross-account functionality</a>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
125 changes: 79 additions & 46 deletions clients/client-ssm-incidents/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,51 @@ export class AccessDeniedException extends __BaseException {
}
}

export enum VariableType {
INCIDENT_RECORD_ARN = "INCIDENT_RECORD_ARN",
INVOLVED_RESOURCES = "INVOLVED_RESOURCES",
}

/**
* <p>The dynamic SSM parameter value.</p>
*/
export type DynamicSsmParameterValue =
| DynamicSsmParameterValue.VariableMember
| DynamicSsmParameterValue.$UnknownMember;

export namespace DynamicSsmParameterValue {
/**
* <p>Variable dynamic parameters. A parameter value is determined when an incident is created.</p>
*/
export interface VariableMember {
variable: VariableType | string;
$unknown?: never;
}

export interface $UnknownMember {
variable?: never;
$unknown: [string, any];
}

export interface Visitor<T> {
variable: (value: VariableType | string) => T;
_: (name: string, value: any) => T;
}

export const visit = <T>(value: DynamicSsmParameterValue, visitor: Visitor<T>): T => {
if (value.variable !== undefined) return visitor.variable(value.variable);
return visitor._(value.$unknown[0], value.$unknown[1]);
};

/**
* @internal
*/
export const filterSensitiveLog = (obj: DynamicSsmParameterValue): any => {
if (obj.variable !== undefined) return { variable: obj.variable };
if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" };
};
}

export enum SsmTargetAccount {
IMPACTED_ACCOUNT = "IMPACTED_ACCOUNT",
RESPONSE_PLAN_OWNER_ACCOUNT = "RESPONSE_PLAN_OWNER_ACCOUNT",
Expand All @@ -34,7 +79,8 @@ export enum SsmTargetAccount {
*/
export interface SsmAutomation {
/**
* <p>The Amazon Resource Name (ARN) of the role that the automation document will assume when running commands.</p>
* <p>The Amazon Resource Name (ARN) of the role that the automation document will assume when
* running commands.</p>
*/
roleArn: string | undefined;

Expand All @@ -49,14 +95,20 @@ export interface SsmAutomation {
documentVersion?: string;

/**
* <p>The account that the automation document will be run in. This can be in either the management account or an application account.</p>
* <p>The account that the automation document will be run in. This can be in either the
* management account or an application account.</p>
*/
targetAccount?: SsmTargetAccount | string;

/**
* <p>The key-value pair parameters to use when running the automation document.</p>
*/
parameters?: { [key: string]: string[] };

/**
* <p>The key-value pair to resolve dynamic parameter values when processing a Systems Manager Automation runbook.</p>
*/
dynamicParameters?: { [key: string]: DynamicSsmParameterValue };
}

export namespace SsmAutomation {
Expand All @@ -65,6 +117,15 @@ export namespace SsmAutomation {
*/
export const filterSensitiveLog = (obj: SsmAutomation): any => ({
...obj,
...(obj.dynamicParameters && {
dynamicParameters: Object.entries(obj.dynamicParameters).reduce(
(acc: any, [key, value]: [string, DynamicSsmParameterValue]) => ({
...acc,
[key]: DynamicSsmParameterValue.filterSensitiveLog(value),
}),
{}
),
}),
});
}

Expand Down Expand Up @@ -260,9 +321,7 @@ export namespace ChatChannel {
/**
* <p>The Amazon SNS targets that Chatbot uses to notify the chat channel
* of updates to an incident. You can also make updates to the incident through the chat
* channel
* by
* using the Amazon SNS topics. </p>
* channel by using the Amazon SNS topics. </p>
*/
export interface ChatbotSnsMember {
empty?: never;
Expand Down Expand Up @@ -634,7 +693,8 @@ export namespace NotificationTargetItem {
}

/**
* <p>Basic details used in creating a response plan. The response plan is then used to create an incident record.</p>
* <p>Basic details used in creating a response plan. The response plan is then used to create
* an incident record.</p>
*/
export interface IncidentTemplate {
/**
Expand All @@ -654,7 +714,8 @@ export interface IncidentTemplate {
summary?: string;

/**
* <p>Used to stop Incident Manager from creating multiple incident records for the same incident. </p>
* <p>Used to stop Incident Manager from creating multiple incident records for the same incident.
* </p>
*/
dedupeString?: string;

Expand Down Expand Up @@ -806,8 +867,7 @@ export interface CreateTimelineEventInput {
eventType: string | undefined;

/**
* <p>A short description of the event as a valid JSON string. There is no other schema
* imposed.</p>
* <p>A short description of the event.</p>
*/
eventData: string | undefined;
}
Expand Down Expand Up @@ -1059,7 +1119,8 @@ export interface Filter {
key: string | undefined;

/**
* <p>The condition accepts before or after a specified time, equal to a string, or equal to an integer.</p>
* <p>The condition accepts before or after a specified time, equal to a string, or equal to
* an integer.</p>
*/
condition: Condition | undefined;
}
Expand Down Expand Up @@ -1100,7 +1161,8 @@ export interface IncidentRecordSource {
createdBy: string | undefined;

/**
* <p>The principal the assumed the role specified of the <code>createdBy</code>.</p>
* <p>The service principal that assumed the role specified in <code>createdBy</code>. If no
* service principal assumed the role this will be left blank.</p>
*/
invokedBy?: string;

Expand Down Expand Up @@ -1192,7 +1254,8 @@ export interface IncidentRecord {
incidentRecordSource: IncidentRecordSource | undefined;

/**
* <p>The string Incident Manager uses to prevent duplicate incidents from being created by the same incident in the same account.</p>
* <p>The string Incident Manager uses to prevent duplicate incidents from being created by the
* same incident in the same account.</p>
*/
dedupeString: string | undefined;

Expand Down Expand Up @@ -1434,7 +1497,8 @@ export namespace GetResourcePoliciesInput {
}

/**
* <p>The resource policy that allows Incident Manager to perform actions on resources on your behalf.</p>
* <p>The resource policy that allows Incident Manager to perform actions on resources on your
* behalf.</p>
*/
export interface ResourcePolicy {
/**
Expand Down Expand Up @@ -1689,6 +1753,7 @@ export enum ItemType {
ATTACHMENT = "ATTACHMENT",
AUTOMATION = "AUTOMATION",
INCIDENT = "INCIDENT",
INVOLVED_RESOURCE = "INVOLVED_RESOURCE",
METRIC = "METRIC",
OTHER = "OTHER",
PARENT = "PARENT",
Expand Down Expand Up @@ -1777,39 +1842,7 @@ export interface ItemIdentifier {
value: ItemValue | undefined;

/**
* <p>The type of related item. Incident Manager supports the following types:</p>
* <ul>
* <li>
* <p>
* <code>ANALYSIS</code>
* </p>
* </li>
* <li>
* <p>
* <code>INCIDENT</code>
* </p>
* </li>
* <li>
* <p>
* <code>METRIC</code>
* </p>
* </li>
* <li>
* <p>
* <code>PARENT</code>
* </p>
* </li>
* <li>
* <p>
* <code>ATTACHMENT</code>
* </p>
* </li>
* <li>
* <p>
* <code>OTHER</code>
* </p>
* </li>
* </ul>
* <p>The type of related item. </p>
*/
type: ItemType | string | undefined;
}
Expand Down
65 changes: 65 additions & 0 deletions clients/client-ssm-incidents/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import {
Condition,
ConflictException,
DeleteRegionAction,
DynamicSsmParameterValue,
EmptyChatChannel,
EventSummary,
Filter,
Expand Down Expand Up @@ -2461,6 +2462,9 @@ const deserializeAws_restJson1UpdateReplicationSetCommandError = async (
case "AccessDeniedException":
case "com.amazonaws.ssmincidents#AccessDeniedException":
throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
case "ConflictException":
case "com.amazonaws.ssmincidents#ConflictException":
throw await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context);
case "InternalServerException":
case "com.amazonaws.ssmincidents#InternalServerException":
throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
Expand Down Expand Up @@ -2806,6 +2810,31 @@ const serializeAws_restJson1DeleteRegionAction = (input: DeleteRegionAction, con
};
};

const serializeAws_restJson1DynamicSsmParameters = (
input: { [key: string]: DynamicSsmParameterValue },
context: __SerdeContext
): any => {
return Object.entries(input).reduce((acc: { [key: string]: any }, [key, value]: [string, any]) => {
if (value === null) {
return acc;
}
return {
...acc,
[key]: serializeAws_restJson1DynamicSsmParameterValue(value, context),
};
}, {});
};

const serializeAws_restJson1DynamicSsmParameterValue = (
input: DynamicSsmParameterValue,
context: __SerdeContext
): any => {
return DynamicSsmParameterValue.visit(input, {
variable: (value) => ({ variable: value }),
_: (name, value) => ({ name: value } as any),
});
};

const serializeAws_restJson1EmptyChatChannel = (input: EmptyChatChannel, context: __SerdeContext): any => {
return {};
};
Expand Down Expand Up @@ -2952,6 +2981,10 @@ const serializeAws_restJson1SsmAutomation = (input: SsmAutomation, context: __Se
...(input.documentName !== undefined && input.documentName !== null && { documentName: input.documentName }),
...(input.documentVersion !== undefined &&
input.documentVersion !== null && { documentVersion: input.documentVersion }),
...(input.dynamicParameters !== undefined &&
input.dynamicParameters !== null && {
dynamicParameters: serializeAws_restJson1DynamicSsmParameters(input.dynamicParameters, context),
}),
...(input.parameters !== undefined &&
input.parameters !== null && { parameters: serializeAws_restJson1SsmParameters(input.parameters, context) }),
...(input.roleArn !== undefined && input.roleArn !== null && { roleArn: input.roleArn }),
Expand Down Expand Up @@ -3106,6 +3139,34 @@ const deserializeAws_restJson1ChatChannel = (output: any, context: __SerdeContex
return { $unknown: Object.entries(output)[0] };
};

const deserializeAws_restJson1DynamicSsmParameters = (
output: any,
context: __SerdeContext
): { [key: string]: DynamicSsmParameterValue } => {
return Object.entries(output).reduce(
(acc: { [key: string]: DynamicSsmParameterValue }, [key, value]: [string, any]) => {
if (value === null) {
return acc;
}
return {
...acc,
[key]: deserializeAws_restJson1DynamicSsmParameterValue(__expectUnion(value), context),
};
},
{}
);
};

const deserializeAws_restJson1DynamicSsmParameterValue = (
output: any,
context: __SerdeContext
): DynamicSsmParameterValue => {
if (__expectString(output.variable) !== undefined) {
return { variable: __expectString(output.variable) as any };
}
return { $unknown: Object.entries(output)[0] };
};

const deserializeAws_restJson1EmptyChatChannel = (output: any, context: __SerdeContext): EmptyChatChannel => {
return {} as any;
};
Expand Down Expand Up @@ -3423,6 +3484,10 @@ const deserializeAws_restJson1SsmAutomation = (output: any, context: __SerdeCont
return {
documentName: __expectString(output.documentName),
documentVersion: __expectString(output.documentVersion),
dynamicParameters:
output.dynamicParameters !== undefined && output.dynamicParameters !== null
? deserializeAws_restJson1DynamicSsmParameters(output.dynamicParameters, context)
: undefined,
parameters:
output.parameters !== undefined && output.parameters !== null
? deserializeAws_restJson1SsmParameters(output.parameters, context)
Expand Down
Loading

0 comments on commit 67fcba1

Please sign in to comment.