33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import * as Joi from 'joi';
|
|
|
|
import { AbstractActionHandler, AwsProperties, Format } from '../abstract-action.handler';
|
|
import { Action } from '../action.enum';
|
|
import { AttributesService } from '../aws-shared-entities/attributes.service';
|
|
import { RequestContext } from '../_context/request.context';
|
|
|
|
type QueryParams = {
|
|
AttributeName: string;
|
|
AttributeValue: string;
|
|
SubscriptionArn: string;
|
|
};
|
|
|
|
@Injectable()
|
|
export class SetSubscriptionAttributesHandler extends AbstractActionHandler<QueryParams> {
|
|
constructor(private readonly attributeService: AttributesService) {
|
|
super();
|
|
}
|
|
|
|
format = Format.Xml;
|
|
action = Action.SnsSetSubscriptionAttributes;
|
|
validator = Joi.object<QueryParams, true>({
|
|
AttributeName: Joi.string().required(),
|
|
AttributeValue: Joi.string().required(),
|
|
SubscriptionArn: Joi.string().required(),
|
|
});
|
|
|
|
protected async handle({ AttributeName, AttributeValue, SubscriptionArn }: QueryParams, { awsProperties }: RequestContext) {
|
|
await this.attributeService.create({ name: AttributeName, value: AttributeValue, arn: SubscriptionArn });
|
|
}
|
|
}
|