private void AddMethod()

in blueprints/dotnet/src/APIGatewayAuthorizerHandler/AuthPolicyBuilder.cs [133:172]


        private void AddMethod(Effect effect, HttpVerb verb, string resource, ICollection<Condition> conditions = null)
        {
            if (verb == null)
                throw new ArgumentNullException(nameof(verb));
            if (resource == null)
                throw new ArgumentNullException(nameof(resource));

            if (!_pathRegex.IsMatch(resource))
                throw new Exception($"Invalid resource path: {resource}. Path should match {_pathRegex}");

            string cleanedResource = resource.First() == '/' ? resource.Substring(1) : resource;

            ApiGatewayArn arn = new ApiGatewayArn
            {
                RestApiId = _restApiId,
                Region = _region,
                Stage = _stage,
                AwsAccountId = AwsAccountId,
                Verb = verb.ToString(),
                Resource = cleanedResource
            };

            switch (effect)
            {
                case Effect.Deny:
                    _denyMethods.Add(new Method
                    {
                        ArnResource = arn.ToString(),
                        Conditions = ConditionsToDictionary(conditions)
                    });
                    return;
                case Effect.Allow:
                    _allowMethods.Add(new Method
                    {
                        ArnResource = arn.ToString(),
                        Conditions = ConditionsToDictionary(conditions)
                    });
                    return;
            }
        }