{
  "typeName" : "AWS::BedrockAgentCore::GatewayTarget",
  "description" : "Resource Type definition for AWS::BedrockAgentCore::GatewayTarget",
  "definitions" : {
    "ApiKeyCredentialLocation" : {
      "type" : "string",
      "enum" : [ "HEADER", "QUERY_PARAMETER" ]
    },
    "ApiKeyCredentialProvider" : {
      "type" : "object",
      "properties" : {
        "ProviderArn" : {
          "type" : "string",
          "pattern" : "^arn:([^:]*):([^:]*):([^:]*):([0-9]{12})?:(.+)$"
        },
        "CredentialParameterName" : {
          "type" : "string",
          "maxLength" : 64,
          "minLength" : 1
        },
        "CredentialPrefix" : {
          "type" : "string",
          "maxLength" : 64,
          "minLength" : 1
        },
        "CredentialLocation" : {
          "$ref" : "#/definitions/ApiKeyCredentialLocation"
        }
      },
      "required" : [ "ProviderArn" ],
      "additionalProperties" : false
    },
    "ApiSchemaConfiguration" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "S3",
        "properties" : {
          "S3" : {
            "$ref" : "#/definitions/S3Configuration"
          }
        },
        "required" : [ "S3" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "InlinePayload",
        "properties" : {
          "InlinePayload" : {
            "type" : "string"
          }
        },
        "required" : [ "InlinePayload" ],
        "additionalProperties" : false
      } ]
    },
    "ApiGatewayTargetConfiguration" : {
      "type" : "object",
      "properties" : {
        "RestApiId" : {
          "type" : "string"
        },
        "Stage" : {
          "type" : "string"
        },
        "ApiGatewayToolConfiguration" : {
          "$ref" : "#/definitions/ApiGatewayToolConfiguration"
        }
      },
      "required" : [ "RestApiId", "Stage", "ApiGatewayToolConfiguration" ],
      "additionalProperties" : false
    },
    "ApiGatewayToolConfiguration" : {
      "type" : "object",
      "properties" : {
        "ToolOverrides" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/ApiGatewayToolOverride"
          }
        },
        "ToolFilters" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/ApiGatewayToolFilter"
          }
        }
      },
      "required" : [ "ToolFilters" ],
      "additionalProperties" : false
    },
    "ApiGatewayToolOverride" : {
      "type" : "object",
      "properties" : {
        "Name" : {
          "type" : "string"
        },
        "Description" : {
          "type" : "string"
        },
        "Path" : {
          "type" : "string"
        },
        "Method" : {
          "$ref" : "#/definitions/RestApiMethod"
        }
      },
      "required" : [ "Name", "Path", "Method" ],
      "additionalProperties" : false
    },
    "ApiGatewayToolFilter" : {
      "type" : "object",
      "properties" : {
        "FilterPath" : {
          "type" : "string"
        },
        "Methods" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/RestApiMethod"
          }
        }
      },
      "required" : [ "FilterPath", "Methods" ],
      "additionalProperties" : false
    },
    "RestApiMethod" : {
      "type" : "string",
      "enum" : [ "GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "PUT", "POST" ]
    },
    "CredentialProvider" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "OauthCredentialProvider",
        "properties" : {
          "OauthCredentialProvider" : {
            "$ref" : "#/definitions/OAuthCredentialProvider"
          }
        },
        "required" : [ "OauthCredentialProvider" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "ApiKeyCredentialProvider",
        "properties" : {
          "ApiKeyCredentialProvider" : {
            "$ref" : "#/definitions/ApiKeyCredentialProvider"
          }
        },
        "required" : [ "ApiKeyCredentialProvider" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "IamCredentialProvider",
        "properties" : {
          "IamCredentialProvider" : {
            "$ref" : "#/definitions/IamCredentialProvider"
          }
        },
        "required" : [ "IamCredentialProvider" ],
        "additionalProperties" : false
      } ]
    },
    "IamCredentialProvider" : {
      "type" : "object",
      "properties" : {
        "Service" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 64,
          "pattern" : "^[a-zA-Z0-9._-]+$"
        },
        "Region" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32,
          "pattern" : "^[a-zA-Z0-9-]+$"
        }
      },
      "required" : [ "Service" ],
      "additionalProperties" : false
    },
    "CredentialProviderConfiguration" : {
      "type" : "object",
      "properties" : {
        "CredentialProviderType" : {
          "$ref" : "#/definitions/CredentialProviderType"
        },
        "CredentialProvider" : {
          "$ref" : "#/definitions/CredentialProvider"
        }
      },
      "required" : [ "CredentialProviderType" ],
      "additionalProperties" : false
    },
    "CredentialProviderType" : {
      "type" : "string",
      "enum" : [ "GATEWAY_IAM_ROLE", "OAUTH", "API_KEY" ]
    },
    "McpLambdaTargetConfiguration" : {
      "type" : "object",
      "properties" : {
        "LambdaArn" : {
          "type" : "string",
          "maxLength" : 170,
          "minLength" : 1,
          "pattern" : "^arn:(aws[a-zA-Z-]*)?:lambda:([a-z]{2}(-gov)?-[a-z]+-\\d{1}):(\\d{12}):function:([a-zA-Z0-9-_.]+)(:(\\$LATEST|[a-zA-Z0-9-_]+))?$"
        },
        "ToolSchema" : {
          "$ref" : "#/definitions/ToolSchema"
        }
      },
      "required" : [ "LambdaArn", "ToolSchema" ],
      "additionalProperties" : false
    },
    "McpServerTargetConfiguration" : {
      "type" : "object",
      "properties" : {
        "Endpoint" : {
          "type" : "string",
          "pattern" : "^https://.*"
        }
      },
      "required" : [ "Endpoint" ],
      "additionalProperties" : false
    },
    "McpTargetConfiguration" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "OpenApiSchema",
        "properties" : {
          "OpenApiSchema" : {
            "$ref" : "#/definitions/ApiSchemaConfiguration"
          }
        },
        "required" : [ "OpenApiSchema" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "SmithyModel",
        "properties" : {
          "SmithyModel" : {
            "$ref" : "#/definitions/ApiSchemaConfiguration"
          }
        },
        "required" : [ "SmithyModel" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Lambda",
        "properties" : {
          "Lambda" : {
            "$ref" : "#/definitions/McpLambdaTargetConfiguration"
          }
        },
        "required" : [ "Lambda" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "McpServer",
        "properties" : {
          "McpServer" : {
            "$ref" : "#/definitions/McpServerTargetConfiguration"
          }
        },
        "required" : [ "McpServer" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "ApiGateway",
        "properties" : {
          "ApiGateway" : {
            "$ref" : "#/definitions/ApiGatewayTargetConfiguration"
          }
        },
        "required" : [ "ApiGateway" ],
        "additionalProperties" : false
      } ]
    },
    "OAuthCredentialProvider" : {
      "type" : "object",
      "properties" : {
        "ProviderArn" : {
          "type" : "string",
          "pattern" : "^arn:([^:]*):([^:]*):([^:]*):([0-9]{12})?:(.+)$"
        },
        "Scopes" : {
          "type" : "array",
          "items" : {
            "type" : "string",
            "maxLength" : 64,
            "minLength" : 1
          },
          "maxItems" : 100
        },
        "CustomParameters" : {
          "$ref" : "#/definitions/OAuthCustomParameters"
        },
        "GrantType" : {
          "$ref" : "#/definitions/OAuthGrantType"
        },
        "DefaultReturnUrl" : {
          "type" : "string",
          "pattern" : "\\w+:(\\/?\\/?)[^\\s]+",
          "maxLength" : 2048,
          "minLength" : 1,
          "description" : "Return URL for OAuth callback."
        }
      },
      "required" : [ "ProviderArn", "Scopes" ],
      "additionalProperties" : false
    },
    "OAuthCustomParameters" : {
      "type" : "object",
      "maxProperties" : 10,
      "minProperties" : 1,
      "patternProperties" : {
        ".+" : {
          "type" : "string",
          "maxLength" : 2048,
          "minLength" : 1
        }
      },
      "additionalProperties" : false
    },
    "OAuthGrantType" : {
      "type" : "string",
      "enum" : [ "AUTHORIZATION_CODE", "CLIENT_CREDENTIALS" ]
    },
    "S3Configuration" : {
      "type" : "object",
      "properties" : {
        "Uri" : {
          "type" : "string",
          "pattern" : "^s3://.{1,2043}$"
        },
        "BucketOwnerAccountId" : {
          "type" : "string",
          "pattern" : "^[0-9]{12}$"
        }
      },
      "additionalProperties" : false
    },
    "SchemaDefinition" : {
      "type" : "object",
      "properties" : {
        "Type" : {
          "$ref" : "#/definitions/SchemaType"
        },
        "Properties" : {
          "$ref" : "#/definitions/SchemaProperties"
        },
        "Required" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          }
        },
        "Items" : {
          "$ref" : "#/definitions/SchemaDefinition"
        },
        "Description" : {
          "type" : "string"
        }
      },
      "required" : [ "Type" ],
      "additionalProperties" : false
    },
    "SchemaProperties" : {
      "type" : "object",
      "patternProperties" : {
        ".+" : {
          "$ref" : "#/definitions/SchemaDefinition"
        }
      },
      "additionalProperties" : false
    },
    "SchemaType" : {
      "type" : "string",
      "enum" : [ "string", "number", "object", "array", "boolean", "integer" ]
    },
    "TargetConfiguration" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "Mcp",
        "properties" : {
          "Mcp" : {
            "$ref" : "#/definitions/McpTargetConfiguration"
          }
        },
        "required" : [ "Mcp" ],
        "additionalProperties" : false
      } ]
    },
    "TargetStatus" : {
      "type" : "string",
      "enum" : [ "CREATING", "UPDATING", "UPDATE_UNSUCCESSFUL", "DELETING", "READY", "FAILED", "SYNCHRONIZING", "SYNCHRONIZE_UNSUCCESSFUL" ]
    },
    "ToolDefinition" : {
      "type" : "object",
      "properties" : {
        "Name" : {
          "type" : "string"
        },
        "Description" : {
          "type" : "string"
        },
        "InputSchema" : {
          "$ref" : "#/definitions/SchemaDefinition"
        },
        "OutputSchema" : {
          "$ref" : "#/definitions/SchemaDefinition"
        }
      },
      "required" : [ "Description", "InputSchema", "Name" ],
      "additionalProperties" : false
    },
    "ToolSchema" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "S3",
        "properties" : {
          "S3" : {
            "$ref" : "#/definitions/S3Configuration"
          }
        },
        "required" : [ "S3" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "InlinePayload",
        "properties" : {
          "InlinePayload" : {
            "type" : "array",
            "items" : {
              "$ref" : "#/definitions/ToolDefinition"
            }
          }
        },
        "required" : [ "InlinePayload" ],
        "additionalProperties" : false
      } ]
    },
    "MetadataConfiguration" : {
      "type" : "object",
      "properties" : {
        "AllowedRequestHeaders" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          }
        },
        "AllowedQueryParameters" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          }
        },
        "AllowedResponseHeaders" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          }
        }
      },
      "additionalProperties" : false
    }
  },
  "properties" : {
    "CreatedAt" : {
      "type" : "string",
      "format" : "date-time"
    },
    "CredentialProviderConfigurations" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/CredentialProviderConfiguration"
      },
      "maxItems" : 1,
      "minItems" : 1
    },
    "Description" : {
      "type" : "string",
      "maxLength" : 200,
      "minLength" : 1
    },
    "GatewayArn" : {
      "type" : "string",
      "pattern" : "^arn:aws(|-cn|-us-gov):bedrock-agentcore:[a-z0-9-]{1,20}:[0-9]{12}:gateway/([0-9a-z][-]?){1,100}-[a-z0-9]{10}$"
    },
    "GatewayIdentifier" : {
      "type" : "string",
      "pattern" : "^([0-9a-z][-]?){1,100}-[0-9a-z]{10}$"
    },
    "LastSynchronizedAt" : {
      "type" : "string",
      "format" : "date-time"
    },
    "MetadataConfiguration" : {
      "$ref" : "#/definitions/MetadataConfiguration"
    },
    "Name" : {
      "type" : "string",
      "pattern" : "^([0-9a-zA-Z][-]?){1,100}$"
    },
    "Status" : {
      "$ref" : "#/definitions/TargetStatus"
    },
    "StatusReasons" : {
      "type" : "array",
      "items" : {
        "type" : "string",
        "maxLength" : 2048
      },
      "maxItems" : 100
    },
    "TargetConfiguration" : {
      "$ref" : "#/definitions/TargetConfiguration"
    },
    "TargetId" : {
      "type" : "string",
      "pattern" : "^[0-9a-zA-Z]{10}$"
    },
    "UpdatedAt" : {
      "type" : "string",
      "format" : "date-time"
    }
  },
  "required" : [ "Name", "TargetConfiguration" ],
  "createOnlyProperties" : [ "/properties/GatewayIdentifier" ],
  "readOnlyProperties" : [ "/properties/CreatedAt", "/properties/GatewayArn", "/properties/LastSynchronizedAt", "/properties/Status", "/properties/StatusReasons", "/properties/TargetId", "/properties/UpdatedAt" ],
  "primaryIdentifier" : [ "/properties/GatewayIdentifier", "/properties/TargetId" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "apigateway:GET", "bedrock-agentcore:CreateGatewayTarget", "bedrock-agentcore:GetGatewayTarget", "bedrock-agentcore:GetResourceOauth2Token", "bedrock-agentcore:GetWorkloadAccessToken", "bedrock-agentcore:SynchronizeGatewayTargets", "kms:Decrypt", "kms:GenerateDataKey", "kms:ListGrants", "s3:GetObject", "secretsmanager:GetSecretValue" ]
    },
    "read" : {
      "permissions" : [ "bedrock-agentcore:GetGatewayTarget" ]
    },
    "update" : {
      "permissions" : [ "apigateway:GET", "bedrock-agentcore:GetGatewayTarget", "bedrock-agentcore:GetResourceOauth2Token", "bedrock-agentcore:GetWorkloadAccessToken", "bedrock-agentcore:SynchronizeGatewayTargets", "bedrock-agentcore:UpdateGatewayTarget", "kms:Decrypt", "kms:GenerateDataKey", "kms:ListGrants", "s3:GetObject", "secretsmanager:GetSecretValue" ]
    },
    "delete" : {
      "permissions" : [ "bedrock-agentcore:DeleteGatewayTarget", "bedrock-agentcore:GetGatewayTarget", "kms:Decrypt", "kms:GenerateDataKey", "kms:ListGrants" ]
    },
    "list" : {
      "permissions" : [ "bedrock-agentcore:ListGatewayTargets" ]
    }
  },
  "additionalProperties" : false,
  "tagging" : {
    "taggable" : false,
    "cloudFormationSystemTags" : false
  }
}