{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amazon-vpc-lattice/json-schema/amazon-vpc-lattice-create-rule-request-schema.json",
  "title": "CreateRuleRequest",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amazon-vpc-lattice-createrule-api-openapi.yml#/components/schemas/CreateRuleRequest",
  "type": "object",
  "properties": {
    "serviceIdentifier": {
      "type": "string",
      "description": "The ID or ARN of the service."
    },
    "listenerIdentifier": {
      "type": "string",
      "description": "The ID or ARN of the listener."
    },
    "name": {
      "type": "string",
      "description": "The name of the rule. The name must be unique within the listener. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen."
    },
    "match": {
      "$ref": "#/$defs/RuleMatch"
    },
    "priority": {
      "type": "integer",
      "description": "The priority assigned to the rule. Each rule for a specific listener must have a unique priority. The lower the priority number the higher the priority."
    },
    "action": {
      "$ref": "#/$defs/RuleAction"
    },
    "clientToken": {
      "type": "string",
      "description": "A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails."
    },
    "tags": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "The tags for the rule."
    }
  },
  "required": [
    "serviceIdentifier",
    "listenerIdentifier",
    "name",
    "match",
    "priority",
    "action"
  ],
  "$defs": {
    "FixedResponseAction": {
      "type": "object",
      "properties": {
        "statusCode": {
          "type": "integer",
          "description": "The HTTP response code. Only 404 and 500 status codes are supported."
        }
      },
      "required": [
        "statusCode"
      ]
    },
    "ForwardAction": {
      "type": "object",
      "properties": {
        "targetGroups": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WeightedTargetGroup"
          },
          "description": "The target groups. Traffic matching the rule is forwarded to the specified target groups. With forward actions, you can assign a weight that controls the prioritization and selection of each target group. This means that requests are distributed to individual target groups based on their weights. For example, if two target groups have the same weight, each target group receives half of the traffic. The default value is 1. This means that if only one target group is provided, there is no need to set the weight; 100% of the traffic goes to that target group."
        }
      },
      "required": [
        "targetGroups"
      ]
    },
    "HeaderMatch": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the header."
        },
        "match": {
          "$ref": "#/$defs/HeaderMatchType"
        },
        "caseSensitive": {
          "type": "boolean",
          "description": "Indicates whether the match is case sensitive."
        }
      },
      "required": [
        "name",
        "match"
      ]
    },
    "HeaderMatchType": {
      "type": "object",
      "properties": {
        "exact": {
          "type": "string",
          "description": "An exact type match."
        },
        "prefix": {
          "type": "string",
          "description": "A prefix type match. Matches the value with the prefix."
        },
        "contains": {
          "type": "string",
          "description": "A contains type match."
        }
      },
      "description": "Exactly one member is set."
    },
    "HttpMatch": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "description": "The HTTP method type."
        },
        "pathMatch": {
          "$ref": "#/$defs/PathMatch"
        },
        "headerMatches": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/HeaderMatch"
          },
          "description": "The header matches. Matches incoming requests with rule based on request header value before applying rule action."
        }
      }
    },
    "PathMatch": {
      "type": "object",
      "properties": {
        "match": {
          "$ref": "#/$defs/PathMatchType"
        },
        "caseSensitive": {
          "type": "boolean",
          "description": "Indicates whether the match is case sensitive."
        }
      },
      "required": [
        "match"
      ]
    },
    "PathMatchType": {
      "type": "object",
      "properties": {
        "exact": {
          "type": "string",
          "description": "An exact match of the path."
        },
        "prefix": {
          "type": "string",
          "description": "A prefix match of the path."
        }
      },
      "description": "Exactly one member is set."
    },
    "RuleAction": {
      "type": "object",
      "properties": {
        "forward": {
          "$ref": "#/$defs/ForwardAction"
        },
        "fixedResponse": {
          "$ref": "#/$defs/FixedResponseAction"
        }
      },
      "description": "Exactly one member is set."
    },
    "RuleMatch": {
      "type": "object",
      "properties": {
        "httpMatch": {
          "$ref": "#/$defs/HttpMatch"
        }
      },
      "description": "Exactly one member is set."
    },
    "WeightedTargetGroup": {
      "type": "object",
      "properties": {
        "targetGroupIdentifier": {
          "type": "string",
          "description": "The ID or ARN of the target group."
        },
        "weight": {
          "type": "integer",
          "description": "Only required if you specify multiple target groups for a forward action. The weight determines how requests are distributed to the target group. For example, if you specify two target groups, each with a weight of 10, each target group receives half the requests. If you specify two target groups, one with a weight of 10 and the other with a weight of 20, the target group with a weight of 20 receives twice as many requests as the other target group. If there's only one target group specified, then the default value is 100."
        }
      },
      "required": [
        "targetGroupIdentifier"
      ]
    }
  }
}