{
  "openapi": "3.0.1",
  "info": {
    "title": "Search Rules",
    "description": "Provide search rules Api Documentation",
    "version": "9.1.20.0",
    "x-introduced": "9.1.6.0"
  },
  "servers": [
    {
      "url": "http://{hostname}:{port}",
      "description": "Toolkit server url",
      "variables": {
        "port": {
          "default": "443",
          "enum": [
            "443",
            "30900"
          ]
        },
        "hostname": {
          "default": "localhost",
          "enum": [
            "localhost",
            "test.hcl.com"
          ]
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Search Rules",
      "description": "This class provides RESTful services to create, read, update and delete new search rules required for Search UI."
    }
  ],
  "paths": {
    "/api/v2/rules": {
      "get": {
        "tags": [
          "Search Term Rules"
        ],
        "summary": "Gets Response for existing search term rules. If search term rule name is specified as query parameter searchTerm, specific search term rule would be returned else all the available search term rules will be returned.",
        "operationId": "getSearchTermRules",
        "parameters": [
          {
            "name": "storeId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "langId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "searchTerm",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "description": "The maximum number of records to return.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "description": "The position within the resulting dataset where the query begins returning item records. If the offset is \"5\", the records that returned begin with the sixth record that matches the query parameters. If the offset is \"0\", the records that are returned begin with the first record that matches the query parameters.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "sort",
            "description": "The comma-separated set of properties that control the order of the listed items. Properties can be prefixed by either (-) to sort in descending order, or (+) to sort in ascending order. By default, properties are sorted in ascending order. For example, sort=name will order the items based on the name value in ascending order.",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The requested completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchTermRulesCollection"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Some of the inputs provided to the request are not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "The specified resource could not be found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Additional details will be contained on the server logs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Search Term Rules"
        ],
        "summary": "This will create new search term rule with name specified as parameter value for parameter searchTerm. This endpoint will throw error if search term rule with same name already exists.",
        "operationId": "addSearchTermRule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchTermRule"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "storeId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "langId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "searchTerm",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The search term rule was created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Some of the inputs provided to the request are not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "The specified resource already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Additional details will be contained on the server logs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Search Term Rules"
        ],
        "summary": "This will update the existing search term rule with name specified as value for parameter searchTerm. If search term rule with specified name doesn't exist, new search term rule will be created.",
        "operationId": "updateSearchTermRule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchTermRule"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "storeId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "langId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "catentryId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "searchTerm",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The search term rule was updated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "201": {
            "description": "The search term rule was created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Some of the inputs provided to the request are not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Additional details will be contained on the server logs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Search Term Rules"
        ],
        "summary": "This will delete the existing search term rules. If search term rule with spedified name doesn't exist, no action will be taken.",
        "operationId": "deleteSearchTermRule",
        "parameters": [
          {
            "name": "storeId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "langId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "searchTerm",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The search term rule was deleted successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Some of the inputs provided to the request are not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Additional details will be contained on the server logs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SearchTermRulesCollection": {
        "properties": {
          "count": {
            "description": "The total number of item records that match the query parameters.",
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchTermRule"
            }
          }
        }
      },
      "SearchTermRule": {
        "type": "object",
        "properties": {
          "searchTerm": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "catentryId": {
                  "type": "string"
                },
                "sequence": {
                  "type": "string"
                },
                "storeId": {
                  "type": "string"
                },
                "langId": {
                  "type": "string"
                },
                "pin": {
                  "type": "string"
                },
                "add": {
                  "type": "string"
                },
                "hide": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
