Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws-json] Migrate SNS SetSubscriptionAttributes API #321

Conversation

kojisaikiAtSony
Copy link
Contributor

No description provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally we can delete this old test file 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha love it!

Comment on lines 53 to 54
// FIXME: This response is literally strange but it's the same behavior with old SetSubscriptionAtteributes.
return utils.CreateErrorResponseV1("SubscriptionNotFound", false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current behavior returns "SubscriptionNotFound" error when an unsupported attribute name is specified.
Should we define another appropriate error?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, good find. Yeah that is weird. Maybe InvalidParameter? The thing is, that I think there's a lot of other attributes they could be targeting that I guess we don't support either.

https://docs.aws.amazon.com/sns/latest/api/API_SetSubscriptionAttributes.html#API_SetSubscriptionAttributes_RequestParameters

I think I would suggest catching all those other ones and maybe just logging that they are unsupported and return. Then our default could be the InvalidParameterValue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! I will apply it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied!

Comment on lines 65 to 74
func getSubscription(subsArn string) *app.Subscription {
for _, topic := range app.SyncTopics.Topics {
for _, sub := range topic.Subscriptions {
if sub.SubscriptionArn == subsArn {
return sub
}
}
}
return nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to separate the loop indent from the following logic.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! If you want to throw it in the utils or somewhere more general it might be helpful in the other handlers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will apply the idea in this PR. At lease, I will apply it on GetSubscriptionAttributes API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shared the getSubscription to just only GetSubscriptionAttributes API.
Unsubscribe API logic also has the same loop and indent but the API requires the subscription index in a topic and modify them by topic level perspective. I thought it will be too much commonize for the API.

uuid := uuid.NewString()
respStruct := models.SetSubscriptionAttributesResponse{
Xmlns: models.BASE_XMLNS,
Metadata: app.ResponseMetadata{RequestId: uuid}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that the "RequestId" in the response is different between APIs (random uuid or models.BASE_RESPONSE_METADATA).
We can align it into which one before merging the feature branch into master.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know. They're all different between SQS and SNS. Let's match to whatever is currently here right now, and I'll go back and untangle them later.

@kojisaikiAtSony
Copy link
Contributor Author

Hi @Admiral-Piett , this is ready for review!

Copy link
Owner

@Admiral-Piett Admiral-Piett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, and great call outs on your comments! I think if we clear our questions up this is ready.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha love it!

Comment on lines 53 to 54
// FIXME: This response is literally strange but it's the same behavior with old SetSubscriptionAtteributes.
return utils.CreateErrorResponseV1("SubscriptionNotFound", false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, good find. Yeah that is weird. Maybe InvalidParameter? The thing is, that I think there's a lot of other attributes they could be targeting that I guess we don't support either.

https://docs.aws.amazon.com/sns/latest/api/API_SetSubscriptionAttributes.html#API_SetSubscriptionAttributes_RequestParameters

I think I would suggest catching all those other ones and maybe just logging that they are unsupported and return. Then our default could be the InvalidParameterValue?

uuid := uuid.NewString()
respStruct := models.SetSubscriptionAttributesResponse{
Xmlns: models.BASE_XMLNS,
Metadata: app.ResponseMetadata{RequestId: uuid}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know. They're all different between SQS and SNS. Let's match to whatever is currently here right now, and I'll go back and untangle them later.

Comment on lines 65 to 74
func getSubscription(subsArn string) *app.Subscription {
for _, topic := range app.SyncTopics.Topics {
for _, sub := range topic.Subscriptions {
if sub.SubscriptionArn == subsArn {
return sub
}
}
}
return nil
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! If you want to throw it in the utils or somewhere more general it might be helpful in the other handlers?

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@kojisaikiAtSony kojisaikiAtSony force-pushed the feature-aws-json-set-subscription-attributes branch from bbedcf3 to a5aa87e Compare September 10, 2024 01:49
@kojisaikiAtSony
Copy link
Contributor Author

@Admiral-Piett Updated!

Copy link
Owner

@Admiral-Piett Admiral-Piett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! Thank you for your diligence, great work my friend!

@Admiral-Piett Admiral-Piett merged commit e54a44f into Admiral-Piett:feature-aws-json Sep 11, 2024
2 checks passed
@kojisaikiAtSony kojisaikiAtSony deleted the feature-aws-json-set-subscription-attributes branch September 12, 2024 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants