{
 "Description": "Integration Test for aws-apigateway-sagemakerendpoint",
 "Resources": {
  "apigatewayroleE6D48DBD": {
   "Type": "AWS::IAM::Role",
   "Properties": {
    "AssumeRolePolicyDocument": {
     "Statement": [
      {
       "Action": "sts:AssumeRole",
       "Effect": "Allow",
       "Principal": {
        "Service": "apigateway.amazonaws.com"
       }
      }
     ],
     "Version": "2012-10-17"
    },
    "Description": "existing role for SageMaker integration",
    "Policies": [
     {
      "PolicyDocument": {
       "Statement": [
        {
         "Action": "sagemaker:InvokeEndpoint",
         "Effect": "Allow",
         "Resource": {
          "Fn::Join": [
           "",
           [
            "arn:",
            {
             "Ref": "AWS::Partition"
            },
            ":sagemaker:",
            {
             "Ref": "AWS::Region"
            },
            ":",
            {
             "Ref": "AWS::AccountId"
            },
            ":endpoint/my-endpoint"
           ]
          ]
         }
        }
       ],
       "Version": "2012-10-17"
      },
      "PolicyName": "InvokePolicy"
     }
    ]
   },
   "Metadata": {
    "guard": {
     "SuppressedRules": [
      "IAM_NO_INLINE_POLICY_CHECK"
     ]
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteApiAccessLogGroupC0933D4E": {
   "Type": "AWS::Logs::LogGroup",
   "UpdateReplacePolicy": "Retain",
   "DeletionPolicy": "Retain",
   "Metadata": {
    "cfn_nag": {
     "rules_to_suppress": [
      {
       "id": "W86",
       "reason": "Retention period for CloudWatchLogs LogGroups are set to 'Never Expire' to preserve customer data indefinitely"
      },
      {
       "id": "W84",
       "reason": "By default CloudWatchLogs LogGroups data is encrypted using the CloudWatch server-side encryption keys (AWS Managed Keys)"
      }
     ]
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApi0EE22754": {
   "Type": "AWS::ApiGateway::RestApi",
   "Properties": {
    "EndpointConfiguration": {
     "Types": [
      "EDGE"
     ]
    },
    "Name": "RestApi"
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApiDeployment3B3B03364a19f99c87430d39385b3313a65df211": {
   "Type": "AWS::ApiGateway::Deployment",
   "Properties": {
    "Description": "Automatically created by the RestApi construct",
    "RestApiId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
    }
   },
   "DependsOn": [
    "testapigatewaysagemakerendpointoverwriteRestApipredictedratingsuseridGET06B35696",
    "testapigatewaysagemakerendpointoverwriteRestApipredictedratingsuseridB999A556",
    "testapigatewaysagemakerendpointoverwriteRestApipredictedratings1C8B9193",
    "testapigatewaysagemakerendpointoverwriteRestApirequestvalidatorFA90CC69"
   ],
   "Metadata": {
    "aws:cdk:do-not-refactor": true,
    "cfn_nag": {
     "rules_to_suppress": [
      {
       "id": "W45",
       "reason": "ApiGateway has AccessLogging enabled in AWS::ApiGateway::Stage resource, but cfn_nag checks for it in AWS::ApiGateway::Deployment resource"
      }
     ]
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApiDeploymentStageprod39A2035F": {
   "Type": "AWS::ApiGateway::Stage",
   "Properties": {
    "AccessLogSetting": {
     "DestinationArn": {
      "Fn::GetAtt": [
       "testapigatewaysagemakerendpointoverwriteApiAccessLogGroupC0933D4E",
       "Arn"
      ]
     },
     "Format": "{\"requestId\":\"$context.requestId\",\"ip\":\"$context.identity.sourceIp\",\"user\":\"$context.identity.user\",\"caller\":\"$context.identity.caller\",\"requestTime\":\"$context.requestTime\",\"httpMethod\":\"$context.httpMethod\",\"resourcePath\":\"$context.resourcePath\",\"status\":\"$context.status\",\"protocol\":\"$context.protocol\",\"responseLength\":\"$context.responseLength\"}"
    },
    "DeploymentId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApiDeployment3B3B03364a19f99c87430d39385b3313a65df211"
    },
    "MethodSettings": [
     {
      "DataTraceEnabled": false,
      "HttpMethod": "*",
      "LoggingLevel": "INFO",
      "ResourcePath": "/*"
     }
    ],
    "RestApiId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
    },
    "StageName": "prod",
    "TracingEnabled": true
   },
   "Metadata": {
    "guard": {
     "SuppressedRules": [
      "API_GW_CACHE_ENABLED_AND_ENCRYPTED"
     ]
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApipredictedratings1C8B9193": {
   "Type": "AWS::ApiGateway::Resource",
   "Properties": {
    "ParentId": {
     "Fn::GetAtt": [
      "testapigatewaysagemakerendpointoverwriteRestApi0EE22754",
      "RootResourceId"
     ]
    },
    "PathPart": "predicted-ratings",
    "RestApiId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApipredictedratingsuseridB999A556": {
   "Type": "AWS::ApiGateway::Resource",
   "Properties": {
    "ParentId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApipredictedratings1C8B9193"
    },
    "PathPart": "{user_id}",
    "RestApiId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApipredictedratingsuseridGET06B35696": {
   "Type": "AWS::ApiGateway::Method",
   "Properties": {
    "AuthorizationType": "AWS_IAM",
    "HttpMethod": "GET",
    "Integration": {
     "Credentials": {
      "Fn::GetAtt": [
       "apigatewayroleE6D48DBD",
       "Arn"
      ]
     },
     "IntegrationHttpMethod": "POST",
     "IntegrationResponses": [
      {
       "ResponseTemplates": {
        "application/json": "{\n    \"ratings\": [\n#set( $predictions = $input.path(\"$.predictions\") )\n#foreach( $item in $predictions )\n    $item.scores[0]#if( $foreach.hasNext ),#end\n    $esc.newline\n#end\n    ]\n}"
       },
       "StatusCode": "200"
      },
      {
       "SelectionPattern": "5\\d{2}",
       "StatusCode": "500"
      },
      {
       "SelectionPattern": "4\\d{2}",
       "StatusCode": "400"
      }
     ],
     "PassthroughBehavior": "NEVER",
     "RequestParameters": {
      "integration.request.header.Content-Type": "'application/json'"
     },
     "RequestTemplates": {
      "application/json": "{\n    \"instances\": [\n#set( $user_id = $input.params(\"user_id\") )\n#set( $items = $input.params(\"items\") )\n#foreach( $item in $items.split(\",\") )\n    {\"in0\": [$user_id], \"in1\": [$item]}#if( $foreach.hasNext ),#end\n    $esc.newline\n#end\n    ]\n}"
     },
     "Type": "AWS",
     "Uri": {
      "Fn::Join": [
       "",
       [
        "arn:",
        {
         "Ref": "AWS::Partition"
        },
        ":apigateway:",
        {
         "Ref": "AWS::Region"
        },
        ":runtime.sagemaker:path/endpoints/my-endpoint/invocations"
       ]
      ]
     }
    },
    "MethodResponses": [
     {
      "StatusCode": "200"
     },
     {
      "StatusCode": "500"
     },
     {
      "StatusCode": "400"
     }
    ],
    "RequestValidatorId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApirequestvalidatorFA90CC69"
    },
    "ResourceId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApipredictedratingsuseridB999A556"
    },
    "RestApiId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApiUsagePlan64BD97E7": {
   "Type": "AWS::ApiGateway::UsagePlan",
   "Properties": {
    "ApiStages": [
     {
      "ApiId": {
       "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
      },
      "Stage": {
       "Ref": "testapigatewaysagemakerendpointoverwriteRestApiDeploymentStageprod39A2035F"
      },
      "Throttle": {}
     }
    ]
   }
  },
  "testapigatewaysagemakerendpointoverwriteRestApirequestvalidatorFA90CC69": {
   "Type": "AWS::ApiGateway::RequestValidator",
   "Properties": {
    "Name": "request-param-validator",
    "RestApiId": {
     "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
    },
    "ValidateRequestParameters": true
   }
  },
  "testapigatewaysagemakerendpointoverwriteLambdaRestApiCloudWatchRole2ED1F54A": {
   "Type": "AWS::IAM::Role",
   "Properties": {
    "AssumeRolePolicyDocument": {
     "Statement": [
      {
       "Action": "sts:AssumeRole",
       "Effect": "Allow",
       "Principal": {
        "Service": "apigateway.amazonaws.com"
       }
      }
     ],
     "Version": "2012-10-17"
    },
    "Policies": [
     {
      "PolicyDocument": {
       "Statement": [
        {
         "Action": [
          "logs:CreateLogGroup",
          "logs:CreateLogStream",
          "logs:DescribeLogGroups",
          "logs:DescribeLogStreams",
          "logs:FilterLogEvents",
          "logs:GetLogEvents",
          "logs:PutLogEvents"
         ],
         "Effect": "Allow",
         "Resource": {
          "Fn::Join": [
           "",
           [
            "arn:",
            {
             "Ref": "AWS::Partition"
            },
            ":logs:",
            {
             "Ref": "AWS::Region"
            },
            ":",
            {
             "Ref": "AWS::AccountId"
            },
            ":*"
           ]
          ]
         }
        }
       ],
       "Version": "2012-10-17"
      },
      "PolicyName": "LambdaRestApiCloudWatchRolePolicy"
     }
    ]
   },
   "Metadata": {
    "guard": {
     "SuppressedRules": [
      "IAM_NO_INLINE_POLICY_CHECK"
     ]
    }
   }
  },
  "testapigatewaysagemakerendpointoverwriteLambdaRestApiAccount8093B262": {
   "Type": "AWS::ApiGateway::Account",
   "Properties": {
    "CloudWatchRoleArn": {
     "Fn::GetAtt": [
      "testapigatewaysagemakerendpointoverwriteLambdaRestApiCloudWatchRole2ED1F54A",
      "Arn"
     ]
    }
   },
   "DependsOn": [
    "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
   ]
  }
 },
 "Outputs": {
  "testapigatewaysagemakerendpointoverwriteRestApiEndpointE0CCBC1C": {
   "Value": {
    "Fn::Join": [
     "",
     [
      "https://",
      {
       "Ref": "testapigatewaysagemakerendpointoverwriteRestApi0EE22754"
      },
      ".execute-api.",
      {
       "Ref": "AWS::Region"
      },
      ".",
      {
       "Ref": "AWS::URLSuffix"
      },
      "/",
      {
       "Ref": "testapigatewaysagemakerendpointoverwriteRestApiDeploymentStageprod39A2035F"
      },
      "/"
     ]
    ]
   }
  }
 },
 "Parameters": {
  "BootstrapVersion": {
   "Type": "AWS::SSM::Parameter::Value<String>",
   "Default": "/cdk-bootstrap/hnb659fds/version",
   "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
  }
 },
 "Rules": {
  "CheckBootstrapVersion": {
   "Assertions": [
    {
     "Assert": {
      "Fn::Not": [
       {
        "Fn::Contains": [
         [
          "1",
          "2",
          "3",
          "4",
          "5"
         ],
         {
          "Ref": "BootstrapVersion"
         }
        ]
       }
      ]
     },
     "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
    }
   ]
  }
 }
}