aws-cloudformation / cloudformation-resource-schema

The CloudFormation Resource Schema defines the shape and semantic for resources provisioned by CloudFormation. It is used by provider developers using the CloudFormation RPDK.
Apache License 2.0
90 stars 38 forks source link

Adding support to fetch handler permissions from schema object #104

Closed johnttompkins closed 3 years ago

johnttompkins commented 3 years ago

Issue #, if available:

Description of changes: Allows for access of handler permissions via the schema object. Can now retrieve permissions in the following way:

ResourceTypeSchema schema = ResourceTypeSchema.load(resourceDefinition);
//Set of permissions required to create a resource
Set<String> createPermissions = schema.getHandlerPermissions.get("create");

I left the handler properties as unprocessed as timeoutInMinutes is still yet to be processed. If necessary I can add in some logic to set another member variable to process these, but there's no use currently for fetching these.

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

PatMyron commented 3 years ago

What's this for btw? Wondering what'll use this vs. parsing JSON directly

johnttompkins commented 3 years ago

What's this for btw? Wondering what'll use this vs. parsing JSON directly

Was working on some items that required comparing the permissions and this seemed to be a more sharable way to do the work. If something is modelled in the schema it should be retrievable in the schema object. Parsing the json directly works but wanted to provide an easy way to get them in case a similar thing needs to be done elsewhere.