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

feat(apigateway): grant methods to ApiKey #10633

Merged
merged 4 commits into from
Oct 9, 2020
Merged

feat(apigateway): grant methods to ApiKey #10633

merged 4 commits into from
Oct 9, 2020

Conversation

ayush987goyal
Copy link
Contributor

feat(apigateway): Add grant* methods to ApiKey

Ref

close #8060


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

nija-at
nija-at previously requested changes Oct 7, 2020
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

Nice! I like the changes in this PR 🙌

Suggestion:

If you could implement these APIs on a class called ApiKeyBase and then have both ApiKey and the Import class extend this base class, then this functionality is also available to imported keys.

Something like this -

class ApiKeyBase extends Resource implements IApiKey {
   public grantRead(...)  { ... }
   public grantWrite(...) { ... } 
   ...
}

export class ApiKey extends ApiKeyBase {
  public static fromApiKeyId(scope: Construct, id: string, apiKeyId: string): IApiKey {
    class Import extends ApiKeyBase {
      public keyId = apiKeyId;
    }
    return new Import(scope, id);
  }
}

Note that, ApiKeyBase is not exported.

packages/@aws-cdk/aws-apigateway/lib/api-key.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-apigateway/lib/api-key.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-apigateway/lib/api-key.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed nija-at’s stale review October 7, 2020 14:52

Pull request has been modified.

@ayush987goyal ayush987goyal requested a review from nija-at October 7, 2020 14:52
@ayush987goyal
Copy link
Contributor Author

Hi @nija-at , you might have to add the pr-readme-exempt label to this one.

@nija-at
Copy link
Contributor

nija-at commented Oct 7, 2020

Hi @nija-at , you might have to add the pr-readme-exempt label to this one.

Instead, how about creating a new section called 'Api Key' at line 154 (and in the table of contents)? It feels like lines154-239 are talking about API keys. Then, add a couple of sentences around the grant APIs to that section

@nija-at
Copy link
Contributor

nija-at commented Oct 9, 2020

I would prefer not to export ApiKeyBase and I think we don't need an ApiKeyBaseProps.

I've pushed a commit that changes this and restructures the code so the export is not needed. Take a look and let me know what you think.

@nija-at nija-at changed the title feat(apigateway): Add grant* methods to ApiKey feat(apigateway): grant methods to ApiKey Oct 9, 2020
nija-at
nija-at previously requested changes Oct 9, 2020
packages/@aws-cdk/aws-apigateway/README.md Outdated Show resolved Hide resolved
@ayush987goyal
Copy link
Contributor Author

ayush987goyal commented Oct 9, 2020

I would prefer not to export ApiKeyBase and I think we don't need an ApiKeyBaseProps.

I've pushed a commit that changes this and restructures the code so the export is not needed. Take a look and let me know what you think.

These changes look good to me. Thanks!

@mergify mergify bot dismissed nija-at’s stale review October 9, 2020 14:17

Pull request has been modified.

nija-at
nija-at previously approved these changes Oct 9, 2020
@mergify mergify bot dismissed nija-at’s stale review October 9, 2020 15:09

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 9cab702
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Oct 9, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 23f77fd into aws:master Oct 9, 2020
@ayush987goyal ayush987goyal deleted the pr/api-key-grant branch October 9, 2020 15:40
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.

[apigateway] ApiKey should implement grant*() APIs
3 participants