// Generated by `moon run cmd/codegen`; DO NOT EDIT.

///|
pub(all) struct AsyncSearchDeleteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for AsyncSearchDeleteQuery with fn to_json(
  _self : AsyncSearchDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for AsyncSearchDeleteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "AsyncSearchDeleteQuery: expected object"))
  }
  AsyncSearchDeleteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn AsyncSearchDeleteQuery::new() -> AsyncSearchDeleteQuery {
  AsyncSearchDeleteQuery::{  }
}

///|
pub fn AsyncSearchDeleteQuery::to_pairs(
  _self : AsyncSearchDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type AsyncSearchDeleteResponse = Json

///|
pub(all) struct AsyncSearchDeleteRequest {
  id : String
  query : AsyncSearchDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AsyncSearchDeleteRequest::new(
  id : String,
  query? : AsyncSearchDeleteQuery = AsyncSearchDeleteQuery::new(),
) -> AsyncSearchDeleteRequest {
  { id, query }
}

///|
pub async fn Client::async_search_delete(
  self : Client,
  request : AsyncSearchDeleteRequest,
) -> EsResponse[AsyncSearchDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_async_search/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct AsyncSearchGetQuery {
  keep_alive : String?
  typed_keys : Bool?
  wait_for_completion_timeout : String?
  return_intermediate_results : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for AsyncSearchGetQuery with fn to_json(
  self : AsyncSearchGetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  match self.return_intermediate_results {
    Some(value) => obj["return_intermediate_results"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AsyncSearchGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "AsyncSearchGetQuery: expected object"))
  }
  {
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
    return_intermediate_results: match obj.get("return_intermediate_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("return_intermediate_results"),
          ),
        )
    },
  }
}

///|
pub fn AsyncSearchGetQuery::new(
  keep_alive? : String,
  typed_keys? : Bool,
  wait_for_completion_timeout? : String,
  return_intermediate_results? : Bool,
) -> AsyncSearchGetQuery {
  {
    keep_alive,
    typed_keys,
    wait_for_completion_timeout,
    return_intermediate_results,
  }
}

///|
pub fn AsyncSearchGetQuery::to_pairs(
  self : AsyncSearchGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion_timeout", value.to_json())
    None => ()
  }
  match self.return_intermediate_results {
    Some(value) =>
      push_query_json(pairs, "return_intermediate_results", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type AsyncSearchGetResponse = Json

///|
pub(all) struct AsyncSearchGetRequest {
  id : String
  query : AsyncSearchGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AsyncSearchGetRequest::new(
  id : String,
  query? : AsyncSearchGetQuery = AsyncSearchGetQuery::new(),
) -> AsyncSearchGetRequest {
  { id, query }
}

///|
pub async fn Client::async_search_get(
  self : Client,
  request : AsyncSearchGetRequest,
) -> EsResponse[AsyncSearchGetResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_async_search/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct AsyncSearchStatusQuery {
  keep_alive : String?
} derive(Eq, Debug)

///|
pub impl ToJson for AsyncSearchStatusQuery with fn to_json(
  self : AsyncSearchStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AsyncSearchStatusQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "AsyncSearchStatusQuery: expected object"))
  }
  {
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
  }
}

///|
pub fn AsyncSearchStatusQuery::new(
  keep_alive? : String,
) -> AsyncSearchStatusQuery {
  { keep_alive, }
}

///|
pub fn AsyncSearchStatusQuery::to_pairs(
  self : AsyncSearchStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type AsyncSearchStatusResponse = Json

///|
pub(all) struct AsyncSearchStatusRequest {
  id : String
  query : AsyncSearchStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AsyncSearchStatusRequest::new(
  id : String,
  query? : AsyncSearchStatusQuery = AsyncSearchStatusQuery::new(),
) -> AsyncSearchStatusRequest {
  { id, query }
}

///|
pub async fn Client::async_search_status(
  self : Client,
  request : AsyncSearchStatusRequest,
) -> EsResponse[AsyncSearchStatusResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_async_search/status/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct AsyncSearchSubmitQuery {
  wait_for_completion_timeout : String?
  keep_alive : String?
  keep_on_completion : Bool?
  allow_no_indices : Bool?
  allow_partial_search_results : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  batched_reduce_size : Int?
  ccs_minimize_roundtrips : Bool?
  default_operator : String?
  df : String?
  docvalue_fields : String?
  expand_wildcards : String?
  explain : Bool?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  lenient : Bool?
  max_concurrent_shard_requests : Int?
  preference : String?
  request_cache : Bool?
  routing : String?
  search_type : String?
  stats : Array[String]?
  stored_fields : String?
  suggest_field : String?
  suggest_mode : String?
  suggest_size : Int?
  suggest_text : String?
  terminate_after : Int?
  timeout : String?
  track_total_hits : String?
  track_scores : Bool?
  typed_keys : Bool?
  rest_total_hits_as_int : Bool?
  version : Bool?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  seq_no_primary_term : Bool?
  q : String?
  size : Int?
  from : Int?
  sort : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for AsyncSearchSubmitQuery with fn to_json(
  self : AsyncSearchSubmitQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => obj["keep_on_completion"] = value.to_json()
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.batched_reduce_size {
    Some(value) => obj["batched_reduce_size"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) => obj["max_concurrent_shard_requests"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.request_cache {
    Some(value) => obj["request_cache"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.suggest_field {
    Some(value) => obj["suggest_field"] = value.to_json()
    None => ()
  }
  match self.suggest_mode {
    Some(value) => obj["suggest_mode"] = value.to_json()
    None => ()
  }
  match self.suggest_size {
    Some(value) => obj["suggest_size"] = value.to_json()
    None => ()
  }
  match self.suggest_text {
    Some(value) => obj["suggest_text"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.track_scores {
    Some(value) => obj["track_scores"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) => obj["seq_no_primary_term"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AsyncSearchSubmitQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "AsyncSearchSubmitQuery: expected object"))
  }
  {
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    keep_on_completion: match obj.get("keep_on_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_on_completion")))
    },
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    batched_reduce_size: match obj.get("batched_reduce_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("batched_reduce_size")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    max_concurrent_shard_requests: match
      obj.get("max_concurrent_shard_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_concurrent_shard_requests"),
          ),
        )
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    request_cache: match obj.get("request_cache") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("request_cache")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    suggest_field: match obj.get("suggest_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_field")))
    },
    suggest_mode: match obj.get("suggest_mode") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_mode")))
    },
    suggest_size: match obj.get("suggest_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_size")))
    },
    suggest_text: match obj.get("suggest_text") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_text")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    track_scores: match obj.get("track_scores") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_scores")))
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    seq_no_primary_term: match obj.get("seq_no_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("seq_no_primary_term")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
  }
}

///|
pub fn AsyncSearchSubmitQuery::new(
  wait_for_completion_timeout? : String,
  keep_alive? : String,
  keep_on_completion? : Bool,
  allow_no_indices? : Bool,
  allow_partial_search_results? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  batched_reduce_size? : Int,
  ccs_minimize_roundtrips? : Bool,
  default_operator? : String,
  df? : String,
  docvalue_fields? : String,
  expand_wildcards? : String,
  explain? : Bool,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  lenient? : Bool,
  max_concurrent_shard_requests? : Int,
  preference? : String,
  request_cache? : Bool,
  routing? : String,
  search_type? : String,
  stats? : Array[String],
  stored_fields? : String,
  suggest_field? : String,
  suggest_mode? : String,
  suggest_size? : Int,
  suggest_text? : String,
  terminate_after? : Int,
  timeout? : String,
  track_total_hits? : String,
  track_scores? : Bool,
  typed_keys? : Bool,
  rest_total_hits_as_int? : Bool,
  version? : Bool,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  seq_no_primary_term? : Bool,
  q? : String,
  size? : Int,
  from? : Int,
  sort? : Json,
) -> AsyncSearchSubmitQuery {
  {
    wait_for_completion_timeout,
    keep_alive,
    keep_on_completion,
    allow_no_indices,
    allow_partial_search_results,
    analyzer,
    analyze_wildcard,
    batched_reduce_size,
    ccs_minimize_roundtrips,
    default_operator,
    df,
    docvalue_fields,
    expand_wildcards,
    explain,
    ignore_throttled,
    ignore_unavailable,
    lenient,
    max_concurrent_shard_requests,
    preference,
    request_cache,
    routing,
    search_type,
    stats,
    stored_fields,
    suggest_field,
    suggest_mode,
    suggest_size,
    suggest_text,
    terminate_after,
    timeout,
    track_total_hits,
    track_scores,
    typed_keys,
    rest_total_hits_as_int,
    version,
    _source,
    _source_excludes,
    _source_includes,
    seq_no_primary_term,
    q,
    size,
    from,
    sort,
  }
}

///|
pub fn AsyncSearchSubmitQuery::to_pairs(
  self : AsyncSearchSubmitQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.wait_for_completion_timeout {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion_timeout", value.to_json())
    None => ()
  }
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => push_query_json(pairs, "keep_on_completion", value.to_json())
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_search_results", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.batched_reduce_size {
    Some(value) =>
      push_query_json(pairs, "batched_reduce_size", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => push_query_json(pairs, "docvalue_fields", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_shard_requests", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.request_cache {
    Some(value) => push_query_json(pairs, "request_cache", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.stats {
    Some(value) => push_query_json(pairs, "stats", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  match self.suggest_field {
    Some(value) => push_query_json(pairs, "suggest_field", value.to_json())
    None => ()
  }
  match self.suggest_mode {
    Some(value) => push_query_json(pairs, "suggest_mode", value.to_json())
    None => ()
  }
  match self.suggest_size {
    Some(value) => push_query_json(pairs, "suggest_size", value.to_json())
    None => ()
  }
  match self.suggest_text {
    Some(value) => push_query_json(pairs, "suggest_text", value.to_json())
    None => ()
  }
  match self.terminate_after {
    Some(value) => push_query_json(pairs, "terminate_after", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.track_total_hits {
    Some(value) => push_query_json(pairs, "track_total_hits", value.to_json())
    None => ()
  }
  match self.track_scores {
    Some(value) => push_query_json(pairs, "track_scores", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) =>
      push_query_json(pairs, "seq_no_primary_term", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct AsyncSearchSubmitBody {
  aggregations : Map[String, Json]?
  collapse : Json?
  explain : Bool?
  ext : Map[String, Json]?
  from : Int?
  highlight : Json?
  track_total_hits : Json?
  indices_boost : Array[Map[String, Json]]?
  docvalue_fields : Array[Json]?
  knn : Json?
  min_score : Double?
  post_filter : Json?
  profile : Bool?
  query : Json?
  rescore : Json?
  script_fields : Map[String, Json]?
  search_after : Json?
  size : Int?
  slice : Json?
  sort : Json?
  _source : Json?
  fields : Array[Json]?
  suggest : Json?
  terminate_after : Int?
  timeout : String?
  track_scores : Bool?
  version : Bool?
  seq_no_primary_term : Bool?
  stored_fields : Json?
  pit : Json?
  runtime_mappings : Json?
  stats : Array[String]?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for AsyncSearchSubmitBody with fn to_json(
  self : AsyncSearchSubmitBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.collapse {
    Some(value) => obj["collapse"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ext {
    Some(value) => obj["ext"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.highlight {
    Some(value) => obj["highlight"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.indices_boost {
    Some(value) => obj["indices_boost"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.knn {
    Some(value) => obj["knn"] = value.to_json()
    None => ()
  }
  match self.min_score {
    Some(value) => obj["min_score"] = value.to_json()
    None => ()
  }
  match self.post_filter {
    Some(value) => obj["post_filter"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.rescore {
    Some(value) => obj["rescore"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.slice {
    Some(value) => obj["slice"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.suggest {
    Some(value) => obj["suggest"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.track_scores {
    Some(value) => obj["track_scores"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) => obj["seq_no_primary_term"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.pit {
    Some(value) => obj["pit"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AsyncSearchSubmitBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "AsyncSearchSubmitBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    collapse: match obj.get("collapse") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("collapse")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ext: match obj.get("ext") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ext")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    highlight: match obj.get("highlight") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("highlight")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    indices_boost: match obj.get("indices_boost") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_boost")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    knn: match obj.get("knn") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("knn")))
    },
    min_score: match obj.get("min_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("min_score")))
    },
    post_filter: match obj.get("post_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("post_filter")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    rescore: match obj.get("rescore") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rescore")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    slice: match obj.get("slice") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    suggest: match obj.get("suggest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("suggest")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    track_scores: match obj.get("track_scores") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_scores")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    seq_no_primary_term: match obj.get("seq_no_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("seq_no_primary_term")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    pit: match obj.get("pit") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pit")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn AsyncSearchSubmitBody::new(
  aggregations? : Map[String, Json],
  collapse? : Json,
  explain? : Bool,
  ext? : Map[String, Json],
  from? : Int,
  highlight? : Json,
  track_total_hits? : Json,
  indices_boost? : Array[Map[String, Json]],
  docvalue_fields? : Array[Json],
  knn? : Json,
  min_score? : Double,
  post_filter? : Json,
  profile? : Bool,
  query? : Json,
  rescore? : Json,
  script_fields? : Map[String, Json],
  search_after? : Json,
  size? : Int,
  slice? : Json,
  sort? : Json,
  _source? : Json,
  fields? : Array[Json],
  suggest? : Json,
  terminate_after? : Int,
  timeout? : String,
  track_scores? : Bool,
  version? : Bool,
  seq_no_primary_term? : Bool,
  stored_fields? : Json,
  pit? : Json,
  runtime_mappings? : Json,
  stats? : Array[String],
  project_routing? : Json,
) -> AsyncSearchSubmitBody {
  {
    aggregations,
    collapse,
    explain,
    ext,
    from,
    highlight,
    track_total_hits,
    indices_boost,
    docvalue_fields,
    knn,
    min_score,
    post_filter,
    profile,
    query,
    rescore,
    script_fields,
    search_after,
    size,
    slice,
    sort,
    _source,
    fields,
    suggest,
    terminate_after,
    timeout,
    track_scores,
    version,
    seq_no_primary_term,
    stored_fields,
    pit,
    runtime_mappings,
    stats,
    project_routing,
  }
}

///|
pub type AsyncSearchSubmitResponse = Json

///|
pub(all) struct AsyncSearchSubmitRequest {
  index : String?
  query : AsyncSearchSubmitQuery
  body : AsyncSearchSubmitBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AsyncSearchSubmitRequest::new(
  index? : String,
  query? : AsyncSearchSubmitQuery = AsyncSearchSubmitQuery::new(),
  body? : AsyncSearchSubmitBody,
) -> AsyncSearchSubmitRequest {
  { index, query, body }
}

///|
pub async fn Client::async_search_submit(
  self : Client,
  request : AsyncSearchSubmitRequest,
) -> EsResponse[AsyncSearchSubmitResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_async_search", ["index"]),
      PathVariant::new("/_async_search", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct AutoscalingDeleteAutoscalingPolicyQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for AutoscalingDeleteAutoscalingPolicyQuery with fn to_json(
  self : AutoscalingDeleteAutoscalingPolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AutoscalingDeleteAutoscalingPolicyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "AutoscalingDeleteAutoscalingPolicyQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn AutoscalingDeleteAutoscalingPolicyQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> AutoscalingDeleteAutoscalingPolicyQuery {
  { master_timeout, timeout }
}

///|
pub fn AutoscalingDeleteAutoscalingPolicyQuery::to_pairs(
  self : AutoscalingDeleteAutoscalingPolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type AutoscalingDeleteAutoscalingPolicyResponse = Json

///|
pub(all) struct AutoscalingDeleteAutoscalingPolicyRequest {
  name : String
  query : AutoscalingDeleteAutoscalingPolicyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AutoscalingDeleteAutoscalingPolicyRequest::new(
  name : String,
  query? : AutoscalingDeleteAutoscalingPolicyQuery = AutoscalingDeleteAutoscalingPolicyQuery::new(),
) -> AutoscalingDeleteAutoscalingPolicyRequest {
  { name, query }
}

///|
pub async fn Client::autoscaling_delete_autoscaling_policy(
  self : Client,
  request : AutoscalingDeleteAutoscalingPolicyRequest,
) -> EsResponse[AutoscalingDeleteAutoscalingPolicyResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_autoscaling/policy/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct AutoscalingGetAutoscalingCapacityQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for AutoscalingGetAutoscalingCapacityQuery with fn to_json(
  self : AutoscalingGetAutoscalingCapacityQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AutoscalingGetAutoscalingCapacityQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "AutoscalingGetAutoscalingCapacityQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn AutoscalingGetAutoscalingCapacityQuery::new(
  master_timeout? : String,
) -> AutoscalingGetAutoscalingCapacityQuery {
  { master_timeout, }
}

///|
pub fn AutoscalingGetAutoscalingCapacityQuery::to_pairs(
  self : AutoscalingGetAutoscalingCapacityQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct AutoscalingGetAutoscalingCapacityResponse {
  policies : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for AutoscalingGetAutoscalingCapacityResponse with fn to_json(
  self : AutoscalingGetAutoscalingCapacityResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["policies"] = self.policies.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for AutoscalingGetAutoscalingCapacityResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "AutoscalingGetAutoscalingCapacityResponse: expected object"),
    )
  }
  {
    policies: @json.from_json(
      obj.get("policies").unwrap_or(Json::null()),
      path=path.add_key("policies"),
    ),
  }
}

///|
pub(all) struct AutoscalingGetAutoscalingCapacityRequest {
  query : AutoscalingGetAutoscalingCapacityQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AutoscalingGetAutoscalingCapacityRequest::new(
  query? : AutoscalingGetAutoscalingCapacityQuery = AutoscalingGetAutoscalingCapacityQuery::new(),
) -> AutoscalingGetAutoscalingCapacityRequest {
  { query, }
}

///|
pub async fn Client::autoscaling_get_autoscaling_capacity(
  self : Client,
  request : AutoscalingGetAutoscalingCapacityRequest,
) -> EsResponse[AutoscalingGetAutoscalingCapacityResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_autoscaling/capacity", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct AutoscalingGetAutoscalingPolicyQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for AutoscalingGetAutoscalingPolicyQuery with fn to_json(
  self : AutoscalingGetAutoscalingPolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AutoscalingGetAutoscalingPolicyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "AutoscalingGetAutoscalingPolicyQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn AutoscalingGetAutoscalingPolicyQuery::new(
  master_timeout? : String,
) -> AutoscalingGetAutoscalingPolicyQuery {
  { master_timeout, }
}

///|
pub fn AutoscalingGetAutoscalingPolicyQuery::to_pairs(
  self : AutoscalingGetAutoscalingPolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type AutoscalingGetAutoscalingPolicyResponse = Json

///|
pub(all) struct AutoscalingGetAutoscalingPolicyRequest {
  name : String
  query : AutoscalingGetAutoscalingPolicyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AutoscalingGetAutoscalingPolicyRequest::new(
  name : String,
  query? : AutoscalingGetAutoscalingPolicyQuery = AutoscalingGetAutoscalingPolicyQuery::new(),
) -> AutoscalingGetAutoscalingPolicyRequest {
  { name, query }
}

///|
pub async fn Client::autoscaling_get_autoscaling_policy(
  self : Client,
  request : AutoscalingGetAutoscalingPolicyRequest,
) -> EsResponse[AutoscalingGetAutoscalingPolicyResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_autoscaling/policy/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct AutoscalingPutAutoscalingPolicyQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for AutoscalingPutAutoscalingPolicyQuery with fn to_json(
  self : AutoscalingPutAutoscalingPolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for AutoscalingPutAutoscalingPolicyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "AutoscalingPutAutoscalingPolicyQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn AutoscalingPutAutoscalingPolicyQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> AutoscalingPutAutoscalingPolicyQuery {
  { master_timeout, timeout }
}

///|
pub fn AutoscalingPutAutoscalingPolicyQuery::to_pairs(
  self : AutoscalingPutAutoscalingPolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type AutoscalingPutAutoscalingPolicyBody = Json

///|
pub type AutoscalingPutAutoscalingPolicyResponse = Json

///|
pub(all) struct AutoscalingPutAutoscalingPolicyRequest {
  name : String
  query : AutoscalingPutAutoscalingPolicyQuery
  body : AutoscalingPutAutoscalingPolicyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn AutoscalingPutAutoscalingPolicyRequest::new(
  name : String,
  body : AutoscalingPutAutoscalingPolicyBody,
  query? : AutoscalingPutAutoscalingPolicyQuery = AutoscalingPutAutoscalingPolicyQuery::new(),
) -> AutoscalingPutAutoscalingPolicyRequest {
  { name, query, body }
}

///|
pub async fn Client::autoscaling_put_autoscaling_policy(
  self : Client,
  request : AutoscalingPutAutoscalingPolicyRequest,
) -> EsResponse[AutoscalingPutAutoscalingPolicyResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_autoscaling/policy/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct BulkQuery {
  include_source_on_error : Bool?
  list_executed_pipelines : Bool?
  pipeline : String?
  refresh : String?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  timeout : String?
  wait_for_active_shards : String?
  require_alias : Bool?
  require_data_stream : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for BulkQuery with fn to_json(self : BulkQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.include_source_on_error {
    Some(value) => obj["include_source_on_error"] = value.to_json()
    None => ()
  }
  match self.list_executed_pipelines {
    Some(value) => obj["list_executed_pipelines"] = value.to_json()
    None => ()
  }
  match self.pipeline {
    Some(value) => obj["pipeline"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.require_alias {
    Some(value) => obj["require_alias"] = value.to_json()
    None => ()
  }
  match self.require_data_stream {
    Some(value) => obj["require_data_stream"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for BulkQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "BulkQuery: expected object"))
  }
  {
    include_source_on_error: match obj.get("include_source_on_error") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_source_on_error")),
        )
    },
    list_executed_pipelines: match obj.get("list_executed_pipelines") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("list_executed_pipelines")),
        )
    },
    pipeline: match obj.get("pipeline") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pipeline")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    require_alias: match obj.get("require_alias") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_alias")))
    },
    require_data_stream: match obj.get("require_data_stream") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_data_stream")))
    },
  }
}

///|
pub fn BulkQuery::new(
  include_source_on_error? : Bool,
  list_executed_pipelines? : Bool,
  pipeline? : String,
  refresh? : String,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  timeout? : String,
  wait_for_active_shards? : String,
  require_alias? : Bool,
  require_data_stream? : Bool,
) -> BulkQuery {
  {
    include_source_on_error,
    list_executed_pipelines,
    pipeline,
    refresh,
    routing,
    _source,
    _source_excludes,
    _source_includes,
    timeout,
    wait_for_active_shards,
    require_alias,
    require_data_stream,
  }
}

///|
pub fn BulkQuery::to_pairs(self : BulkQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.include_source_on_error {
    Some(value) =>
      push_query_json(pairs, "include_source_on_error", value.to_json())
    None => ()
  }
  match self.list_executed_pipelines {
    Some(value) =>
      push_query_json(pairs, "list_executed_pipelines", value.to_json())
    None => ()
  }
  match self.pipeline {
    Some(value) => push_query_json(pairs, "pipeline", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.require_alias {
    Some(value) => push_query_json(pairs, "require_alias", value.to_json())
    None => ()
  }
  match self.require_data_stream {
    Some(value) =>
      push_query_json(pairs, "require_data_stream", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type BulkBody = Array[Json]

///|
pub(all) struct BulkResponse {
  errors : Bool
  items : Array[Map[String, Json]]
  took : Int
  ingest_took : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for BulkResponse with fn to_json(self : BulkResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["errors"] = self.errors.to_json()
  obj["items"] = self.items.to_json()
  obj["took"] = self.took.to_json()
  match self.ingest_took {
    Some(value) => obj["ingest_took"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for BulkResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "BulkResponse: expected object"))
  }
  {
    errors: @json.from_json(
      obj.get("errors").unwrap_or(Json::null()),
      path=path.add_key("errors"),
    ),
    items: @json.from_json(
      obj.get("items").unwrap_or(Json::null()),
      path=path.add_key("items"),
    ),
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    ingest_took: match obj.get("ingest_took") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ingest_took")))
    },
  }
}

///|
pub(all) struct BulkRequest {
  index : String?
  query : BulkQuery
  body : BulkBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn BulkRequest::new(
  body : BulkBody,
  index? : String,
  query? : BulkQuery = BulkQuery::new(),
) -> BulkRequest {
  { index, query, body }
}

///|
pub async fn Client::bulk(
  self : Client,
  request : BulkRequest,
) -> EsResponse[BulkResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_bulk", ["index"]),
      PathVariant::new("/_bulk", []),
    ],
    params,
  )
  let body = Ndjson(request.body)
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct CancelReindexQuery {
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for CancelReindexQuery with fn to_json(
  self : CancelReindexQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CancelReindexQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CancelReindexQuery: expected object"))
  }
  {
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn CancelReindexQuery::new(
  wait_for_completion? : Bool,
) -> CancelReindexQuery {
  { wait_for_completion, }
}

///|
pub fn CancelReindexQuery::to_pairs(
  self : CancelReindexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CancelReindexResponse {
  acknowledged : Bool?
  completed : Bool?
  id : Json?
  description : String?
  start_time_in_millis : Json?
  start_time : String?
  running_time : Json?
  running_time_in_nanos : Json?
  cancelled : Bool?
  status : Json?
  error : Json?
  response : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for CancelReindexResponse with fn to_json(
  self : CancelReindexResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acknowledged {
    Some(value) => obj["acknowledged"] = value.to_json()
    None => ()
  }
  match self.completed {
    Some(value) => obj["completed"] = value.to_json()
    None => ()
  }
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.start_time_in_millis {
    Some(value) => obj["start_time_in_millis"] = value.to_json()
    None => ()
  }
  match self.start_time {
    Some(value) => obj["start_time"] = value.to_json()
    None => ()
  }
  match self.running_time {
    Some(value) => obj["running_time"] = value.to_json()
    None => ()
  }
  match self.running_time_in_nanos {
    Some(value) => obj["running_time_in_nanos"] = value.to_json()
    None => ()
  }
  match self.cancelled {
    Some(value) => obj["cancelled"] = value.to_json()
    None => ()
  }
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  match self.error {
    Some(value) => obj["error"] = value.to_json()
    None => ()
  }
  match self.response {
    Some(value) => obj["response"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CancelReindexResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CancelReindexResponse: expected object"))
  }
  {
    acknowledged: match obj.get("acknowledged") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("acknowledged")))
    },
    completed: match obj.get("completed") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("completed")))
    },
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    start_time_in_millis: match obj.get("start_time_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("start_time_in_millis")))
    },
    start_time: match obj.get("start_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("start_time")))
    },
    running_time: match obj.get("running_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("running_time")))
    },
    running_time_in_nanos: match obj.get("running_time_in_nanos") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("running_time_in_nanos")))
    },
    cancelled: match obj.get("cancelled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("cancelled")))
    },
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
    error: match obj.get("error") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("error")))
    },
    response: match obj.get("response") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("response")))
    },
  }
}

///|
pub(all) struct CancelReindexRequest {
  task_id : String
  query : CancelReindexQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CancelReindexRequest::new(
  task_id : String,
  query? : CancelReindexQuery = CancelReindexQuery::new(),
) -> CancelReindexRequest {
  { task_id, query }
}

///|
pub async fn Client::cancel_reindex(
  self : Client,
  request : CancelReindexRequest,
) -> EsResponse[CancelReindexResponse] {
  let params : Map[String, String] = Map([])
  params["task_id"] = request.task_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_reindex/{task_id}/_cancel", ["task_id"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct CapabilitiesQuery {
  method_ : String?
  path : String?
  parameters : Json?
  capabilities : Json?
  local_only : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CapabilitiesQuery with fn to_json(self : CapabilitiesQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.method_ {
    Some(value) => obj["method"] = value.to_json()
    None => ()
  }
  match self.path {
    Some(value) => obj["path"] = value.to_json()
    None => ()
  }
  match self.parameters {
    Some(value) => obj["parameters"] = value.to_json()
    None => ()
  }
  match self.capabilities {
    Some(value) => obj["capabilities"] = value.to_json()
    None => ()
  }
  match self.local_only {
    Some(value) => obj["local_only"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CapabilitiesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CapabilitiesQuery: expected object"))
  }
  {
    method_: match obj.get("method") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("method")))
    },
    path: match obj.get("path") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("path")))
    },
    parameters: match obj.get("parameters") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("parameters")))
    },
    capabilities: match obj.get("capabilities") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("capabilities")))
    },
    local_only: match obj.get("local_only") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("local_only")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn CapabilitiesQuery::new(
  method_? : String,
  path? : String,
  parameters? : Json,
  capabilities? : Json,
  local_only? : Bool,
  timeout? : String,
) -> CapabilitiesQuery {
  { method_, path, parameters, capabilities, local_only, timeout }
}

///|
pub fn CapabilitiesQuery::to_pairs(
  self : CapabilitiesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.method_ {
    Some(value) => push_query_json(pairs, "method", value.to_json())
    None => ()
  }
  match self.path {
    Some(value) => push_query_json(pairs, "path", value.to_json())
    None => ()
  }
  match self.parameters {
    Some(value) => push_query_json(pairs, "parameters", value.to_json())
    None => ()
  }
  match self.capabilities {
    Some(value) => push_query_json(pairs, "capabilities", value.to_json())
    None => ()
  }
  match self.local_only {
    Some(value) => push_query_json(pairs, "local_only", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CapabilitiesResponse {
  _nodes : Json
  cluster_name : Json
  supported : Json
  failures : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for CapabilitiesResponse with fn to_json(
  self : CapabilitiesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["supported"] = self.supported.to_json()
  match self.failures {
    Some(value) => obj["failures"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CapabilitiesResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CapabilitiesResponse: expected object"))
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    supported: @json.from_json(
      obj.get("supported").unwrap_or(Json::null()),
      path=path.add_key("supported"),
    ),
    failures: match obj.get("failures") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("failures")))
    },
  }
}

///|
pub(all) struct CapabilitiesRequest {
  query : CapabilitiesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CapabilitiesRequest::new(
  query? : CapabilitiesQuery = CapabilitiesQuery::new(),
) -> CapabilitiesRequest {
  { query, }
}

///|
pub async fn Client::capabilities(
  self : Client,
  request : CapabilitiesRequest,
) -> EsResponse[CapabilitiesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_capabilities", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatAliasesQuery {
  h : String?
  s : String?
  expand_wildcards : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatAliasesQuery with fn to_json(self : CatAliasesQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatAliasesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatAliasesQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatAliasesQuery::new(
  h? : String,
  s? : String,
  expand_wildcards? : String,
  master_timeout? : String,
) -> CatAliasesQuery {
  { h, s, expand_wildcards, master_timeout }
}

///|
pub fn CatAliasesQuery::to_pairs(
  self : CatAliasesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatAliasesResponse = Json

///|
pub(all) struct CatAliasesRequest {
  name : String?
  query : CatAliasesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatAliasesRequest::new(
  name? : String,
  query? : CatAliasesQuery = CatAliasesQuery::new(),
) -> CatAliasesRequest {
  { name, query }
}

///|
pub async fn Client::cat_aliases(
  self : Client,
  request : CatAliasesRequest,
) -> EsResponse[CatAliasesResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/aliases/{name}", ["name"]),
      PathVariant::new("/_cat/aliases", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatAllocationQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatAllocationQuery with fn to_json(
  self : CatAllocationQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatAllocationQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatAllocationQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatAllocationQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatAllocationQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatAllocationQuery::to_pairs(
  self : CatAllocationQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatAllocationResponse = Json

///|
pub(all) struct CatAllocationRequest {
  node_id : String?
  query : CatAllocationQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatAllocationRequest::new(
  node_id? : String,
  query? : CatAllocationQuery = CatAllocationQuery::new(),
) -> CatAllocationRequest {
  { node_id, query }
}

///|
pub async fn Client::cat_allocation(
  self : Client,
  request : CatAllocationRequest,
) -> EsResponse[CatAllocationResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/allocation/{node_id}", ["node_id"]),
      PathVariant::new("/_cat/allocation", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatCircuitBreakerQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatCircuitBreakerQuery with fn to_json(
  self : CatCircuitBreakerQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatCircuitBreakerQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatCircuitBreakerQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatCircuitBreakerQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatCircuitBreakerQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatCircuitBreakerQuery::to_pairs(
  self : CatCircuitBreakerQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatCircuitBreakerResponse = Json

///|
pub(all) struct CatCircuitBreakerRequest {
  circuit_breaker_patterns : String?
  query : CatCircuitBreakerQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatCircuitBreakerRequest::new(
  circuit_breaker_patterns? : String,
  query? : CatCircuitBreakerQuery = CatCircuitBreakerQuery::new(),
) -> CatCircuitBreakerRequest {
  { circuit_breaker_patterns, query }
}

///|
pub async fn Client::cat_circuit_breaker(
  self : Client,
  request : CatCircuitBreakerRequest,
) -> EsResponse[CatCircuitBreakerResponse] {
  let params : Map[String, String] = Map([])
  match request.circuit_breaker_patterns {
    Some(value) => params["circuit_breaker_patterns"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/circuit_breaker/{circuit_breaker_patterns}", [
        "circuit_breaker_patterns",
      ]),
      PathVariant::new("/_cat/circuit_breaker", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatComponentTemplatesQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatComponentTemplatesQuery with fn to_json(
  self : CatComponentTemplatesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatComponentTemplatesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatComponentTemplatesQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatComponentTemplatesQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatComponentTemplatesQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatComponentTemplatesQuery::to_pairs(
  self : CatComponentTemplatesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatComponentTemplatesResponse = Json

///|
pub(all) struct CatComponentTemplatesRequest {
  name : String?
  query : CatComponentTemplatesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatComponentTemplatesRequest::new(
  name? : String,
  query? : CatComponentTemplatesQuery = CatComponentTemplatesQuery::new(),
) -> CatComponentTemplatesRequest {
  { name, query }
}

///|
pub async fn Client::cat_component_templates(
  self : Client,
  request : CatComponentTemplatesRequest,
) -> EsResponse[CatComponentTemplatesResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/component_templates/{name}", ["name"]),
      PathVariant::new("/_cat/component_templates", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatCountQuery {
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatCountQuery with fn to_json(self : CatCountQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatCountQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatCountQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatCountQuery::new(h? : String, s? : String) -> CatCountQuery {
  { h, s }
}

///|
pub fn CatCountQuery::to_pairs(self : CatCountQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatCountResponse = Json

///|
pub(all) struct CatCountRequest {
  index : String?
  query : CatCountQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatCountRequest::new(
  index? : String,
  query? : CatCountQuery = CatCountQuery::new(),
) -> CatCountRequest {
  { index, query }
}

///|
pub async fn Client::cat_count(
  self : Client,
  request : CatCountRequest,
) -> EsResponse[CatCountResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/count/{index}", ["index"]),
      PathVariant::new("/_cat/count", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct CatFielddataQuery {
  fields : String?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatFielddataQuery with fn to_json(self : CatFielddataQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatFielddataQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatFielddataQuery: expected object"))
  }
  {
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatFielddataQuery::new(
  fields? : String,
  h? : String,
  s? : String,
) -> CatFielddataQuery {
  { fields, h, s }
}

///|
pub fn CatFielddataQuery::to_pairs(
  self : CatFielddataQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatFielddataResponse = Json

///|
pub(all) struct CatFielddataRequest {
  fields : String?
  query : CatFielddataQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatFielddataRequest::new(
  fields? : String,
  query? : CatFielddataQuery = CatFielddataQuery::new(),
) -> CatFielddataRequest {
  { fields, query }
}

///|
pub async fn Client::cat_fielddata(
  self : Client,
  request : CatFielddataRequest,
) -> EsResponse[CatFielddataResponse] {
  let params : Map[String, String] = Map([])
  match request.fields {
    Some(value) => params["fields"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/fielddata/{fields}", ["fields"]),
      PathVariant::new("/_cat/fielddata", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatHealthQuery {
  ts : Bool?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatHealthQuery with fn to_json(self : CatHealthQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ts {
    Some(value) => obj["ts"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatHealthQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatHealthQuery: expected object"))
  }
  {
    ts: match obj.get("ts") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ts")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatHealthQuery::new(
  ts? : Bool,
  h? : String,
  s? : String,
) -> CatHealthQuery {
  { ts, h, s }
}

///|
pub fn CatHealthQuery::to_pairs(
  self : CatHealthQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ts {
    Some(value) => push_query_json(pairs, "ts", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatHealthResponse = Json

///|
pub(all) struct CatHealthRequest {
  query : CatHealthQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatHealthRequest::new(
  query? : CatHealthQuery = CatHealthQuery::new(),
) -> CatHealthRequest {
  { query, }
}

///|
pub async fn Client::cat_health(
  self : Client,
  request : CatHealthRequest,
) -> EsResponse[CatHealthResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/health", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatHelpQuery {} derive(Eq, Debug)

///|
pub impl ToJson for CatHelpQuery with fn to_json(_self : CatHelpQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for CatHelpQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "CatHelpQuery: expected object"))
  }
  CatHelpQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn CatHelpQuery::new() -> CatHelpQuery {
  CatHelpQuery::{  }
}

///|
pub fn CatHelpQuery::to_pairs(_self : CatHelpQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type CatHelpResponse = Json

///|
pub(all) struct CatHelpRequest {
  query : CatHelpQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatHelpRequest::new(
  query? : CatHelpQuery = CatHelpQuery::new(),
) -> CatHelpRequest {
  { query, }
}

///|
pub async fn Client::cat_help(
  self : Client,
  request : CatHelpRequest,
) -> EsResponse[CatHelpResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatIndicesQuery {
  expand_wildcards : String?
  health : String?
  include_unloaded_segments : Bool?
  pri : Bool?
  master_timeout : String?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatIndicesQuery with fn to_json(self : CatIndicesQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.health {
    Some(value) => obj["health"] = value.to_json()
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) => obj["include_unloaded_segments"] = value.to_json()
    None => ()
  }
  match self.pri {
    Some(value) => obj["pri"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatIndicesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatIndicesQuery: expected object"))
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    health: match obj.get("health") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("health")))
    },
    include_unloaded_segments: match obj.get("include_unloaded_segments") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_unloaded_segments")),
        )
    },
    pri: match obj.get("pri") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pri")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatIndicesQuery::new(
  expand_wildcards? : String,
  health? : String,
  include_unloaded_segments? : Bool,
  pri? : Bool,
  master_timeout? : String,
  h? : String,
  s? : String,
) -> CatIndicesQuery {
  {
    expand_wildcards,
    health,
    include_unloaded_segments,
    pri,
    master_timeout,
    h,
    s,
  }
}

///|
pub fn CatIndicesQuery::to_pairs(
  self : CatIndicesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.health {
    Some(value) => push_query_json(pairs, "health", value.to_json())
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) =>
      push_query_json(pairs, "include_unloaded_segments", value.to_json())
    None => ()
  }
  match self.pri {
    Some(value) => push_query_json(pairs, "pri", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatIndicesResponse = Json

///|
pub(all) struct CatIndicesRequest {
  index : String?
  query : CatIndicesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatIndicesRequest::new(
  index? : String,
  query? : CatIndicesQuery = CatIndicesQuery::new(),
) -> CatIndicesRequest {
  { index, query }
}

///|
pub async fn Client::cat_indices(
  self : Client,
  request : CatIndicesRequest,
) -> EsResponse[CatIndicesResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/indices/{index}", ["index"]),
      PathVariant::new("/_cat/indices", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatMasterQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatMasterQuery with fn to_json(self : CatMasterQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatMasterQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatMasterQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatMasterQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatMasterQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatMasterQuery::to_pairs(
  self : CatMasterQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatMasterResponse = Json

///|
pub(all) struct CatMasterRequest {
  query : CatMasterQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatMasterRequest::new(
  query? : CatMasterQuery = CatMasterQuery::new(),
) -> CatMasterRequest {
  { query, }
}

///|
pub async fn Client::cat_master(
  self : Client,
  request : CatMasterRequest,
) -> EsResponse[CatMasterResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/master", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatMlDataFrameAnalyticsQuery {
  allow_no_match : Bool?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatMlDataFrameAnalyticsQuery with fn to_json(
  self : CatMlDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatMlDataFrameAnalyticsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CatMlDataFrameAnalyticsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatMlDataFrameAnalyticsQuery::new(
  allow_no_match? : Bool,
  h? : String,
  s? : String,
) -> CatMlDataFrameAnalyticsQuery {
  { allow_no_match, h, s }
}

///|
pub fn CatMlDataFrameAnalyticsQuery::to_pairs(
  self : CatMlDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatMlDataFrameAnalyticsResponse = Json

///|
pub(all) struct CatMlDataFrameAnalyticsRequest {
  id : String?
  query : CatMlDataFrameAnalyticsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatMlDataFrameAnalyticsRequest::new(
  id? : String,
  query? : CatMlDataFrameAnalyticsQuery = CatMlDataFrameAnalyticsQuery::new(),
) -> CatMlDataFrameAnalyticsRequest {
  { id, query }
}

///|
pub async fn Client::cat_ml_data_frame_analytics(
  self : Client,
  request : CatMlDataFrameAnalyticsRequest,
) -> EsResponse[CatMlDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/ml/data_frame/analytics/{id}", ["id"]),
      PathVariant::new("/_cat/ml/data_frame/analytics", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatMlDatafeedsQuery {
  allow_no_match : Bool?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatMlDatafeedsQuery with fn to_json(
  self : CatMlDatafeedsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatMlDatafeedsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatMlDatafeedsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatMlDatafeedsQuery::new(
  allow_no_match? : Bool,
  h? : String,
  s? : String,
) -> CatMlDatafeedsQuery {
  { allow_no_match, h, s }
}

///|
pub fn CatMlDatafeedsQuery::to_pairs(
  self : CatMlDatafeedsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatMlDatafeedsResponse = Json

///|
pub(all) struct CatMlDatafeedsRequest {
  datafeed_id : String?
  query : CatMlDatafeedsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatMlDatafeedsRequest::new(
  datafeed_id? : String,
  query? : CatMlDatafeedsQuery = CatMlDatafeedsQuery::new(),
) -> CatMlDatafeedsRequest {
  { datafeed_id, query }
}

///|
pub async fn Client::cat_ml_datafeeds(
  self : Client,
  request : CatMlDatafeedsRequest,
) -> EsResponse[CatMlDatafeedsResponse] {
  let params : Map[String, String] = Map([])
  match request.datafeed_id {
    Some(value) => params["datafeed_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/ml/datafeeds/{datafeed_id}", ["datafeed_id"]),
      PathVariant::new("/_cat/ml/datafeeds", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatMlJobsQuery {
  allow_no_match : Bool?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatMlJobsQuery with fn to_json(self : CatMlJobsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatMlJobsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatMlJobsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatMlJobsQuery::new(
  allow_no_match? : Bool,
  h? : String,
  s? : String,
) -> CatMlJobsQuery {
  { allow_no_match, h, s }
}

///|
pub fn CatMlJobsQuery::to_pairs(
  self : CatMlJobsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatMlJobsResponse = Json

///|
pub(all) struct CatMlJobsRequest {
  job_id : String?
  query : CatMlJobsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatMlJobsRequest::new(
  job_id? : String,
  query? : CatMlJobsQuery = CatMlJobsQuery::new(),
) -> CatMlJobsRequest {
  { job_id, query }
}

///|
pub async fn Client::cat_ml_jobs(
  self : Client,
  request : CatMlJobsRequest,
) -> EsResponse[CatMlJobsResponse] {
  let params : Map[String, String] = Map([])
  match request.job_id {
    Some(value) => params["job_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/ml/anomaly_detectors/{job_id}", ["job_id"]),
      PathVariant::new("/_cat/ml/anomaly_detectors", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatMlTrainedModelsQuery {
  allow_no_match : Bool?
  h : String?
  s : String?
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for CatMlTrainedModelsQuery with fn to_json(
  self : CatMlTrainedModelsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatMlTrainedModelsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatMlTrainedModelsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn CatMlTrainedModelsQuery::new(
  allow_no_match? : Bool,
  h? : String,
  s? : String,
  from? : Int,
  size? : Int,
) -> CatMlTrainedModelsQuery {
  { allow_no_match, h, s, from, size }
}

///|
pub fn CatMlTrainedModelsQuery::to_pairs(
  self : CatMlTrainedModelsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatMlTrainedModelsResponse = Json

///|
pub(all) struct CatMlTrainedModelsRequest {
  model_id : String?
  query : CatMlTrainedModelsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatMlTrainedModelsRequest::new(
  model_id? : String,
  query? : CatMlTrainedModelsQuery = CatMlTrainedModelsQuery::new(),
) -> CatMlTrainedModelsRequest {
  { model_id, query }
}

///|
pub async fn Client::cat_ml_trained_models(
  self : Client,
  request : CatMlTrainedModelsRequest,
) -> EsResponse[CatMlTrainedModelsResponse] {
  let params : Map[String, String] = Map([])
  match request.model_id {
    Some(value) => params["model_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/ml/trained_models/{model_id}", ["model_id"]),
      PathVariant::new("/_cat/ml/trained_models", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatNodeattrsQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatNodeattrsQuery with fn to_json(self : CatNodeattrsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatNodeattrsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatNodeattrsQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatNodeattrsQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatNodeattrsQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatNodeattrsQuery::to_pairs(
  self : CatNodeattrsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatNodeattrsResponse = Json

///|
pub(all) struct CatNodeattrsRequest {
  query : CatNodeattrsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatNodeattrsRequest::new(
  query? : CatNodeattrsQuery = CatNodeattrsQuery::new(),
) -> CatNodeattrsRequest {
  { query, }
}

///|
pub async fn Client::cat_nodeattrs(
  self : Client,
  request : CatNodeattrsRequest,
) -> EsResponse[CatNodeattrsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/nodeattrs", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatNodesQuery {
  full_id : Bool?
  include_unloaded_segments : Bool?
  h : String?
  s : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatNodesQuery with fn to_json(self : CatNodesQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.full_id {
    Some(value) => obj["full_id"] = value.to_json()
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) => obj["include_unloaded_segments"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatNodesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatNodesQuery: expected object"))
  }
  {
    full_id: match obj.get("full_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("full_id")))
    },
    include_unloaded_segments: match obj.get("include_unloaded_segments") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_unloaded_segments")),
        )
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatNodesQuery::new(
  full_id? : Bool,
  include_unloaded_segments? : Bool,
  h? : String,
  s? : String,
  master_timeout? : String,
) -> CatNodesQuery {
  { full_id, include_unloaded_segments, h, s, master_timeout }
}

///|
pub fn CatNodesQuery::to_pairs(self : CatNodesQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.full_id {
    Some(value) => push_query_json(pairs, "full_id", value.to_json())
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) =>
      push_query_json(pairs, "include_unloaded_segments", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatNodesResponse = Json

///|
pub(all) struct CatNodesRequest {
  query : CatNodesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatNodesRequest::new(
  query? : CatNodesQuery = CatNodesQuery::new(),
) -> CatNodesRequest {
  { query, }
}

///|
pub async fn Client::cat_nodes(
  self : Client,
  request : CatNodesRequest,
) -> EsResponse[CatNodesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/nodes", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatPendingTasksQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatPendingTasksQuery with fn to_json(
  self : CatPendingTasksQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatPendingTasksQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatPendingTasksQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatPendingTasksQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatPendingTasksQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatPendingTasksQuery::to_pairs(
  self : CatPendingTasksQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatPendingTasksResponse = Json

///|
pub(all) struct CatPendingTasksRequest {
  query : CatPendingTasksQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatPendingTasksRequest::new(
  query? : CatPendingTasksQuery = CatPendingTasksQuery::new(),
) -> CatPendingTasksRequest {
  { query, }
}

///|
pub async fn Client::cat_pending_tasks(
  self : Client,
  request : CatPendingTasksRequest,
) -> EsResponse[CatPendingTasksResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/pending_tasks", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatPluginsQuery {
  h : String?
  s : String?
  include_bootstrap : Bool?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatPluginsQuery with fn to_json(self : CatPluginsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.include_bootstrap {
    Some(value) => obj["include_bootstrap"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatPluginsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatPluginsQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    include_bootstrap: match obj.get("include_bootstrap") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_bootstrap")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatPluginsQuery::new(
  h? : String,
  s? : String,
  include_bootstrap? : Bool,
  local_? : Bool,
  master_timeout? : String,
) -> CatPluginsQuery {
  { h, s, include_bootstrap, local_, master_timeout }
}

///|
pub fn CatPluginsQuery::to_pairs(
  self : CatPluginsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.include_bootstrap {
    Some(value) => push_query_json(pairs, "include_bootstrap", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatPluginsResponse = Json

///|
pub(all) struct CatPluginsRequest {
  query : CatPluginsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatPluginsRequest::new(
  query? : CatPluginsQuery = CatPluginsQuery::new(),
) -> CatPluginsRequest {
  { query, }
}

///|
pub async fn Client::cat_plugins(
  self : Client,
  request : CatPluginsRequest,
) -> EsResponse[CatPluginsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/plugins", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatRecoveryQuery {
  active_only : Bool?
  detailed : Bool?
  index : String?
  h : String?
  s : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatRecoveryQuery with fn to_json(self : CatRecoveryQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.active_only {
    Some(value) => obj["active_only"] = value.to_json()
    None => ()
  }
  match self.detailed {
    Some(value) => obj["detailed"] = value.to_json()
    None => ()
  }
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatRecoveryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatRecoveryQuery: expected object"))
  }
  {
    active_only: match obj.get("active_only") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("active_only")))
    },
    detailed: match obj.get("detailed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detailed")))
    },
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
  }
}

///|
pub fn CatRecoveryQuery::new(
  active_only? : Bool,
  detailed? : Bool,
  index? : String,
  h? : String,
  s? : String,
) -> CatRecoveryQuery {
  { active_only, detailed, index, h, s }
}

///|
pub fn CatRecoveryQuery::to_pairs(
  self : CatRecoveryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.active_only {
    Some(value) => push_query_json(pairs, "active_only", value.to_json())
    None => ()
  }
  match self.detailed {
    Some(value) => push_query_json(pairs, "detailed", value.to_json())
    None => ()
  }
  match self.index {
    Some(value) => push_query_json(pairs, "index", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatRecoveryResponse = Json

///|
pub(all) struct CatRecoveryRequest {
  index : String?
  query : CatRecoveryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatRecoveryRequest::new(
  index? : String,
  query? : CatRecoveryQuery = CatRecoveryQuery::new(),
) -> CatRecoveryRequest {
  { index, query }
}

///|
pub async fn Client::cat_recovery(
  self : Client,
  request : CatRecoveryRequest,
) -> EsResponse[CatRecoveryResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/recovery/{index}", ["index"]),
      PathVariant::new("/_cat/recovery", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatRepositoriesQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatRepositoriesQuery with fn to_json(
  self : CatRepositoriesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatRepositoriesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatRepositoriesQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatRepositoriesQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatRepositoriesQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatRepositoriesQuery::to_pairs(
  self : CatRepositoriesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatRepositoriesResponse = Json

///|
pub(all) struct CatRepositoriesRequest {
  query : CatRepositoriesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatRepositoriesRequest::new(
  query? : CatRepositoriesQuery = CatRepositoriesQuery::new(),
) -> CatRepositoriesRequest {
  { query, }
}

///|
pub async fn Client::cat_repositories(
  self : Client,
  request : CatRepositoriesRequest,
) -> EsResponse[CatRepositoriesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/repositories", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatSegmentsQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
  expand_wildcards : String?
  allow_no_indices : Bool?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  allow_closed : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for CatSegmentsQuery with fn to_json(self : CatSegmentsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.allow_closed {
    Some(value) => obj["allow_closed"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatSegmentsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatSegmentsQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    allow_closed: match obj.get("allow_closed") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_closed")))
    },
  }
}

///|
pub fn CatSegmentsQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
  expand_wildcards? : String,
  allow_no_indices? : Bool,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  allow_closed? : Bool,
) -> CatSegmentsQuery {
  {
    h,
    s,
    local_,
    master_timeout,
    expand_wildcards,
    allow_no_indices,
    ignore_throttled,
    ignore_unavailable,
    allow_closed,
  }
}

///|
pub fn CatSegmentsQuery::to_pairs(
  self : CatSegmentsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.allow_closed {
    Some(value) => push_query_json(pairs, "allow_closed", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatSegmentsResponse = Json

///|
pub(all) struct CatSegmentsRequest {
  index : String?
  query : CatSegmentsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatSegmentsRequest::new(
  index? : String,
  query? : CatSegmentsQuery = CatSegmentsQuery::new(),
) -> CatSegmentsRequest {
  { index, query }
}

///|
pub async fn Client::cat_segments(
  self : Client,
  request : CatSegmentsRequest,
) -> EsResponse[CatSegmentsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/segments/{index}", ["index"]),
      PathVariant::new("/_cat/segments", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatShardsQuery {
  h : String?
  s : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatShardsQuery with fn to_json(self : CatShardsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatShardsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatShardsQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatShardsQuery::new(
  h? : String,
  s? : String,
  master_timeout? : String,
) -> CatShardsQuery {
  { h, s, master_timeout }
}

///|
pub fn CatShardsQuery::to_pairs(
  self : CatShardsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatShardsResponse = Json

///|
pub(all) struct CatShardsRequest {
  index : String?
  query : CatShardsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatShardsRequest::new(
  index? : String,
  query? : CatShardsQuery = CatShardsQuery::new(),
) -> CatShardsRequest {
  { index, query }
}

///|
pub async fn Client::cat_shards(
  self : Client,
  request : CatShardsRequest,
) -> EsResponse[CatShardsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/shards/{index}", ["index"]),
      PathVariant::new("/_cat/shards", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatSnapshotsQuery {
  ignore_unavailable : Bool?
  h : String?
  s : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatSnapshotsQuery with fn to_json(self : CatSnapshotsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatSnapshotsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatSnapshotsQuery: expected object"))
  }
  {
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatSnapshotsQuery::new(
  ignore_unavailable? : Bool,
  h? : String,
  s? : String,
  master_timeout? : String,
) -> CatSnapshotsQuery {
  { ignore_unavailable, h, s, master_timeout }
}

///|
pub fn CatSnapshotsQuery::to_pairs(
  self : CatSnapshotsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatSnapshotsResponse = Json

///|
pub(all) struct CatSnapshotsRequest {
  repository : String?
  query : CatSnapshotsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatSnapshotsRequest::new(
  repository? : String,
  query? : CatSnapshotsQuery = CatSnapshotsQuery::new(),
) -> CatSnapshotsRequest {
  { repository, query }
}

///|
pub async fn Client::cat_snapshots(
  self : Client,
  request : CatSnapshotsRequest,
) -> EsResponse[CatSnapshotsResponse] {
  let params : Map[String, String] = Map([])
  match request.repository {
    Some(value) => params["repository"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/snapshots/{repository}", ["repository"]),
      PathVariant::new("/_cat/snapshots", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatTasksQuery {
  actions : Array[String]?
  detailed : Bool?
  nodes : Array[String]?
  parent_task_id : String?
  h : String?
  s : String?
  timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for CatTasksQuery with fn to_json(self : CatTasksQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.actions {
    Some(value) => obj["actions"] = value.to_json()
    None => ()
  }
  match self.detailed {
    Some(value) => obj["detailed"] = value.to_json()
    None => ()
  }
  match self.nodes {
    Some(value) => obj["nodes"] = value.to_json()
    None => ()
  }
  match self.parent_task_id {
    Some(value) => obj["parent_task_id"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatTasksQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatTasksQuery: expected object"))
  }
  {
    actions: match obj.get("actions") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("actions")))
    },
    detailed: match obj.get("detailed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detailed")))
    },
    nodes: match obj.get("nodes") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("nodes")))
    },
    parent_task_id: match obj.get("parent_task_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("parent_task_id")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn CatTasksQuery::new(
  actions? : Array[String],
  detailed? : Bool,
  nodes? : Array[String],
  parent_task_id? : String,
  h? : String,
  s? : String,
  timeout? : String,
  wait_for_completion? : Bool,
) -> CatTasksQuery {
  {
    actions,
    detailed,
    nodes,
    parent_task_id,
    h,
    s,
    timeout,
    wait_for_completion,
  }
}

///|
pub fn CatTasksQuery::to_pairs(self : CatTasksQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.actions {
    Some(value) => push_query_json(pairs, "actions", value.to_json())
    None => ()
  }
  match self.detailed {
    Some(value) => push_query_json(pairs, "detailed", value.to_json())
    None => ()
  }
  match self.nodes {
    Some(value) => push_query_json(pairs, "nodes", value.to_json())
    None => ()
  }
  match self.parent_task_id {
    Some(value) => push_query_json(pairs, "parent_task_id", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatTasksResponse = Json

///|
pub(all) struct CatTasksRequest {
  query : CatTasksQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatTasksRequest::new(
  query? : CatTasksQuery = CatTasksQuery::new(),
) -> CatTasksRequest {
  { query, }
}

///|
pub async fn Client::cat_tasks(
  self : Client,
  request : CatTasksRequest,
) -> EsResponse[CatTasksResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cat/tasks", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatTemplatesQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatTemplatesQuery with fn to_json(self : CatTemplatesQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatTemplatesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatTemplatesQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatTemplatesQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatTemplatesQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatTemplatesQuery::to_pairs(
  self : CatTemplatesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatTemplatesResponse = Json

///|
pub(all) struct CatTemplatesRequest {
  name : String?
  query : CatTemplatesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatTemplatesRequest::new(
  name? : String,
  query? : CatTemplatesQuery = CatTemplatesQuery::new(),
) -> CatTemplatesRequest {
  { name, query }
}

///|
pub async fn Client::cat_templates(
  self : Client,
  request : CatTemplatesRequest,
) -> EsResponse[CatTemplatesResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/templates/{name}", ["name"]),
      PathVariant::new("/_cat/templates", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatThreadPoolQuery {
  h : String?
  s : String?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CatThreadPoolQuery with fn to_json(
  self : CatThreadPoolQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatThreadPoolQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatThreadPoolQuery: expected object"))
  }
  {
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CatThreadPoolQuery::new(
  h? : String,
  s? : String,
  local_? : Bool,
  master_timeout? : String,
) -> CatThreadPoolQuery {
  { h, s, local_, master_timeout }
}

///|
pub fn CatThreadPoolQuery::to_pairs(
  self : CatThreadPoolQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatThreadPoolResponse = Json

///|
pub(all) struct CatThreadPoolRequest {
  thread_pool_patterns : String?
  query : CatThreadPoolQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatThreadPoolRequest::new(
  thread_pool_patterns? : String,
  query? : CatThreadPoolQuery = CatThreadPoolQuery::new(),
) -> CatThreadPoolRequest {
  { thread_pool_patterns, query }
}

///|
pub async fn Client::cat_thread_pool(
  self : Client,
  request : CatThreadPoolRequest,
) -> EsResponse[CatThreadPoolResponse] {
  let params : Map[String, String] = Map([])
  match request.thread_pool_patterns {
    Some(value) => params["thread_pool_patterns"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/thread_pool/{thread_pool_patterns}", [
        "thread_pool_patterns",
      ]),
      PathVariant::new("/_cat/thread_pool", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CatTransformsQuery {
  allow_no_match : Bool?
  from : Int?
  h : String?
  s : String?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for CatTransformsQuery with fn to_json(
  self : CatTransformsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.h {
    Some(value) => obj["h"] = value.to_json()
    None => ()
  }
  match self.s {
    Some(value) => obj["s"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CatTransformsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CatTransformsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    h: match obj.get("h") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("h")))
    },
    s: match obj.get("s") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("s")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn CatTransformsQuery::new(
  allow_no_match? : Bool,
  from? : Int,
  h? : String,
  s? : String,
  size? : Int,
) -> CatTransformsQuery {
  { allow_no_match, from, h, s, size }
}

///|
pub fn CatTransformsQuery::to_pairs(
  self : CatTransformsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.h {
    Some(value) => push_query_json(pairs, "h", value.to_json())
    None => ()
  }
  match self.s {
    Some(value) => push_query_json(pairs, "s", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CatTransformsResponse = Json

///|
pub(all) struct CatTransformsRequest {
  transform_id : String?
  query : CatTransformsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CatTransformsRequest::new(
  transform_id? : String,
  query? : CatTransformsQuery = CatTransformsQuery::new(),
) -> CatTransformsRequest {
  { transform_id, query }
}

///|
pub async fn Client::cat_transforms(
  self : Client,
  request : CatTransformsRequest,
) -> EsResponse[CatTransformsResponse] {
  let params : Map[String, String] = Map([])
  match request.transform_id {
    Some(value) => params["transform_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cat/transforms/{transform_id}", ["transform_id"]),
      PathVariant::new("/_cat/transforms", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CcrDeleteAutoFollowPatternQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrDeleteAutoFollowPatternQuery with fn to_json(
  self : CcrDeleteAutoFollowPatternQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrDeleteAutoFollowPatternQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrDeleteAutoFollowPatternQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrDeleteAutoFollowPatternQuery::new(
  master_timeout? : String,
) -> CcrDeleteAutoFollowPatternQuery {
  { master_timeout, }
}

///|
pub fn CcrDeleteAutoFollowPatternQuery::to_pairs(
  self : CcrDeleteAutoFollowPatternQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CcrDeleteAutoFollowPatternResponse = Json

///|
pub(all) struct CcrDeleteAutoFollowPatternRequest {
  name : String
  query : CcrDeleteAutoFollowPatternQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrDeleteAutoFollowPatternRequest::new(
  name : String,
  query? : CcrDeleteAutoFollowPatternQuery = CcrDeleteAutoFollowPatternQuery::new(),
) -> CcrDeleteAutoFollowPatternRequest {
  { name, query }
}

///|
pub async fn Client::ccr_delete_auto_follow_pattern(
  self : Client,
  request : CcrDeleteAutoFollowPatternRequest,
) -> EsResponse[CcrDeleteAutoFollowPatternResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ccr/auto_follow/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct CcrFollowQuery {
  master_timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowQuery with fn to_json(self : CcrFollowQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn CcrFollowQuery::new(
  master_timeout? : String,
  wait_for_active_shards? : String,
) -> CcrFollowQuery {
  { master_timeout, wait_for_active_shards }
}

///|
pub fn CcrFollowQuery::to_pairs(
  self : CcrFollowQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrFollowBody {
  data_stream_name : String?
  leader_index : Json
  max_outstanding_read_requests : Int?
  max_outstanding_write_requests : Int?
  max_read_request_operation_count : Int?
  max_read_request_size : Json?
  max_retry_delay : Json?
  max_write_buffer_count : Int?
  max_write_buffer_size : Json?
  max_write_request_operation_count : Int?
  max_write_request_size : Json?
  read_poll_timeout : Json?
  remote_cluster : String
  settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowBody with fn to_json(self : CcrFollowBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.data_stream_name {
    Some(value) => obj["data_stream_name"] = value.to_json()
    None => ()
  }
  obj["leader_index"] = self.leader_index.to_json()
  match self.max_outstanding_read_requests {
    Some(value) => obj["max_outstanding_read_requests"] = value.to_json()
    None => ()
  }
  match self.max_outstanding_write_requests {
    Some(value) => obj["max_outstanding_write_requests"] = value.to_json()
    None => ()
  }
  match self.max_read_request_operation_count {
    Some(value) => obj["max_read_request_operation_count"] = value.to_json()
    None => ()
  }
  match self.max_read_request_size {
    Some(value) => obj["max_read_request_size"] = value.to_json()
    None => ()
  }
  match self.max_retry_delay {
    Some(value) => obj["max_retry_delay"] = value.to_json()
    None => ()
  }
  match self.max_write_buffer_count {
    Some(value) => obj["max_write_buffer_count"] = value.to_json()
    None => ()
  }
  match self.max_write_buffer_size {
    Some(value) => obj["max_write_buffer_size"] = value.to_json()
    None => ()
  }
  match self.max_write_request_operation_count {
    Some(value) => obj["max_write_request_operation_count"] = value.to_json()
    None => ()
  }
  match self.max_write_request_size {
    Some(value) => obj["max_write_request_size"] = value.to_json()
    None => ()
  }
  match self.read_poll_timeout {
    Some(value) => obj["read_poll_timeout"] = value.to_json()
    None => ()
  }
  obj["remote_cluster"] = self.remote_cluster.to_json()
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowBody: expected object"))
  }
  {
    data_stream_name: match obj.get("data_stream_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_stream_name")))
    },
    leader_index: @json.from_json(
      obj.get("leader_index").unwrap_or(Json::null()),
      path=path.add_key("leader_index"),
    ),
    max_outstanding_read_requests: match
      obj.get("max_outstanding_read_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_outstanding_read_requests"),
          ),
        )
    },
    max_outstanding_write_requests: match
      obj.get("max_outstanding_write_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_outstanding_write_requests"),
          ),
        )
    },
    max_read_request_operation_count: match
      obj.get("max_read_request_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_read_request_operation_count"),
          ),
        )
    },
    max_read_request_size: match obj.get("max_read_request_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_read_request_size")))
    },
    max_retry_delay: match obj.get("max_retry_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_retry_delay")))
    },
    max_write_buffer_count: match obj.get("max_write_buffer_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_write_buffer_count")),
        )
    },
    max_write_buffer_size: match obj.get("max_write_buffer_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_write_buffer_size")))
    },
    max_write_request_operation_count: match
      obj.get("max_write_request_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_write_request_operation_count"),
          ),
        )
    },
    max_write_request_size: match obj.get("max_write_request_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_write_request_size")),
        )
    },
    read_poll_timeout: match obj.get("read_poll_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("read_poll_timeout")))
    },
    remote_cluster: @json.from_json(
      obj.get("remote_cluster").unwrap_or(Json::null()),
      path=path.add_key("remote_cluster"),
    ),
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
  }
}

///|
pub fn CcrFollowBody::new(
  leader_index : Json,
  remote_cluster : String,
  data_stream_name? : String,
  max_outstanding_read_requests? : Int,
  max_outstanding_write_requests? : Int,
  max_read_request_operation_count? : Int,
  max_read_request_size? : Json,
  max_retry_delay? : Json,
  max_write_buffer_count? : Int,
  max_write_buffer_size? : Json,
  max_write_request_operation_count? : Int,
  max_write_request_size? : Json,
  read_poll_timeout? : Json,
  settings? : Json,
) -> CcrFollowBody {
  {
    data_stream_name,
    leader_index,
    max_outstanding_read_requests,
    max_outstanding_write_requests,
    max_read_request_operation_count,
    max_read_request_size,
    max_retry_delay,
    max_write_buffer_count,
    max_write_buffer_size,
    max_write_request_operation_count,
    max_write_request_size,
    read_poll_timeout,
    remote_cluster,
    settings,
  }
}

///|
pub(all) struct CcrFollowResponse {
  follow_index_created : Bool
  follow_index_shards_acked : Bool
  index_following_started : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowResponse with fn to_json(self : CcrFollowResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["follow_index_created"] = self.follow_index_created.to_json()
  obj["follow_index_shards_acked"] = self.follow_index_shards_acked.to_json()
  obj["index_following_started"] = self.index_following_started.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowResponse: expected object"))
  }
  {
    follow_index_created: @json.from_json(
      obj.get("follow_index_created").unwrap_or(Json::null()),
      path=path.add_key("follow_index_created"),
    ),
    follow_index_shards_acked: @json.from_json(
      obj.get("follow_index_shards_acked").unwrap_or(Json::null()),
      path=path.add_key("follow_index_shards_acked"),
    ),
    index_following_started: @json.from_json(
      obj.get("index_following_started").unwrap_or(Json::null()),
      path=path.add_key("index_following_started"),
    ),
  }
}

///|
pub(all) struct CcrFollowRequest {
  index : String
  query : CcrFollowQuery
  body : CcrFollowBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrFollowRequest::new(
  index : String,
  body : CcrFollowBody,
  query? : CcrFollowQuery = CcrFollowQuery::new(),
) -> CcrFollowRequest {
  { index, query, body }
}

///|
pub async fn Client::ccr_follow(
  self : Client,
  request : CcrFollowRequest,
) -> EsResponse[CcrFollowResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/follow", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct CcrFollowInfoQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowInfoQuery with fn to_json(
  self : CcrFollowInfoQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowInfoQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowInfoQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrFollowInfoQuery::new(master_timeout? : String) -> CcrFollowInfoQuery {
  { master_timeout, }
}

///|
pub fn CcrFollowInfoQuery::to_pairs(
  self : CcrFollowInfoQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrFollowInfoResponse {
  follower_indices : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowInfoResponse with fn to_json(
  self : CcrFollowInfoResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["follower_indices"] = self.follower_indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowInfoResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowInfoResponse: expected object"))
  }
  {
    follower_indices: @json.from_json(
      obj.get("follower_indices").unwrap_or(Json::null()),
      path=path.add_key("follower_indices"),
    ),
  }
}

///|
pub(all) struct CcrFollowInfoRequest {
  index : String
  query : CcrFollowInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrFollowInfoRequest::new(
  index : String,
  query? : CcrFollowInfoQuery = CcrFollowInfoQuery::new(),
) -> CcrFollowInfoRequest {
  { index, query }
}

///|
pub async fn Client::ccr_follow_info(
  self : Client,
  request : CcrFollowInfoRequest,
) -> EsResponse[CcrFollowInfoResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/info", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CcrFollowStatsQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowStatsQuery with fn to_json(
  self : CcrFollowStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowStatsQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn CcrFollowStatsQuery::new(timeout? : String) -> CcrFollowStatsQuery {
  { timeout, }
}

///|
pub fn CcrFollowStatsQuery::to_pairs(
  self : CcrFollowStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrFollowStatsResponse {
  indices : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for CcrFollowStatsResponse with fn to_json(
  self : CcrFollowStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CcrFollowStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrFollowStatsResponse: expected object"))
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct CcrFollowStatsRequest {
  index : String
  query : CcrFollowStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrFollowStatsRequest::new(
  index : String,
  query? : CcrFollowStatsQuery = CcrFollowStatsQuery::new(),
) -> CcrFollowStatsRequest {
  { index, query }
}

///|
pub async fn Client::ccr_follow_stats(
  self : Client,
  request : CcrFollowStatsRequest,
) -> EsResponse[CcrFollowStatsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/stats", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CcrForgetFollowerQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrForgetFollowerQuery with fn to_json(
  self : CcrForgetFollowerQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrForgetFollowerQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrForgetFollowerQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn CcrForgetFollowerQuery::new(timeout? : String) -> CcrForgetFollowerQuery {
  { timeout, }
}

///|
pub fn CcrForgetFollowerQuery::to_pairs(
  self : CcrForgetFollowerQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrForgetFollowerBody {
  follower_cluster : String?
  follower_index : Json?
  follower_index_uuid : Json?
  leader_remote_cluster : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrForgetFollowerBody with fn to_json(
  self : CcrForgetFollowerBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.follower_cluster {
    Some(value) => obj["follower_cluster"] = value.to_json()
    None => ()
  }
  match self.follower_index {
    Some(value) => obj["follower_index"] = value.to_json()
    None => ()
  }
  match self.follower_index_uuid {
    Some(value) => obj["follower_index_uuid"] = value.to_json()
    None => ()
  }
  match self.leader_remote_cluster {
    Some(value) => obj["leader_remote_cluster"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrForgetFollowerBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrForgetFollowerBody: expected object"))
  }
  {
    follower_cluster: match obj.get("follower_cluster") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("follower_cluster")))
    },
    follower_index: match obj.get("follower_index") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("follower_index")))
    },
    follower_index_uuid: match obj.get("follower_index_uuid") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("follower_index_uuid")))
    },
    leader_remote_cluster: match obj.get("leader_remote_cluster") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("leader_remote_cluster")))
    },
  }
}

///|
pub fn CcrForgetFollowerBody::new(
  follower_cluster? : String,
  follower_index? : Json,
  follower_index_uuid? : Json,
  leader_remote_cluster? : String,
) -> CcrForgetFollowerBody {
  {
    follower_cluster,
    follower_index,
    follower_index_uuid,
    leader_remote_cluster,
  }
}

///|
pub(all) struct CcrForgetFollowerResponse {
  _shards : Json
} derive(Eq, Debug)

///|
pub impl ToJson for CcrForgetFollowerResponse with fn to_json(
  self : CcrForgetFollowerResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_shards"] = self._shards.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CcrForgetFollowerResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrForgetFollowerResponse: expected object"))
  }
  {
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
  }
}

///|
pub(all) struct CcrForgetFollowerRequest {
  index : String
  query : CcrForgetFollowerQuery
  body : CcrForgetFollowerBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrForgetFollowerRequest::new(
  index : String,
  body : CcrForgetFollowerBody,
  query? : CcrForgetFollowerQuery = CcrForgetFollowerQuery::new(),
) -> CcrForgetFollowerRequest {
  { index, query, body }
}

///|
pub async fn Client::ccr_forget_follower(
  self : Client,
  request : CcrForgetFollowerRequest,
) -> EsResponse[CcrForgetFollowerResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/forget_follower", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct CcrGetAutoFollowPatternQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrGetAutoFollowPatternQuery with fn to_json(
  self : CcrGetAutoFollowPatternQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrGetAutoFollowPatternQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrGetAutoFollowPatternQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrGetAutoFollowPatternQuery::new(
  master_timeout? : String,
) -> CcrGetAutoFollowPatternQuery {
  { master_timeout, }
}

///|
pub fn CcrGetAutoFollowPatternQuery::to_pairs(
  self : CcrGetAutoFollowPatternQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrGetAutoFollowPatternResponse {
  patterns : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for CcrGetAutoFollowPatternResponse with fn to_json(
  self : CcrGetAutoFollowPatternResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["patterns"] = self.patterns.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CcrGetAutoFollowPatternResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrGetAutoFollowPatternResponse: expected object"),
    )
  }
  {
    patterns: @json.from_json(
      obj.get("patterns").unwrap_or(Json::null()),
      path=path.add_key("patterns"),
    ),
  }
}

///|
pub(all) struct CcrGetAutoFollowPatternRequest {
  name : String?
  query : CcrGetAutoFollowPatternQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrGetAutoFollowPatternRequest::new(
  name? : String,
  query? : CcrGetAutoFollowPatternQuery = CcrGetAutoFollowPatternQuery::new(),
) -> CcrGetAutoFollowPatternRequest {
  { name, query }
}

///|
pub async fn Client::ccr_get_auto_follow_pattern(
  self : Client,
  request : CcrGetAutoFollowPatternRequest,
) -> EsResponse[CcrGetAutoFollowPatternResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ccr/auto_follow/{name}", ["name"]),
      PathVariant::new("/_ccr/auto_follow", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CcrPauseAutoFollowPatternQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrPauseAutoFollowPatternQuery with fn to_json(
  self : CcrPauseAutoFollowPatternQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrPauseAutoFollowPatternQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrPauseAutoFollowPatternQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrPauseAutoFollowPatternQuery::new(
  master_timeout? : String,
) -> CcrPauseAutoFollowPatternQuery {
  { master_timeout, }
}

///|
pub fn CcrPauseAutoFollowPatternQuery::to_pairs(
  self : CcrPauseAutoFollowPatternQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CcrPauseAutoFollowPatternResponse = Json

///|
pub(all) struct CcrPauseAutoFollowPatternRequest {
  name : String
  query : CcrPauseAutoFollowPatternQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrPauseAutoFollowPatternRequest::new(
  name : String,
  query? : CcrPauseAutoFollowPatternQuery = CcrPauseAutoFollowPatternQuery::new(),
) -> CcrPauseAutoFollowPatternRequest {
  { name, query }
}

///|
pub async fn Client::ccr_pause_auto_follow_pattern(
  self : Client,
  request : CcrPauseAutoFollowPatternRequest,
) -> EsResponse[CcrPauseAutoFollowPatternResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ccr/auto_follow/{name}/pause", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct CcrPauseFollowQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrPauseFollowQuery with fn to_json(
  self : CcrPauseFollowQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrPauseFollowQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrPauseFollowQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrPauseFollowQuery::new(
  master_timeout? : String,
) -> CcrPauseFollowQuery {
  { master_timeout, }
}

///|
pub fn CcrPauseFollowQuery::to_pairs(
  self : CcrPauseFollowQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CcrPauseFollowResponse = Json

///|
pub(all) struct CcrPauseFollowRequest {
  index : String
  query : CcrPauseFollowQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrPauseFollowRequest::new(
  index : String,
  query? : CcrPauseFollowQuery = CcrPauseFollowQuery::new(),
) -> CcrPauseFollowRequest {
  { index, query }
}

///|
pub async fn Client::ccr_pause_follow(
  self : Client,
  request : CcrPauseFollowRequest,
) -> EsResponse[CcrPauseFollowResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/pause_follow", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct CcrPutAutoFollowPatternQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrPutAutoFollowPatternQuery with fn to_json(
  self : CcrPutAutoFollowPatternQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrPutAutoFollowPatternQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrPutAutoFollowPatternQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrPutAutoFollowPatternQuery::new(
  master_timeout? : String,
) -> CcrPutAutoFollowPatternQuery {
  { master_timeout, }
}

///|
pub fn CcrPutAutoFollowPatternQuery::to_pairs(
  self : CcrPutAutoFollowPatternQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrPutAutoFollowPatternBody {
  remote_cluster : String
  follow_index_pattern : Json?
  leader_index_patterns : Json?
  leader_index_exclusion_patterns : Json?
  max_outstanding_read_requests : Int?
  settings : Map[String, Json]?
  max_outstanding_write_requests : Int?
  read_poll_timeout : Json?
  max_read_request_operation_count : Int?
  max_read_request_size : Json?
  max_retry_delay : Json?
  max_write_buffer_count : Int?
  max_write_buffer_size : Json?
  max_write_request_operation_count : Int?
  max_write_request_size : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrPutAutoFollowPatternBody with fn to_json(
  self : CcrPutAutoFollowPatternBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["remote_cluster"] = self.remote_cluster.to_json()
  match self.follow_index_pattern {
    Some(value) => obj["follow_index_pattern"] = value.to_json()
    None => ()
  }
  match self.leader_index_patterns {
    Some(value) => obj["leader_index_patterns"] = value.to_json()
    None => ()
  }
  match self.leader_index_exclusion_patterns {
    Some(value) => obj["leader_index_exclusion_patterns"] = value.to_json()
    None => ()
  }
  match self.max_outstanding_read_requests {
    Some(value) => obj["max_outstanding_read_requests"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  match self.max_outstanding_write_requests {
    Some(value) => obj["max_outstanding_write_requests"] = value.to_json()
    None => ()
  }
  match self.read_poll_timeout {
    Some(value) => obj["read_poll_timeout"] = value.to_json()
    None => ()
  }
  match self.max_read_request_operation_count {
    Some(value) => obj["max_read_request_operation_count"] = value.to_json()
    None => ()
  }
  match self.max_read_request_size {
    Some(value) => obj["max_read_request_size"] = value.to_json()
    None => ()
  }
  match self.max_retry_delay {
    Some(value) => obj["max_retry_delay"] = value.to_json()
    None => ()
  }
  match self.max_write_buffer_count {
    Some(value) => obj["max_write_buffer_count"] = value.to_json()
    None => ()
  }
  match self.max_write_buffer_size {
    Some(value) => obj["max_write_buffer_size"] = value.to_json()
    None => ()
  }
  match self.max_write_request_operation_count {
    Some(value) => obj["max_write_request_operation_count"] = value.to_json()
    None => ()
  }
  match self.max_write_request_size {
    Some(value) => obj["max_write_request_size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrPutAutoFollowPatternBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrPutAutoFollowPatternBody: expected object"),
    )
  }
  {
    remote_cluster: @json.from_json(
      obj.get("remote_cluster").unwrap_or(Json::null()),
      path=path.add_key("remote_cluster"),
    ),
    follow_index_pattern: match obj.get("follow_index_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("follow_index_pattern")))
    },
    leader_index_patterns: match obj.get("leader_index_patterns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("leader_index_patterns")))
    },
    leader_index_exclusion_patterns: match
      obj.get("leader_index_exclusion_patterns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("leader_index_exclusion_patterns"),
          ),
        )
    },
    max_outstanding_read_requests: match
      obj.get("max_outstanding_read_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_outstanding_read_requests"),
          ),
        )
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
    max_outstanding_write_requests: match
      obj.get("max_outstanding_write_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_outstanding_write_requests"),
          ),
        )
    },
    read_poll_timeout: match obj.get("read_poll_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("read_poll_timeout")))
    },
    max_read_request_operation_count: match
      obj.get("max_read_request_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_read_request_operation_count"),
          ),
        )
    },
    max_read_request_size: match obj.get("max_read_request_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_read_request_size")))
    },
    max_retry_delay: match obj.get("max_retry_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_retry_delay")))
    },
    max_write_buffer_count: match obj.get("max_write_buffer_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_write_buffer_count")),
        )
    },
    max_write_buffer_size: match obj.get("max_write_buffer_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_write_buffer_size")))
    },
    max_write_request_operation_count: match
      obj.get("max_write_request_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_write_request_operation_count"),
          ),
        )
    },
    max_write_request_size: match obj.get("max_write_request_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_write_request_size")),
        )
    },
  }
}

///|
pub fn CcrPutAutoFollowPatternBody::new(
  remote_cluster : String,
  follow_index_pattern? : Json,
  leader_index_patterns? : Json,
  leader_index_exclusion_patterns? : Json,
  max_outstanding_read_requests? : Int,
  settings? : Map[String, Json],
  max_outstanding_write_requests? : Int,
  read_poll_timeout? : Json,
  max_read_request_operation_count? : Int,
  max_read_request_size? : Json,
  max_retry_delay? : Json,
  max_write_buffer_count? : Int,
  max_write_buffer_size? : Json,
  max_write_request_operation_count? : Int,
  max_write_request_size? : Json,
) -> CcrPutAutoFollowPatternBody {
  {
    remote_cluster,
    follow_index_pattern,
    leader_index_patterns,
    leader_index_exclusion_patterns,
    max_outstanding_read_requests,
    settings,
    max_outstanding_write_requests,
    read_poll_timeout,
    max_read_request_operation_count,
    max_read_request_size,
    max_retry_delay,
    max_write_buffer_count,
    max_write_buffer_size,
    max_write_request_operation_count,
    max_write_request_size,
  }
}

///|
pub type CcrPutAutoFollowPatternResponse = Json

///|
pub(all) struct CcrPutAutoFollowPatternRequest {
  name : String
  query : CcrPutAutoFollowPatternQuery
  body : CcrPutAutoFollowPatternBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrPutAutoFollowPatternRequest::new(
  name : String,
  body : CcrPutAutoFollowPatternBody,
  query? : CcrPutAutoFollowPatternQuery = CcrPutAutoFollowPatternQuery::new(),
) -> CcrPutAutoFollowPatternRequest {
  { name, query, body }
}

///|
pub async fn Client::ccr_put_auto_follow_pattern(
  self : Client,
  request : CcrPutAutoFollowPatternRequest,
) -> EsResponse[CcrPutAutoFollowPatternResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ccr/auto_follow/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct CcrResumeAutoFollowPatternQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrResumeAutoFollowPatternQuery with fn to_json(
  self : CcrResumeAutoFollowPatternQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrResumeAutoFollowPatternQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "CcrResumeAutoFollowPatternQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrResumeAutoFollowPatternQuery::new(
  master_timeout? : String,
) -> CcrResumeAutoFollowPatternQuery {
  { master_timeout, }
}

///|
pub fn CcrResumeAutoFollowPatternQuery::to_pairs(
  self : CcrResumeAutoFollowPatternQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CcrResumeAutoFollowPatternResponse = Json

///|
pub(all) struct CcrResumeAutoFollowPatternRequest {
  name : String
  query : CcrResumeAutoFollowPatternQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrResumeAutoFollowPatternRequest::new(
  name : String,
  query? : CcrResumeAutoFollowPatternQuery = CcrResumeAutoFollowPatternQuery::new(),
) -> CcrResumeAutoFollowPatternRequest {
  { name, query }
}

///|
pub async fn Client::ccr_resume_auto_follow_pattern(
  self : Client,
  request : CcrResumeAutoFollowPatternRequest,
) -> EsResponse[CcrResumeAutoFollowPatternResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ccr/auto_follow/{name}/resume", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct CcrResumeFollowQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrResumeFollowQuery with fn to_json(
  self : CcrResumeFollowQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrResumeFollowQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrResumeFollowQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrResumeFollowQuery::new(
  master_timeout? : String,
) -> CcrResumeFollowQuery {
  { master_timeout, }
}

///|
pub fn CcrResumeFollowQuery::to_pairs(
  self : CcrResumeFollowQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrResumeFollowBody {
  max_outstanding_read_requests : Int?
  max_outstanding_write_requests : Int?
  max_read_request_operation_count : Int?
  max_read_request_size : String?
  max_retry_delay : Json?
  max_write_buffer_count : Int?
  max_write_buffer_size : String?
  max_write_request_operation_count : Int?
  max_write_request_size : String?
  read_poll_timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrResumeFollowBody with fn to_json(
  self : CcrResumeFollowBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.max_outstanding_read_requests {
    Some(value) => obj["max_outstanding_read_requests"] = value.to_json()
    None => ()
  }
  match self.max_outstanding_write_requests {
    Some(value) => obj["max_outstanding_write_requests"] = value.to_json()
    None => ()
  }
  match self.max_read_request_operation_count {
    Some(value) => obj["max_read_request_operation_count"] = value.to_json()
    None => ()
  }
  match self.max_read_request_size {
    Some(value) => obj["max_read_request_size"] = value.to_json()
    None => ()
  }
  match self.max_retry_delay {
    Some(value) => obj["max_retry_delay"] = value.to_json()
    None => ()
  }
  match self.max_write_buffer_count {
    Some(value) => obj["max_write_buffer_count"] = value.to_json()
    None => ()
  }
  match self.max_write_buffer_size {
    Some(value) => obj["max_write_buffer_size"] = value.to_json()
    None => ()
  }
  match self.max_write_request_operation_count {
    Some(value) => obj["max_write_request_operation_count"] = value.to_json()
    None => ()
  }
  match self.max_write_request_size {
    Some(value) => obj["max_write_request_size"] = value.to_json()
    None => ()
  }
  match self.read_poll_timeout {
    Some(value) => obj["read_poll_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrResumeFollowBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrResumeFollowBody: expected object"))
  }
  {
    max_outstanding_read_requests: match
      obj.get("max_outstanding_read_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_outstanding_read_requests"),
          ),
        )
    },
    max_outstanding_write_requests: match
      obj.get("max_outstanding_write_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_outstanding_write_requests"),
          ),
        )
    },
    max_read_request_operation_count: match
      obj.get("max_read_request_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_read_request_operation_count"),
          ),
        )
    },
    max_read_request_size: match obj.get("max_read_request_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_read_request_size")))
    },
    max_retry_delay: match obj.get("max_retry_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_retry_delay")))
    },
    max_write_buffer_count: match obj.get("max_write_buffer_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_write_buffer_count")),
        )
    },
    max_write_buffer_size: match obj.get("max_write_buffer_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_write_buffer_size")))
    },
    max_write_request_operation_count: match
      obj.get("max_write_request_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_write_request_operation_count"),
          ),
        )
    },
    max_write_request_size: match obj.get("max_write_request_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_write_request_size")),
        )
    },
    read_poll_timeout: match obj.get("read_poll_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("read_poll_timeout")))
    },
  }
}

///|
pub fn CcrResumeFollowBody::new(
  max_outstanding_read_requests? : Int,
  max_outstanding_write_requests? : Int,
  max_read_request_operation_count? : Int,
  max_read_request_size? : String,
  max_retry_delay? : Json,
  max_write_buffer_count? : Int,
  max_write_buffer_size? : String,
  max_write_request_operation_count? : Int,
  max_write_request_size? : String,
  read_poll_timeout? : Json,
) -> CcrResumeFollowBody {
  {
    max_outstanding_read_requests,
    max_outstanding_write_requests,
    max_read_request_operation_count,
    max_read_request_size,
    max_retry_delay,
    max_write_buffer_count,
    max_write_buffer_size,
    max_write_request_operation_count,
    max_write_request_size,
    read_poll_timeout,
  }
}

///|
pub type CcrResumeFollowResponse = Json

///|
pub(all) struct CcrResumeFollowRequest {
  index : String
  query : CcrResumeFollowQuery
  body : CcrResumeFollowBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrResumeFollowRequest::new(
  index : String,
  query? : CcrResumeFollowQuery = CcrResumeFollowQuery::new(),
  body? : CcrResumeFollowBody,
) -> CcrResumeFollowRequest {
  { index, query, body }
}

///|
pub async fn Client::ccr_resume_follow(
  self : Client,
  request : CcrResumeFollowRequest,
) -> EsResponse[CcrResumeFollowResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/resume_follow", ["index"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct CcrStatsQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrStatsQuery with fn to_json(self : CcrStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrStatsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn CcrStatsQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> CcrStatsQuery {
  { master_timeout, timeout }
}

///|
pub fn CcrStatsQuery::to_pairs(self : CcrStatsQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CcrStatsResponse {
  auto_follow_stats : Json
  follow_stats : Json
} derive(Eq, Debug)

///|
pub impl ToJson for CcrStatsResponse with fn to_json(self : CcrStatsResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["auto_follow_stats"] = self.auto_follow_stats.to_json()
  obj["follow_stats"] = self.follow_stats.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CcrStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrStatsResponse: expected object"))
  }
  {
    auto_follow_stats: @json.from_json(
      obj.get("auto_follow_stats").unwrap_or(Json::null()),
      path=path.add_key("auto_follow_stats"),
    ),
    follow_stats: @json.from_json(
      obj.get("follow_stats").unwrap_or(Json::null()),
      path=path.add_key("follow_stats"),
    ),
  }
}

///|
pub(all) struct CcrStatsRequest {
  query : CcrStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrStatsRequest::new(
  query? : CcrStatsQuery = CcrStatsQuery::new(),
) -> CcrStatsRequest {
  { query, }
}

///|
pub async fn Client::ccr_stats(
  self : Client,
  request : CcrStatsRequest,
) -> EsResponse[CcrStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ccr/stats", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct CcrUnfollowQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CcrUnfollowQuery with fn to_json(self : CcrUnfollowQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CcrUnfollowQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CcrUnfollowQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn CcrUnfollowQuery::new(master_timeout? : String) -> CcrUnfollowQuery {
  { master_timeout, }
}

///|
pub fn CcrUnfollowQuery::to_pairs(
  self : CcrUnfollowQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CcrUnfollowResponse = Json

///|
pub(all) struct CcrUnfollowRequest {
  index : String
  query : CcrUnfollowQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CcrUnfollowRequest::new(
  index : String,
  query? : CcrUnfollowQuery = CcrUnfollowQuery::new(),
) -> CcrUnfollowRequest {
  { index, query }
}

///|
pub async fn Client::ccr_unfollow(
  self : Client,
  request : CcrUnfollowRequest,
) -> EsResponse[CcrUnfollowResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ccr/unfollow", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct ClearScrollQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ClearScrollQuery with fn to_json(_self : ClearScrollQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ClearScrollQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ClearScrollQuery: expected object"))
  }
  ClearScrollQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ClearScrollQuery::new() -> ClearScrollQuery {
  ClearScrollQuery::{  }
}

///|
pub fn ClearScrollQuery::to_pairs(
  _self : ClearScrollQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ClearScrollBody = String

///|
pub(all) struct ClearScrollResponse {
  succeeded : Bool
  num_freed : Int
} derive(Eq, Debug)

///|
pub impl ToJson for ClearScrollResponse with fn to_json(
  self : ClearScrollResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["succeeded"] = self.succeeded.to_json()
  obj["num_freed"] = self.num_freed.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ClearScrollResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClearScrollResponse: expected object"))
  }
  {
    succeeded: @json.from_json(
      obj.get("succeeded").unwrap_or(Json::null()),
      path=path.add_key("succeeded"),
    ),
    num_freed: @json.from_json(
      obj.get("num_freed").unwrap_or(Json::null()),
      path=path.add_key("num_freed"),
    ),
  }
}

///|
pub(all) struct ClearScrollRequest {
  scroll_id : String?
  query : ClearScrollQuery
  body : ClearScrollBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClearScrollRequest::new(
  scroll_id? : String,
  query? : ClearScrollQuery = ClearScrollQuery::new(),
  body? : ClearScrollBody,
) -> ClearScrollRequest {
  { scroll_id, query, body }
}

///|
pub async fn Client::clear_scroll(
  self : Client,
  request : ClearScrollRequest,
) -> EsResponse[ClearScrollResponse] {
  let params : Map[String, String] = Map([])
  match request.scroll_id {
    Some(value) => params["scroll_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_search/scroll/{scroll_id}", ["scroll_id"]),
      PathVariant::new("/_search/scroll", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => TextBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct ClosePointInTimeQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ClosePointInTimeQuery with fn to_json(
  _self : ClosePointInTimeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ClosePointInTimeQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ClosePointInTimeQuery: expected object"))
  }
  ClosePointInTimeQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ClosePointInTimeQuery::new() -> ClosePointInTimeQuery {
  ClosePointInTimeQuery::{  }
}

///|
pub fn ClosePointInTimeQuery::to_pairs(
  _self : ClosePointInTimeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ClosePointInTimeBody {
  id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ClosePointInTimeBody with fn to_json(
  self : ClosePointInTimeBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ClosePointInTimeBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClosePointInTimeBody: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub fn ClosePointInTimeBody::new(id : Json) -> ClosePointInTimeBody {
  { id, }
}

///|
pub(all) struct ClosePointInTimeResponse {
  succeeded : Bool
  num_freed : Int
} derive(Eq, Debug)

///|
pub impl ToJson for ClosePointInTimeResponse with fn to_json(
  self : ClosePointInTimeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["succeeded"] = self.succeeded.to_json()
  obj["num_freed"] = self.num_freed.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ClosePointInTimeResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClosePointInTimeResponse: expected object"))
  }
  {
    succeeded: @json.from_json(
      obj.get("succeeded").unwrap_or(Json::null()),
      path=path.add_key("succeeded"),
    ),
    num_freed: @json.from_json(
      obj.get("num_freed").unwrap_or(Json::null()),
      path=path.add_key("num_freed"),
    ),
  }
}

///|
pub(all) struct ClosePointInTimeRequest {
  query : ClosePointInTimeQuery
  body : ClosePointInTimeBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClosePointInTimeRequest::new(
  body : ClosePointInTimeBody,
  query? : ClosePointInTimeQuery = ClosePointInTimeQuery::new(),
) -> ClosePointInTimeRequest {
  { query, body }
}

///|
pub async fn Client::close_point_in_time(
  self : Client,
  request : ClosePointInTimeRequest,
) -> EsResponse[ClosePointInTimeResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_pit", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct ClusterAllocationExplainQuery {
  index : String?
  shard : Int?
  primary : Bool?
  current_node : String?
  include_disk_info : Bool?
  include_yes_decisions : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterAllocationExplainQuery with fn to_json(
  self : ClusterAllocationExplainQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  match self.shard {
    Some(value) => obj["shard"] = value.to_json()
    None => ()
  }
  match self.primary {
    Some(value) => obj["primary"] = value.to_json()
    None => ()
  }
  match self.current_node {
    Some(value) => obj["current_node"] = value.to_json()
    None => ()
  }
  match self.include_disk_info {
    Some(value) => obj["include_disk_info"] = value.to_json()
    None => ()
  }
  match self.include_yes_decisions {
    Some(value) => obj["include_yes_decisions"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterAllocationExplainQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterAllocationExplainQuery: expected object"),
    )
  }
  {
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
    shard: match obj.get("shard") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("shard")))
    },
    primary: match obj.get("primary") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("primary")))
    },
    current_node: match obj.get("current_node") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("current_node")))
    },
    include_disk_info: match obj.get("include_disk_info") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_disk_info")))
    },
    include_yes_decisions: match obj.get("include_yes_decisions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_yes_decisions")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn ClusterAllocationExplainQuery::new(
  index? : String,
  shard? : Int,
  primary? : Bool,
  current_node? : String,
  include_disk_info? : Bool,
  include_yes_decisions? : Bool,
  master_timeout? : String,
) -> ClusterAllocationExplainQuery {
  {
    index,
    shard,
    primary,
    current_node,
    include_disk_info,
    include_yes_decisions,
    master_timeout,
  }
}

///|
pub fn ClusterAllocationExplainQuery::to_pairs(
  self : ClusterAllocationExplainQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.index {
    Some(value) => push_query_json(pairs, "index", value.to_json())
    None => ()
  }
  match self.shard {
    Some(value) => push_query_json(pairs, "shard", value.to_json())
    None => ()
  }
  match self.primary {
    Some(value) => push_query_json(pairs, "primary", value.to_json())
    None => ()
  }
  match self.current_node {
    Some(value) => push_query_json(pairs, "current_node", value.to_json())
    None => ()
  }
  match self.include_disk_info {
    Some(value) => push_query_json(pairs, "include_disk_info", value.to_json())
    None => ()
  }
  match self.include_yes_decisions {
    Some(value) =>
      push_query_json(pairs, "include_yes_decisions", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterAllocationExplainBody {
  index : Json?
  shard : Int?
  primary : Bool?
  current_node : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterAllocationExplainBody with fn to_json(
  self : ClusterAllocationExplainBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  match self.shard {
    Some(value) => obj["shard"] = value.to_json()
    None => ()
  }
  match self.primary {
    Some(value) => obj["primary"] = value.to_json()
    None => ()
  }
  match self.current_node {
    Some(value) => obj["current_node"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterAllocationExplainBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterAllocationExplainBody: expected object"),
    )
  }
  {
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
    shard: match obj.get("shard") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("shard")))
    },
    primary: match obj.get("primary") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("primary")))
    },
    current_node: match obj.get("current_node") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("current_node")))
    },
  }
}

///|
pub fn ClusterAllocationExplainBody::new(
  index? : Json,
  shard? : Int,
  primary? : Bool,
  current_node? : Json,
) -> ClusterAllocationExplainBody {
  { index, shard, primary, current_node }
}

///|
pub(all) struct ClusterAllocationExplainResponse {
  allocate_explanation : String?
  allocation_delay : Json?
  allocation_delay_in_millis : Json?
  can_allocate : Json?
  can_move_to_other_node : Json?
  can_rebalance_cluster : Json?
  can_rebalance_cluster_decisions : Array[Json]?
  can_rebalance_to_other_node : Json?
  can_remain_decisions : Array[Json]?
  can_remain_on_current_node : Json?
  cluster_info : Json?
  configured_delay : Json?
  configured_delay_in_millis : Json?
  current_node : Json?
  current_state : String
  index : Json
  move_explanation : String?
  node_allocation_decisions : Array[Json]?
  primary : Bool
  rebalance_explanation : String?
  remaining_delay : Json?
  remaining_delay_in_millis : Json?
  shard : Int
  unassigned_info : Json?
  note : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterAllocationExplainResponse with fn to_json(
  self : ClusterAllocationExplainResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allocate_explanation {
    Some(value) => obj["allocate_explanation"] = value.to_json()
    None => ()
  }
  match self.allocation_delay {
    Some(value) => obj["allocation_delay"] = value.to_json()
    None => ()
  }
  match self.allocation_delay_in_millis {
    Some(value) => obj["allocation_delay_in_millis"] = value.to_json()
    None => ()
  }
  match self.can_allocate {
    Some(value) => obj["can_allocate"] = value.to_json()
    None => ()
  }
  match self.can_move_to_other_node {
    Some(value) => obj["can_move_to_other_node"] = value.to_json()
    None => ()
  }
  match self.can_rebalance_cluster {
    Some(value) => obj["can_rebalance_cluster"] = value.to_json()
    None => ()
  }
  match self.can_rebalance_cluster_decisions {
    Some(value) => obj["can_rebalance_cluster_decisions"] = value.to_json()
    None => ()
  }
  match self.can_rebalance_to_other_node {
    Some(value) => obj["can_rebalance_to_other_node"] = value.to_json()
    None => ()
  }
  match self.can_remain_decisions {
    Some(value) => obj["can_remain_decisions"] = value.to_json()
    None => ()
  }
  match self.can_remain_on_current_node {
    Some(value) => obj["can_remain_on_current_node"] = value.to_json()
    None => ()
  }
  match self.cluster_info {
    Some(value) => obj["cluster_info"] = value.to_json()
    None => ()
  }
  match self.configured_delay {
    Some(value) => obj["configured_delay"] = value.to_json()
    None => ()
  }
  match self.configured_delay_in_millis {
    Some(value) => obj["configured_delay_in_millis"] = value.to_json()
    None => ()
  }
  match self.current_node {
    Some(value) => obj["current_node"] = value.to_json()
    None => ()
  }
  obj["current_state"] = self.current_state.to_json()
  obj["index"] = self.index.to_json()
  match self.move_explanation {
    Some(value) => obj["move_explanation"] = value.to_json()
    None => ()
  }
  match self.node_allocation_decisions {
    Some(value) => obj["node_allocation_decisions"] = value.to_json()
    None => ()
  }
  obj["primary"] = self.primary.to_json()
  match self.rebalance_explanation {
    Some(value) => obj["rebalance_explanation"] = value.to_json()
    None => ()
  }
  match self.remaining_delay {
    Some(value) => obj["remaining_delay"] = value.to_json()
    None => ()
  }
  match self.remaining_delay_in_millis {
    Some(value) => obj["remaining_delay_in_millis"] = value.to_json()
    None => ()
  }
  obj["shard"] = self.shard.to_json()
  match self.unassigned_info {
    Some(value) => obj["unassigned_info"] = value.to_json()
    None => ()
  }
  match self.note {
    Some(value) => obj["note"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterAllocationExplainResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterAllocationExplainResponse: expected object"),
    )
  }
  {
    allocate_explanation: match obj.get("allocate_explanation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allocate_explanation")))
    },
    allocation_delay: match obj.get("allocation_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allocation_delay")))
    },
    allocation_delay_in_millis: match obj.get("allocation_delay_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allocation_delay_in_millis"),
          ),
        )
    },
    can_allocate: match obj.get("can_allocate") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("can_allocate")))
    },
    can_move_to_other_node: match obj.get("can_move_to_other_node") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("can_move_to_other_node")),
        )
    },
    can_rebalance_cluster: match obj.get("can_rebalance_cluster") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("can_rebalance_cluster")))
    },
    can_rebalance_cluster_decisions: match
      obj.get("can_rebalance_cluster_decisions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("can_rebalance_cluster_decisions"),
          ),
        )
    },
    can_rebalance_to_other_node: match obj.get("can_rebalance_to_other_node") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("can_rebalance_to_other_node"),
          ),
        )
    },
    can_remain_decisions: match obj.get("can_remain_decisions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("can_remain_decisions")))
    },
    can_remain_on_current_node: match obj.get("can_remain_on_current_node") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("can_remain_on_current_node"),
          ),
        )
    },
    cluster_info: match obj.get("cluster_info") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("cluster_info")))
    },
    configured_delay: match obj.get("configured_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("configured_delay")))
    },
    configured_delay_in_millis: match obj.get("configured_delay_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("configured_delay_in_millis"),
          ),
        )
    },
    current_node: match obj.get("current_node") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("current_node")))
    },
    current_state: @json.from_json(
      obj.get("current_state").unwrap_or(Json::null()),
      path=path.add_key("current_state"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    move_explanation: match obj.get("move_explanation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("move_explanation")))
    },
    node_allocation_decisions: match obj.get("node_allocation_decisions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("node_allocation_decisions")),
        )
    },
    primary: @json.from_json(
      obj.get("primary").unwrap_or(Json::null()),
      path=path.add_key("primary"),
    ),
    rebalance_explanation: match obj.get("rebalance_explanation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("rebalance_explanation")))
    },
    remaining_delay: match obj.get("remaining_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("remaining_delay")))
    },
    remaining_delay_in_millis: match obj.get("remaining_delay_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("remaining_delay_in_millis")),
        )
    },
    shard: @json.from_json(
      obj.get("shard").unwrap_or(Json::null()),
      path=path.add_key("shard"),
    ),
    unassigned_info: match obj.get("unassigned_info") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("unassigned_info")))
    },
    note: match obj.get("note") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("note")))
    },
  }
}

///|
pub(all) struct ClusterAllocationExplainRequest {
  query : ClusterAllocationExplainQuery
  body : ClusterAllocationExplainBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterAllocationExplainRequest::new(
  query? : ClusterAllocationExplainQuery = ClusterAllocationExplainQuery::new(),
  body? : ClusterAllocationExplainBody,
) -> ClusterAllocationExplainRequest {
  { query, body }
}

///|
pub async fn Client::cluster_allocation_explain(
  self : Client,
  request : ClusterAllocationExplainRequest,
) -> EsResponse[ClusterAllocationExplainResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_cluster/allocation/explain", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ClusterDeleteComponentTemplateQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterDeleteComponentTemplateQuery with fn to_json(
  self : ClusterDeleteComponentTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterDeleteComponentTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterDeleteComponentTemplateQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ClusterDeleteComponentTemplateQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> ClusterDeleteComponentTemplateQuery {
  { master_timeout, timeout }
}

///|
pub fn ClusterDeleteComponentTemplateQuery::to_pairs(
  self : ClusterDeleteComponentTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterDeleteComponentTemplateResponse = Json

///|
pub(all) struct ClusterDeleteComponentTemplateRequest {
  name : String
  query : ClusterDeleteComponentTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterDeleteComponentTemplateRequest::new(
  name : String,
  query? : ClusterDeleteComponentTemplateQuery = ClusterDeleteComponentTemplateQuery::new(),
) -> ClusterDeleteComponentTemplateRequest {
  { name, query }
}

///|
pub async fn Client::cluster_delete_component_template(
  self : Client,
  request : ClusterDeleteComponentTemplateRequest,
) -> EsResponse[ClusterDeleteComponentTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_component_template/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct ClusterDeleteVotingConfigExclusionsQuery {
  master_timeout : String?
  wait_for_removal : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterDeleteVotingConfigExclusionsQuery with fn to_json(
  self : ClusterDeleteVotingConfigExclusionsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_removal {
    Some(value) => obj["wait_for_removal"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterDeleteVotingConfigExclusionsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterDeleteVotingConfigExclusionsQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_removal: match obj.get("wait_for_removal") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_removal")))
    },
  }
}

///|
pub fn ClusterDeleteVotingConfigExclusionsQuery::new(
  master_timeout? : String,
  wait_for_removal? : Bool,
) -> ClusterDeleteVotingConfigExclusionsQuery {
  { master_timeout, wait_for_removal }
}

///|
pub fn ClusterDeleteVotingConfigExclusionsQuery::to_pairs(
  self : ClusterDeleteVotingConfigExclusionsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_removal {
    Some(value) => push_query_json(pairs, "wait_for_removal", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterDeleteVotingConfigExclusionsResponse = Json

///|
pub(all) struct ClusterDeleteVotingConfigExclusionsRequest {
  query : ClusterDeleteVotingConfigExclusionsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterDeleteVotingConfigExclusionsRequest::new(
  query? : ClusterDeleteVotingConfigExclusionsQuery = ClusterDeleteVotingConfigExclusionsQuery::new(),
) -> ClusterDeleteVotingConfigExclusionsRequest {
  { query, }
}

///|
pub async fn Client::cluster_delete_voting_config_exclusions(
  self : Client,
  request : ClusterDeleteVotingConfigExclusionsRequest,
) -> EsResponse[ClusterDeleteVotingConfigExclusionsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_cluster/voting_config_exclusions", [])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct ClusterExistsComponentTemplateQuery {
  master_timeout : String?
  local_ : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterExistsComponentTemplateQuery with fn to_json(
  self : ClusterExistsComponentTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterExistsComponentTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterExistsComponentTemplateQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
  }
}

///|
pub fn ClusterExistsComponentTemplateQuery::new(
  master_timeout? : String,
  local_? : Bool,
) -> ClusterExistsComponentTemplateQuery {
  { master_timeout, local_ }
}

///|
pub fn ClusterExistsComponentTemplateQuery::to_pairs(
  self : ClusterExistsComponentTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterExistsComponentTemplateResponse = Json

///|
pub(all) struct ClusterExistsComponentTemplateRequest {
  name : String
  query : ClusterExistsComponentTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterExistsComponentTemplateRequest::new(
  name : String,
  query? : ClusterExistsComponentTemplateQuery = ClusterExistsComponentTemplateQuery::new(),
) -> ClusterExistsComponentTemplateRequest {
  { name, query }
}

///|
pub async fn Client::cluster_exists_component_template(
  self : Client,
  request : ClusterExistsComponentTemplateRequest,
) -> EsResponse[ClusterExistsComponentTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_component_template/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct ClusterGetComponentTemplateQuery {
  flat_settings : Bool?
  settings_filter : Json?
  include_defaults : Bool?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterGetComponentTemplateQuery with fn to_json(
  self : ClusterGetComponentTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.settings_filter {
    Some(value) => obj["settings_filter"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterGetComponentTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterGetComponentTemplateQuery: expected object"),
    )
  }
  {
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    settings_filter: match obj.get("settings_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("settings_filter")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn ClusterGetComponentTemplateQuery::new(
  flat_settings? : Bool,
  settings_filter? : Json,
  include_defaults? : Bool,
  local_? : Bool,
  master_timeout? : String,
) -> ClusterGetComponentTemplateQuery {
  { flat_settings, settings_filter, include_defaults, local_, master_timeout }
}

///|
pub fn ClusterGetComponentTemplateQuery::to_pairs(
  self : ClusterGetComponentTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.settings_filter {
    Some(value) => push_query_json(pairs, "settings_filter", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterGetComponentTemplateResponse {
  component_templates : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterGetComponentTemplateResponse with fn to_json(
  self : ClusterGetComponentTemplateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["component_templates"] = self.component_templates.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ClusterGetComponentTemplateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterGetComponentTemplateResponse: expected object"),
    )
  }
  {
    component_templates: @json.from_json(
      obj.get("component_templates").unwrap_or(Json::null()),
      path=path.add_key("component_templates"),
    ),
  }
}

///|
pub(all) struct ClusterGetComponentTemplateRequest {
  name : String?
  query : ClusterGetComponentTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterGetComponentTemplateRequest::new(
  name? : String,
  query? : ClusterGetComponentTemplateQuery = ClusterGetComponentTemplateQuery::new(),
) -> ClusterGetComponentTemplateRequest {
  { name, query }
}

///|
pub async fn Client::cluster_get_component_template(
  self : Client,
  request : ClusterGetComponentTemplateRequest,
) -> EsResponse[ClusterGetComponentTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_component_template/{name}", ["name"]),
      PathVariant::new("/_component_template", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterGetSettingsQuery {
  flat_settings : Bool?
  include_defaults : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterGetSettingsQuery with fn to_json(
  self : ClusterGetSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterGetSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterGetSettingsQuery: expected object"))
  }
  {
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ClusterGetSettingsQuery::new(
  flat_settings? : Bool,
  include_defaults? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> ClusterGetSettingsQuery {
  { flat_settings, include_defaults, master_timeout, timeout }
}

///|
pub fn ClusterGetSettingsQuery::to_pairs(
  self : ClusterGetSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterGetSettingsResponse {
  persistent : Map[String, Json]
  transient : Map[String, Json]
  defaults : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterGetSettingsResponse with fn to_json(
  self : ClusterGetSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["persistent"] = self.persistent.to_json()
  obj["transient"] = self.transient.to_json()
  match self.defaults {
    Some(value) => obj["defaults"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterGetSettingsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterGetSettingsResponse: expected object"))
  }
  {
    persistent: @json.from_json(
      obj.get("persistent").unwrap_or(Json::null()),
      path=path.add_key("persistent"),
    ),
    transient: @json.from_json(
      obj.get("transient").unwrap_or(Json::null()),
      path=path.add_key("transient"),
    ),
    defaults: match obj.get("defaults") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("defaults")))
    },
  }
}

///|
pub(all) struct ClusterGetSettingsRequest {
  query : ClusterGetSettingsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterGetSettingsRequest::new(
  query? : ClusterGetSettingsQuery = ClusterGetSettingsQuery::new(),
) -> ClusterGetSettingsRequest {
  { query, }
}

///|
pub async fn Client::cluster_get_settings(
  self : Client,
  request : ClusterGetSettingsRequest,
) -> EsResponse[ClusterGetSettingsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cluster/settings", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterHealthQuery {
  expand_wildcards : String?
  level : String?
  local_ : Bool?
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
  wait_for_events : String?
  wait_for_nodes : String?
  wait_for_no_initializing_shards : Bool?
  wait_for_no_relocating_shards : Bool?
  wait_for_status : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterHealthQuery with fn to_json(
  self : ClusterHealthQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.level {
    Some(value) => obj["level"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.wait_for_events {
    Some(value) => obj["wait_for_events"] = value.to_json()
    None => ()
  }
  match self.wait_for_nodes {
    Some(value) => obj["wait_for_nodes"] = value.to_json()
    None => ()
  }
  match self.wait_for_no_initializing_shards {
    Some(value) => obj["wait_for_no_initializing_shards"] = value.to_json()
    None => ()
  }
  match self.wait_for_no_relocating_shards {
    Some(value) => obj["wait_for_no_relocating_shards"] = value.to_json()
    None => ()
  }
  match self.wait_for_status {
    Some(value) => obj["wait_for_status"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterHealthQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterHealthQuery: expected object"))
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    level: match obj.get("level") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("level")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    wait_for_events: match obj.get("wait_for_events") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_events")))
    },
    wait_for_nodes: match obj.get("wait_for_nodes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_nodes")))
    },
    wait_for_no_initializing_shards: match
      obj.get("wait_for_no_initializing_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_no_initializing_shards"),
          ),
        )
    },
    wait_for_no_relocating_shards: match
      obj.get("wait_for_no_relocating_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_no_relocating_shards"),
          ),
        )
    },
    wait_for_status: match obj.get("wait_for_status") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_status")))
    },
  }
}

///|
pub fn ClusterHealthQuery::new(
  expand_wildcards? : String,
  level? : String,
  local_? : Bool,
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
  wait_for_events? : String,
  wait_for_nodes? : String,
  wait_for_no_initializing_shards? : Bool,
  wait_for_no_relocating_shards? : Bool,
  wait_for_status? : String,
) -> ClusterHealthQuery {
  {
    expand_wildcards,
    level,
    local_,
    master_timeout,
    timeout,
    wait_for_active_shards,
    wait_for_events,
    wait_for_nodes,
    wait_for_no_initializing_shards,
    wait_for_no_relocating_shards,
    wait_for_status,
  }
}

///|
pub fn ClusterHealthQuery::to_pairs(
  self : ClusterHealthQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.level {
    Some(value) => push_query_json(pairs, "level", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.wait_for_events {
    Some(value) => push_query_json(pairs, "wait_for_events", value.to_json())
    None => ()
  }
  match self.wait_for_nodes {
    Some(value) => push_query_json(pairs, "wait_for_nodes", value.to_json())
    None => ()
  }
  match self.wait_for_no_initializing_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_no_initializing_shards", value.to_json())
    None => ()
  }
  match self.wait_for_no_relocating_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_no_relocating_shards", value.to_json())
    None => ()
  }
  match self.wait_for_status {
    Some(value) => push_query_json(pairs, "wait_for_status", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterHealthResponse = Json

///|
pub(all) struct ClusterHealthRequest {
  index : String?
  query : ClusterHealthQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterHealthRequest::new(
  index? : String,
  query? : ClusterHealthQuery = ClusterHealthQuery::new(),
) -> ClusterHealthRequest {
  { index, query }
}

///|
pub async fn Client::cluster_health(
  self : Client,
  request : ClusterHealthRequest,
) -> EsResponse[ClusterHealthResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cluster/health/{index}", ["index"]),
      PathVariant::new("/_cluster/health", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterInfoQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ClusterInfoQuery with fn to_json(_self : ClusterInfoQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ClusterInfoQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ClusterInfoQuery: expected object"))
  }
  ClusterInfoQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ClusterInfoQuery::new() -> ClusterInfoQuery {
  ClusterInfoQuery::{  }
}

///|
pub fn ClusterInfoQuery::to_pairs(
  _self : ClusterInfoQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ClusterInfoResponse {
  cluster_name : Json
  http : Json?
  ingest : Json?
  thread_pool : Map[String, Json]?
  script : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterInfoResponse with fn to_json(
  self : ClusterInfoResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cluster_name"] = self.cluster_name.to_json()
  match self.http {
    Some(value) => obj["http"] = value.to_json()
    None => ()
  }
  match self.ingest {
    Some(value) => obj["ingest"] = value.to_json()
    None => ()
  }
  match self.thread_pool {
    Some(value) => obj["thread_pool"] = value.to_json()
    None => ()
  }
  match self.script {
    Some(value) => obj["script"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterInfoResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterInfoResponse: expected object"))
  }
  {
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    http: match obj.get("http") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("http")))
    },
    ingest: match obj.get("ingest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ingest")))
    },
    thread_pool: match obj.get("thread_pool") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("thread_pool")))
    },
    script: match obj.get("script") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("script")))
    },
  }
}

///|
pub(all) struct ClusterInfoRequest {
  target : String
  query : ClusterInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterInfoRequest::new(
  target : String,
  query? : ClusterInfoQuery = ClusterInfoQuery::new(),
) -> ClusterInfoRequest {
  { target, query }
}

///|
pub async fn Client::cluster_info(
  self : Client,
  request : ClusterInfoRequest,
) -> EsResponse[ClusterInfoResponse] {
  let params : Map[String, String] = Map([])
  params["target"] = request.target
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_info/{target}", ["target"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterPendingTasksQuery {
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPendingTasksQuery with fn to_json(
  self : ClusterPendingTasksQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPendingTasksQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterPendingTasksQuery: expected object"))
  }
  {
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn ClusterPendingTasksQuery::new(
  local_? : Bool,
  master_timeout? : String,
) -> ClusterPendingTasksQuery {
  { local_, master_timeout }
}

///|
pub fn ClusterPendingTasksQuery::to_pairs(
  self : ClusterPendingTasksQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterPendingTasksResponse {
  tasks : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPendingTasksResponse with fn to_json(
  self : ClusterPendingTasksResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["tasks"] = self.tasks.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPendingTasksResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterPendingTasksResponse: expected object"),
    )
  }
  {
    tasks: @json.from_json(
      obj.get("tasks").unwrap_or(Json::null()),
      path=path.add_key("tasks"),
    ),
  }
}

///|
pub(all) struct ClusterPendingTasksRequest {
  query : ClusterPendingTasksQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterPendingTasksRequest::new(
  query? : ClusterPendingTasksQuery = ClusterPendingTasksQuery::new(),
) -> ClusterPendingTasksRequest {
  { query, }
}

///|
pub async fn Client::cluster_pending_tasks(
  self : Client,
  request : ClusterPendingTasksRequest,
) -> EsResponse[ClusterPendingTasksResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_cluster/pending_tasks", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterPostVotingConfigExclusionsQuery {
  node_names : String?
  node_ids : String?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPostVotingConfigExclusionsQuery with fn to_json(
  self : ClusterPostVotingConfigExclusionsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.node_names {
    Some(value) => obj["node_names"] = value.to_json()
    None => ()
  }
  match self.node_ids {
    Some(value) => obj["node_ids"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPostVotingConfigExclusionsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterPostVotingConfigExclusionsQuery: expected object"),
    )
  }
  {
    node_names: match obj.get("node_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("node_names")))
    },
    node_ids: match obj.get("node_ids") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("node_ids")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ClusterPostVotingConfigExclusionsQuery::new(
  node_names? : String,
  node_ids? : String,
  master_timeout? : String,
  timeout? : String,
) -> ClusterPostVotingConfigExclusionsQuery {
  { node_names, node_ids, master_timeout, timeout }
}

///|
pub fn ClusterPostVotingConfigExclusionsQuery::to_pairs(
  self : ClusterPostVotingConfigExclusionsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.node_names {
    Some(value) => push_query_json(pairs, "node_names", value.to_json())
    None => ()
  }
  match self.node_ids {
    Some(value) => push_query_json(pairs, "node_ids", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterPostVotingConfigExclusionsResponse = Json

///|
pub(all) struct ClusterPostVotingConfigExclusionsRequest {
  query : ClusterPostVotingConfigExclusionsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterPostVotingConfigExclusionsRequest::new(
  query? : ClusterPostVotingConfigExclusionsQuery = ClusterPostVotingConfigExclusionsQuery::new(),
) -> ClusterPostVotingConfigExclusionsRequest {
  { query, }
}

///|
pub async fn Client::cluster_post_voting_config_exclusions(
  self : Client,
  request : ClusterPostVotingConfigExclusionsRequest,
) -> EsResponse[ClusterPostVotingConfigExclusionsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_cluster/voting_config_exclusions", [])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct ClusterPutComponentTemplateQuery {
  create : Bool?
  cause : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPutComponentTemplateQuery with fn to_json(
  self : ClusterPutComponentTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.create {
    Some(value) => obj["create"] = value.to_json()
    None => ()
  }
  match self.cause {
    Some(value) => obj["cause"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPutComponentTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterPutComponentTemplateQuery: expected object"),
    )
  }
  {
    create: match obj.get("create") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("create")))
    },
    cause: match obj.get("cause") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cause")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn ClusterPutComponentTemplateQuery::new(
  create? : Bool,
  cause? : String,
  master_timeout? : String,
) -> ClusterPutComponentTemplateQuery {
  { create, cause, master_timeout }
}

///|
pub fn ClusterPutComponentTemplateQuery::to_pairs(
  self : ClusterPutComponentTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.create {
    Some(value) => push_query_json(pairs, "create", value.to_json())
    None => ()
  }
  match self.cause {
    Some(value) => push_query_json(pairs, "cause", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterPutComponentTemplateBody {
  template : Json
  version : Json?
  _meta : Json?
  deprecated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPutComponentTemplateBody with fn to_json(
  self : ClusterPutComponentTemplateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["template"] = self.template.to_json()
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.deprecated {
    Some(value) => obj["deprecated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPutComponentTemplateBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ClusterPutComponentTemplateBody: expected object"),
    )
  }
  {
    template: @json.from_json(
      obj.get("template").unwrap_or(Json::null()),
      path=path.add_key("template"),
    ),
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    deprecated: match obj.get("deprecated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("deprecated")))
    },
  }
}

///|
pub fn ClusterPutComponentTemplateBody::new(
  template : Json,
  version? : Json,
  _meta? : Json,
  deprecated? : Bool,
) -> ClusterPutComponentTemplateBody {
  { template, version, _meta, deprecated }
}

///|
pub type ClusterPutComponentTemplateResponse = Json

///|
pub(all) struct ClusterPutComponentTemplateRequest {
  name : String
  query : ClusterPutComponentTemplateQuery
  body : ClusterPutComponentTemplateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterPutComponentTemplateRequest::new(
  name : String,
  body : ClusterPutComponentTemplateBody,
  query? : ClusterPutComponentTemplateQuery = ClusterPutComponentTemplateQuery::new(),
) -> ClusterPutComponentTemplateRequest {
  { name, query, body }
}

///|
pub async fn Client::cluster_put_component_template(
  self : Client,
  request : ClusterPutComponentTemplateRequest,
) -> EsResponse[ClusterPutComponentTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_component_template/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ClusterPutSettingsQuery {
  flat_settings : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPutSettingsQuery with fn to_json(
  self : ClusterPutSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPutSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterPutSettingsQuery: expected object"))
  }
  {
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ClusterPutSettingsQuery::new(
  flat_settings? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> ClusterPutSettingsQuery {
  { flat_settings, master_timeout, timeout }
}

///|
pub fn ClusterPutSettingsQuery::to_pairs(
  self : ClusterPutSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterPutSettingsBody {
  persistent : Map[String, Json]?
  transient : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPutSettingsBody with fn to_json(
  self : ClusterPutSettingsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.persistent {
    Some(value) => obj["persistent"] = value.to_json()
    None => ()
  }
  match self.transient {
    Some(value) => obj["transient"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPutSettingsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterPutSettingsBody: expected object"))
  }
  {
    persistent: match obj.get("persistent") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("persistent")))
    },
    transient: match obj.get("transient") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("transient")))
    },
  }
}

///|
pub fn ClusterPutSettingsBody::new(
  persistent? : Map[String, Json],
  transient? : Map[String, Json],
) -> ClusterPutSettingsBody {
  { persistent, transient }
}

///|
pub(all) struct ClusterPutSettingsResponse {
  acknowledged : Bool
  persistent : Map[String, Json]
  transient : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterPutSettingsResponse with fn to_json(
  self : ClusterPutSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["persistent"] = self.persistent.to_json()
  obj["transient"] = self.transient.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ClusterPutSettingsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterPutSettingsResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    persistent: @json.from_json(
      obj.get("persistent").unwrap_or(Json::null()),
      path=path.add_key("persistent"),
    ),
    transient: @json.from_json(
      obj.get("transient").unwrap_or(Json::null()),
      path=path.add_key("transient"),
    ),
  }
}

///|
pub(all) struct ClusterPutSettingsRequest {
  query : ClusterPutSettingsQuery
  body : ClusterPutSettingsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterPutSettingsRequest::new(
  body : ClusterPutSettingsBody,
  query? : ClusterPutSettingsQuery = ClusterPutSettingsQuery::new(),
) -> ClusterPutSettingsRequest {
  { query, body }
}

///|
pub async fn Client::cluster_put_settings(
  self : Client,
  request : ClusterPutSettingsRequest,
) -> EsResponse[ClusterPutSettingsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cluster/settings", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ClusterRemoteInfoQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ClusterRemoteInfoQuery with fn to_json(
  _self : ClusterRemoteInfoQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ClusterRemoteInfoQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ClusterRemoteInfoQuery: expected object"))
  }
  ClusterRemoteInfoQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ClusterRemoteInfoQuery::new() -> ClusterRemoteInfoQuery {
  ClusterRemoteInfoQuery::{  }
}

///|
pub fn ClusterRemoteInfoQuery::to_pairs(
  _self : ClusterRemoteInfoQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ClusterRemoteInfoResponse = Json

///|
pub(all) struct ClusterRemoteInfoRequest {
  query : ClusterRemoteInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterRemoteInfoRequest::new(
  query? : ClusterRemoteInfoQuery = ClusterRemoteInfoQuery::new(),
) -> ClusterRemoteInfoRequest {
  { query, }
}

///|
pub async fn Client::cluster_remote_info(
  self : Client,
  request : ClusterRemoteInfoRequest,
) -> EsResponse[ClusterRemoteInfoResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_remote/info", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterRerouteQuery {
  dry_run : Bool?
  explain : Bool?
  metric : Json?
  retry_failed : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterRerouteQuery with fn to_json(
  self : ClusterRerouteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.metric {
    Some(value) => obj["metric"] = value.to_json()
    None => ()
  }
  match self.retry_failed {
    Some(value) => obj["retry_failed"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterRerouteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterRerouteQuery: expected object"))
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    metric: match obj.get("metric") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metric")))
    },
    retry_failed: match obj.get("retry_failed") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retry_failed")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ClusterRerouteQuery::new(
  dry_run? : Bool,
  explain? : Bool,
  metric? : Json,
  retry_failed? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> ClusterRerouteQuery {
  { dry_run, explain, metric, retry_failed, master_timeout, timeout }
}

///|
pub fn ClusterRerouteQuery::to_pairs(
  self : ClusterRerouteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.metric {
    Some(value) => push_query_json(pairs, "metric", value.to_json())
    None => ()
  }
  match self.retry_failed {
    Some(value) => push_query_json(pairs, "retry_failed", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ClusterRerouteBody {
  commands : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterRerouteBody with fn to_json(
  self : ClusterRerouteBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.commands {
    Some(value) => obj["commands"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterRerouteBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterRerouteBody: expected object"))
  }
  {
    commands: match obj.get("commands") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("commands")))
    },
  }
}

///|
pub fn ClusterRerouteBody::new(commands? : Array[Json]) -> ClusterRerouteBody {
  { commands, }
}

///|
pub(all) struct ClusterRerouteResponse {
  acknowledged : Bool
  explanations : Array[Json]?
  state : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterRerouteResponse with fn to_json(
  self : ClusterRerouteResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  match self.explanations {
    Some(value) => obj["explanations"] = value.to_json()
    None => ()
  }
  match self.state {
    Some(value) => obj["state"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterRerouteResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterRerouteResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    explanations: match obj.get("explanations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("explanations")))
    },
    state: match obj.get("state") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("state")))
    },
  }
}

///|
pub(all) struct ClusterRerouteRequest {
  query : ClusterRerouteQuery
  body : ClusterRerouteBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterRerouteRequest::new(
  query? : ClusterRerouteQuery = ClusterRerouteQuery::new(),
  body? : ClusterRerouteBody,
) -> ClusterRerouteRequest {
  { query, body }
}

///|
pub async fn Client::cluster_reroute(
  self : Client,
  request : ClusterRerouteRequest,
) -> EsResponse[ClusterRerouteResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_cluster/reroute", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ClusterStateQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flat_settings : Bool?
  ignore_unavailable : Bool?
  local_ : Bool?
  master_timeout : String?
  wait_for_metadata_version : String?
  wait_for_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterStateQuery with fn to_json(self : ClusterStateQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_metadata_version {
    Some(value) => obj["wait_for_metadata_version"] = value.to_json()
    None => ()
  }
  match self.wait_for_timeout {
    Some(value) => obj["wait_for_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterStateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterStateQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_metadata_version: match obj.get("wait_for_metadata_version") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_metadata_version")),
        )
    },
    wait_for_timeout: match obj.get("wait_for_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_timeout")))
    },
  }
}

///|
pub fn ClusterStateQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flat_settings? : Bool,
  ignore_unavailable? : Bool,
  local_? : Bool,
  master_timeout? : String,
  wait_for_metadata_version? : String,
  wait_for_timeout? : String,
) -> ClusterStateQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flat_settings,
    ignore_unavailable,
    local_,
    master_timeout,
    wait_for_metadata_version,
    wait_for_timeout,
  }
}

///|
pub fn ClusterStateQuery::to_pairs(
  self : ClusterStateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_metadata_version {
    Some(value) =>
      push_query_json(pairs, "wait_for_metadata_version", value.to_json())
    None => ()
  }
  match self.wait_for_timeout {
    Some(value) => push_query_json(pairs, "wait_for_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterStateResponse = Json

///|
pub(all) struct ClusterStateRequest {
  metric : String?
  index : String?
  query : ClusterStateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterStateRequest::new(
  metric? : String,
  index? : String,
  query? : ClusterStateQuery = ClusterStateQuery::new(),
) -> ClusterStateRequest {
  { metric, index, query }
}

///|
pub async fn Client::cluster_state(
  self : Client,
  request : ClusterStateRequest,
) -> EsResponse[ClusterStateResponse] {
  let params : Map[String, String] = Map([])
  match request.metric {
    Some(value) => params["metric"] = value
    None => ()
  }
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cluster/state/{metric}/{index}", ["metric", "index"]),
      PathVariant::new("/_cluster/state/{metric}", ["metric"]),
      PathVariant::new("/_cluster/state", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ClusterStatsQuery {
  include_remotes : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ClusterStatsQuery with fn to_json(self : ClusterStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.include_remotes {
    Some(value) => obj["include_remotes"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ClusterStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ClusterStatsQuery: expected object"))
  }
  {
    include_remotes: match obj.get("include_remotes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_remotes")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ClusterStatsQuery::new(
  include_remotes? : Bool,
  timeout? : String,
) -> ClusterStatsQuery {
  { include_remotes, timeout }
}

///|
pub fn ClusterStatsQuery::to_pairs(
  self : ClusterStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.include_remotes {
    Some(value) => push_query_json(pairs, "include_remotes", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ClusterStatsResponse = Json

///|
pub(all) struct ClusterStatsRequest {
  node_id : String?
  query : ClusterStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ClusterStatsRequest::new(
  node_id? : String,
  query? : ClusterStatsQuery = ClusterStatsQuery::new(),
) -> ClusterStatsRequest {
  { node_id, query }
}

///|
pub async fn Client::cluster_stats(
  self : Client,
  request : ClusterStatsRequest,
) -> EsResponse[ClusterStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_cluster/stats/nodes/{node_id}", ["node_id"]),
      PathVariant::new("/_cluster/stats", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ConnectorCheckInQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorCheckInQuery with fn to_json(
  _self : ConnectorCheckInQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorCheckInQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorCheckInQuery: expected object"))
  }
  ConnectorCheckInQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorCheckInQuery::new() -> ConnectorCheckInQuery {
  ConnectorCheckInQuery::{  }
}

///|
pub fn ConnectorCheckInQuery::to_pairs(
  _self : ConnectorCheckInQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorCheckInResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorCheckInResponse with fn to_json(
  self : ConnectorCheckInResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorCheckInResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorCheckInResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorCheckInRequest {
  connector_id : String
  query : ConnectorCheckInQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorCheckInRequest::new(
  connector_id : String,
  query? : ConnectorCheckInQuery = ConnectorCheckInQuery::new(),
) -> ConnectorCheckInRequest {
  { connector_id, query }
}

///|
pub async fn Client::connector_check_in(
  self : Client,
  request : ConnectorCheckInRequest,
) -> EsResponse[ConnectorCheckInResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_check_in", ["connector_id"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct ConnectorDeleteQuery {
  delete_sync_jobs : Bool?
  hard : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorDeleteQuery with fn to_json(
  self : ConnectorDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.delete_sync_jobs {
    Some(value) => obj["delete_sync_jobs"] = value.to_json()
    None => ()
  }
  match self.hard {
    Some(value) => obj["hard"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorDeleteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorDeleteQuery: expected object"))
  }
  {
    delete_sync_jobs: match obj.get("delete_sync_jobs") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delete_sync_jobs")))
    },
    hard: match obj.get("hard") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("hard")))
    },
  }
}

///|
pub fn ConnectorDeleteQuery::new(
  delete_sync_jobs? : Bool,
  hard? : Bool,
) -> ConnectorDeleteQuery {
  { delete_sync_jobs, hard }
}

///|
pub fn ConnectorDeleteQuery::to_pairs(
  self : ConnectorDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.delete_sync_jobs {
    Some(value) => push_query_json(pairs, "delete_sync_jobs", value.to_json())
    None => ()
  }
  match self.hard {
    Some(value) => push_query_json(pairs, "hard", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ConnectorDeleteResponse = Json

///|
pub(all) struct ConnectorDeleteRequest {
  connector_id : String
  query : ConnectorDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorDeleteRequest::new(
  connector_id : String,
  query? : ConnectorDeleteQuery = ConnectorDeleteQuery::new(),
) -> ConnectorDeleteRequest {
  { connector_id, query }
}

///|
pub async fn Client::connector_delete(
  self : Client,
  request : ConnectorDeleteRequest,
) -> EsResponse[ConnectorDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}", ["connector_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct ConnectorGetQuery {
  include_deleted : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorGetQuery with fn to_json(self : ConnectorGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.include_deleted {
    Some(value) => obj["include_deleted"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorGetQuery: expected object"))
  }
  {
    include_deleted: match obj.get("include_deleted") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_deleted")))
    },
  }
}

///|
pub fn ConnectorGetQuery::new(include_deleted? : Bool) -> ConnectorGetQuery {
  { include_deleted, }
}

///|
pub fn ConnectorGetQuery::to_pairs(
  self : ConnectorGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.include_deleted {
    Some(value) => push_query_json(pairs, "include_deleted", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ConnectorGetResponse = Json

///|
pub(all) struct ConnectorGetRequest {
  connector_id : String
  query : ConnectorGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorGetRequest::new(
  connector_id : String,
  query? : ConnectorGetQuery = ConnectorGetQuery::new(),
) -> ConnectorGetRequest {
  { connector_id, query }
}

///|
pub async fn Client::connector_get(
  self : Client,
  request : ConnectorGetRequest,
) -> EsResponse[ConnectorGetResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}", ["connector_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ConnectorLastSyncQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorLastSyncQuery with fn to_json(
  _self : ConnectorLastSyncQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorLastSyncQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorLastSyncQuery: expected object"))
  }
  ConnectorLastSyncQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorLastSyncQuery::new() -> ConnectorLastSyncQuery {
  ConnectorLastSyncQuery::{  }
}

///|
pub fn ConnectorLastSyncQuery::to_pairs(
  _self : ConnectorLastSyncQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorLastSyncBody {
  last_access_control_sync_error : String?
  last_access_control_sync_scheduled_at : Json?
  last_access_control_sync_status : Json?
  last_deleted_document_count : Int?
  last_incremental_sync_scheduled_at : Json?
  last_indexed_document_count : Int?
  last_seen : Json?
  last_sync_error : String?
  last_sync_scheduled_at : Json?
  last_sync_status : Json?
  last_synced : Json?
  sync_cursor : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorLastSyncBody with fn to_json(
  self : ConnectorLastSyncBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.last_access_control_sync_error {
    Some(value) => obj["last_access_control_sync_error"] = value.to_json()
    None => ()
  }
  match self.last_access_control_sync_scheduled_at {
    Some(value) =>
      obj["last_access_control_sync_scheduled_at"] = value.to_json()
    None => ()
  }
  match self.last_access_control_sync_status {
    Some(value) => obj["last_access_control_sync_status"] = value.to_json()
    None => ()
  }
  match self.last_deleted_document_count {
    Some(value) => obj["last_deleted_document_count"] = value.to_json()
    None => ()
  }
  match self.last_incremental_sync_scheduled_at {
    Some(value) => obj["last_incremental_sync_scheduled_at"] = value.to_json()
    None => ()
  }
  match self.last_indexed_document_count {
    Some(value) => obj["last_indexed_document_count"] = value.to_json()
    None => ()
  }
  match self.last_seen {
    Some(value) => obj["last_seen"] = value.to_json()
    None => ()
  }
  match self.last_sync_error {
    Some(value) => obj["last_sync_error"] = value.to_json()
    None => ()
  }
  match self.last_sync_scheduled_at {
    Some(value) => obj["last_sync_scheduled_at"] = value.to_json()
    None => ()
  }
  match self.last_sync_status {
    Some(value) => obj["last_sync_status"] = value.to_json()
    None => ()
  }
  match self.last_synced {
    Some(value) => obj["last_synced"] = value.to_json()
    None => ()
  }
  match self.sync_cursor {
    Some(value) => obj["sync_cursor"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorLastSyncBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorLastSyncBody: expected object"))
  }
  {
    last_access_control_sync_error: match
      obj.get("last_access_control_sync_error") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_access_control_sync_error"),
          ),
        )
    },
    last_access_control_sync_scheduled_at: match
      obj.get("last_access_control_sync_scheduled_at") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_access_control_sync_scheduled_at"),
          ),
        )
    },
    last_access_control_sync_status: match
      obj.get("last_access_control_sync_status") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_access_control_sync_status"),
          ),
        )
    },
    last_deleted_document_count: match obj.get("last_deleted_document_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_deleted_document_count"),
          ),
        )
    },
    last_incremental_sync_scheduled_at: match
      obj.get("last_incremental_sync_scheduled_at") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_incremental_sync_scheduled_at"),
          ),
        )
    },
    last_indexed_document_count: match obj.get("last_indexed_document_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_indexed_document_count"),
          ),
        )
    },
    last_seen: match obj.get("last_seen") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("last_seen")))
    },
    last_sync_error: match obj.get("last_sync_error") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("last_sync_error")))
    },
    last_sync_scheduled_at: match obj.get("last_sync_scheduled_at") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("last_sync_scheduled_at")),
        )
    },
    last_sync_status: match obj.get("last_sync_status") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("last_sync_status")))
    },
    last_synced: match obj.get("last_synced") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("last_synced")))
    },
    sync_cursor: match obj.get("sync_cursor") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("sync_cursor")))
    },
  }
}

///|
pub fn ConnectorLastSyncBody::new(
  last_access_control_sync_error? : String,
  last_access_control_sync_scheduled_at? : Json,
  last_access_control_sync_status? : Json,
  last_deleted_document_count? : Int,
  last_incremental_sync_scheduled_at? : Json,
  last_indexed_document_count? : Int,
  last_seen? : Json,
  last_sync_error? : String,
  last_sync_scheduled_at? : Json,
  last_sync_status? : Json,
  last_synced? : Json,
  sync_cursor? : Json,
) -> ConnectorLastSyncBody {
  {
    last_access_control_sync_error,
    last_access_control_sync_scheduled_at,
    last_access_control_sync_status,
    last_deleted_document_count,
    last_incremental_sync_scheduled_at,
    last_indexed_document_count,
    last_seen,
    last_sync_error,
    last_sync_scheduled_at,
    last_sync_status,
    last_synced,
    sync_cursor,
  }
}

///|
pub(all) struct ConnectorLastSyncResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorLastSyncResponse with fn to_json(
  self : ConnectorLastSyncResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorLastSyncResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorLastSyncResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorLastSyncRequest {
  connector_id : String
  query : ConnectorLastSyncQuery
  body : ConnectorLastSyncBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorLastSyncRequest::new(
  connector_id : String,
  body : ConnectorLastSyncBody,
  query? : ConnectorLastSyncQuery = ConnectorLastSyncQuery::new(),
) -> ConnectorLastSyncRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_last_sync(
  self : Client,
  request : ConnectorLastSyncRequest,
) -> EsResponse[ConnectorLastSyncResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_last_sync", ["connector_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorListQuery {
  from : Int?
  size : Int?
  index_name : String?
  connector_name : String?
  service_type : String?
  include_deleted : Bool?
  query : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorListQuery with fn to_json(
  self : ConnectorListQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.index_name {
    Some(value) => obj["index_name"] = value.to_json()
    None => ()
  }
  match self.connector_name {
    Some(value) => obj["connector_name"] = value.to_json()
    None => ()
  }
  match self.service_type {
    Some(value) => obj["service_type"] = value.to_json()
    None => ()
  }
  match self.include_deleted {
    Some(value) => obj["include_deleted"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorListQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorListQuery: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    index_name: match obj.get("index_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_name")))
    },
    connector_name: match obj.get("connector_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("connector_name")))
    },
    service_type: match obj.get("service_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("service_type")))
    },
    include_deleted: match obj.get("include_deleted") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_deleted")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
  }
}

///|
pub fn ConnectorListQuery::new(
  from? : Int,
  size? : Int,
  index_name? : String,
  connector_name? : String,
  service_type? : String,
  include_deleted? : Bool,
  query? : String,
) -> ConnectorListQuery {
  {
    from,
    size,
    index_name,
    connector_name,
    service_type,
    include_deleted,
    query,
  }
}

///|
pub fn ConnectorListQuery::to_pairs(
  self : ConnectorListQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.index_name {
    Some(value) => push_query_json(pairs, "index_name", value.to_json())
    None => ()
  }
  match self.connector_name {
    Some(value) => push_query_json(pairs, "connector_name", value.to_json())
    None => ()
  }
  match self.service_type {
    Some(value) => push_query_json(pairs, "service_type", value.to_json())
    None => ()
  }
  match self.include_deleted {
    Some(value) => push_query_json(pairs, "include_deleted", value.to_json())
    None => ()
  }
  match self.query {
    Some(value) => push_query_json(pairs, "query", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ConnectorListResponse {
  count : Int
  results : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorListResponse with fn to_json(
  self : ConnectorListResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["results"] = self.results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorListResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorListResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    results: @json.from_json(
      obj.get("results").unwrap_or(Json::null()),
      path=path.add_key("results"),
    ),
  }
}

///|
pub(all) struct ConnectorListRequest {
  query : ConnectorListQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorListRequest::new(
  query? : ConnectorListQuery = ConnectorListQuery::new(),
) -> ConnectorListRequest {
  { query, }
}

///|
pub async fn Client::connector_list(
  self : Client,
  request : ConnectorListRequest,
) -> EsResponse[ConnectorListResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_connector", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ConnectorPostQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorPostQuery with fn to_json(
  _self : ConnectorPostQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorPostQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorPostQuery: expected object"))
  }
  ConnectorPostQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorPostQuery::new() -> ConnectorPostQuery {
  ConnectorPostQuery::{  }
}

///|
pub fn ConnectorPostQuery::to_pairs(
  _self : ConnectorPostQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorPostBody {
  description : String?
  index_name : Json?
  is_native : Bool?
  language : String?
  name : String?
  service_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorPostBody with fn to_json(self : ConnectorPostBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.index_name {
    Some(value) => obj["index_name"] = value.to_json()
    None => ()
  }
  match self.is_native {
    Some(value) => obj["is_native"] = value.to_json()
    None => ()
  }
  match self.language {
    Some(value) => obj["language"] = value.to_json()
    None => ()
  }
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.service_type {
    Some(value) => obj["service_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorPostBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorPostBody: expected object"))
  }
  {
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    index_name: match obj.get("index_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_name")))
    },
    is_native: match obj.get("is_native") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("is_native")))
    },
    language: match obj.get("language") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("language")))
    },
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    service_type: match obj.get("service_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("service_type")))
    },
  }
}

///|
pub fn ConnectorPostBody::new(
  description? : String,
  index_name? : Json,
  is_native? : Bool,
  language? : String,
  name? : String,
  service_type? : String,
) -> ConnectorPostBody {
  { description, index_name, is_native, language, name, service_type }
}

///|
pub(all) struct ConnectorPostResponse {
  result : Json
  id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorPostResponse with fn to_json(
  self : ConnectorPostResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorPostResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorPostResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub(all) struct ConnectorPostRequest {
  query : ConnectorPostQuery
  body : ConnectorPostBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorPostRequest::new(
  query? : ConnectorPostQuery = ConnectorPostQuery::new(),
  body? : ConnectorPostBody,
) -> ConnectorPostRequest {
  { query, body }
}

///|
pub async fn Client::connector_post(
  self : Client,
  request : ConnectorPostRequest,
) -> EsResponse[ConnectorPostResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_connector", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ConnectorPutQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorPutQuery with fn to_json(_self : ConnectorPutQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorPutQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorPutQuery: expected object"))
  }
  ConnectorPutQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorPutQuery::new() -> ConnectorPutQuery {
  ConnectorPutQuery::{  }
}

///|
pub fn ConnectorPutQuery::to_pairs(
  _self : ConnectorPutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorPutBody {
  description : String?
  index_name : Json?
  is_native : Bool?
  language : String?
  name : String?
  service_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorPutBody with fn to_json(self : ConnectorPutBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.index_name {
    Some(value) => obj["index_name"] = value.to_json()
    None => ()
  }
  match self.is_native {
    Some(value) => obj["is_native"] = value.to_json()
    None => ()
  }
  match self.language {
    Some(value) => obj["language"] = value.to_json()
    None => ()
  }
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.service_type {
    Some(value) => obj["service_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorPutBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorPutBody: expected object"))
  }
  {
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    index_name: match obj.get("index_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_name")))
    },
    is_native: match obj.get("is_native") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("is_native")))
    },
    language: match obj.get("language") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("language")))
    },
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    service_type: match obj.get("service_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("service_type")))
    },
  }
}

///|
pub fn ConnectorPutBody::new(
  description? : String,
  index_name? : Json,
  is_native? : Bool,
  language? : String,
  name? : String,
  service_type? : String,
) -> ConnectorPutBody {
  { description, index_name, is_native, language, name, service_type }
}

///|
pub(all) struct ConnectorPutResponse {
  result : Json
  id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorPutResponse with fn to_json(
  self : ConnectorPutResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorPutResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorPutResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub(all) struct ConnectorPutRequest {
  connector_id : String?
  query : ConnectorPutQuery
  body : ConnectorPutBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorPutRequest::new(
  connector_id? : String,
  query? : ConnectorPutQuery = ConnectorPutQuery::new(),
  body? : ConnectorPutBody,
) -> ConnectorPutRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_put(
  self : Client,
  request : ConnectorPutRequest,
) -> EsResponse[ConnectorPutResponse] {
  let params : Map[String, String] = Map([])
  match request.connector_id {
    Some(value) => params["connector_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}", ["connector_id"]),
      PathVariant::new("/_connector", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorSecretDeleteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretDeleteQuery with fn to_json(
  _self : ConnectorSecretDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSecretDeleteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSecretDeleteQuery: expected object"))
  }
  ConnectorSecretDeleteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSecretDeleteQuery::new() -> ConnectorSecretDeleteQuery {
  ConnectorSecretDeleteQuery::{  }
}

///|
pub fn ConnectorSecretDeleteQuery::to_pairs(
  _self : ConnectorSecretDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSecretDeleteResponse {
  deleted : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretDeleteResponse with fn to_json(
  self : ConnectorSecretDeleteResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["deleted"] = self.deleted.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSecretDeleteResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorSecretDeleteResponse: expected object"),
    )
  }
  {
    deleted: @json.from_json(
      obj.get("deleted").unwrap_or(Json::null()),
      path=path.add_key("deleted"),
    ),
  }
}

///|
pub(all) struct ConnectorSecretDeleteRequest {
  id : String
  query : ConnectorSecretDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSecretDeleteRequest::new(
  id : String,
  query? : ConnectorSecretDeleteQuery = ConnectorSecretDeleteQuery::new(),
) -> ConnectorSecretDeleteRequest {
  { id, query }
}

///|
pub async fn Client::connector_secret_delete(
  self : Client,
  request : ConnectorSecretDeleteRequest,
) -> EsResponse[ConnectorSecretDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/_secret/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct ConnectorSecretGetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretGetQuery with fn to_json(
  _self : ConnectorSecretGetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSecretGetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSecretGetQuery: expected object"))
  }
  ConnectorSecretGetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSecretGetQuery::new() -> ConnectorSecretGetQuery {
  ConnectorSecretGetQuery::{  }
}

///|
pub fn ConnectorSecretGetQuery::to_pairs(
  _self : ConnectorSecretGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSecretGetResponse {
  id : String
  value : String
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretGetResponse with fn to_json(
  self : ConnectorSecretGetResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  obj["value"] = self.value.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSecretGetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorSecretGetResponse: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    value: @json.from_json(
      obj.get("value").unwrap_or(Json::null()),
      path=path.add_key("value"),
    ),
  }
}

///|
pub(all) struct ConnectorSecretGetRequest {
  id : String
  query : ConnectorSecretGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSecretGetRequest::new(
  id : String,
  query? : ConnectorSecretGetQuery = ConnectorSecretGetQuery::new(),
) -> ConnectorSecretGetRequest {
  { id, query }
}

///|
pub async fn Client::connector_secret_get(
  self : Client,
  request : ConnectorSecretGetRequest,
) -> EsResponse[ConnectorSecretGetResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/_secret/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ConnectorSecretPostQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretPostQuery with fn to_json(
  _self : ConnectorSecretPostQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSecretPostQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSecretPostQuery: expected object"))
  }
  ConnectorSecretPostQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSecretPostQuery::new() -> ConnectorSecretPostQuery {
  ConnectorSecretPostQuery::{  }
}

///|
pub fn ConnectorSecretPostQuery::to_pairs(
  _self : ConnectorSecretPostQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSecretPostResponse {
  id : String
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretPostResponse with fn to_json(
  self : ConnectorSecretPostResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSecretPostResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorSecretPostResponse: expected object"),
    )
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub(all) struct ConnectorSecretPostRequest {
  query : ConnectorSecretPostQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSecretPostRequest::new(
  query? : ConnectorSecretPostQuery = ConnectorSecretPostQuery::new(),
) -> ConnectorSecretPostRequest {
  { query, }
}

///|
pub async fn Client::connector_secret_post(
  self : Client,
  request : ConnectorSecretPostRequest,
) -> EsResponse[ConnectorSecretPostResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_connector/_secret", [])], params)
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct ConnectorSecretPutQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretPutQuery with fn to_json(
  _self : ConnectorSecretPutQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSecretPutQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSecretPutQuery: expected object"))
  }
  ConnectorSecretPutQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSecretPutQuery::new() -> ConnectorSecretPutQuery {
  ConnectorSecretPutQuery::{  }
}

///|
pub fn ConnectorSecretPutQuery::to_pairs(
  _self : ConnectorSecretPutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSecretPutResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSecretPutResponse with fn to_json(
  self : ConnectorSecretPutResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSecretPutResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorSecretPutResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorSecretPutRequest {
  id : String
  query : ConnectorSecretPutQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSecretPutRequest::new(
  id : String,
  query? : ConnectorSecretPutQuery = ConnectorSecretPutQuery::new(),
) -> ConnectorSecretPutRequest {
  { id, query }
}

///|
pub async fn Client::connector_secret_put(
  self : Client,
  request : ConnectorSecretPutRequest,
) -> EsResponse[ConnectorSecretPutResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/_secret/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct ConnectorSyncJobCancelQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobCancelQuery with fn to_json(
  _self : ConnectorSyncJobCancelQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobCancelQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobCancelQuery: expected object"),
    )
  }
  ConnectorSyncJobCancelQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobCancelQuery::new() -> ConnectorSyncJobCancelQuery {
  ConnectorSyncJobCancelQuery::{  }
}

///|
pub fn ConnectorSyncJobCancelQuery::to_pairs(
  _self : ConnectorSyncJobCancelQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSyncJobCancelResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobCancelResponse with fn to_json(
  self : ConnectorSyncJobCancelResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobCancelResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobCancelResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorSyncJobCancelRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobCancelQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobCancelRequest::new(
  connector_sync_job_id : String,
  query? : ConnectorSyncJobCancelQuery = ConnectorSyncJobCancelQuery::new(),
) -> ConnectorSyncJobCancelRequest {
  { connector_sync_job_id, query }
}

///|
pub async fn Client::connector_sync_job_cancel(
  self : Client,
  request : ConnectorSyncJobCancelRequest,
) -> EsResponse[ConnectorSyncJobCancelResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_connector/_sync_job/{connector_sync_job_id}/_cancel",
        ["connector_sync_job_id"],
      ),
    ],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct ConnectorSyncJobCheckInQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobCheckInQuery with fn to_json(
  _self : ConnectorSyncJobCheckInQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobCheckInQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobCheckInQuery: expected object"),
    )
  }
  ConnectorSyncJobCheckInQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobCheckInQuery::new() -> ConnectorSyncJobCheckInQuery {
  ConnectorSyncJobCheckInQuery::{  }
}

///|
pub fn ConnectorSyncJobCheckInQuery::to_pairs(
  _self : ConnectorSyncJobCheckInQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ConnectorSyncJobCheckInResponse = Json

///|
pub(all) struct ConnectorSyncJobCheckInRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobCheckInQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobCheckInRequest::new(
  connector_sync_job_id : String,
  query? : ConnectorSyncJobCheckInQuery = ConnectorSyncJobCheckInQuery::new(),
) -> ConnectorSyncJobCheckInRequest {
  { connector_sync_job_id, query }
}

///|
pub async fn Client::connector_sync_job_check_in(
  self : Client,
  request : ConnectorSyncJobCheckInRequest,
) -> EsResponse[ConnectorSyncJobCheckInResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_connector/_sync_job/{connector_sync_job_id}/_check_in",
        ["connector_sync_job_id"],
      ),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct ConnectorSyncJobClaimQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobClaimQuery with fn to_json(
  _self : ConnectorSyncJobClaimQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobClaimQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSyncJobClaimQuery: expected object"))
  }
  ConnectorSyncJobClaimQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobClaimQuery::new() -> ConnectorSyncJobClaimQuery {
  ConnectorSyncJobClaimQuery::{  }
}

///|
pub fn ConnectorSyncJobClaimQuery::to_pairs(
  _self : ConnectorSyncJobClaimQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSyncJobClaimBody {
  sync_cursor : Json?
  worker_hostname : String
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobClaimBody with fn to_json(
  self : ConnectorSyncJobClaimBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.sync_cursor {
    Some(value) => obj["sync_cursor"] = value.to_json()
    None => ()
  }
  obj["worker_hostname"] = self.worker_hostname.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobClaimBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorSyncJobClaimBody: expected object"))
  }
  {
    sync_cursor: match obj.get("sync_cursor") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("sync_cursor")))
    },
    worker_hostname: @json.from_json(
      obj.get("worker_hostname").unwrap_or(Json::null()),
      path=path.add_key("worker_hostname"),
    ),
  }
}

///|
pub fn ConnectorSyncJobClaimBody::new(
  worker_hostname : String,
  sync_cursor? : Json,
) -> ConnectorSyncJobClaimBody {
  { sync_cursor, worker_hostname }
}

///|
pub type ConnectorSyncJobClaimResponse = Json

///|
pub(all) struct ConnectorSyncJobClaimRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobClaimQuery
  body : ConnectorSyncJobClaimBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobClaimRequest::new(
  connector_sync_job_id : String,
  body : ConnectorSyncJobClaimBody,
  query? : ConnectorSyncJobClaimQuery = ConnectorSyncJobClaimQuery::new(),
) -> ConnectorSyncJobClaimRequest {
  { connector_sync_job_id, query, body }
}

///|
pub async fn Client::connector_sync_job_claim(
  self : Client,
  request : ConnectorSyncJobClaimRequest,
) -> EsResponse[ConnectorSyncJobClaimResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/_sync_job/{connector_sync_job_id}/_claim", [
        "connector_sync_job_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorSyncJobDeleteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobDeleteQuery with fn to_json(
  _self : ConnectorSyncJobDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobDeleteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobDeleteQuery: expected object"),
    )
  }
  ConnectorSyncJobDeleteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobDeleteQuery::new() -> ConnectorSyncJobDeleteQuery {
  ConnectorSyncJobDeleteQuery::{  }
}

///|
pub fn ConnectorSyncJobDeleteQuery::to_pairs(
  _self : ConnectorSyncJobDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ConnectorSyncJobDeleteResponse = Json

///|
pub(all) struct ConnectorSyncJobDeleteRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobDeleteRequest::new(
  connector_sync_job_id : String,
  query? : ConnectorSyncJobDeleteQuery = ConnectorSyncJobDeleteQuery::new(),
) -> ConnectorSyncJobDeleteRequest {
  { connector_sync_job_id, query }
}

///|
pub async fn Client::connector_sync_job_delete(
  self : Client,
  request : ConnectorSyncJobDeleteRequest,
) -> EsResponse[ConnectorSyncJobDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/_sync_job/{connector_sync_job_id}", [
        "connector_sync_job_id",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct ConnectorSyncJobErrorQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobErrorQuery with fn to_json(
  _self : ConnectorSyncJobErrorQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobErrorQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSyncJobErrorQuery: expected object"))
  }
  ConnectorSyncJobErrorQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobErrorQuery::new() -> ConnectorSyncJobErrorQuery {
  ConnectorSyncJobErrorQuery::{  }
}

///|
pub fn ConnectorSyncJobErrorQuery::to_pairs(
  _self : ConnectorSyncJobErrorQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSyncJobErrorBody {
  error : String
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobErrorBody with fn to_json(
  self : ConnectorSyncJobErrorBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["error"] = self.error.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobErrorBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorSyncJobErrorBody: expected object"))
  }
  {
    error: @json.from_json(
      obj.get("error").unwrap_or(Json::null()),
      path=path.add_key("error"),
    ),
  }
}

///|
pub fn ConnectorSyncJobErrorBody::new(
  error : String,
) -> ConnectorSyncJobErrorBody {
  { error, }
}

///|
pub type ConnectorSyncJobErrorResponse = Json

///|
pub(all) struct ConnectorSyncJobErrorRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobErrorQuery
  body : ConnectorSyncJobErrorBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobErrorRequest::new(
  connector_sync_job_id : String,
  body : ConnectorSyncJobErrorBody,
  query? : ConnectorSyncJobErrorQuery = ConnectorSyncJobErrorQuery::new(),
) -> ConnectorSyncJobErrorRequest {
  { connector_sync_job_id, query, body }
}

///|
pub async fn Client::connector_sync_job_error(
  self : Client,
  request : ConnectorSyncJobErrorRequest,
) -> EsResponse[ConnectorSyncJobErrorResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/_sync_job/{connector_sync_job_id}/_error", [
        "connector_sync_job_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorSyncJobGetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobGetQuery with fn to_json(
  _self : ConnectorSyncJobGetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobGetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSyncJobGetQuery: expected object"))
  }
  ConnectorSyncJobGetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobGetQuery::new() -> ConnectorSyncJobGetQuery {
  ConnectorSyncJobGetQuery::{  }
}

///|
pub fn ConnectorSyncJobGetQuery::to_pairs(
  _self : ConnectorSyncJobGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ConnectorSyncJobGetResponse = Json

///|
pub(all) struct ConnectorSyncJobGetRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobGetRequest::new(
  connector_sync_job_id : String,
  query? : ConnectorSyncJobGetQuery = ConnectorSyncJobGetQuery::new(),
) -> ConnectorSyncJobGetRequest {
  { connector_sync_job_id, query }
}

///|
pub async fn Client::connector_sync_job_get(
  self : Client,
  request : ConnectorSyncJobGetRequest,
) -> EsResponse[ConnectorSyncJobGetResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/_sync_job/{connector_sync_job_id}", [
        "connector_sync_job_id",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ConnectorSyncJobListQuery {
  from : Int?
  size : Int?
  status : String?
  connector_id : String?
  job_type : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobListQuery with fn to_json(
  self : ConnectorSyncJobListQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  match self.connector_id {
    Some(value) => obj["connector_id"] = value.to_json()
    None => ()
  }
  match self.job_type {
    Some(value) => obj["job_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobListQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorSyncJobListQuery: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
    connector_id: match obj.get("connector_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("connector_id")))
    },
    job_type: match obj.get("job_type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_type")))
    },
  }
}

///|
pub fn ConnectorSyncJobListQuery::new(
  from? : Int,
  size? : Int,
  status? : String,
  connector_id? : String,
  job_type? : Json,
) -> ConnectorSyncJobListQuery {
  { from, size, status, connector_id, job_type }
}

///|
pub fn ConnectorSyncJobListQuery::to_pairs(
  self : ConnectorSyncJobListQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.status {
    Some(value) => push_query_json(pairs, "status", value.to_json())
    None => ()
  }
  match self.connector_id {
    Some(value) => push_query_json(pairs, "connector_id", value.to_json())
    None => ()
  }
  match self.job_type {
    Some(value) => push_query_json(pairs, "job_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ConnectorSyncJobListResponse {
  count : Int
  results : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobListResponse with fn to_json(
  self : ConnectorSyncJobListResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["results"] = self.results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobListResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobListResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    results: @json.from_json(
      obj.get("results").unwrap_or(Json::null()),
      path=path.add_key("results"),
    ),
  }
}

///|
pub(all) struct ConnectorSyncJobListRequest {
  query : ConnectorSyncJobListQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobListRequest::new(
  query? : ConnectorSyncJobListQuery = ConnectorSyncJobListQuery::new(),
) -> ConnectorSyncJobListRequest {
  { query, }
}

///|
pub async fn Client::connector_sync_job_list(
  self : Client,
  request : ConnectorSyncJobListRequest,
) -> EsResponse[ConnectorSyncJobListResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/_sync_job", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ConnectorSyncJobPostQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobPostQuery with fn to_json(
  _self : ConnectorSyncJobPostQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobPostQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorSyncJobPostQuery: expected object"))
  }
  ConnectorSyncJobPostQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobPostQuery::new() -> ConnectorSyncJobPostQuery {
  ConnectorSyncJobPostQuery::{  }
}

///|
pub fn ConnectorSyncJobPostQuery::to_pairs(
  _self : ConnectorSyncJobPostQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSyncJobPostBody {
  id : Json
  job_type : Json?
  trigger_method : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobPostBody with fn to_json(
  self : ConnectorSyncJobPostBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  match self.job_type {
    Some(value) => obj["job_type"] = value.to_json()
    None => ()
  }
  match self.trigger_method {
    Some(value) => obj["trigger_method"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobPostBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorSyncJobPostBody: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    job_type: match obj.get("job_type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_type")))
    },
    trigger_method: match obj.get("trigger_method") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("trigger_method")))
    },
  }
}

///|
pub fn ConnectorSyncJobPostBody::new(
  id : Json,
  job_type? : Json,
  trigger_method? : Json,
) -> ConnectorSyncJobPostBody {
  { id, job_type, trigger_method }
}

///|
pub(all) struct ConnectorSyncJobPostResponse {
  id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobPostResponse with fn to_json(
  self : ConnectorSyncJobPostResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobPostResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobPostResponse: expected object"),
    )
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub(all) struct ConnectorSyncJobPostRequest {
  query : ConnectorSyncJobPostQuery
  body : ConnectorSyncJobPostBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobPostRequest::new(
  body : ConnectorSyncJobPostBody,
  query? : ConnectorSyncJobPostQuery = ConnectorSyncJobPostQuery::new(),
) -> ConnectorSyncJobPostRequest {
  { query, body }
}

///|
pub async fn Client::connector_sync_job_post(
  self : Client,
  request : ConnectorSyncJobPostRequest,
) -> EsResponse[ConnectorSyncJobPostResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/_sync_job", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ConnectorSyncJobUpdateStatsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobUpdateStatsQuery with fn to_json(
  _self : ConnectorSyncJobUpdateStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorSyncJobUpdateStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobUpdateStatsQuery: expected object"),
    )
  }
  ConnectorSyncJobUpdateStatsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorSyncJobUpdateStatsQuery::new() -> ConnectorSyncJobUpdateStatsQuery {
  ConnectorSyncJobUpdateStatsQuery::{  }
}

///|
pub fn ConnectorSyncJobUpdateStatsQuery::to_pairs(
  _self : ConnectorSyncJobUpdateStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorSyncJobUpdateStatsBody {
  deleted_document_count : Int
  indexed_document_count : Int
  indexed_document_volume : Int
  last_seen : Json?
  metadata : Json?
  total_document_count : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorSyncJobUpdateStatsBody with fn to_json(
  self : ConnectorSyncJobUpdateStatsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["deleted_document_count"] = self.deleted_document_count.to_json()
  obj["indexed_document_count"] = self.indexed_document_count.to_json()
  obj["indexed_document_volume"] = self.indexed_document_volume.to_json()
  match self.last_seen {
    Some(value) => obj["last_seen"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.total_document_count {
    Some(value) => obj["total_document_count"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorSyncJobUpdateStatsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorSyncJobUpdateStatsBody: expected object"),
    )
  }
  {
    deleted_document_count: @json.from_json(
      obj.get("deleted_document_count").unwrap_or(Json::null()),
      path=path.add_key("deleted_document_count"),
    ),
    indexed_document_count: @json.from_json(
      obj.get("indexed_document_count").unwrap_or(Json::null()),
      path=path.add_key("indexed_document_count"),
    ),
    indexed_document_volume: @json.from_json(
      obj.get("indexed_document_volume").unwrap_or(Json::null()),
      path=path.add_key("indexed_document_volume"),
    ),
    last_seen: match obj.get("last_seen") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("last_seen")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    total_document_count: match obj.get("total_document_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("total_document_count")))
    },
  }
}

///|
pub fn ConnectorSyncJobUpdateStatsBody::new(
  deleted_document_count : Int,
  indexed_document_count : Int,
  indexed_document_volume : Int,
  last_seen? : Json,
  metadata? : Json,
  total_document_count? : Int,
) -> ConnectorSyncJobUpdateStatsBody {
  {
    deleted_document_count,
    indexed_document_count,
    indexed_document_volume,
    last_seen,
    metadata,
    total_document_count,
  }
}

///|
pub type ConnectorSyncJobUpdateStatsResponse = Json

///|
pub(all) struct ConnectorSyncJobUpdateStatsRequest {
  connector_sync_job_id : String
  query : ConnectorSyncJobUpdateStatsQuery
  body : ConnectorSyncJobUpdateStatsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorSyncJobUpdateStatsRequest::new(
  connector_sync_job_id : String,
  body : ConnectorSyncJobUpdateStatsBody,
  query? : ConnectorSyncJobUpdateStatsQuery = ConnectorSyncJobUpdateStatsQuery::new(),
) -> ConnectorSyncJobUpdateStatsRequest {
  { connector_sync_job_id, query, body }
}

///|
pub async fn Client::connector_sync_job_update_stats(
  self : Client,
  request : ConnectorSyncJobUpdateStatsRequest,
) -> EsResponse[ConnectorSyncJobUpdateStatsResponse] {
  let params : Map[String, String] = Map([])
  params["connector_sync_job_id"] = request.connector_sync_job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/_sync_job/{connector_sync_job_id}/_stats", [
        "connector_sync_job_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateActiveFilteringQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateActiveFilteringQuery with fn to_json(
  _self : ConnectorUpdateActiveFilteringQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateActiveFilteringQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateActiveFilteringQuery: expected object"),
    )
  }
  ConnectorUpdateActiveFilteringQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateActiveFilteringQuery::new() -> ConnectorUpdateActiveFilteringQuery {
  ConnectorUpdateActiveFilteringQuery::{  }
}

///|
pub fn ConnectorUpdateActiveFilteringQuery::to_pairs(
  _self : ConnectorUpdateActiveFilteringQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ConnectorUpdateActiveFilteringBody = Json

///|
pub(all) struct ConnectorUpdateActiveFilteringResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateActiveFilteringResponse with fn to_json(
  self : ConnectorUpdateActiveFilteringResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateActiveFilteringResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateActiveFilteringResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateActiveFilteringRequest {
  connector_id : String
  query : ConnectorUpdateActiveFilteringQuery
  body : ConnectorUpdateActiveFilteringBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateActiveFilteringRequest::new(
  connector_id : String,
  query? : ConnectorUpdateActiveFilteringQuery = ConnectorUpdateActiveFilteringQuery::new(),
  body? : ConnectorUpdateActiveFilteringBody,
) -> ConnectorUpdateActiveFilteringRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_active_filtering(
  self : Client,
  request : ConnectorUpdateActiveFilteringRequest,
) -> EsResponse[ConnectorUpdateActiveFilteringResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_filtering/_activate", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateApiKeyIdQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateApiKeyIdQuery with fn to_json(
  _self : ConnectorUpdateApiKeyIdQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateApiKeyIdQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateApiKeyIdQuery: expected object"),
    )
  }
  ConnectorUpdateApiKeyIdQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateApiKeyIdQuery::new() -> ConnectorUpdateApiKeyIdQuery {
  ConnectorUpdateApiKeyIdQuery::{  }
}

///|
pub fn ConnectorUpdateApiKeyIdQuery::to_pairs(
  _self : ConnectorUpdateApiKeyIdQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateApiKeyIdBody {
  api_key_id : String?
  api_key_secret_id : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateApiKeyIdBody with fn to_json(
  self : ConnectorUpdateApiKeyIdBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.api_key_id {
    Some(value) => obj["api_key_id"] = value.to_json()
    None => ()
  }
  match self.api_key_secret_id {
    Some(value) => obj["api_key_secret_id"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateApiKeyIdBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateApiKeyIdBody: expected object"),
    )
  }
  {
    api_key_id: match obj.get("api_key_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("api_key_id")))
    },
    api_key_secret_id: match obj.get("api_key_secret_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("api_key_secret_id")))
    },
  }
}

///|
pub fn ConnectorUpdateApiKeyIdBody::new(
  api_key_id? : String,
  api_key_secret_id? : String,
) -> ConnectorUpdateApiKeyIdBody {
  { api_key_id, api_key_secret_id }
}

///|
pub(all) struct ConnectorUpdateApiKeyIdResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateApiKeyIdResponse with fn to_json(
  self : ConnectorUpdateApiKeyIdResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateApiKeyIdResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateApiKeyIdResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateApiKeyIdRequest {
  connector_id : String
  query : ConnectorUpdateApiKeyIdQuery
  body : ConnectorUpdateApiKeyIdBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateApiKeyIdRequest::new(
  connector_id : String,
  body : ConnectorUpdateApiKeyIdBody,
  query? : ConnectorUpdateApiKeyIdQuery = ConnectorUpdateApiKeyIdQuery::new(),
) -> ConnectorUpdateApiKeyIdRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_api_key_id(
  self : Client,
  request : ConnectorUpdateApiKeyIdRequest,
) -> EsResponse[ConnectorUpdateApiKeyIdResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_api_key_id", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateConfigurationQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateConfigurationQuery with fn to_json(
  _self : ConnectorUpdateConfigurationQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateConfigurationQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateConfigurationQuery: expected object"),
    )
  }
  ConnectorUpdateConfigurationQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateConfigurationQuery::new() -> ConnectorUpdateConfigurationQuery {
  ConnectorUpdateConfigurationQuery::{  }
}

///|
pub fn ConnectorUpdateConfigurationQuery::to_pairs(
  _self : ConnectorUpdateConfigurationQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateConfigurationBody {
  configuration : Json?
  values : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateConfigurationBody with fn to_json(
  self : ConnectorUpdateConfigurationBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.configuration {
    Some(value) => obj["configuration"] = value.to_json()
    None => ()
  }
  match self.values {
    Some(value) => obj["values"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateConfigurationBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateConfigurationBody: expected object"),
    )
  }
  {
    configuration: match obj.get("configuration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("configuration")))
    },
    values: match obj.get("values") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("values")))
    },
  }
}

///|
pub fn ConnectorUpdateConfigurationBody::new(
  configuration? : Json,
  values? : Map[String, Json],
) -> ConnectorUpdateConfigurationBody {
  { configuration, values }
}

///|
pub(all) struct ConnectorUpdateConfigurationResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateConfigurationResponse with fn to_json(
  self : ConnectorUpdateConfigurationResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateConfigurationResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateConfigurationResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateConfigurationRequest {
  connector_id : String
  query : ConnectorUpdateConfigurationQuery
  body : ConnectorUpdateConfigurationBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateConfigurationRequest::new(
  connector_id : String,
  body : ConnectorUpdateConfigurationBody,
  query? : ConnectorUpdateConfigurationQuery = ConnectorUpdateConfigurationQuery::new(),
) -> ConnectorUpdateConfigurationRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_configuration(
  self : Client,
  request : ConnectorUpdateConfigurationRequest,
) -> EsResponse[ConnectorUpdateConfigurationResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_configuration", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateErrorQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateErrorQuery with fn to_json(
  _self : ConnectorUpdateErrorQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateErrorQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorUpdateErrorQuery: expected object"))
  }
  ConnectorUpdateErrorQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateErrorQuery::new() -> ConnectorUpdateErrorQuery {
  ConnectorUpdateErrorQuery::{  }
}

///|
pub fn ConnectorUpdateErrorQuery::to_pairs(
  _self : ConnectorUpdateErrorQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateErrorBody {
  error : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateErrorBody with fn to_json(
  self : ConnectorUpdateErrorBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["error"] = self.error.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateErrorBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorUpdateErrorBody: expected object"))
  }
  {
    error: @json.from_json(
      obj.get("error").unwrap_or(Json::null()),
      path=path.add_key("error"),
    ),
  }
}

///|
pub fn ConnectorUpdateErrorBody::new(error : Json) -> ConnectorUpdateErrorBody {
  { error, }
}

///|
pub(all) struct ConnectorUpdateErrorResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateErrorResponse with fn to_json(
  self : ConnectorUpdateErrorResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateErrorResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateErrorResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateErrorRequest {
  connector_id : String
  query : ConnectorUpdateErrorQuery
  body : ConnectorUpdateErrorBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateErrorRequest::new(
  connector_id : String,
  body : ConnectorUpdateErrorBody,
  query? : ConnectorUpdateErrorQuery = ConnectorUpdateErrorQuery::new(),
) -> ConnectorUpdateErrorRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_error(
  self : Client,
  request : ConnectorUpdateErrorRequest,
) -> EsResponse[ConnectorUpdateErrorResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_error", ["connector_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateFeaturesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFeaturesQuery with fn to_json(
  _self : ConnectorUpdateFeaturesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateFeaturesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFeaturesQuery: expected object"),
    )
  }
  ConnectorUpdateFeaturesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateFeaturesQuery::new() -> ConnectorUpdateFeaturesQuery {
  ConnectorUpdateFeaturesQuery::{  }
}

///|
pub fn ConnectorUpdateFeaturesQuery::to_pairs(
  _self : ConnectorUpdateFeaturesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateFeaturesBody {
  features : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFeaturesBody with fn to_json(
  self : ConnectorUpdateFeaturesBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["features"] = self.features.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateFeaturesBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFeaturesBody: expected object"),
    )
  }
  {
    features: @json.from_json(
      obj.get("features").unwrap_or(Json::null()),
      path=path.add_key("features"),
    ),
  }
}

///|
pub fn ConnectorUpdateFeaturesBody::new(
  features : Json,
) -> ConnectorUpdateFeaturesBody {
  { features, }
}

///|
pub(all) struct ConnectorUpdateFeaturesResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFeaturesResponse with fn to_json(
  self : ConnectorUpdateFeaturesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateFeaturesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFeaturesResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateFeaturesRequest {
  connector_id : String
  query : ConnectorUpdateFeaturesQuery
  body : ConnectorUpdateFeaturesBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateFeaturesRequest::new(
  connector_id : String,
  body : ConnectorUpdateFeaturesBody,
  query? : ConnectorUpdateFeaturesQuery = ConnectorUpdateFeaturesQuery::new(),
) -> ConnectorUpdateFeaturesRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_features(
  self : Client,
  request : ConnectorUpdateFeaturesRequest,
) -> EsResponse[ConnectorUpdateFeaturesResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_features", ["connector_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateFilteringQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFilteringQuery with fn to_json(
  _self : ConnectorUpdateFilteringQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateFilteringQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFilteringQuery: expected object"),
    )
  }
  ConnectorUpdateFilteringQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateFilteringQuery::new() -> ConnectorUpdateFilteringQuery {
  ConnectorUpdateFilteringQuery::{  }
}

///|
pub fn ConnectorUpdateFilteringQuery::to_pairs(
  _self : ConnectorUpdateFilteringQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateFilteringBody {
  filtering : Array[Json]?
  rules : Array[Json]?
  advanced_snippet : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFilteringBody with fn to_json(
  self : ConnectorUpdateFilteringBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.filtering {
    Some(value) => obj["filtering"] = value.to_json()
    None => ()
  }
  match self.rules {
    Some(value) => obj["rules"] = value.to_json()
    None => ()
  }
  match self.advanced_snippet {
    Some(value) => obj["advanced_snippet"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateFilteringBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFilteringBody: expected object"),
    )
  }
  {
    filtering: match obj.get("filtering") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("filtering")))
    },
    rules: match obj.get("rules") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rules")))
    },
    advanced_snippet: match obj.get("advanced_snippet") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("advanced_snippet")))
    },
  }
}

///|
pub fn ConnectorUpdateFilteringBody::new(
  filtering? : Array[Json],
  rules? : Array[Json],
  advanced_snippet? : Json,
) -> ConnectorUpdateFilteringBody {
  { filtering, rules, advanced_snippet }
}

///|
pub(all) struct ConnectorUpdateFilteringResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFilteringResponse with fn to_json(
  self : ConnectorUpdateFilteringResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateFilteringResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFilteringResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateFilteringRequest {
  connector_id : String
  query : ConnectorUpdateFilteringQuery
  body : ConnectorUpdateFilteringBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateFilteringRequest::new(
  connector_id : String,
  body : ConnectorUpdateFilteringBody,
  query? : ConnectorUpdateFilteringQuery = ConnectorUpdateFilteringQuery::new(),
) -> ConnectorUpdateFilteringRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_filtering(
  self : Client,
  request : ConnectorUpdateFilteringRequest,
) -> EsResponse[ConnectorUpdateFilteringResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_filtering", ["connector_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateFilteringValidationQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFilteringValidationQuery with fn to_json(
  _self : ConnectorUpdateFilteringValidationQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateFilteringValidationQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFilteringValidationQuery: expected object"),
    )
  }
  ConnectorUpdateFilteringValidationQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateFilteringValidationQuery::new() -> ConnectorUpdateFilteringValidationQuery {
  ConnectorUpdateFilteringValidationQuery::{  }
}

///|
pub fn ConnectorUpdateFilteringValidationQuery::to_pairs(
  _self : ConnectorUpdateFilteringValidationQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateFilteringValidationBody {
  validation : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFilteringValidationBody with fn to_json(
  self : ConnectorUpdateFilteringValidationBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["validation"] = self.validation.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateFilteringValidationBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFilteringValidationBody: expected object"),
    )
  }
  {
    validation: @json.from_json(
      obj.get("validation").unwrap_or(Json::null()),
      path=path.add_key("validation"),
    ),
  }
}

///|
pub fn ConnectorUpdateFilteringValidationBody::new(
  validation : Json,
) -> ConnectorUpdateFilteringValidationBody {
  { validation, }
}

///|
pub(all) struct ConnectorUpdateFilteringValidationResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateFilteringValidationResponse with fn to_json(
  self : ConnectorUpdateFilteringValidationResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateFilteringValidationResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateFilteringValidationResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateFilteringValidationRequest {
  connector_id : String
  query : ConnectorUpdateFilteringValidationQuery
  body : ConnectorUpdateFilteringValidationBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateFilteringValidationRequest::new(
  connector_id : String,
  body : ConnectorUpdateFilteringValidationBody,
  query? : ConnectorUpdateFilteringValidationQuery = ConnectorUpdateFilteringValidationQuery::new(),
) -> ConnectorUpdateFilteringValidationRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_filtering_validation(
  self : Client,
  request : ConnectorUpdateFilteringValidationRequest,
) -> EsResponse[ConnectorUpdateFilteringValidationResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_filtering/_validation", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateIndexNameQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateIndexNameQuery with fn to_json(
  _self : ConnectorUpdateIndexNameQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateIndexNameQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateIndexNameQuery: expected object"),
    )
  }
  ConnectorUpdateIndexNameQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateIndexNameQuery::new() -> ConnectorUpdateIndexNameQuery {
  ConnectorUpdateIndexNameQuery::{  }
}

///|
pub fn ConnectorUpdateIndexNameQuery::to_pairs(
  _self : ConnectorUpdateIndexNameQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateIndexNameBody {
  index_name : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateIndexNameBody with fn to_json(
  self : ConnectorUpdateIndexNameBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["index_name"] = self.index_name.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateIndexNameBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateIndexNameBody: expected object"),
    )
  }
  {
    index_name: @json.from_json(
      obj.get("index_name").unwrap_or(Json::null()),
      path=path.add_key("index_name"),
    ),
  }
}

///|
pub fn ConnectorUpdateIndexNameBody::new(
  index_name : Json,
) -> ConnectorUpdateIndexNameBody {
  { index_name, }
}

///|
pub(all) struct ConnectorUpdateIndexNameResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateIndexNameResponse with fn to_json(
  self : ConnectorUpdateIndexNameResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateIndexNameResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateIndexNameResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateIndexNameRequest {
  connector_id : String
  query : ConnectorUpdateIndexNameQuery
  body : ConnectorUpdateIndexNameBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateIndexNameRequest::new(
  connector_id : String,
  body : ConnectorUpdateIndexNameBody,
  query? : ConnectorUpdateIndexNameQuery = ConnectorUpdateIndexNameQuery::new(),
) -> ConnectorUpdateIndexNameRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_index_name(
  self : Client,
  request : ConnectorUpdateIndexNameRequest,
) -> EsResponse[ConnectorUpdateIndexNameResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_index_name", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateNameQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateNameQuery with fn to_json(
  _self : ConnectorUpdateNameQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateNameQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorUpdateNameQuery: expected object"))
  }
  ConnectorUpdateNameQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateNameQuery::new() -> ConnectorUpdateNameQuery {
  ConnectorUpdateNameQuery::{  }
}

///|
pub fn ConnectorUpdateNameQuery::to_pairs(
  _self : ConnectorUpdateNameQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateNameBody {
  name : String?
  description : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateNameBody with fn to_json(
  self : ConnectorUpdateNameBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateNameBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorUpdateNameBody: expected object"))
  }
  {
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
  }
}

///|
pub fn ConnectorUpdateNameBody::new(
  name? : String,
  description? : String,
) -> ConnectorUpdateNameBody {
  { name, description }
}

///|
pub(all) struct ConnectorUpdateNameResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateNameResponse with fn to_json(
  self : ConnectorUpdateNameResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateNameResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateNameResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateNameRequest {
  connector_id : String
  query : ConnectorUpdateNameQuery
  body : ConnectorUpdateNameBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateNameRequest::new(
  connector_id : String,
  body : ConnectorUpdateNameBody,
  query? : ConnectorUpdateNameQuery = ConnectorUpdateNameQuery::new(),
) -> ConnectorUpdateNameRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_name(
  self : Client,
  request : ConnectorUpdateNameRequest,
) -> EsResponse[ConnectorUpdateNameResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_name", ["connector_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateNativeQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateNativeQuery with fn to_json(
  _self : ConnectorUpdateNativeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateNativeQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorUpdateNativeQuery: expected object"))
  }
  ConnectorUpdateNativeQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateNativeQuery::new() -> ConnectorUpdateNativeQuery {
  ConnectorUpdateNativeQuery::{  }
}

///|
pub fn ConnectorUpdateNativeQuery::to_pairs(
  _self : ConnectorUpdateNativeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateNativeBody {
  is_native : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateNativeBody with fn to_json(
  self : ConnectorUpdateNativeBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["is_native"] = self.is_native.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateNativeBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorUpdateNativeBody: expected object"))
  }
  {
    is_native: @json.from_json(
      obj.get("is_native").unwrap_or(Json::null()),
      path=path.add_key("is_native"),
    ),
  }
}

///|
pub fn ConnectorUpdateNativeBody::new(
  is_native : Bool,
) -> ConnectorUpdateNativeBody {
  { is_native, }
}

///|
pub(all) struct ConnectorUpdateNativeResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateNativeResponse with fn to_json(
  self : ConnectorUpdateNativeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateNativeResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateNativeResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateNativeRequest {
  connector_id : String
  query : ConnectorUpdateNativeQuery
  body : ConnectorUpdateNativeBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateNativeRequest::new(
  connector_id : String,
  body : ConnectorUpdateNativeBody,
  query? : ConnectorUpdateNativeQuery = ConnectorUpdateNativeQuery::new(),
) -> ConnectorUpdateNativeRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_native(
  self : Client,
  request : ConnectorUpdateNativeRequest,
) -> EsResponse[ConnectorUpdateNativeResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_native", ["connector_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdatePipelineQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdatePipelineQuery with fn to_json(
  _self : ConnectorUpdatePipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdatePipelineQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdatePipelineQuery: expected object"),
    )
  }
  ConnectorUpdatePipelineQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdatePipelineQuery::new() -> ConnectorUpdatePipelineQuery {
  ConnectorUpdatePipelineQuery::{  }
}

///|
pub fn ConnectorUpdatePipelineQuery::to_pairs(
  _self : ConnectorUpdatePipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdatePipelineBody {
  pipeline : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdatePipelineBody with fn to_json(
  self : ConnectorUpdatePipelineBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["pipeline"] = self.pipeline.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdatePipelineBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdatePipelineBody: expected object"),
    )
  }
  {
    pipeline: @json.from_json(
      obj.get("pipeline").unwrap_or(Json::null()),
      path=path.add_key("pipeline"),
    ),
  }
}

///|
pub fn ConnectorUpdatePipelineBody::new(
  pipeline : Json,
) -> ConnectorUpdatePipelineBody {
  { pipeline, }
}

///|
pub(all) struct ConnectorUpdatePipelineResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdatePipelineResponse with fn to_json(
  self : ConnectorUpdatePipelineResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdatePipelineResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdatePipelineResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdatePipelineRequest {
  connector_id : String
  query : ConnectorUpdatePipelineQuery
  body : ConnectorUpdatePipelineBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdatePipelineRequest::new(
  connector_id : String,
  body : ConnectorUpdatePipelineBody,
  query? : ConnectorUpdatePipelineQuery = ConnectorUpdatePipelineQuery::new(),
) -> ConnectorUpdatePipelineRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_pipeline(
  self : Client,
  request : ConnectorUpdatePipelineRequest,
) -> EsResponse[ConnectorUpdatePipelineResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_pipeline", ["connector_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateSchedulingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateSchedulingQuery with fn to_json(
  _self : ConnectorUpdateSchedulingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateSchedulingQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateSchedulingQuery: expected object"),
    )
  }
  ConnectorUpdateSchedulingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateSchedulingQuery::new() -> ConnectorUpdateSchedulingQuery {
  ConnectorUpdateSchedulingQuery::{  }
}

///|
pub fn ConnectorUpdateSchedulingQuery::to_pairs(
  _self : ConnectorUpdateSchedulingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateSchedulingBody {
  scheduling : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateSchedulingBody with fn to_json(
  self : ConnectorUpdateSchedulingBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["scheduling"] = self.scheduling.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateSchedulingBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateSchedulingBody: expected object"),
    )
  }
  {
    scheduling: @json.from_json(
      obj.get("scheduling").unwrap_or(Json::null()),
      path=path.add_key("scheduling"),
    ),
  }
}

///|
pub fn ConnectorUpdateSchedulingBody::new(
  scheduling : Json,
) -> ConnectorUpdateSchedulingBody {
  { scheduling, }
}

///|
pub(all) struct ConnectorUpdateSchedulingResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateSchedulingResponse with fn to_json(
  self : ConnectorUpdateSchedulingResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateSchedulingResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateSchedulingResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateSchedulingRequest {
  connector_id : String
  query : ConnectorUpdateSchedulingQuery
  body : ConnectorUpdateSchedulingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateSchedulingRequest::new(
  connector_id : String,
  body : ConnectorUpdateSchedulingBody,
  query? : ConnectorUpdateSchedulingQuery = ConnectorUpdateSchedulingQuery::new(),
) -> ConnectorUpdateSchedulingRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_scheduling(
  self : Client,
  request : ConnectorUpdateSchedulingRequest,
) -> EsResponse[ConnectorUpdateSchedulingResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_scheduling", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateServiceTypeQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateServiceTypeQuery with fn to_json(
  _self : ConnectorUpdateServiceTypeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateServiceTypeQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateServiceTypeQuery: expected object"),
    )
  }
  ConnectorUpdateServiceTypeQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateServiceTypeQuery::new() -> ConnectorUpdateServiceTypeQuery {
  ConnectorUpdateServiceTypeQuery::{  }
}

///|
pub fn ConnectorUpdateServiceTypeQuery::to_pairs(
  _self : ConnectorUpdateServiceTypeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateServiceTypeBody {
  service_type : String
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateServiceTypeBody with fn to_json(
  self : ConnectorUpdateServiceTypeBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service_type"] = self.service_type.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateServiceTypeBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateServiceTypeBody: expected object"),
    )
  }
  {
    service_type: @json.from_json(
      obj.get("service_type").unwrap_or(Json::null()),
      path=path.add_key("service_type"),
    ),
  }
}

///|
pub fn ConnectorUpdateServiceTypeBody::new(
  service_type : String,
) -> ConnectorUpdateServiceTypeBody {
  { service_type, }
}

///|
pub(all) struct ConnectorUpdateServiceTypeResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateServiceTypeResponse with fn to_json(
  self : ConnectorUpdateServiceTypeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateServiceTypeResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateServiceTypeResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateServiceTypeRequest {
  connector_id : String
  query : ConnectorUpdateServiceTypeQuery
  body : ConnectorUpdateServiceTypeBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateServiceTypeRequest::new(
  connector_id : String,
  body : ConnectorUpdateServiceTypeBody,
  query? : ConnectorUpdateServiceTypeQuery = ConnectorUpdateServiceTypeQuery::new(),
) -> ConnectorUpdateServiceTypeRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_service_type(
  self : Client,
  request : ConnectorUpdateServiceTypeRequest,
) -> EsResponse[ConnectorUpdateServiceTypeResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_connector/{connector_id}/_service_type", [
        "connector_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ConnectorUpdateStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateStatusQuery with fn to_json(
  _self : ConnectorUpdateStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ConnectorUpdateStatusQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ConnectorUpdateStatusQuery: expected object"))
  }
  ConnectorUpdateStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ConnectorUpdateStatusQuery::new() -> ConnectorUpdateStatusQuery {
  ConnectorUpdateStatusQuery::{  }
}

///|
pub fn ConnectorUpdateStatusQuery::to_pairs(
  _self : ConnectorUpdateStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ConnectorUpdateStatusBody {
  status : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateStatusBody with fn to_json(
  self : ConnectorUpdateStatusBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["status"] = self.status.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateStatusBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ConnectorUpdateStatusBody: expected object"))
  }
  {
    status: @json.from_json(
      obj.get("status").unwrap_or(Json::null()),
      path=path.add_key("status"),
    ),
  }
}

///|
pub fn ConnectorUpdateStatusBody::new(
  status : Json,
) -> ConnectorUpdateStatusBody {
  { status, }
}

///|
pub(all) struct ConnectorUpdateStatusResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ConnectorUpdateStatusResponse with fn to_json(
  self : ConnectorUpdateStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ConnectorUpdateStatusResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ConnectorUpdateStatusResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ConnectorUpdateStatusRequest {
  connector_id : String
  query : ConnectorUpdateStatusQuery
  body : ConnectorUpdateStatusBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ConnectorUpdateStatusRequest::new(
  connector_id : String,
  body : ConnectorUpdateStatusBody,
  query? : ConnectorUpdateStatusQuery = ConnectorUpdateStatusQuery::new(),
) -> ConnectorUpdateStatusRequest {
  { connector_id, query, body }
}

///|
pub async fn Client::connector_update_status(
  self : Client,
  request : ConnectorUpdateStatusRequest,
) -> EsResponse[ConnectorUpdateStatusResponse] {
  let params : Map[String, String] = Map([])
  params["connector_id"] = request.connector_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_connector/{connector_id}/_status", ["connector_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct CountQuery {
  allow_no_indices : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  default_operator : String?
  df : String?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  lenient : Bool?
  min_score : Double?
  preference : String?
  routing : String?
  terminate_after : Int?
  q : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CountQuery with fn to_json(self : CountQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.min_score {
    Some(value) => obj["min_score"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CountQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CountQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    min_score: match obj.get("min_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("min_score")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
  }
}

///|
pub fn CountQuery::new(
  allow_no_indices? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  default_operator? : String,
  df? : String,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  lenient? : Bool,
  min_score? : Double,
  preference? : String,
  routing? : String,
  terminate_after? : Int,
  q? : String,
) -> CountQuery {
  {
    allow_no_indices,
    analyzer,
    analyze_wildcard,
    default_operator,
    df,
    expand_wildcards,
    ignore_throttled,
    ignore_unavailable,
    lenient,
    min_score,
    preference,
    routing,
    terminate_after,
    q,
  }
}

///|
pub fn CountQuery::to_pairs(self : CountQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.min_score {
    Some(value) => push_query_json(pairs, "min_score", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.terminate_after {
    Some(value) => push_query_json(pairs, "terminate_after", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct CountBody {
  query : Json?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for CountBody with fn to_json(self : CountBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CountBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CountBody: expected object"))
  }
  {
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn CountBody::new(query? : Json, project_routing? : Json) -> CountBody {
  { query, project_routing }
}

///|
pub(all) struct CountResponse {
  count : Int
  _shards : Json
} derive(Eq, Debug)

///|
pub impl ToJson for CountResponse with fn to_json(self : CountResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["_shards"] = self._shards.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for CountResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CountResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
  }
}

///|
pub(all) struct CountRequest {
  index : String?
  query : CountQuery
  body : CountBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CountRequest::new(
  index? : String,
  query? : CountQuery = CountQuery::new(),
  body? : CountBody,
) -> CountRequest {
  { index, query, body }
}

///|
pub async fn Client::count(
  self : Client,
  request : CountRequest,
) -> EsResponse[CountResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_count", ["index"]),
      PathVariant::new("/_count", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct CreateQuery {
  include_source_on_error : Bool?
  pipeline : String?
  refresh : String?
  require_alias : Bool?
  require_data_stream : Bool?
  routing : String?
  timeout : String?
  version : String?
  version_type : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for CreateQuery with fn to_json(self : CreateQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.include_source_on_error {
    Some(value) => obj["include_source_on_error"] = value.to_json()
    None => ()
  }
  match self.pipeline {
    Some(value) => obj["pipeline"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.require_alias {
    Some(value) => obj["require_alias"] = value.to_json()
    None => ()
  }
  match self.require_data_stream {
    Some(value) => obj["require_data_stream"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for CreateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "CreateQuery: expected object"))
  }
  {
    include_source_on_error: match obj.get("include_source_on_error") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_source_on_error")),
        )
    },
    pipeline: match obj.get("pipeline") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pipeline")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    require_alias: match obj.get("require_alias") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_alias")))
    },
    require_data_stream: match obj.get("require_data_stream") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_data_stream")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn CreateQuery::new(
  include_source_on_error? : Bool,
  pipeline? : String,
  refresh? : String,
  require_alias? : Bool,
  require_data_stream? : Bool,
  routing? : String,
  timeout? : String,
  version? : String,
  version_type? : String,
  wait_for_active_shards? : String,
) -> CreateQuery {
  {
    include_source_on_error,
    pipeline,
    refresh,
    require_alias,
    require_data_stream,
    routing,
    timeout,
    version,
    version_type,
    wait_for_active_shards,
  }
}

///|
pub fn CreateQuery::to_pairs(self : CreateQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.include_source_on_error {
    Some(value) =>
      push_query_json(pairs, "include_source_on_error", value.to_json())
    None => ()
  }
  match self.pipeline {
    Some(value) => push_query_json(pairs, "pipeline", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.require_alias {
    Some(value) => push_query_json(pairs, "require_alias", value.to_json())
    None => ()
  }
  match self.require_data_stream {
    Some(value) =>
      push_query_json(pairs, "require_data_stream", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type CreateBody = Json

///|
pub type CreateResponse = Json

///|
pub(all) struct CreateRequest {
  index : String
  id : String
  query : CreateQuery
  body : CreateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn CreateRequest::new(
  index : String,
  id : String,
  body : CreateBody,
  query? : CreateQuery = CreateQuery::new(),
) -> CreateRequest {
  { index, id, query, body }
}

///|
pub async fn Client::create(
  self : Client,
  request : CreateRequest,
) -> EsResponse[CreateResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_create/{id}", ["index", "id"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct DanglingIndicesDeleteDanglingIndexQuery {
  accept_data_loss : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for DanglingIndicesDeleteDanglingIndexQuery with fn to_json(
  self : DanglingIndicesDeleteDanglingIndexQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.accept_data_loss {
    Some(value) => obj["accept_data_loss"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DanglingIndicesDeleteDanglingIndexQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "DanglingIndicesDeleteDanglingIndexQuery: expected object"),
    )
  }
  {
    accept_data_loss: match obj.get("accept_data_loss") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("accept_data_loss")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn DanglingIndicesDeleteDanglingIndexQuery::new(
  accept_data_loss? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> DanglingIndicesDeleteDanglingIndexQuery {
  { accept_data_loss, master_timeout, timeout }
}

///|
pub fn DanglingIndicesDeleteDanglingIndexQuery::to_pairs(
  self : DanglingIndicesDeleteDanglingIndexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.accept_data_loss {
    Some(value) => push_query_json(pairs, "accept_data_loss", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type DanglingIndicesDeleteDanglingIndexResponse = Json

///|
pub(all) struct DanglingIndicesDeleteDanglingIndexRequest {
  index_uuid : String
  query : DanglingIndicesDeleteDanglingIndexQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DanglingIndicesDeleteDanglingIndexRequest::new(
  index_uuid : String,
  query? : DanglingIndicesDeleteDanglingIndexQuery = DanglingIndicesDeleteDanglingIndexQuery::new(),
) -> DanglingIndicesDeleteDanglingIndexRequest {
  { index_uuid, query }
}

///|
pub async fn Client::dangling_indices_delete_dangling_index(
  self : Client,
  request : DanglingIndicesDeleteDanglingIndexRequest,
) -> EsResponse[DanglingIndicesDeleteDanglingIndexResponse] {
  let params : Map[String, String] = Map([])
  params["index_uuid"] = request.index_uuid
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_dangling/{index_uuid}", ["index_uuid"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct DanglingIndicesImportDanglingIndexQuery {
  accept_data_loss : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for DanglingIndicesImportDanglingIndexQuery with fn to_json(
  self : DanglingIndicesImportDanglingIndexQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.accept_data_loss {
    Some(value) => obj["accept_data_loss"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DanglingIndicesImportDanglingIndexQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "DanglingIndicesImportDanglingIndexQuery: expected object"),
    )
  }
  {
    accept_data_loss: match obj.get("accept_data_loss") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("accept_data_loss")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn DanglingIndicesImportDanglingIndexQuery::new(
  accept_data_loss? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> DanglingIndicesImportDanglingIndexQuery {
  { accept_data_loss, master_timeout, timeout }
}

///|
pub fn DanglingIndicesImportDanglingIndexQuery::to_pairs(
  self : DanglingIndicesImportDanglingIndexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.accept_data_loss {
    Some(value) => push_query_json(pairs, "accept_data_loss", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type DanglingIndicesImportDanglingIndexResponse = Json

///|
pub(all) struct DanglingIndicesImportDanglingIndexRequest {
  index_uuid : String
  query : DanglingIndicesImportDanglingIndexQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DanglingIndicesImportDanglingIndexRequest::new(
  index_uuid : String,
  query? : DanglingIndicesImportDanglingIndexQuery = DanglingIndicesImportDanglingIndexQuery::new(),
) -> DanglingIndicesImportDanglingIndexRequest {
  { index_uuid, query }
}

///|
pub async fn Client::dangling_indices_import_dangling_index(
  self : Client,
  request : DanglingIndicesImportDanglingIndexRequest,
) -> EsResponse[DanglingIndicesImportDanglingIndexResponse] {
  let params : Map[String, String] = Map([])
  params["index_uuid"] = request.index_uuid
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_dangling/{index_uuid}", ["index_uuid"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct DanglingIndicesListDanglingIndicesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for DanglingIndicesListDanglingIndicesQuery with fn to_json(
  _self : DanglingIndicesListDanglingIndicesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for DanglingIndicesListDanglingIndicesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "DanglingIndicesListDanglingIndicesQuery: expected object"),
    )
  }
  DanglingIndicesListDanglingIndicesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn DanglingIndicesListDanglingIndicesQuery::new() -> DanglingIndicesListDanglingIndicesQuery {
  DanglingIndicesListDanglingIndicesQuery::{  }
}

///|
pub fn DanglingIndicesListDanglingIndicesQuery::to_pairs(
  _self : DanglingIndicesListDanglingIndicesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct DanglingIndicesListDanglingIndicesResponse {
  dangling_indices : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for DanglingIndicesListDanglingIndicesResponse with fn to_json(
  self : DanglingIndicesListDanglingIndicesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["dangling_indices"] = self.dangling_indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for DanglingIndicesListDanglingIndicesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "DanglingIndicesListDanglingIndicesResponse: expected object"),
    )
  }
  {
    dangling_indices: @json.from_json(
      obj.get("dangling_indices").unwrap_or(Json::null()),
      path=path.add_key("dangling_indices"),
    ),
  }
}

///|
pub(all) struct DanglingIndicesListDanglingIndicesRequest {
  query : DanglingIndicesListDanglingIndicesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DanglingIndicesListDanglingIndicesRequest::new(
  query? : DanglingIndicesListDanglingIndicesQuery = DanglingIndicesListDanglingIndicesQuery::new(),
) -> DanglingIndicesListDanglingIndicesRequest {
  { query, }
}

///|
pub async fn Client::dangling_indices_list_dangling_indices(
  self : Client,
  request : DanglingIndicesListDanglingIndicesRequest,
) -> EsResponse[DanglingIndicesListDanglingIndicesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_dangling", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct DeleteQuery {
  if_primary_term : Int?
  if_seq_no : String?
  refresh : String?
  routing : String?
  timeout : String?
  version : String?
  version_type : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for DeleteQuery with fn to_json(self : DeleteQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.if_primary_term {
    Some(value) => obj["if_primary_term"] = value.to_json()
    None => ()
  }
  match self.if_seq_no {
    Some(value) => obj["if_seq_no"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DeleteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "DeleteQuery: expected object"))
  }
  {
    if_primary_term: match obj.get("if_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_primary_term")))
    },
    if_seq_no: match obj.get("if_seq_no") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_seq_no")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn DeleteQuery::new(
  if_primary_term? : Int,
  if_seq_no? : String,
  refresh? : String,
  routing? : String,
  timeout? : String,
  version? : String,
  version_type? : String,
  wait_for_active_shards? : String,
) -> DeleteQuery {
  {
    if_primary_term,
    if_seq_no,
    refresh,
    routing,
    timeout,
    version,
    version_type,
    wait_for_active_shards,
  }
}

///|
pub fn DeleteQuery::to_pairs(self : DeleteQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.if_primary_term {
    Some(value) => push_query_json(pairs, "if_primary_term", value.to_json())
    None => ()
  }
  match self.if_seq_no {
    Some(value) => push_query_json(pairs, "if_seq_no", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type DeleteResponse = Json

///|
pub(all) struct DeleteRequest {
  index : String
  id : String
  query : DeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DeleteRequest::new(
  index : String,
  id : String,
  query? : DeleteQuery = DeleteQuery::new(),
) -> DeleteRequest {
  { index, id, query }
}

///|
pub async fn Client::delete(
  self : Client,
  request : DeleteRequest,
) -> EsResponse[DeleteResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_doc/{id}", ["index", "id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct DeleteByQueryQuery {
  allow_no_indices : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  conflicts : String?
  default_operator : String?
  df : String?
  expand_wildcards : String?
  from : Int?
  ignore_unavailable : Bool?
  lenient : Bool?
  max_docs : Int?
  preference : String?
  refresh : Bool?
  request_cache : Bool?
  requests_per_second : Double?
  routing : String?
  q : String?
  scroll : String?
  scroll_size : Int?
  search_timeout : String?
  search_type : String?
  slices : String?
  sort : Array[String]?
  stats : Array[String]?
  terminate_after : Int?
  timeout : String?
  version : Bool?
  wait_for_active_shards : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for DeleteByQueryQuery with fn to_json(
  self : DeleteByQueryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.conflicts {
    Some(value) => obj["conflicts"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.max_docs {
    Some(value) => obj["max_docs"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.request_cache {
    Some(value) => obj["request_cache"] = value.to_json()
    None => ()
  }
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.scroll_size {
    Some(value) => obj["scroll_size"] = value.to_json()
    None => ()
  }
  match self.search_timeout {
    Some(value) => obj["search_timeout"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.slices {
    Some(value) => obj["slices"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DeleteByQueryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "DeleteByQueryQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    conflicts: match obj.get("conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("conflicts")))
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    max_docs: match obj.get("max_docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("max_docs")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    request_cache: match obj.get("request_cache") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("request_cache")))
    },
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    scroll_size: match obj.get("scroll_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("scroll_size")))
    },
    search_timeout: match obj.get("search_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_timeout")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    slices: match obj.get("slices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slices")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn DeleteByQueryQuery::new(
  allow_no_indices? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  conflicts? : String,
  default_operator? : String,
  df? : String,
  expand_wildcards? : String,
  from? : Int,
  ignore_unavailable? : Bool,
  lenient? : Bool,
  max_docs? : Int,
  preference? : String,
  refresh? : Bool,
  request_cache? : Bool,
  requests_per_second? : Double,
  routing? : String,
  q? : String,
  scroll? : String,
  scroll_size? : Int,
  search_timeout? : String,
  search_type? : String,
  slices? : String,
  sort? : Array[String],
  stats? : Array[String],
  terminate_after? : Int,
  timeout? : String,
  version? : Bool,
  wait_for_active_shards? : String,
  wait_for_completion? : Bool,
) -> DeleteByQueryQuery {
  {
    allow_no_indices,
    analyzer,
    analyze_wildcard,
    conflicts,
    default_operator,
    df,
    expand_wildcards,
    from,
    ignore_unavailable,
    lenient,
    max_docs,
    preference,
    refresh,
    request_cache,
    requests_per_second,
    routing,
    q,
    scroll,
    scroll_size,
    search_timeout,
    search_type,
    slices,
    sort,
    stats,
    terminate_after,
    timeout,
    version,
    wait_for_active_shards,
    wait_for_completion,
  }
}

///|
pub fn DeleteByQueryQuery::to_pairs(
  self : DeleteByQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.conflicts {
    Some(value) => push_query_json(pairs, "conflicts", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.max_docs {
    Some(value) => push_query_json(pairs, "max_docs", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.request_cache {
    Some(value) => push_query_json(pairs, "request_cache", value.to_json())
    None => ()
  }
  match self.requests_per_second {
    Some(value) =>
      push_query_json(pairs, "requests_per_second", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.scroll_size {
    Some(value) => push_query_json(pairs, "scroll_size", value.to_json())
    None => ()
  }
  match self.search_timeout {
    Some(value) => push_query_json(pairs, "search_timeout", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.slices {
    Some(value) => push_query_json(pairs, "slices", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.stats {
    Some(value) => push_query_json(pairs, "stats", value.to_json())
    None => ()
  }
  match self.terminate_after {
    Some(value) => push_query_json(pairs, "terminate_after", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct DeleteByQueryBody {
  max_docs : Int?
  query : Json?
  slice : Json?
  sort : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for DeleteByQueryBody with fn to_json(self : DeleteByQueryBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.max_docs {
    Some(value) => obj["max_docs"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.slice {
    Some(value) => obj["slice"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DeleteByQueryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "DeleteByQueryBody: expected object"))
  }
  {
    max_docs: match obj.get("max_docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("max_docs")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    slice: match obj.get("slice") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
  }
}

///|
pub fn DeleteByQueryBody::new(
  max_docs? : Int,
  query? : Json,
  slice? : Json,
  sort? : Json,
) -> DeleteByQueryBody {
  { max_docs, query, slice, sort }
}

///|
pub(all) struct DeleteByQueryResponse {
  batches : Int?
  deleted : Int?
  failures : Array[Json]?
  noops : Int?
  requests_per_second : Double?
  retries : Json?
  slice_id : Int?
  slices : Array[Json]?
  task : Json?
  throttled : Json?
  throttled_millis : Json?
  throttled_until : Json?
  throttled_until_millis : Json?
  timed_out : Bool?
  took : Json?
  total : Int?
  version_conflicts : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for DeleteByQueryResponse with fn to_json(
  self : DeleteByQueryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.batches {
    Some(value) => obj["batches"] = value.to_json()
    None => ()
  }
  match self.deleted {
    Some(value) => obj["deleted"] = value.to_json()
    None => ()
  }
  match self.failures {
    Some(value) => obj["failures"] = value.to_json()
    None => ()
  }
  match self.noops {
    Some(value) => obj["noops"] = value.to_json()
    None => ()
  }
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.retries {
    Some(value) => obj["retries"] = value.to_json()
    None => ()
  }
  match self.slice_id {
    Some(value) => obj["slice_id"] = value.to_json()
    None => ()
  }
  match self.slices {
    Some(value) => obj["slices"] = value.to_json()
    None => ()
  }
  match self.task {
    Some(value) => obj["task"] = value.to_json()
    None => ()
  }
  match self.throttled {
    Some(value) => obj["throttled"] = value.to_json()
    None => ()
  }
  match self.throttled_millis {
    Some(value) => obj["throttled_millis"] = value.to_json()
    None => ()
  }
  match self.throttled_until {
    Some(value) => obj["throttled_until"] = value.to_json()
    None => ()
  }
  match self.throttled_until_millis {
    Some(value) => obj["throttled_until_millis"] = value.to_json()
    None => ()
  }
  match self.timed_out {
    Some(value) => obj["timed_out"] = value.to_json()
    None => ()
  }
  match self.took {
    Some(value) => obj["took"] = value.to_json()
    None => ()
  }
  match self.total {
    Some(value) => obj["total"] = value.to_json()
    None => ()
  }
  match self.version_conflicts {
    Some(value) => obj["version_conflicts"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DeleteByQueryResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "DeleteByQueryResponse: expected object"))
  }
  {
    batches: match obj.get("batches") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("batches")))
    },
    deleted: match obj.get("deleted") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("deleted")))
    },
    failures: match obj.get("failures") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("failures")))
    },
    noops: match obj.get("noops") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("noops")))
    },
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    retries: match obj.get("retries") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("retries")))
    },
    slice_id: match obj.get("slice_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice_id")))
    },
    slices: match obj.get("slices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slices")))
    },
    task: match obj.get("task") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("task")))
    },
    throttled: match obj.get("throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled")))
    },
    throttled_millis: match obj.get("throttled_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled_millis")))
    },
    throttled_until: match obj.get("throttled_until") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled_until")))
    },
    throttled_until_millis: match obj.get("throttled_until_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("throttled_until_millis")),
        )
    },
    timed_out: match obj.get("timed_out") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timed_out")))
    },
    took: match obj.get("took") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("took")))
    },
    total: match obj.get("total") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("total")))
    },
    version_conflicts: match obj.get("version_conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_conflicts")))
    },
  }
}

///|
pub(all) struct DeleteByQueryRequest {
  index : String
  query : DeleteByQueryQuery
  body : DeleteByQueryBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DeleteByQueryRequest::new(
  index : String,
  body : DeleteByQueryBody,
  query? : DeleteByQueryQuery = DeleteByQueryQuery::new(),
) -> DeleteByQueryRequest {
  { index, query, body }
}

///|
pub async fn Client::delete_by_query(
  self : Client,
  request : DeleteByQueryRequest,
) -> EsResponse[DeleteByQueryResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_delete_by_query", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct DeleteByQueryRethrottleQuery {
  requests_per_second : Double
} derive(Eq, Debug)

///|
pub impl ToJson for DeleteByQueryRethrottleQuery with fn to_json(
  self : DeleteByQueryRethrottleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["requests_per_second"] = self.requests_per_second.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for DeleteByQueryRethrottleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "DeleteByQueryRethrottleQuery: expected object"),
    )
  }
  {
    requests_per_second: @json.from_json(
      obj.get("requests_per_second").unwrap_or(Json::null()),
      path=path.add_key("requests_per_second"),
    ),
  }
}

///|
pub fn DeleteByQueryRethrottleQuery::new(
  requests_per_second : Double,
) -> DeleteByQueryRethrottleQuery {
  { requests_per_second, }
}

///|
pub fn DeleteByQueryRethrottleQuery::to_pairs(
  self : DeleteByQueryRethrottleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  push_query_json(
    pairs,
    "requests_per_second",
    self.requests_per_second.to_json(),
  )
  pairs
}

///|
pub type DeleteByQueryRethrottleResponse = Json

///|
pub(all) struct DeleteByQueryRethrottleRequest {
  task_id : String
  query : DeleteByQueryRethrottleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DeleteByQueryRethrottleRequest::new(
  task_id : String,
  query : DeleteByQueryRethrottleQuery,
) -> DeleteByQueryRethrottleRequest {
  { task_id, query }
}

///|
pub async fn Client::delete_by_query_rethrottle(
  self : Client,
  request : DeleteByQueryRethrottleRequest,
) -> EsResponse[DeleteByQueryRethrottleResponse] {
  let params : Map[String, String] = Map([])
  params["task_id"] = request.task_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_delete_by_query/{task_id}/_rethrottle", ["task_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct DeleteScriptQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for DeleteScriptQuery with fn to_json(self : DeleteScriptQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for DeleteScriptQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "DeleteScriptQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn DeleteScriptQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> DeleteScriptQuery {
  { master_timeout, timeout }
}

///|
pub fn DeleteScriptQuery::to_pairs(
  self : DeleteScriptQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type DeleteScriptResponse = Json

///|
pub(all) struct DeleteScriptRequest {
  id : String
  query : DeleteScriptQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn DeleteScriptRequest::new(
  id : String,
  query? : DeleteScriptQuery = DeleteScriptQuery::new(),
) -> DeleteScriptRequest {
  { id, query }
}

///|
pub async fn Client::delete_script(
  self : Client,
  request : DeleteScriptRequest,
) -> EsResponse[DeleteScriptResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_scripts/{id}", ["id"])], params)
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct EnrichDeletePolicyQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichDeletePolicyQuery with fn to_json(
  self : EnrichDeletePolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichDeletePolicyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichDeletePolicyQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn EnrichDeletePolicyQuery::new(
  master_timeout? : String,
) -> EnrichDeletePolicyQuery {
  { master_timeout, }
}

///|
pub fn EnrichDeletePolicyQuery::to_pairs(
  self : EnrichDeletePolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type EnrichDeletePolicyResponse = Json

///|
pub(all) struct EnrichDeletePolicyRequest {
  name : String
  query : EnrichDeletePolicyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EnrichDeletePolicyRequest::new(
  name : String,
  query? : EnrichDeletePolicyQuery = EnrichDeletePolicyQuery::new(),
) -> EnrichDeletePolicyRequest {
  { name, query }
}

///|
pub async fn Client::enrich_delete_policy(
  self : Client,
  request : EnrichDeletePolicyRequest,
) -> EsResponse[EnrichDeletePolicyResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_enrich/policy/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct EnrichExecutePolicyQuery {
  master_timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichExecutePolicyQuery with fn to_json(
  self : EnrichExecutePolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichExecutePolicyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichExecutePolicyQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn EnrichExecutePolicyQuery::new(
  master_timeout? : String,
  wait_for_completion? : Bool,
) -> EnrichExecutePolicyQuery {
  { master_timeout, wait_for_completion }
}

///|
pub fn EnrichExecutePolicyQuery::to_pairs(
  self : EnrichExecutePolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EnrichExecutePolicyResponse {
  status : Json?
  task : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichExecutePolicyResponse with fn to_json(
  self : EnrichExecutePolicyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  match self.task {
    Some(value) => obj["task"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichExecutePolicyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "EnrichExecutePolicyResponse: expected object"),
    )
  }
  {
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
    task: match obj.get("task") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("task")))
    },
  }
}

///|
pub(all) struct EnrichExecutePolicyRequest {
  name : String
  query : EnrichExecutePolicyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EnrichExecutePolicyRequest::new(
  name : String,
  query? : EnrichExecutePolicyQuery = EnrichExecutePolicyQuery::new(),
) -> EnrichExecutePolicyRequest {
  { name, query }
}

///|
pub async fn Client::enrich_execute_policy(
  self : Client,
  request : EnrichExecutePolicyRequest,
) -> EsResponse[EnrichExecutePolicyResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_enrich/policy/{name}/_execute", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct EnrichGetPolicyQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichGetPolicyQuery with fn to_json(
  self : EnrichGetPolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichGetPolicyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichGetPolicyQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn EnrichGetPolicyQuery::new(
  master_timeout? : String,
) -> EnrichGetPolicyQuery {
  { master_timeout, }
}

///|
pub fn EnrichGetPolicyQuery::to_pairs(
  self : EnrichGetPolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EnrichGetPolicyResponse {
  policies : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichGetPolicyResponse with fn to_json(
  self : EnrichGetPolicyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["policies"] = self.policies.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for EnrichGetPolicyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichGetPolicyResponse: expected object"))
  }
  {
    policies: @json.from_json(
      obj.get("policies").unwrap_or(Json::null()),
      path=path.add_key("policies"),
    ),
  }
}

///|
pub(all) struct EnrichGetPolicyRequest {
  name : String?
  query : EnrichGetPolicyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EnrichGetPolicyRequest::new(
  name? : String,
  query? : EnrichGetPolicyQuery = EnrichGetPolicyQuery::new(),
) -> EnrichGetPolicyRequest {
  { name, query }
}

///|
pub async fn Client::enrich_get_policy(
  self : Client,
  request : EnrichGetPolicyRequest,
) -> EsResponse[EnrichGetPolicyResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_enrich/policy/{name}", ["name"]),
      PathVariant::new("/_enrich/policy", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct EnrichPutPolicyQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichPutPolicyQuery with fn to_json(
  self : EnrichPutPolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichPutPolicyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichPutPolicyQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn EnrichPutPolicyQuery::new(
  master_timeout? : String,
) -> EnrichPutPolicyQuery {
  { master_timeout, }
}

///|
pub fn EnrichPutPolicyQuery::to_pairs(
  self : EnrichPutPolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EnrichPutPolicyBody {
  geo_match : Json?
  match_ : Json?
  range : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichPutPolicyBody with fn to_json(
  self : EnrichPutPolicyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.geo_match {
    Some(value) => obj["geo_match"] = value.to_json()
    None => ()
  }
  match self.match_ {
    Some(value) => obj["match"] = value.to_json()
    None => ()
  }
  match self.range {
    Some(value) => obj["range"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichPutPolicyBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichPutPolicyBody: expected object"))
  }
  {
    geo_match: match obj.get("geo_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("geo_match")))
    },
    match_: match obj.get("match") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("match")))
    },
    range: match obj.get("range") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("range")))
    },
  }
}

///|
pub fn EnrichPutPolicyBody::new(
  geo_match? : Json,
  match_? : Json,
  range? : Json,
) -> EnrichPutPolicyBody {
  { geo_match, match_, range }
}

///|
pub type EnrichPutPolicyResponse = Json

///|
pub(all) struct EnrichPutPolicyRequest {
  name : String
  query : EnrichPutPolicyQuery
  body : EnrichPutPolicyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EnrichPutPolicyRequest::new(
  name : String,
  body : EnrichPutPolicyBody,
  query? : EnrichPutPolicyQuery = EnrichPutPolicyQuery::new(),
) -> EnrichPutPolicyRequest {
  { name, query, body }
}

///|
pub async fn Client::enrich_put_policy(
  self : Client,
  request : EnrichPutPolicyRequest,
) -> EsResponse[EnrichPutPolicyResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_enrich/policy/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct EnrichStatsQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichStatsQuery with fn to_json(self : EnrichStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichStatsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn EnrichStatsQuery::new(master_timeout? : String) -> EnrichStatsQuery {
  { master_timeout, }
}

///|
pub fn EnrichStatsQuery::to_pairs(
  self : EnrichStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EnrichStatsResponse {
  coordinator_stats : Array[Json]
  executing_policies : Array[Json]
  cache_stats : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for EnrichStatsResponse with fn to_json(
  self : EnrichStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["coordinator_stats"] = self.coordinator_stats.to_json()
  obj["executing_policies"] = self.executing_policies.to_json()
  match self.cache_stats {
    Some(value) => obj["cache_stats"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EnrichStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EnrichStatsResponse: expected object"))
  }
  {
    coordinator_stats: @json.from_json(
      obj.get("coordinator_stats").unwrap_or(Json::null()),
      path=path.add_key("coordinator_stats"),
    ),
    executing_policies: @json.from_json(
      obj.get("executing_policies").unwrap_or(Json::null()),
      path=path.add_key("executing_policies"),
    ),
    cache_stats: match obj.get("cache_stats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("cache_stats")))
    },
  }
}

///|
pub(all) struct EnrichStatsRequest {
  query : EnrichStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EnrichStatsRequest::new(
  query? : EnrichStatsQuery = EnrichStatsQuery::new(),
) -> EnrichStatsRequest {
  { query, }
}

///|
pub async fn Client::enrich_stats(
  self : Client,
  request : EnrichStatsRequest,
) -> EsResponse[EnrichStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_enrich/_stats", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct EqlDeleteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EqlDeleteQuery with fn to_json(_self : EqlDeleteQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EqlDeleteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EqlDeleteQuery: expected object"))
  }
  EqlDeleteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EqlDeleteQuery::new() -> EqlDeleteQuery {
  EqlDeleteQuery::{  }
}

///|
pub fn EqlDeleteQuery::to_pairs(
  _self : EqlDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type EqlDeleteResponse = Json

///|
pub(all) struct EqlDeleteRequest {
  id : String
  query : EqlDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EqlDeleteRequest::new(
  id : String,
  query? : EqlDeleteQuery = EqlDeleteQuery::new(),
) -> EqlDeleteRequest {
  { id, query }
}

///|
pub async fn Client::eql_delete(
  self : Client,
  request : EqlDeleteRequest,
) -> EsResponse[EqlDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_eql/search/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct EqlGetQuery {
  keep_alive : String?
  wait_for_completion_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EqlGetQuery with fn to_json(self : EqlGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EqlGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EqlGetQuery: expected object"))
  }
  {
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
  }
}

///|
pub fn EqlGetQuery::new(
  keep_alive? : String,
  wait_for_completion_timeout? : String,
) -> EqlGetQuery {
  { keep_alive, wait_for_completion_timeout }
}

///|
pub fn EqlGetQuery::to_pairs(self : EqlGetQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type EqlGetResponse = Json

///|
pub(all) struct EqlGetRequest {
  id : String
  query : EqlGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EqlGetRequest::new(
  id : String,
  query? : EqlGetQuery = EqlGetQuery::new(),
) -> EqlGetRequest {
  { id, query }
}

///|
pub async fn Client::eql_get(
  self : Client,
  request : EqlGetRequest,
) -> EsResponse[EqlGetResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_eql/search/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct EqlGetStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EqlGetStatusQuery with fn to_json(_self : EqlGetStatusQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EqlGetStatusQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EqlGetStatusQuery: expected object"))
  }
  EqlGetStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EqlGetStatusQuery::new() -> EqlGetStatusQuery {
  EqlGetStatusQuery::{  }
}

///|
pub fn EqlGetStatusQuery::to_pairs(
  _self : EqlGetStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct EqlGetStatusResponse {
  id : Json
  is_partial : Bool
  is_running : Bool
  start_time_in_millis : Json?
  expiration_time_in_millis : Json?
  completion_status : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for EqlGetStatusResponse with fn to_json(
  self : EqlGetStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  obj["is_partial"] = self.is_partial.to_json()
  obj["is_running"] = self.is_running.to_json()
  match self.start_time_in_millis {
    Some(value) => obj["start_time_in_millis"] = value.to_json()
    None => ()
  }
  match self.expiration_time_in_millis {
    Some(value) => obj["expiration_time_in_millis"] = value.to_json()
    None => ()
  }
  match self.completion_status {
    Some(value) => obj["completion_status"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EqlGetStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EqlGetStatusResponse: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    is_partial: @json.from_json(
      obj.get("is_partial").unwrap_or(Json::null()),
      path=path.add_key("is_partial"),
    ),
    is_running: @json.from_json(
      obj.get("is_running").unwrap_or(Json::null()),
      path=path.add_key("is_running"),
    ),
    start_time_in_millis: match obj.get("start_time_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("start_time_in_millis")))
    },
    expiration_time_in_millis: match obj.get("expiration_time_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("expiration_time_in_millis")),
        )
    },
    completion_status: match obj.get("completion_status") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("completion_status")))
    },
  }
}

///|
pub(all) struct EqlGetStatusRequest {
  id : String
  query : EqlGetStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EqlGetStatusRequest::new(
  id : String,
  query? : EqlGetStatusQuery = EqlGetStatusQuery::new(),
) -> EqlGetStatusRequest {
  { id, query }
}

///|
pub async fn Client::eql_get_status(
  self : Client,
  request : EqlGetStatusRequest,
) -> EsResponse[EqlGetStatusResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_eql/search/status/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct EqlSearchQuery {
  allow_no_indices : Bool?
  allow_partial_search_results : Bool?
  allow_partial_sequence_results : Bool?
  expand_wildcards : String?
  ccs_minimize_roundtrips : Bool?
  ignore_unavailable : Bool?
  keep_alive : String?
  keep_on_completion : Bool?
  wait_for_completion_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EqlSearchQuery with fn to_json(self : EqlSearchQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  match self.allow_partial_sequence_results {
    Some(value) => obj["allow_partial_sequence_results"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => obj["keep_on_completion"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EqlSearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EqlSearchQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
    allow_partial_sequence_results: match
      obj.get("allow_partial_sequence_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_sequence_results"),
          ),
        )
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    keep_on_completion: match obj.get("keep_on_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_on_completion")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
  }
}

///|
pub fn EqlSearchQuery::new(
  allow_no_indices? : Bool,
  allow_partial_search_results? : Bool,
  allow_partial_sequence_results? : Bool,
  expand_wildcards? : String,
  ccs_minimize_roundtrips? : Bool,
  ignore_unavailable? : Bool,
  keep_alive? : String,
  keep_on_completion? : Bool,
  wait_for_completion_timeout? : String,
) -> EqlSearchQuery {
  {
    allow_no_indices,
    allow_partial_search_results,
    allow_partial_sequence_results,
    expand_wildcards,
    ccs_minimize_roundtrips,
    ignore_unavailable,
    keep_alive,
    keep_on_completion,
    wait_for_completion_timeout,
  }
}

///|
pub fn EqlSearchQuery::to_pairs(
  self : EqlSearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_search_results", value.to_json())
    None => ()
  }
  match self.allow_partial_sequence_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_sequence_results", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => push_query_json(pairs, "keep_on_completion", value.to_json())
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EqlSearchBody {
  project_routing : Json?
  query : String
  case_sensitive : Bool?
  event_category_field : Json?
  tiebreaker_field : Json?
  timestamp_field : Json?
  fetch_size : Json?
  filter : Json?
  keep_alive : Json?
  keep_on_completion : Bool?
  wait_for_completion_timeout : Json?
  allow_partial_search_results : Bool?
  allow_partial_sequence_results : Bool?
  size : Json?
  fields : Json?
  result_position : Json?
  runtime_mappings : Json?
  max_samples_per_key : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for EqlSearchBody with fn to_json(self : EqlSearchBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  obj["query"] = self.query.to_json()
  match self.case_sensitive {
    Some(value) => obj["case_sensitive"] = value.to_json()
    None => ()
  }
  match self.event_category_field {
    Some(value) => obj["event_category_field"] = value.to_json()
    None => ()
  }
  match self.tiebreaker_field {
    Some(value) => obj["tiebreaker_field"] = value.to_json()
    None => ()
  }
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  match self.fetch_size {
    Some(value) => obj["fetch_size"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => obj["keep_on_completion"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  match self.allow_partial_sequence_results {
    Some(value) => obj["allow_partial_sequence_results"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.result_position {
    Some(value) => obj["result_position"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.max_samples_per_key {
    Some(value) => obj["max_samples_per_key"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EqlSearchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EqlSearchBody: expected object"))
  }
  {
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    case_sensitive: match obj.get("case_sensitive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("case_sensitive")))
    },
    event_category_field: match obj.get("event_category_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("event_category_field")))
    },
    tiebreaker_field: match obj.get("tiebreaker_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("tiebreaker_field")))
    },
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
    fetch_size: match obj.get("fetch_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("fetch_size")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    keep_on_completion: match obj.get("keep_on_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_on_completion")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
    allow_partial_sequence_results: match
      obj.get("allow_partial_sequence_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_sequence_results"),
          ),
        )
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    result_position: match obj.get("result_position") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("result_position")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    max_samples_per_key: match obj.get("max_samples_per_key") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_samples_per_key")))
    },
  }
}

///|
pub fn EqlSearchBody::new(
  query : String,
  project_routing? : Json,
  case_sensitive? : Bool,
  event_category_field? : Json,
  tiebreaker_field? : Json,
  timestamp_field? : Json,
  fetch_size? : Json,
  filter? : Json,
  keep_alive? : Json,
  keep_on_completion? : Bool,
  wait_for_completion_timeout? : Json,
  allow_partial_search_results? : Bool,
  allow_partial_sequence_results? : Bool,
  size? : Json,
  fields? : Json,
  result_position? : Json,
  runtime_mappings? : Json,
  max_samples_per_key? : Int,
) -> EqlSearchBody {
  {
    project_routing,
    query,
    case_sensitive,
    event_category_field,
    tiebreaker_field,
    timestamp_field,
    fetch_size,
    filter,
    keep_alive,
    keep_on_completion,
    wait_for_completion_timeout,
    allow_partial_search_results,
    allow_partial_sequence_results,
    size,
    fields,
    result_position,
    runtime_mappings,
    max_samples_per_key,
  }
}

///|
pub type EqlSearchResponse = Json

///|
pub(all) struct EqlSearchRequest {
  index : String
  query : EqlSearchQuery
  body : EqlSearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EqlSearchRequest::new(
  index : String,
  body : EqlSearchBody,
  query? : EqlSearchQuery = EqlSearchQuery::new(),
) -> EqlSearchRequest {
  { index, query, body }
}

///|
pub async fn Client::eql_search(
  self : Client,
  request : EqlSearchRequest,
) -> EsResponse[EqlSearchResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_eql/search", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct EsqlAsyncQueryQuery {
  allow_partial_results : Bool?
  delimiter : String?
  drop_null_columns : Bool?
  format : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlAsyncQueryQuery with fn to_json(
  self : EsqlAsyncQueryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_partial_results {
    Some(value) => obj["allow_partial_results"] = value.to_json()
    None => ()
  }
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  match self.drop_null_columns {
    Some(value) => obj["drop_null_columns"] = value.to_json()
    None => ()
  }
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EsqlAsyncQueryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlAsyncQueryQuery: expected object"))
  }
  {
    allow_partial_results: match obj.get("allow_partial_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_partial_results")))
    },
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    drop_null_columns: match obj.get("drop_null_columns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("drop_null_columns")))
    },
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
  }
}

///|
pub fn EsqlAsyncQueryQuery::new(
  allow_partial_results? : Bool,
  delimiter? : String,
  drop_null_columns? : Bool,
  format? : String,
) -> EsqlAsyncQueryQuery {
  { allow_partial_results, delimiter, drop_null_columns, format }
}

///|
pub fn EsqlAsyncQueryQuery::to_pairs(
  self : EsqlAsyncQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_partial_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_results", value.to_json())
    None => ()
  }
  match self.delimiter {
    Some(value) => push_query_json(pairs, "delimiter", value.to_json())
    None => ()
  }
  match self.drop_null_columns {
    Some(value) => push_query_json(pairs, "drop_null_columns", value.to_json())
    None => ()
  }
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EsqlAsyncQueryBody {
  columnar : Bool?
  filter : Json?
  time_zone : String?
  locale : String?
  params : Json?
  profile : Bool?
  query : String
  tables : Map[String, Json]?
  include_ccs_metadata : Bool?
  include_execution_metadata : Bool?
  wait_for_completion_timeout : Json?
  keep_alive : Json?
  keep_on_completion : Bool?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlAsyncQueryBody with fn to_json(
  self : EsqlAsyncQueryBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.columnar {
    Some(value) => obj["columnar"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.time_zone {
    Some(value) => obj["time_zone"] = value.to_json()
    None => ()
  }
  match self.locale {
    Some(value) => obj["locale"] = value.to_json()
    None => ()
  }
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  obj["query"] = self.query.to_json()
  match self.tables {
    Some(value) => obj["tables"] = value.to_json()
    None => ()
  }
  match self.include_ccs_metadata {
    Some(value) => obj["include_ccs_metadata"] = value.to_json()
    None => ()
  }
  match self.include_execution_metadata {
    Some(value) => obj["include_execution_metadata"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => obj["keep_on_completion"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EsqlAsyncQueryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlAsyncQueryBody: expected object"))
  }
  {
    columnar: match obj.get("columnar") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("columnar")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    time_zone: match obj.get("time_zone") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("time_zone")))
    },
    locale: match obj.get("locale") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("locale")))
    },
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    tables: match obj.get("tables") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("tables")))
    },
    include_ccs_metadata: match obj.get("include_ccs_metadata") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_ccs_metadata")))
    },
    include_execution_metadata: match obj.get("include_execution_metadata") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("include_execution_metadata"),
          ),
        )
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    keep_on_completion: match obj.get("keep_on_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_on_completion")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn EsqlAsyncQueryBody::new(
  query : String,
  columnar? : Bool,
  filter? : Json,
  time_zone? : String,
  locale? : String,
  params? : Json,
  profile? : Bool,
  tables? : Map[String, Json],
  include_ccs_metadata? : Bool,
  include_execution_metadata? : Bool,
  wait_for_completion_timeout? : Json,
  keep_alive? : Json,
  keep_on_completion? : Bool,
  project_routing? : Json,
) -> EsqlAsyncQueryBody {
  {
    columnar,
    filter,
    time_zone,
    locale,
    params,
    profile,
    query,
    tables,
    include_ccs_metadata,
    include_execution_metadata,
    wait_for_completion_timeout,
    keep_alive,
    keep_on_completion,
    project_routing,
  }
}

///|
pub type EsqlAsyncQueryResponse = Json

///|
pub(all) struct EsqlAsyncQueryRequest {
  query : EsqlAsyncQueryQuery
  body : EsqlAsyncQueryBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlAsyncQueryRequest::new(
  body : EsqlAsyncQueryBody,
  query? : EsqlAsyncQueryQuery = EsqlAsyncQueryQuery::new(),
) -> EsqlAsyncQueryRequest {
  { query, body }
}

///|
pub async fn Client::esql_async_query(
  self : Client,
  request : EsqlAsyncQueryRequest,
) -> EsResponse[EsqlAsyncQueryResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_query/async", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct EsqlAsyncQueryDeleteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EsqlAsyncQueryDeleteQuery with fn to_json(
  _self : EsqlAsyncQueryDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EsqlAsyncQueryDeleteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EsqlAsyncQueryDeleteQuery: expected object"))
  }
  EsqlAsyncQueryDeleteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EsqlAsyncQueryDeleteQuery::new() -> EsqlAsyncQueryDeleteQuery {
  EsqlAsyncQueryDeleteQuery::{  }
}

///|
pub fn EsqlAsyncQueryDeleteQuery::to_pairs(
  _self : EsqlAsyncQueryDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type EsqlAsyncQueryDeleteResponse = Json

///|
pub(all) struct EsqlAsyncQueryDeleteRequest {
  id : String
  query : EsqlAsyncQueryDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlAsyncQueryDeleteRequest::new(
  id : String,
  query? : EsqlAsyncQueryDeleteQuery = EsqlAsyncQueryDeleteQuery::new(),
) -> EsqlAsyncQueryDeleteRequest {
  { id, query }
}

///|
pub async fn Client::esql_async_query_delete(
  self : Client,
  request : EsqlAsyncQueryDeleteRequest,
) -> EsResponse[EsqlAsyncQueryDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query/async/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct EsqlAsyncQueryGetQuery {
  drop_null_columns : Bool?
  format : String?
  keep_alive : String?
  wait_for_completion_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlAsyncQueryGetQuery with fn to_json(
  self : EsqlAsyncQueryGetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.drop_null_columns {
    Some(value) => obj["drop_null_columns"] = value.to_json()
    None => ()
  }
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EsqlAsyncQueryGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlAsyncQueryGetQuery: expected object"))
  }
  {
    drop_null_columns: match obj.get("drop_null_columns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("drop_null_columns")))
    },
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
  }
}

///|
pub fn EsqlAsyncQueryGetQuery::new(
  drop_null_columns? : Bool,
  format? : String,
  keep_alive? : String,
  wait_for_completion_timeout? : String,
) -> EsqlAsyncQueryGetQuery {
  { drop_null_columns, format, keep_alive, wait_for_completion_timeout }
}

///|
pub fn EsqlAsyncQueryGetQuery::to_pairs(
  self : EsqlAsyncQueryGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.drop_null_columns {
    Some(value) => push_query_json(pairs, "drop_null_columns", value.to_json())
    None => ()
  }
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type EsqlAsyncQueryGetResponse = Json

///|
pub(all) struct EsqlAsyncQueryGetRequest {
  id : String
  query : EsqlAsyncQueryGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlAsyncQueryGetRequest::new(
  id : String,
  query? : EsqlAsyncQueryGetQuery = EsqlAsyncQueryGetQuery::new(),
) -> EsqlAsyncQueryGetRequest {
  { id, query }
}

///|
pub async fn Client::esql_async_query_get(
  self : Client,
  request : EsqlAsyncQueryGetRequest,
) -> EsResponse[EsqlAsyncQueryGetResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query/async/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct EsqlAsyncQueryStopQuery {
  drop_null_columns : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlAsyncQueryStopQuery with fn to_json(
  self : EsqlAsyncQueryStopQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.drop_null_columns {
    Some(value) => obj["drop_null_columns"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EsqlAsyncQueryStopQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlAsyncQueryStopQuery: expected object"))
  }
  {
    drop_null_columns: match obj.get("drop_null_columns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("drop_null_columns")))
    },
  }
}

///|
pub fn EsqlAsyncQueryStopQuery::new(
  drop_null_columns? : Bool,
) -> EsqlAsyncQueryStopQuery {
  { drop_null_columns, }
}

///|
pub fn EsqlAsyncQueryStopQuery::to_pairs(
  self : EsqlAsyncQueryStopQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.drop_null_columns {
    Some(value) => push_query_json(pairs, "drop_null_columns", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type EsqlAsyncQueryStopResponse = Json

///|
pub(all) struct EsqlAsyncQueryStopRequest {
  id : String
  query : EsqlAsyncQueryStopQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlAsyncQueryStopRequest::new(
  id : String,
  query? : EsqlAsyncQueryStopQuery = EsqlAsyncQueryStopQuery::new(),
) -> EsqlAsyncQueryStopRequest {
  { id, query }
}

///|
pub async fn Client::esql_async_query_stop(
  self : Client,
  request : EsqlAsyncQueryStopRequest,
) -> EsResponse[EsqlAsyncQueryStopResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query/async/{id}/stop", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct EsqlDeleteViewQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EsqlDeleteViewQuery with fn to_json(
  _self : EsqlDeleteViewQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EsqlDeleteViewQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EsqlDeleteViewQuery: expected object"))
  }
  EsqlDeleteViewQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EsqlDeleteViewQuery::new() -> EsqlDeleteViewQuery {
  EsqlDeleteViewQuery::{  }
}

///|
pub fn EsqlDeleteViewQuery::to_pairs(
  _self : EsqlDeleteViewQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type EsqlDeleteViewBody = Json

///|
pub type EsqlDeleteViewResponse = Json

///|
pub(all) struct EsqlDeleteViewRequest {
  name : String
  query : EsqlDeleteViewQuery
  body : EsqlDeleteViewBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlDeleteViewRequest::new(
  name : String,
  query? : EsqlDeleteViewQuery = EsqlDeleteViewQuery::new(),
  body? : EsqlDeleteViewBody,
) -> EsqlDeleteViewRequest {
  { name, query, body }
}

///|
pub async fn Client::esql_delete_view(
  self : Client,
  request : EsqlDeleteViewRequest,
) -> EsResponse[EsqlDeleteViewResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query/view/{name}", ["name"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct EsqlGetQueryQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EsqlGetQueryQuery with fn to_json(_self : EsqlGetQueryQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EsqlGetQueryQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EsqlGetQueryQuery: expected object"))
  }
  EsqlGetQueryQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EsqlGetQueryQuery::new() -> EsqlGetQueryQuery {
  EsqlGetQueryQuery::{  }
}

///|
pub fn EsqlGetQueryQuery::to_pairs(
  _self : EsqlGetQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type EsqlGetQueryBody = Json

///|
pub(all) struct EsqlGetQueryResponse {
  id : Int
  node : Json
  start_time_millis : Int
  running_time_nanos : Int
  query : String
  coordinating_node : Json
  data_nodes : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlGetQueryResponse with fn to_json(
  self : EsqlGetQueryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  obj["node"] = self.node.to_json()
  obj["start_time_millis"] = self.start_time_millis.to_json()
  obj["running_time_nanos"] = self.running_time_nanos.to_json()
  obj["query"] = self.query.to_json()
  obj["coordinating_node"] = self.coordinating_node.to_json()
  obj["data_nodes"] = self.data_nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for EsqlGetQueryResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlGetQueryResponse: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    node: @json.from_json(
      obj.get("node").unwrap_or(Json::null()),
      path=path.add_key("node"),
    ),
    start_time_millis: @json.from_json(
      obj.get("start_time_millis").unwrap_or(Json::null()),
      path=path.add_key("start_time_millis"),
    ),
    running_time_nanos: @json.from_json(
      obj.get("running_time_nanos").unwrap_or(Json::null()),
      path=path.add_key("running_time_nanos"),
    ),
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    coordinating_node: @json.from_json(
      obj.get("coordinating_node").unwrap_or(Json::null()),
      path=path.add_key("coordinating_node"),
    ),
    data_nodes: @json.from_json(
      obj.get("data_nodes").unwrap_or(Json::null()),
      path=path.add_key("data_nodes"),
    ),
  }
}

///|
pub(all) struct EsqlGetQueryRequest {
  id : String
  query : EsqlGetQueryQuery
  body : EsqlGetQueryBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlGetQueryRequest::new(
  id : String,
  query? : EsqlGetQueryQuery = EsqlGetQueryQuery::new(),
  body? : EsqlGetQueryBody,
) -> EsqlGetQueryRequest {
  { id, query, body }
}

///|
pub async fn Client::esql_get_query(
  self : Client,
  request : EsqlGetQueryRequest,
) -> EsResponse[EsqlGetQueryResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query/queries/{id}", ["id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct EsqlGetViewQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EsqlGetViewQuery with fn to_json(_self : EsqlGetViewQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EsqlGetViewQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EsqlGetViewQuery: expected object"))
  }
  EsqlGetViewQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EsqlGetViewQuery::new() -> EsqlGetViewQuery {
  EsqlGetViewQuery::{  }
}

///|
pub fn EsqlGetViewQuery::to_pairs(
  _self : EsqlGetViewQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type EsqlGetViewBody = Json

///|
pub(all) struct EsqlGetViewResponse {
  views : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlGetViewResponse with fn to_json(
  self : EsqlGetViewResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["views"] = self.views.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for EsqlGetViewResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlGetViewResponse: expected object"))
  }
  {
    views: @json.from_json(
      obj.get("views").unwrap_or(Json::null()),
      path=path.add_key("views"),
    ),
  }
}

///|
pub(all) struct EsqlGetViewRequest {
  name : String?
  query : EsqlGetViewQuery
  body : EsqlGetViewBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlGetViewRequest::new(
  name? : String,
  query? : EsqlGetViewQuery = EsqlGetViewQuery::new(),
  body? : EsqlGetViewBody,
) -> EsqlGetViewRequest {
  { name, query, body }
}

///|
pub async fn Client::esql_get_view(
  self : Client,
  request : EsqlGetViewRequest,
) -> EsResponse[EsqlGetViewResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_query/view/{name}", ["name"]),
      PathVariant::new("/_query/view", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct EsqlListQueriesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EsqlListQueriesQuery with fn to_json(
  _self : EsqlListQueriesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EsqlListQueriesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EsqlListQueriesQuery: expected object"))
  }
  EsqlListQueriesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EsqlListQueriesQuery::new() -> EsqlListQueriesQuery {
  EsqlListQueriesQuery::{  }
}

///|
pub fn EsqlListQueriesQuery::to_pairs(
  _self : EsqlListQueriesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type EsqlListQueriesBody = Json

///|
pub(all) struct EsqlListQueriesResponse {
  queries : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlListQueriesResponse with fn to_json(
  self : EsqlListQueriesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["queries"] = self.queries.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for EsqlListQueriesResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlListQueriesResponse: expected object"))
  }
  {
    queries: @json.from_json(
      obj.get("queries").unwrap_or(Json::null()),
      path=path.add_key("queries"),
    ),
  }
}

///|
pub(all) struct EsqlListQueriesRequest {
  query : EsqlListQueriesQuery
  body : EsqlListQueriesBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlListQueriesRequest::new(
  query? : EsqlListQueriesQuery = EsqlListQueriesQuery::new(),
  body? : EsqlListQueriesBody,
) -> EsqlListQueriesRequest {
  { query, body }
}

///|
pub async fn Client::esql_list_queries(
  self : Client,
  request : EsqlListQueriesRequest,
) -> EsResponse[EsqlListQueriesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_query/queries", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct EsqlPutViewQuery {} derive(Eq, Debug)

///|
pub impl ToJson for EsqlPutViewQuery with fn to_json(_self : EsqlPutViewQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for EsqlPutViewQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "EsqlPutViewQuery: expected object"))
  }
  EsqlPutViewQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn EsqlPutViewQuery::new() -> EsqlPutViewQuery {
  EsqlPutViewQuery::{  }
}

///|
pub fn EsqlPutViewQuery::to_pairs(
  _self : EsqlPutViewQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct EsqlPutViewBody {
  query : String
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlPutViewBody with fn to_json(self : EsqlPutViewBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["query"] = self.query.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for EsqlPutViewBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlPutViewBody: expected object"))
  }
  {
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
  }
}

///|
pub fn EsqlPutViewBody::new(query : String) -> EsqlPutViewBody {
  { query, }
}

///|
pub type EsqlPutViewResponse = Json

///|
pub(all) struct EsqlPutViewRequest {
  name : String
  query : EsqlPutViewQuery
  body : EsqlPutViewBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlPutViewRequest::new(
  name : String,
  body : EsqlPutViewBody,
  query? : EsqlPutViewQuery = EsqlPutViewQuery::new(),
) -> EsqlPutViewRequest {
  { name, query, body }
}

///|
pub async fn Client::esql_put_view(
  self : Client,
  request : EsqlPutViewRequest,
) -> EsResponse[EsqlPutViewResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query/view/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct EsqlQueryQuery {
  format : String?
  delimiter : String?
  drop_null_columns : Bool?
  allow_partial_results : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlQueryQuery with fn to_json(self : EsqlQueryQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  match self.drop_null_columns {
    Some(value) => obj["drop_null_columns"] = value.to_json()
    None => ()
  }
  match self.allow_partial_results {
    Some(value) => obj["allow_partial_results"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EsqlQueryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlQueryQuery: expected object"))
  }
  {
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    drop_null_columns: match obj.get("drop_null_columns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("drop_null_columns")))
    },
    allow_partial_results: match obj.get("allow_partial_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_partial_results")))
    },
  }
}

///|
pub fn EsqlQueryQuery::new(
  format? : String,
  delimiter? : String,
  drop_null_columns? : Bool,
  allow_partial_results? : Bool,
) -> EsqlQueryQuery {
  { format, delimiter, drop_null_columns, allow_partial_results }
}

///|
pub fn EsqlQueryQuery::to_pairs(
  self : EsqlQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  match self.delimiter {
    Some(value) => push_query_json(pairs, "delimiter", value.to_json())
    None => ()
  }
  match self.drop_null_columns {
    Some(value) => push_query_json(pairs, "drop_null_columns", value.to_json())
    None => ()
  }
  match self.allow_partial_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_results", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct EsqlQueryBody {
  columnar : Bool?
  filter : Json?
  time_zone : String?
  locale : String?
  params : Json?
  profile : Bool?
  query : String
  tables : Map[String, Json]?
  include_ccs_metadata : Bool?
  include_execution_metadata : Bool?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for EsqlQueryBody with fn to_json(self : EsqlQueryBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.columnar {
    Some(value) => obj["columnar"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.time_zone {
    Some(value) => obj["time_zone"] = value.to_json()
    None => ()
  }
  match self.locale {
    Some(value) => obj["locale"] = value.to_json()
    None => ()
  }
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  obj["query"] = self.query.to_json()
  match self.tables {
    Some(value) => obj["tables"] = value.to_json()
    None => ()
  }
  match self.include_ccs_metadata {
    Some(value) => obj["include_ccs_metadata"] = value.to_json()
    None => ()
  }
  match self.include_execution_metadata {
    Some(value) => obj["include_execution_metadata"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for EsqlQueryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "EsqlQueryBody: expected object"))
  }
  {
    columnar: match obj.get("columnar") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("columnar")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    time_zone: match obj.get("time_zone") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("time_zone")))
    },
    locale: match obj.get("locale") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("locale")))
    },
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    tables: match obj.get("tables") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("tables")))
    },
    include_ccs_metadata: match obj.get("include_ccs_metadata") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_ccs_metadata")))
    },
    include_execution_metadata: match obj.get("include_execution_metadata") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("include_execution_metadata"),
          ),
        )
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn EsqlQueryBody::new(
  query : String,
  columnar? : Bool,
  filter? : Json,
  time_zone? : String,
  locale? : String,
  params? : Json,
  profile? : Bool,
  tables? : Map[String, Json],
  include_ccs_metadata? : Bool,
  include_execution_metadata? : Bool,
  project_routing? : Json,
) -> EsqlQueryBody {
  {
    columnar,
    filter,
    time_zone,
    locale,
    params,
    profile,
    query,
    tables,
    include_ccs_metadata,
    include_execution_metadata,
    project_routing,
  }
}

///|
pub type EsqlQueryResponse = Json

///|
pub(all) struct EsqlQueryRequest {
  query : EsqlQueryQuery
  body : EsqlQueryBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn EsqlQueryRequest::new(
  body : EsqlQueryBody,
  query? : EsqlQueryQuery = EsqlQueryQuery::new(),
) -> EsqlQueryRequest {
  { query, body }
}

///|
pub async fn Client::esql_query(
  self : Client,
  request : EsqlQueryRequest,
) -> EsResponse[EsqlQueryResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_query", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ExistsQuery {
  preference : String?
  realtime : Bool?
  refresh : Bool?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  stored_fields : String?
  version : String?
  version_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ExistsQuery with fn to_json(self : ExistsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ExistsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ExistsQuery: expected object"))
  }
  {
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn ExistsQuery::new(
  preference? : String,
  realtime? : Bool,
  refresh? : Bool,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  stored_fields? : String,
  version? : String,
  version_type? : String,
) -> ExistsQuery {
  {
    preference,
    realtime,
    refresh,
    routing,
    _source,
    _source_excludes,
    _source_includes,
    stored_fields,
    version,
    version_type,
  }
}

///|
pub fn ExistsQuery::to_pairs(self : ExistsQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ExistsResponse = Json

///|
pub(all) struct ExistsRequest {
  index : String
  id : String
  query : ExistsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ExistsRequest::new(
  index : String,
  id : String,
  query? : ExistsQuery = ExistsQuery::new(),
) -> ExistsRequest {
  { index, id, query }
}

///|
pub async fn Client::exists(
  self : Client,
  request : ExistsRequest,
) -> EsResponse[ExistsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_doc/{id}", ["index", "id"])],
    params,
  )
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct ExistsSourceQuery {
  preference : String?
  realtime : Bool?
  refresh : Bool?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  version : String?
  version_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ExistsSourceQuery with fn to_json(self : ExistsSourceQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ExistsSourceQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ExistsSourceQuery: expected object"))
  }
  {
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn ExistsSourceQuery::new(
  preference? : String,
  realtime? : Bool,
  refresh? : Bool,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  version? : String,
  version_type? : String,
) -> ExistsSourceQuery {
  {
    preference,
    realtime,
    refresh,
    routing,
    _source,
    _source_excludes,
    _source_includes,
    version,
    version_type,
  }
}

///|
pub fn ExistsSourceQuery::to_pairs(
  self : ExistsSourceQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ExistsSourceResponse = Json

///|
pub(all) struct ExistsSourceRequest {
  index : String
  id : String
  query : ExistsSourceQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ExistsSourceRequest::new(
  index : String,
  id : String,
  query? : ExistsSourceQuery = ExistsSourceQuery::new(),
) -> ExistsSourceRequest {
  { index, id, query }
}

///|
pub async fn Client::exists_source(
  self : Client,
  request : ExistsSourceRequest,
) -> EsResponse[ExistsSourceResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_source/{id}", ["index", "id"])],
    params,
  )
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct ExplainQuery {
  analyzer : String?
  analyze_wildcard : Bool?
  default_operator : String?
  df : String?
  lenient : Bool?
  preference : String?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  stored_fields : String?
  q : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ExplainQuery with fn to_json(self : ExplainQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ExplainQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ExplainQuery: expected object"))
  }
  {
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
  }
}

///|
pub fn ExplainQuery::new(
  analyzer? : String,
  analyze_wildcard? : Bool,
  default_operator? : String,
  df? : String,
  lenient? : Bool,
  preference? : String,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  stored_fields? : String,
  q? : String,
) -> ExplainQuery {
  {
    analyzer,
    analyze_wildcard,
    default_operator,
    df,
    lenient,
    preference,
    routing,
    _source,
    _source_excludes,
    _source_includes,
    stored_fields,
    q,
  }
}

///|
pub fn ExplainQuery::to_pairs(self : ExplainQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ExplainBody {
  query : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ExplainBody with fn to_json(self : ExplainBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ExplainBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ExplainBody: expected object"))
  }
  {
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
  }
}

///|
pub fn ExplainBody::new(query? : Json) -> ExplainBody {
  { query, }
}

///|
pub(all) struct ExplainResponse {
  _index : Json
  _id : Json
  matched : Bool
  explanation : Json?
  get : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ExplainResponse with fn to_json(self : ExplainResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_index"] = self._index.to_json()
  obj["_id"] = self._id.to_json()
  obj["matched"] = self.matched.to_json()
  match self.explanation {
    Some(value) => obj["explanation"] = value.to_json()
    None => ()
  }
  match self.get {
    Some(value) => obj["get"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ExplainResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ExplainResponse: expected object"))
  }
  {
    _index: @json.from_json(
      obj.get("_index").unwrap_or(Json::null()),
      path=path.add_key("_index"),
    ),
    _id: @json.from_json(
      obj.get("_id").unwrap_or(Json::null()),
      path=path.add_key("_id"),
    ),
    matched: @json.from_json(
      obj.get("matched").unwrap_or(Json::null()),
      path=path.add_key("matched"),
    ),
    explanation: match obj.get("explanation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("explanation")))
    },
    get: match obj.get("get") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("get")))
    },
  }
}

///|
pub(all) struct ExplainRequest {
  index : String
  id : String
  query : ExplainQuery
  body : ExplainBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ExplainRequest::new(
  index : String,
  id : String,
  query? : ExplainQuery = ExplainQuery::new(),
  body? : ExplainBody,
) -> ExplainRequest {
  { index, id, query, body }
}

///|
pub async fn Client::explain(
  self : Client,
  request : ExplainRequest,
) -> EsResponse[ExplainResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_explain/{id}", ["index", "id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct FeaturesGetFeaturesQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for FeaturesGetFeaturesQuery with fn to_json(
  self : FeaturesGetFeaturesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FeaturesGetFeaturesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FeaturesGetFeaturesQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn FeaturesGetFeaturesQuery::new(
  master_timeout? : String,
) -> FeaturesGetFeaturesQuery {
  { master_timeout, }
}

///|
pub fn FeaturesGetFeaturesQuery::to_pairs(
  self : FeaturesGetFeaturesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct FeaturesGetFeaturesResponse {
  features : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for FeaturesGetFeaturesResponse with fn to_json(
  self : FeaturesGetFeaturesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["features"] = self.features.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FeaturesGetFeaturesResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "FeaturesGetFeaturesResponse: expected object"),
    )
  }
  {
    features: @json.from_json(
      obj.get("features").unwrap_or(Json::null()),
      path=path.add_key("features"),
    ),
  }
}

///|
pub(all) struct FeaturesGetFeaturesRequest {
  query : FeaturesGetFeaturesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FeaturesGetFeaturesRequest::new(
  query? : FeaturesGetFeaturesQuery = FeaturesGetFeaturesQuery::new(),
) -> FeaturesGetFeaturesRequest {
  { query, }
}

///|
pub async fn Client::features_get_features(
  self : Client,
  request : FeaturesGetFeaturesRequest,
) -> EsResponse[FeaturesGetFeaturesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_features", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct FeaturesResetFeaturesQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for FeaturesResetFeaturesQuery with fn to_json(
  self : FeaturesResetFeaturesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FeaturesResetFeaturesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FeaturesResetFeaturesQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn FeaturesResetFeaturesQuery::new(
  master_timeout? : String,
) -> FeaturesResetFeaturesQuery {
  { master_timeout, }
}

///|
pub fn FeaturesResetFeaturesQuery::to_pairs(
  self : FeaturesResetFeaturesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct FeaturesResetFeaturesResponse {
  features : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for FeaturesResetFeaturesResponse with fn to_json(
  self : FeaturesResetFeaturesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["features"] = self.features.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FeaturesResetFeaturesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "FeaturesResetFeaturesResponse: expected object"),
    )
  }
  {
    features: @json.from_json(
      obj.get("features").unwrap_or(Json::null()),
      path=path.add_key("features"),
    ),
  }
}

///|
pub(all) struct FeaturesResetFeaturesRequest {
  query : FeaturesResetFeaturesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FeaturesResetFeaturesRequest::new(
  query? : FeaturesResetFeaturesQuery = FeaturesResetFeaturesQuery::new(),
) -> FeaturesResetFeaturesRequest {
  { query, }
}

///|
pub async fn Client::features_reset_features(
  self : Client,
  request : FeaturesResetFeaturesRequest,
) -> EsResponse[FeaturesResetFeaturesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_features/_reset", [])], params)
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct FieldCapsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  fields : String?
  ignore_unavailable : Bool?
  include_unmapped : Bool?
  filters : Json?
  types : Array[String]?
  include_empty_fields : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for FieldCapsQuery with fn to_json(self : FieldCapsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_unmapped {
    Some(value) => obj["include_unmapped"] = value.to_json()
    None => ()
  }
  match self.filters {
    Some(value) => obj["filters"] = value.to_json()
    None => ()
  }
  match self.types {
    Some(value) => obj["types"] = value.to_json()
    None => ()
  }
  match self.include_empty_fields {
    Some(value) => obj["include_empty_fields"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FieldCapsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FieldCapsQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_unmapped: match obj.get("include_unmapped") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_unmapped")))
    },
    filters: match obj.get("filters") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filters")))
    },
    types: match obj.get("types") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("types")))
    },
    include_empty_fields: match obj.get("include_empty_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_empty_fields")))
    },
  }
}

///|
pub fn FieldCapsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  fields? : String,
  ignore_unavailable? : Bool,
  include_unmapped? : Bool,
  filters? : Json,
  types? : Array[String],
  include_empty_fields? : Bool,
) -> FieldCapsQuery {
  {
    allow_no_indices,
    expand_wildcards,
    fields,
    ignore_unavailable,
    include_unmapped,
    filters,
    types,
    include_empty_fields,
  }
}

///|
pub fn FieldCapsQuery::to_pairs(
  self : FieldCapsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_unmapped {
    Some(value) => push_query_json(pairs, "include_unmapped", value.to_json())
    None => ()
  }
  match self.filters {
    Some(value) => push_query_json(pairs, "filters", value.to_json())
    None => ()
  }
  match self.types {
    Some(value) => push_query_json(pairs, "types", value.to_json())
    None => ()
  }
  match self.include_empty_fields {
    Some(value) =>
      push_query_json(pairs, "include_empty_fields", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct FieldCapsBody {
  fields : Json?
  index_filter : Json?
  runtime_mappings : Json?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for FieldCapsBody with fn to_json(self : FieldCapsBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.index_filter {
    Some(value) => obj["index_filter"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FieldCapsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FieldCapsBody: expected object"))
  }
  {
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    index_filter: match obj.get("index_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_filter")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn FieldCapsBody::new(
  fields? : Json,
  index_filter? : Json,
  runtime_mappings? : Json,
  project_routing? : Json,
) -> FieldCapsBody {
  { fields, index_filter, runtime_mappings, project_routing }
}

///|
pub(all) struct FieldCapsResponse {
  indices : Json
  fields : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for FieldCapsResponse with fn to_json(self : FieldCapsResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  obj["fields"] = self.fields.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FieldCapsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FieldCapsResponse: expected object"))
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    fields: @json.from_json(
      obj.get("fields").unwrap_or(Json::null()),
      path=path.add_key("fields"),
    ),
  }
}

///|
pub(all) struct FieldCapsRequest {
  index : String?
  query : FieldCapsQuery
  body : FieldCapsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FieldCapsRequest::new(
  index? : String,
  query? : FieldCapsQuery = FieldCapsQuery::new(),
  body? : FieldCapsBody,
) -> FieldCapsRequest {
  { index, query, body }
}

///|
pub async fn Client::field_caps(
  self : Client,
  request : FieldCapsRequest,
) -> EsResponse[FieldCapsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_field_caps", ["index"]),
      PathVariant::new("/_field_caps", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct FleetDeleteSecretQuery {} derive(Eq, Debug)

///|
pub impl ToJson for FleetDeleteSecretQuery with fn to_json(
  _self : FleetDeleteSecretQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for FleetDeleteSecretQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "FleetDeleteSecretQuery: expected object"))
  }
  FleetDeleteSecretQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn FleetDeleteSecretQuery::new() -> FleetDeleteSecretQuery {
  FleetDeleteSecretQuery::{  }
}

///|
pub fn FleetDeleteSecretQuery::to_pairs(
  _self : FleetDeleteSecretQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct FleetDeleteSecretResponse {
  deleted : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for FleetDeleteSecretResponse with fn to_json(
  self : FleetDeleteSecretResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["deleted"] = self.deleted.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FleetDeleteSecretResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetDeleteSecretResponse: expected object"))
  }
  {
    deleted: @json.from_json(
      obj.get("deleted").unwrap_or(Json::null()),
      path=path.add_key("deleted"),
    ),
  }
}

///|
pub(all) struct FleetDeleteSecretRequest {
  id : String
  query : FleetDeleteSecretQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FleetDeleteSecretRequest::new(
  id : String,
  query? : FleetDeleteSecretQuery = FleetDeleteSecretQuery::new(),
) -> FleetDeleteSecretRequest {
  { id, query }
}

///|
pub async fn Client::fleet_delete_secret(
  self : Client,
  request : FleetDeleteSecretRequest,
) -> EsResponse[FleetDeleteSecretResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_fleet/secret/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct FleetGetSecretQuery {} derive(Eq, Debug)

///|
pub impl ToJson for FleetGetSecretQuery with fn to_json(
  _self : FleetGetSecretQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for FleetGetSecretQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "FleetGetSecretQuery: expected object"))
  }
  FleetGetSecretQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn FleetGetSecretQuery::new() -> FleetGetSecretQuery {
  FleetGetSecretQuery::{  }
}

///|
pub fn FleetGetSecretQuery::to_pairs(
  _self : FleetGetSecretQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct FleetGetSecretResponse {
  id : String
  value : String
} derive(Eq, Debug)

///|
pub impl ToJson for FleetGetSecretResponse with fn to_json(
  self : FleetGetSecretResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  obj["value"] = self.value.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FleetGetSecretResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetGetSecretResponse: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    value: @json.from_json(
      obj.get("value").unwrap_or(Json::null()),
      path=path.add_key("value"),
    ),
  }
}

///|
pub(all) struct FleetGetSecretRequest {
  id : String
  query : FleetGetSecretQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FleetGetSecretRequest::new(
  id : String,
  query? : FleetGetSecretQuery = FleetGetSecretQuery::new(),
) -> FleetGetSecretRequest {
  { id, query }
}

///|
pub async fn Client::fleet_get_secret(
  self : Client,
  request : FleetGetSecretRequest,
) -> EsResponse[FleetGetSecretResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_fleet/secret/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct FleetGlobalCheckpointsQuery {
  wait_for_advance : Bool?
  wait_for_index : Bool?
  checkpoints : Array[String]?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for FleetGlobalCheckpointsQuery with fn to_json(
  self : FleetGlobalCheckpointsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.wait_for_advance {
    Some(value) => obj["wait_for_advance"] = value.to_json()
    None => ()
  }
  match self.wait_for_index {
    Some(value) => obj["wait_for_index"] = value.to_json()
    None => ()
  }
  match self.checkpoints {
    Some(value) => obj["checkpoints"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FleetGlobalCheckpointsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "FleetGlobalCheckpointsQuery: expected object"),
    )
  }
  {
    wait_for_advance: match obj.get("wait_for_advance") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_advance")))
    },
    wait_for_index: match obj.get("wait_for_index") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_index")))
    },
    checkpoints: match obj.get("checkpoints") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("checkpoints")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn FleetGlobalCheckpointsQuery::new(
  wait_for_advance? : Bool,
  wait_for_index? : Bool,
  checkpoints? : Array[String],
  timeout? : String,
) -> FleetGlobalCheckpointsQuery {
  { wait_for_advance, wait_for_index, checkpoints, timeout }
}

///|
pub fn FleetGlobalCheckpointsQuery::to_pairs(
  self : FleetGlobalCheckpointsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.wait_for_advance {
    Some(value) => push_query_json(pairs, "wait_for_advance", value.to_json())
    None => ()
  }
  match self.wait_for_index {
    Some(value) => push_query_json(pairs, "wait_for_index", value.to_json())
    None => ()
  }
  match self.checkpoints {
    Some(value) => push_query_json(pairs, "checkpoints", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type FleetGlobalCheckpointsBody = Json

///|
pub(all) struct FleetGlobalCheckpointsResponse {
  global_checkpoints : Array[Json]
  timed_out : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for FleetGlobalCheckpointsResponse with fn to_json(
  self : FleetGlobalCheckpointsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["global_checkpoints"] = self.global_checkpoints.to_json()
  obj["timed_out"] = self.timed_out.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FleetGlobalCheckpointsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "FleetGlobalCheckpointsResponse: expected object"),
    )
  }
  {
    global_checkpoints: @json.from_json(
      obj.get("global_checkpoints").unwrap_or(Json::null()),
      path=path.add_key("global_checkpoints"),
    ),
    timed_out: @json.from_json(
      obj.get("timed_out").unwrap_or(Json::null()),
      path=path.add_key("timed_out"),
    ),
  }
}

///|
pub(all) struct FleetGlobalCheckpointsRequest {
  index : String
  query : FleetGlobalCheckpointsQuery
  body : FleetGlobalCheckpointsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FleetGlobalCheckpointsRequest::new(
  index : String,
  query? : FleetGlobalCheckpointsQuery = FleetGlobalCheckpointsQuery::new(),
  body? : FleetGlobalCheckpointsBody,
) -> FleetGlobalCheckpointsRequest {
  { index, query, body }
}

///|
pub async fn Client::fleet_global_checkpoints(
  self : Client,
  request : FleetGlobalCheckpointsRequest,
) -> EsResponse[FleetGlobalCheckpointsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_fleet/global_checkpoints", ["index"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct FleetMsearchQuery {
  allow_no_indices : Bool?
  ccs_minimize_roundtrips : Bool?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  max_concurrent_searches : Int?
  max_concurrent_shard_requests : Int?
  pre_filter_shard_size : Int?
  search_type : String?
  rest_total_hits_as_int : Bool?
  typed_keys : Bool?
  wait_for_checkpoints : Array[String]?
  allow_partial_search_results : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for FleetMsearchQuery with fn to_json(self : FleetMsearchQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_searches {
    Some(value) => obj["max_concurrent_searches"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) => obj["max_concurrent_shard_requests"] = value.to_json()
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) => obj["pre_filter_shard_size"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  match self.wait_for_checkpoints {
    Some(value) => obj["wait_for_checkpoints"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FleetMsearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetMsearchQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    max_concurrent_searches: match obj.get("max_concurrent_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_concurrent_searches")),
        )
    },
    max_concurrent_shard_requests: match
      obj.get("max_concurrent_shard_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_concurrent_shard_requests"),
          ),
        )
    },
    pre_filter_shard_size: match obj.get("pre_filter_shard_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("pre_filter_shard_size")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
    wait_for_checkpoints: match obj.get("wait_for_checkpoints") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_checkpoints")))
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
  }
}

///|
pub fn FleetMsearchQuery::new(
  allow_no_indices? : Bool,
  ccs_minimize_roundtrips? : Bool,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  max_concurrent_searches? : Int,
  max_concurrent_shard_requests? : Int,
  pre_filter_shard_size? : Int,
  search_type? : String,
  rest_total_hits_as_int? : Bool,
  typed_keys? : Bool,
  wait_for_checkpoints? : Array[String],
  allow_partial_search_results? : Bool,
) -> FleetMsearchQuery {
  {
    allow_no_indices,
    ccs_minimize_roundtrips,
    expand_wildcards,
    ignore_throttled,
    ignore_unavailable,
    max_concurrent_searches,
    max_concurrent_shard_requests,
    pre_filter_shard_size,
    search_type,
    rest_total_hits_as_int,
    typed_keys,
    wait_for_checkpoints,
    allow_partial_search_results,
  }
}

///|
pub fn FleetMsearchQuery::to_pairs(
  self : FleetMsearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.max_concurrent_searches {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_searches", value.to_json())
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_shard_requests", value.to_json())
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) =>
      push_query_json(pairs, "pre_filter_shard_size", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  match self.wait_for_checkpoints {
    Some(value) =>
      push_query_json(pairs, "wait_for_checkpoints", value.to_json())
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_search_results", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type FleetMsearchBody = Array[Json]

///|
pub(all) struct FleetMsearchResponse {
  docs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for FleetMsearchResponse with fn to_json(
  self : FleetMsearchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FleetMsearchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetMsearchResponse: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
  }
}

///|
pub(all) struct FleetMsearchRequest {
  index : String?
  query : FleetMsearchQuery
  body : FleetMsearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FleetMsearchRequest::new(
  body : FleetMsearchBody,
  index? : String,
  query? : FleetMsearchQuery = FleetMsearchQuery::new(),
) -> FleetMsearchRequest {
  { index, query, body }
}

///|
pub async fn Client::fleet_msearch(
  self : Client,
  request : FleetMsearchRequest,
) -> EsResponse[FleetMsearchResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_fleet/_fleet_msearch", ["index"]),
      PathVariant::new("/_fleet/_fleet_msearch", []),
    ],
    params,
  )
  let body = Ndjson(request.body)
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct FleetPostSecretQuery {} derive(Eq, Debug)

///|
pub impl ToJson for FleetPostSecretQuery with fn to_json(
  _self : FleetPostSecretQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for FleetPostSecretQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "FleetPostSecretQuery: expected object"))
  }
  FleetPostSecretQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn FleetPostSecretQuery::new() -> FleetPostSecretQuery {
  FleetPostSecretQuery::{  }
}

///|
pub fn FleetPostSecretQuery::to_pairs(
  _self : FleetPostSecretQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct FleetPostSecretResponse {
  id : String
} derive(Eq, Debug)

///|
pub impl ToJson for FleetPostSecretResponse with fn to_json(
  self : FleetPostSecretResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for FleetPostSecretResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetPostSecretResponse: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub(all) struct FleetPostSecretRequest {
  query : FleetPostSecretQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FleetPostSecretRequest::new(
  query? : FleetPostSecretQuery = FleetPostSecretQuery::new(),
) -> FleetPostSecretRequest {
  { query, }
}

///|
pub async fn Client::fleet_post_secret(
  self : Client,
  request : FleetPostSecretRequest,
) -> EsResponse[FleetPostSecretResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_fleet/secret", [])], params)
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct FleetSearchQuery {
  allow_no_indices : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  batched_reduce_size : Int?
  ccs_minimize_roundtrips : Bool?
  default_operator : String?
  df : String?
  docvalue_fields : String?
  expand_wildcards : String?
  explain : Bool?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  lenient : Bool?
  max_concurrent_shard_requests : Int?
  preference : String?
  pre_filter_shard_size : Int?
  request_cache : Bool?
  routing : String?
  scroll : String?
  search_type : String?
  stats : Array[String]?
  stored_fields : String?
  suggest_field : String?
  suggest_mode : String?
  suggest_size : Int?
  suggest_text : String?
  terminate_after : Int?
  timeout : String?
  track_total_hits : String?
  track_scores : Bool?
  typed_keys : Bool?
  rest_total_hits_as_int : Bool?
  version : Bool?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  seq_no_primary_term : Bool?
  q : String?
  size : Int?
  from : Int?
  sort : Json?
  wait_for_checkpoints : Array[String]?
  allow_partial_search_results : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for FleetSearchQuery with fn to_json(self : FleetSearchQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.batched_reduce_size {
    Some(value) => obj["batched_reduce_size"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) => obj["max_concurrent_shard_requests"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) => obj["pre_filter_shard_size"] = value.to_json()
    None => ()
  }
  match self.request_cache {
    Some(value) => obj["request_cache"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.suggest_field {
    Some(value) => obj["suggest_field"] = value.to_json()
    None => ()
  }
  match self.suggest_mode {
    Some(value) => obj["suggest_mode"] = value.to_json()
    None => ()
  }
  match self.suggest_size {
    Some(value) => obj["suggest_size"] = value.to_json()
    None => ()
  }
  match self.suggest_text {
    Some(value) => obj["suggest_text"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.track_scores {
    Some(value) => obj["track_scores"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) => obj["seq_no_primary_term"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.wait_for_checkpoints {
    Some(value) => obj["wait_for_checkpoints"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FleetSearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetSearchQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    batched_reduce_size: match obj.get("batched_reduce_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("batched_reduce_size")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    max_concurrent_shard_requests: match
      obj.get("max_concurrent_shard_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_concurrent_shard_requests"),
          ),
        )
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    pre_filter_shard_size: match obj.get("pre_filter_shard_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("pre_filter_shard_size")))
    },
    request_cache: match obj.get("request_cache") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("request_cache")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    suggest_field: match obj.get("suggest_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_field")))
    },
    suggest_mode: match obj.get("suggest_mode") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_mode")))
    },
    suggest_size: match obj.get("suggest_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_size")))
    },
    suggest_text: match obj.get("suggest_text") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_text")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    track_scores: match obj.get("track_scores") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_scores")))
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    seq_no_primary_term: match obj.get("seq_no_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("seq_no_primary_term")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    wait_for_checkpoints: match obj.get("wait_for_checkpoints") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_checkpoints")))
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
  }
}

///|
pub fn FleetSearchQuery::new(
  allow_no_indices? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  batched_reduce_size? : Int,
  ccs_minimize_roundtrips? : Bool,
  default_operator? : String,
  df? : String,
  docvalue_fields? : String,
  expand_wildcards? : String,
  explain? : Bool,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  lenient? : Bool,
  max_concurrent_shard_requests? : Int,
  preference? : String,
  pre_filter_shard_size? : Int,
  request_cache? : Bool,
  routing? : String,
  scroll? : String,
  search_type? : String,
  stats? : Array[String],
  stored_fields? : String,
  suggest_field? : String,
  suggest_mode? : String,
  suggest_size? : Int,
  suggest_text? : String,
  terminate_after? : Int,
  timeout? : String,
  track_total_hits? : String,
  track_scores? : Bool,
  typed_keys? : Bool,
  rest_total_hits_as_int? : Bool,
  version? : Bool,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  seq_no_primary_term? : Bool,
  q? : String,
  size? : Int,
  from? : Int,
  sort? : Json,
  wait_for_checkpoints? : Array[String],
  allow_partial_search_results? : Bool,
) -> FleetSearchQuery {
  {
    allow_no_indices,
    analyzer,
    analyze_wildcard,
    batched_reduce_size,
    ccs_minimize_roundtrips,
    default_operator,
    df,
    docvalue_fields,
    expand_wildcards,
    explain,
    ignore_throttled,
    ignore_unavailable,
    lenient,
    max_concurrent_shard_requests,
    preference,
    pre_filter_shard_size,
    request_cache,
    routing,
    scroll,
    search_type,
    stats,
    stored_fields,
    suggest_field,
    suggest_mode,
    suggest_size,
    suggest_text,
    terminate_after,
    timeout,
    track_total_hits,
    track_scores,
    typed_keys,
    rest_total_hits_as_int,
    version,
    _source,
    _source_excludes,
    _source_includes,
    seq_no_primary_term,
    q,
    size,
    from,
    sort,
    wait_for_checkpoints,
    allow_partial_search_results,
  }
}

///|
pub fn FleetSearchQuery::to_pairs(
  self : FleetSearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.batched_reduce_size {
    Some(value) =>
      push_query_json(pairs, "batched_reduce_size", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => push_query_json(pairs, "docvalue_fields", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_shard_requests", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) =>
      push_query_json(pairs, "pre_filter_shard_size", value.to_json())
    None => ()
  }
  match self.request_cache {
    Some(value) => push_query_json(pairs, "request_cache", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.stats {
    Some(value) => push_query_json(pairs, "stats", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  match self.suggest_field {
    Some(value) => push_query_json(pairs, "suggest_field", value.to_json())
    None => ()
  }
  match self.suggest_mode {
    Some(value) => push_query_json(pairs, "suggest_mode", value.to_json())
    None => ()
  }
  match self.suggest_size {
    Some(value) => push_query_json(pairs, "suggest_size", value.to_json())
    None => ()
  }
  match self.suggest_text {
    Some(value) => push_query_json(pairs, "suggest_text", value.to_json())
    None => ()
  }
  match self.terminate_after {
    Some(value) => push_query_json(pairs, "terminate_after", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.track_total_hits {
    Some(value) => push_query_json(pairs, "track_total_hits", value.to_json())
    None => ()
  }
  match self.track_scores {
    Some(value) => push_query_json(pairs, "track_scores", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) =>
      push_query_json(pairs, "seq_no_primary_term", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.wait_for_checkpoints {
    Some(value) =>
      push_query_json(pairs, "wait_for_checkpoints", value.to_json())
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_search_results", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct FleetSearchBody {
  aggregations : Map[String, Json]?
  collapse : Json?
  explain : Bool?
  ext : Map[String, Json]?
  from : Int?
  highlight : Json?
  track_total_hits : Json?
  indices_boost : Array[Map[String, Json]]?
  docvalue_fields : Array[Json]?
  min_score : Double?
  post_filter : Json?
  profile : Bool?
  query : Json?
  rescore : Json?
  script_fields : Map[String, Json]?
  search_after : Json?
  size : Int?
  slice : Json?
  sort : Json?
  _source : Json?
  fields : Array[Json]?
  suggest : Json?
  terminate_after : Int?
  timeout : String?
  track_scores : Bool?
  version : Bool?
  seq_no_primary_term : Bool?
  stored_fields : Json?
  pit : Json?
  runtime_mappings : Json?
  stats : Array[String]?
} derive(Eq, Debug)

///|
pub impl ToJson for FleetSearchBody with fn to_json(self : FleetSearchBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.collapse {
    Some(value) => obj["collapse"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ext {
    Some(value) => obj["ext"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.highlight {
    Some(value) => obj["highlight"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.indices_boost {
    Some(value) => obj["indices_boost"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.min_score {
    Some(value) => obj["min_score"] = value.to_json()
    None => ()
  }
  match self.post_filter {
    Some(value) => obj["post_filter"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.rescore {
    Some(value) => obj["rescore"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.slice {
    Some(value) => obj["slice"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.suggest {
    Some(value) => obj["suggest"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.track_scores {
    Some(value) => obj["track_scores"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) => obj["seq_no_primary_term"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.pit {
    Some(value) => obj["pit"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FleetSearchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetSearchBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    collapse: match obj.get("collapse") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("collapse")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ext: match obj.get("ext") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ext")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    highlight: match obj.get("highlight") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("highlight")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    indices_boost: match obj.get("indices_boost") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_boost")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    min_score: match obj.get("min_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("min_score")))
    },
    post_filter: match obj.get("post_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("post_filter")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    rescore: match obj.get("rescore") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rescore")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    slice: match obj.get("slice") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    suggest: match obj.get("suggest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("suggest")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    track_scores: match obj.get("track_scores") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_scores")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    seq_no_primary_term: match obj.get("seq_no_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("seq_no_primary_term")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    pit: match obj.get("pit") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pit")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
  }
}

///|
pub fn FleetSearchBody::new(
  aggregations? : Map[String, Json],
  collapse? : Json,
  explain? : Bool,
  ext? : Map[String, Json],
  from? : Int,
  highlight? : Json,
  track_total_hits? : Json,
  indices_boost? : Array[Map[String, Json]],
  docvalue_fields? : Array[Json],
  min_score? : Double,
  post_filter? : Json,
  profile? : Bool,
  query? : Json,
  rescore? : Json,
  script_fields? : Map[String, Json],
  search_after? : Json,
  size? : Int,
  slice? : Json,
  sort? : Json,
  _source? : Json,
  fields? : Array[Json],
  suggest? : Json,
  terminate_after? : Int,
  timeout? : String,
  track_scores? : Bool,
  version? : Bool,
  seq_no_primary_term? : Bool,
  stored_fields? : Json,
  pit? : Json,
  runtime_mappings? : Json,
  stats? : Array[String],
) -> FleetSearchBody {
  {
    aggregations,
    collapse,
    explain,
    ext,
    from,
    highlight,
    track_total_hits,
    indices_boost,
    docvalue_fields,
    min_score,
    post_filter,
    profile,
    query,
    rescore,
    script_fields,
    search_after,
    size,
    slice,
    sort,
    _source,
    fields,
    suggest,
    terminate_after,
    timeout,
    track_scores,
    version,
    seq_no_primary_term,
    stored_fields,
    pit,
    runtime_mappings,
    stats,
  }
}

///|
pub(all) struct FleetSearchResponse {
  took : Int
  timed_out : Bool
  _shards : Json
  hits : Json
  aggregations : Map[String, Json]?
  _clusters : Json?
  fields : Map[String, Json]?
  max_score : Double?
  num_reduce_phases : Int?
  profile : Json?
  pit_id : Json?
  _scroll_id : Json?
  suggest : Map[String, Json]?
  terminated_early : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for FleetSearchResponse with fn to_json(
  self : FleetSearchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["took"] = self.took.to_json()
  obj["timed_out"] = self.timed_out.to_json()
  obj["_shards"] = self._shards.to_json()
  obj["hits"] = self.hits.to_json()
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self._clusters {
    Some(value) => obj["_clusters"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.max_score {
    Some(value) => obj["max_score"] = value.to_json()
    None => ()
  }
  match self.num_reduce_phases {
    Some(value) => obj["num_reduce_phases"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.pit_id {
    Some(value) => obj["pit_id"] = value.to_json()
    None => ()
  }
  match self._scroll_id {
    Some(value) => obj["_scroll_id"] = value.to_json()
    None => ()
  }
  match self.suggest {
    Some(value) => obj["suggest"] = value.to_json()
    None => ()
  }
  match self.terminated_early {
    Some(value) => obj["terminated_early"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for FleetSearchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "FleetSearchResponse: expected object"))
  }
  {
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    timed_out: @json.from_json(
      obj.get("timed_out").unwrap_or(Json::null()),
      path=path.add_key("timed_out"),
    ),
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    hits: @json.from_json(
      obj.get("hits").unwrap_or(Json::null()),
      path=path.add_key("hits"),
    ),
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    _clusters: match obj.get("_clusters") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_clusters")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    max_score: match obj.get("max_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_score")))
    },
    num_reduce_phases: match obj.get("num_reduce_phases") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("num_reduce_phases")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    pit_id: match obj.get("pit_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pit_id")))
    },
    _scroll_id: match obj.get("_scroll_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_scroll_id")))
    },
    suggest: match obj.get("suggest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("suggest")))
    },
    terminated_early: match obj.get("terminated_early") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminated_early")))
    },
  }
}

///|
pub(all) struct FleetSearchRequest {
  index : String
  query : FleetSearchQuery
  body : FleetSearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn FleetSearchRequest::new(
  index : String,
  body : FleetSearchBody,
  query? : FleetSearchQuery = FleetSearchQuery::new(),
) -> FleetSearchRequest {
  { index, query, body }
}

///|
pub async fn Client::fleet_search(
  self : Client,
  request : FleetSearchRequest,
) -> EsResponse[FleetSearchResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_fleet/_fleet_search", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct GetQuery {
  force_synthetic_source : Bool?
  preference : String?
  realtime : Bool?
  refresh : Bool?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_exclude_vectors : Bool?
  _source_includes : String?
  stored_fields : String?
  version : String?
  version_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for GetQuery with fn to_json(self : GetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force_synthetic_source {
    Some(value) => obj["force_synthetic_source"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_exclude_vectors {
    Some(value) => obj["_source_exclude_vectors"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetQuery: expected object"))
  }
  {
    force_synthetic_source: match obj.get("force_synthetic_source") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("force_synthetic_source")),
        )
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_exclude_vectors: match obj.get("_source_exclude_vectors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("_source_exclude_vectors")),
        )
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn GetQuery::new(
  force_synthetic_source? : Bool,
  preference? : String,
  realtime? : Bool,
  refresh? : Bool,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_exclude_vectors? : Bool,
  _source_includes? : String,
  stored_fields? : String,
  version? : String,
  version_type? : String,
) -> GetQuery {
  {
    force_synthetic_source,
    preference,
    realtime,
    refresh,
    routing,
    _source,
    _source_excludes,
    _source_exclude_vectors,
    _source_includes,
    stored_fields,
    version,
    version_type,
  }
}

///|
pub fn GetQuery::to_pairs(self : GetQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force_synthetic_source {
    Some(value) =>
      push_query_json(pairs, "force_synthetic_source", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_exclude_vectors {
    Some(value) =>
      push_query_json(pairs, "_source_exclude_vectors", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type GetResponse = Json

///|
pub(all) struct GetRequest {
  index : String
  id : String
  query : GetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GetRequest::new(
  index : String,
  id : String,
  query? : GetQuery = GetQuery::new(),
) -> GetRequest {
  { index, id, query }
}

///|
pub async fn Client::get(
  self : Client,
  request : GetRequest,
) -> EsResponse[GetResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_doc/{id}", ["index", "id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct GetReindexQuery {
  wait_for_completion : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for GetReindexQuery with fn to_json(self : GetReindexQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GetReindexQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetReindexQuery: expected object"))
  }
  {
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn GetReindexQuery::new(
  wait_for_completion? : Bool,
  timeout? : String,
) -> GetReindexQuery {
  { wait_for_completion, timeout }
}

///|
pub fn GetReindexQuery::to_pairs(
  self : GetReindexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct GetReindexResponse {
  completed : Bool
  id : Json
  description : String?
  start_time_in_millis : Json
  start_time : String?
  running_time : Json?
  running_time_in_nanos : Json
  cancelled : Bool
  status : Json?
  error : Json?
  response : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for GetReindexResponse with fn to_json(
  self : GetReindexResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["completed"] = self.completed.to_json()
  obj["id"] = self.id.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["start_time_in_millis"] = self.start_time_in_millis.to_json()
  match self.start_time {
    Some(value) => obj["start_time"] = value.to_json()
    None => ()
  }
  match self.running_time {
    Some(value) => obj["running_time"] = value.to_json()
    None => ()
  }
  obj["running_time_in_nanos"] = self.running_time_in_nanos.to_json()
  obj["cancelled"] = self.cancelled.to_json()
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  match self.error {
    Some(value) => obj["error"] = value.to_json()
    None => ()
  }
  match self.response {
    Some(value) => obj["response"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GetReindexResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetReindexResponse: expected object"))
  }
  {
    completed: @json.from_json(
      obj.get("completed").unwrap_or(Json::null()),
      path=path.add_key("completed"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    start_time_in_millis: @json.from_json(
      obj.get("start_time_in_millis").unwrap_or(Json::null()),
      path=path.add_key("start_time_in_millis"),
    ),
    start_time: match obj.get("start_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("start_time")))
    },
    running_time: match obj.get("running_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("running_time")))
    },
    running_time_in_nanos: @json.from_json(
      obj.get("running_time_in_nanos").unwrap_or(Json::null()),
      path=path.add_key("running_time_in_nanos"),
    ),
    cancelled: @json.from_json(
      obj.get("cancelled").unwrap_or(Json::null()),
      path=path.add_key("cancelled"),
    ),
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
    error: match obj.get("error") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("error")))
    },
    response: match obj.get("response") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("response")))
    },
  }
}

///|
pub(all) struct GetReindexRequest {
  task_id : String
  query : GetReindexQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GetReindexRequest::new(
  task_id : String,
  query? : GetReindexQuery = GetReindexQuery::new(),
) -> GetReindexRequest {
  { task_id, query }
}

///|
pub async fn Client::get_reindex(
  self : Client,
  request : GetReindexRequest,
) -> EsResponse[GetReindexResponse] {
  let params : Map[String, String] = Map([])
  params["task_id"] = request.task_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_reindex/{task_id}", ["task_id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct GetScriptQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for GetScriptQuery with fn to_json(self : GetScriptQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GetScriptQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetScriptQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn GetScriptQuery::new(master_timeout? : String) -> GetScriptQuery {
  { master_timeout, }
}

///|
pub fn GetScriptQuery::to_pairs(
  self : GetScriptQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct GetScriptResponse {
  _id : Json
  found : Bool
  script : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for GetScriptResponse with fn to_json(self : GetScriptResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_id"] = self._id.to_json()
  obj["found"] = self.found.to_json()
  match self.script {
    Some(value) => obj["script"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GetScriptResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetScriptResponse: expected object"))
  }
  {
    _id: @json.from_json(
      obj.get("_id").unwrap_or(Json::null()),
      path=path.add_key("_id"),
    ),
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
    script: match obj.get("script") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("script")))
    },
  }
}

///|
pub(all) struct GetScriptRequest {
  id : String
  query : GetScriptQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GetScriptRequest::new(
  id : String,
  query? : GetScriptQuery = GetScriptQuery::new(),
) -> GetScriptRequest {
  { id, query }
}

///|
pub async fn Client::get_script(
  self : Client,
  request : GetScriptRequest,
) -> EsResponse[GetScriptResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_scripts/{id}", ["id"])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct GetScriptContextQuery {} derive(Eq, Debug)

///|
pub impl ToJson for GetScriptContextQuery with fn to_json(
  _self : GetScriptContextQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for GetScriptContextQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "GetScriptContextQuery: expected object"))
  }
  GetScriptContextQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn GetScriptContextQuery::new() -> GetScriptContextQuery {
  GetScriptContextQuery::{  }
}

///|
pub fn GetScriptContextQuery::to_pairs(
  _self : GetScriptContextQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct GetScriptContextResponse {
  contexts : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for GetScriptContextResponse with fn to_json(
  self : GetScriptContextResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["contexts"] = self.contexts.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for GetScriptContextResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetScriptContextResponse: expected object"))
  }
  {
    contexts: @json.from_json(
      obj.get("contexts").unwrap_or(Json::null()),
      path=path.add_key("contexts"),
    ),
  }
}

///|
pub(all) struct GetScriptContextRequest {
  query : GetScriptContextQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GetScriptContextRequest::new(
  query? : GetScriptContextQuery = GetScriptContextQuery::new(),
) -> GetScriptContextRequest {
  { query, }
}

///|
pub async fn Client::get_script_context(
  self : Client,
  request : GetScriptContextRequest,
) -> EsResponse[GetScriptContextResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_script_context", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct GetScriptLanguagesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for GetScriptLanguagesQuery with fn to_json(
  _self : GetScriptLanguagesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for GetScriptLanguagesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "GetScriptLanguagesQuery: expected object"))
  }
  GetScriptLanguagesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn GetScriptLanguagesQuery::new() -> GetScriptLanguagesQuery {
  GetScriptLanguagesQuery::{  }
}

///|
pub fn GetScriptLanguagesQuery::to_pairs(
  _self : GetScriptLanguagesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct GetScriptLanguagesResponse {
  language_contexts : Array[Json]
  types_allowed : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for GetScriptLanguagesResponse with fn to_json(
  self : GetScriptLanguagesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["language_contexts"] = self.language_contexts.to_json()
  obj["types_allowed"] = self.types_allowed.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for GetScriptLanguagesResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetScriptLanguagesResponse: expected object"))
  }
  {
    language_contexts: @json.from_json(
      obj.get("language_contexts").unwrap_or(Json::null()),
      path=path.add_key("language_contexts"),
    ),
    types_allowed: @json.from_json(
      obj.get("types_allowed").unwrap_or(Json::null()),
      path=path.add_key("types_allowed"),
    ),
  }
}

///|
pub(all) struct GetScriptLanguagesRequest {
  query : GetScriptLanguagesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GetScriptLanguagesRequest::new(
  query? : GetScriptLanguagesQuery = GetScriptLanguagesQuery::new(),
) -> GetScriptLanguagesRequest {
  { query, }
}

///|
pub async fn Client::get_script_languages(
  self : Client,
  request : GetScriptLanguagesRequest,
) -> EsResponse[GetScriptLanguagesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_script_language", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct GetSourceQuery {
  preference : String?
  realtime : Bool?
  refresh : Bool?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  version : String?
  version_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for GetSourceQuery with fn to_json(self : GetSourceQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GetSourceQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GetSourceQuery: expected object"))
  }
  {
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn GetSourceQuery::new(
  preference? : String,
  realtime? : Bool,
  refresh? : Bool,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  version? : String,
  version_type? : String,
) -> GetSourceQuery {
  {
    preference,
    realtime,
    refresh,
    routing,
    _source,
    _source_excludes,
    _source_includes,
    version,
    version_type,
  }
}

///|
pub fn GetSourceQuery::to_pairs(
  self : GetSourceQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type GetSourceResponse = Json

///|
pub(all) struct GetSourceRequest {
  index : String
  id : String
  query : GetSourceQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GetSourceRequest::new(
  index : String,
  id : String,
  query? : GetSourceQuery = GetSourceQuery::new(),
) -> GetSourceRequest {
  { index, id, query }
}

///|
pub async fn Client::get_source(
  self : Client,
  request : GetSourceRequest,
) -> EsResponse[GetSourceResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_source/{id}", ["index", "id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct GraphExploreQuery {
  routing : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for GraphExploreQuery with fn to_json(self : GraphExploreQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GraphExploreQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GraphExploreQuery: expected object"))
  }
  {
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn GraphExploreQuery::new(
  routing? : String,
  timeout? : String,
) -> GraphExploreQuery {
  { routing, timeout }
}

///|
pub fn GraphExploreQuery::to_pairs(
  self : GraphExploreQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct GraphExploreBody {
  connections : Json?
  controls : Json?
  query : Json?
  vertices : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for GraphExploreBody with fn to_json(self : GraphExploreBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.connections {
    Some(value) => obj["connections"] = value.to_json()
    None => ()
  }
  match self.controls {
    Some(value) => obj["controls"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.vertices {
    Some(value) => obj["vertices"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for GraphExploreBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GraphExploreBody: expected object"))
  }
  {
    connections: match obj.get("connections") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("connections")))
    },
    controls: match obj.get("controls") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("controls")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    vertices: match obj.get("vertices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("vertices")))
    },
  }
}

///|
pub fn GraphExploreBody::new(
  connections? : Json,
  controls? : Json,
  query? : Json,
  vertices? : Array[Json],
) -> GraphExploreBody {
  { connections, controls, query, vertices }
}

///|
pub(all) struct GraphExploreResponse {
  connections : Array[Json]
  failures : Array[Json]
  timed_out : Bool
  took : Int
  vertices : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for GraphExploreResponse with fn to_json(
  self : GraphExploreResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["connections"] = self.connections.to_json()
  obj["failures"] = self.failures.to_json()
  obj["timed_out"] = self.timed_out.to_json()
  obj["took"] = self.took.to_json()
  obj["vertices"] = self.vertices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for GraphExploreResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "GraphExploreResponse: expected object"))
  }
  {
    connections: @json.from_json(
      obj.get("connections").unwrap_or(Json::null()),
      path=path.add_key("connections"),
    ),
    failures: @json.from_json(
      obj.get("failures").unwrap_or(Json::null()),
      path=path.add_key("failures"),
    ),
    timed_out: @json.from_json(
      obj.get("timed_out").unwrap_or(Json::null()),
      path=path.add_key("timed_out"),
    ),
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    vertices: @json.from_json(
      obj.get("vertices").unwrap_or(Json::null()),
      path=path.add_key("vertices"),
    ),
  }
}

///|
pub(all) struct GraphExploreRequest {
  index : String
  query : GraphExploreQuery
  body : GraphExploreBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn GraphExploreRequest::new(
  index : String,
  body : GraphExploreBody,
  query? : GraphExploreQuery = GraphExploreQuery::new(),
) -> GraphExploreRequest {
  { index, query, body }
}

///|
pub async fn Client::graph_explore(
  self : Client,
  request : GraphExploreRequest,
) -> EsResponse[GraphExploreResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_graph/explore", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct HealthReportQuery {
  timeout : String?
  verbose : Bool?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for HealthReportQuery with fn to_json(self : HealthReportQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.verbose {
    Some(value) => obj["verbose"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for HealthReportQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "HealthReportQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    verbose: match obj.get("verbose") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("verbose")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn HealthReportQuery::new(
  timeout? : String,
  verbose? : Bool,
  size? : Int,
) -> HealthReportQuery {
  { timeout, verbose, size }
}

///|
pub fn HealthReportQuery::to_pairs(
  self : HealthReportQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.verbose {
    Some(value) => push_query_json(pairs, "verbose", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct HealthReportResponse {
  cluster_name : String
  indicators : Json
  status : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for HealthReportResponse with fn to_json(
  self : HealthReportResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["indicators"] = self.indicators.to_json()
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for HealthReportResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "HealthReportResponse: expected object"))
  }
  {
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    indicators: @json.from_json(
      obj.get("indicators").unwrap_or(Json::null()),
      path=path.add_key("indicators"),
    ),
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
  }
}

///|
pub(all) struct HealthReportRequest {
  feature : String?
  query : HealthReportQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn HealthReportRequest::new(
  feature? : String,
  query? : HealthReportQuery = HealthReportQuery::new(),
) -> HealthReportRequest {
  { feature, query }
}

///|
pub async fn Client::health_report(
  self : Client,
  request : HealthReportRequest,
) -> EsResponse[HealthReportResponse] {
  let params : Map[String, String] = Map([])
  match request.feature {
    Some(value) => params["feature"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_health_report/{feature}", ["feature"]),
      PathVariant::new("/_health_report", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IlmDeleteLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmDeleteLifecycleQuery with fn to_json(
  self : IlmDeleteLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmDeleteLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmDeleteLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IlmDeleteLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IlmDeleteLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn IlmDeleteLifecycleQuery::to_pairs(
  self : IlmDeleteLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IlmDeleteLifecycleResponse = Json

///|
pub(all) struct IlmDeleteLifecycleRequest {
  policy : String
  query : IlmDeleteLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmDeleteLifecycleRequest::new(
  policy : String,
  query? : IlmDeleteLifecycleQuery = IlmDeleteLifecycleQuery::new(),
) -> IlmDeleteLifecycleRequest {
  { policy, query }
}

///|
pub async fn Client::ilm_delete_lifecycle(
  self : Client,
  request : IlmDeleteLifecycleRequest,
) -> EsResponse[IlmDeleteLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["policy"] = request.policy
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ilm/policy/{policy}", ["policy"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IlmExplainLifecycleQuery {
  only_errors : Bool?
  only_managed : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmExplainLifecycleQuery with fn to_json(
  self : IlmExplainLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.only_errors {
    Some(value) => obj["only_errors"] = value.to_json()
    None => ()
  }
  match self.only_managed {
    Some(value) => obj["only_managed"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmExplainLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmExplainLifecycleQuery: expected object"))
  }
  {
    only_errors: match obj.get("only_errors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("only_errors")))
    },
    only_managed: match obj.get("only_managed") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("only_managed")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IlmExplainLifecycleQuery::new(
  only_errors? : Bool,
  only_managed? : Bool,
  master_timeout? : String,
) -> IlmExplainLifecycleQuery {
  { only_errors, only_managed, master_timeout }
}

///|
pub fn IlmExplainLifecycleQuery::to_pairs(
  self : IlmExplainLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.only_errors {
    Some(value) => push_query_json(pairs, "only_errors", value.to_json())
    None => ()
  }
  match self.only_managed {
    Some(value) => push_query_json(pairs, "only_managed", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IlmExplainLifecycleResponse {
  indices : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IlmExplainLifecycleResponse with fn to_json(
  self : IlmExplainLifecycleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IlmExplainLifecycleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IlmExplainLifecycleResponse: expected object"),
    )
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct IlmExplainLifecycleRequest {
  index : String
  query : IlmExplainLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmExplainLifecycleRequest::new(
  index : String,
  query? : IlmExplainLifecycleQuery = IlmExplainLifecycleQuery::new(),
) -> IlmExplainLifecycleRequest {
  { index, query }
}

///|
pub async fn Client::ilm_explain_lifecycle(
  self : Client,
  request : IlmExplainLifecycleRequest,
) -> EsResponse[IlmExplainLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ilm/explain", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IlmGetLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmGetLifecycleQuery with fn to_json(
  self : IlmGetLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmGetLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmGetLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IlmGetLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IlmGetLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn IlmGetLifecycleQuery::to_pairs(
  self : IlmGetLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IlmGetLifecycleResponse = Json

///|
pub(all) struct IlmGetLifecycleRequest {
  policy : String?
  query : IlmGetLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmGetLifecycleRequest::new(
  policy? : String,
  query? : IlmGetLifecycleQuery = IlmGetLifecycleQuery::new(),
) -> IlmGetLifecycleRequest {
  { policy, query }
}

///|
pub async fn Client::ilm_get_lifecycle(
  self : Client,
  request : IlmGetLifecycleRequest,
) -> EsResponse[IlmGetLifecycleResponse] {
  let params : Map[String, String] = Map([])
  match request.policy {
    Some(value) => params["policy"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ilm/policy/{policy}", ["policy"]),
      PathVariant::new("/_ilm/policy", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IlmGetStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IlmGetStatusQuery with fn to_json(_self : IlmGetStatusQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IlmGetStatusQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IlmGetStatusQuery: expected object"))
  }
  IlmGetStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IlmGetStatusQuery::new() -> IlmGetStatusQuery {
  IlmGetStatusQuery::{  }
}

///|
pub fn IlmGetStatusQuery::to_pairs(
  _self : IlmGetStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IlmGetStatusResponse {
  operation_mode : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IlmGetStatusResponse with fn to_json(
  self : IlmGetStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["operation_mode"] = self.operation_mode.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IlmGetStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmGetStatusResponse: expected object"))
  }
  {
    operation_mode: @json.from_json(
      obj.get("operation_mode").unwrap_or(Json::null()),
      path=path.add_key("operation_mode"),
    ),
  }
}

///|
pub(all) struct IlmGetStatusRequest {
  query : IlmGetStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmGetStatusRequest::new(
  query? : IlmGetStatusQuery = IlmGetStatusQuery::new(),
) -> IlmGetStatusRequest {
  { query, }
}

///|
pub async fn Client::ilm_get_status(
  self : Client,
  request : IlmGetStatusRequest,
) -> EsResponse[IlmGetStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ilm/status", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IlmMigrateToDataTiersQuery {
  dry_run : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmMigrateToDataTiersQuery with fn to_json(
  self : IlmMigrateToDataTiersQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmMigrateToDataTiersQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmMigrateToDataTiersQuery: expected object"))
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IlmMigrateToDataTiersQuery::new(
  dry_run? : Bool,
  master_timeout? : String,
) -> IlmMigrateToDataTiersQuery {
  { dry_run, master_timeout }
}

///|
pub fn IlmMigrateToDataTiersQuery::to_pairs(
  self : IlmMigrateToDataTiersQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IlmMigrateToDataTiersBody {
  legacy_template_to_delete : String?
  node_attribute : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmMigrateToDataTiersBody with fn to_json(
  self : IlmMigrateToDataTiersBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.legacy_template_to_delete {
    Some(value) => obj["legacy_template_to_delete"] = value.to_json()
    None => ()
  }
  match self.node_attribute {
    Some(value) => obj["node_attribute"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmMigrateToDataTiersBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmMigrateToDataTiersBody: expected object"))
  }
  {
    legacy_template_to_delete: match obj.get("legacy_template_to_delete") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("legacy_template_to_delete")),
        )
    },
    node_attribute: match obj.get("node_attribute") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("node_attribute")))
    },
  }
}

///|
pub fn IlmMigrateToDataTiersBody::new(
  legacy_template_to_delete? : String,
  node_attribute? : String,
) -> IlmMigrateToDataTiersBody {
  { legacy_template_to_delete, node_attribute }
}

///|
pub(all) struct IlmMigrateToDataTiersResponse {
  dry_run : Bool
  removed_legacy_template : String
  migrated_ilm_policies : Array[String]
  migrated_indices : Json
  migrated_legacy_templates : Array[String]
  migrated_composable_templates : Array[String]
  migrated_component_templates : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for IlmMigrateToDataTiersResponse with fn to_json(
  self : IlmMigrateToDataTiersResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["dry_run"] = self.dry_run.to_json()
  obj["removed_legacy_template"] = self.removed_legacy_template.to_json()
  obj["migrated_ilm_policies"] = self.migrated_ilm_policies.to_json()
  obj["migrated_indices"] = self.migrated_indices.to_json()
  obj["migrated_legacy_templates"] = self.migrated_legacy_templates.to_json()
  obj["migrated_composable_templates"] = self.migrated_composable_templates.to_json()
  obj["migrated_component_templates"] = self.migrated_component_templates.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IlmMigrateToDataTiersResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IlmMigrateToDataTiersResponse: expected object"),
    )
  }
  {
    dry_run: @json.from_json(
      obj.get("dry_run").unwrap_or(Json::null()),
      path=path.add_key("dry_run"),
    ),
    removed_legacy_template: @json.from_json(
      obj.get("removed_legacy_template").unwrap_or(Json::null()),
      path=path.add_key("removed_legacy_template"),
    ),
    migrated_ilm_policies: @json.from_json(
      obj.get("migrated_ilm_policies").unwrap_or(Json::null()),
      path=path.add_key("migrated_ilm_policies"),
    ),
    migrated_indices: @json.from_json(
      obj.get("migrated_indices").unwrap_or(Json::null()),
      path=path.add_key("migrated_indices"),
    ),
    migrated_legacy_templates: @json.from_json(
      obj.get("migrated_legacy_templates").unwrap_or(Json::null()),
      path=path.add_key("migrated_legacy_templates"),
    ),
    migrated_composable_templates: @json.from_json(
      obj.get("migrated_composable_templates").unwrap_or(Json::null()),
      path=path.add_key("migrated_composable_templates"),
    ),
    migrated_component_templates: @json.from_json(
      obj.get("migrated_component_templates").unwrap_or(Json::null()),
      path=path.add_key("migrated_component_templates"),
    ),
  }
}

///|
pub(all) struct IlmMigrateToDataTiersRequest {
  query : IlmMigrateToDataTiersQuery
  body : IlmMigrateToDataTiersBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmMigrateToDataTiersRequest::new(
  query? : IlmMigrateToDataTiersQuery = IlmMigrateToDataTiersQuery::new(),
  body? : IlmMigrateToDataTiersBody,
) -> IlmMigrateToDataTiersRequest {
  { query, body }
}

///|
pub async fn Client::ilm_migrate_to_data_tiers(
  self : Client,
  request : IlmMigrateToDataTiersRequest,
) -> EsResponse[IlmMigrateToDataTiersResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ilm/migrate_to_data_tiers", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IlmMoveToStepQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IlmMoveToStepQuery with fn to_json(
  _self : IlmMoveToStepQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IlmMoveToStepQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IlmMoveToStepQuery: expected object"))
  }
  IlmMoveToStepQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IlmMoveToStepQuery::new() -> IlmMoveToStepQuery {
  IlmMoveToStepQuery::{  }
}

///|
pub fn IlmMoveToStepQuery::to_pairs(
  _self : IlmMoveToStepQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IlmMoveToStepBody {
  current_step : Json
  next_step : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IlmMoveToStepBody with fn to_json(self : IlmMoveToStepBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["current_step"] = self.current_step.to_json()
  obj["next_step"] = self.next_step.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IlmMoveToStepBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmMoveToStepBody: expected object"))
  }
  {
    current_step: @json.from_json(
      obj.get("current_step").unwrap_or(Json::null()),
      path=path.add_key("current_step"),
    ),
    next_step: @json.from_json(
      obj.get("next_step").unwrap_or(Json::null()),
      path=path.add_key("next_step"),
    ),
  }
}

///|
pub fn IlmMoveToStepBody::new(
  current_step : Json,
  next_step : Json,
) -> IlmMoveToStepBody {
  { current_step, next_step }
}

///|
pub type IlmMoveToStepResponse = Json

///|
pub(all) struct IlmMoveToStepRequest {
  index : String
  query : IlmMoveToStepQuery
  body : IlmMoveToStepBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmMoveToStepRequest::new(
  index : String,
  body : IlmMoveToStepBody,
  query? : IlmMoveToStepQuery = IlmMoveToStepQuery::new(),
) -> IlmMoveToStepRequest {
  { index, query, body }
}

///|
pub async fn Client::ilm_move_to_step(
  self : Client,
  request : IlmMoveToStepRequest,
) -> EsResponse[IlmMoveToStepResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ilm/move/{index}", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IlmPutLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmPutLifecycleQuery with fn to_json(
  self : IlmPutLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmPutLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmPutLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IlmPutLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IlmPutLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn IlmPutLifecycleQuery::to_pairs(
  self : IlmPutLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IlmPutLifecycleBody {
  policy : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmPutLifecycleBody with fn to_json(
  self : IlmPutLifecycleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.policy {
    Some(value) => obj["policy"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmPutLifecycleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmPutLifecycleBody: expected object"))
  }
  {
    policy: match obj.get("policy") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("policy")))
    },
  }
}

///|
pub fn IlmPutLifecycleBody::new(policy? : Json) -> IlmPutLifecycleBody {
  { policy, }
}

///|
pub type IlmPutLifecycleResponse = Json

///|
pub(all) struct IlmPutLifecycleRequest {
  policy : String
  query : IlmPutLifecycleQuery
  body : IlmPutLifecycleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmPutLifecycleRequest::new(
  policy : String,
  body : IlmPutLifecycleBody,
  query? : IlmPutLifecycleQuery = IlmPutLifecycleQuery::new(),
) -> IlmPutLifecycleRequest {
  { policy, query, body }
}

///|
pub async fn Client::ilm_put_lifecycle(
  self : Client,
  request : IlmPutLifecycleRequest,
) -> EsResponse[IlmPutLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["policy"] = request.policy
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ilm/policy/{policy}", ["policy"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IlmRemovePolicyQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IlmRemovePolicyQuery with fn to_json(
  _self : IlmRemovePolicyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IlmRemovePolicyQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IlmRemovePolicyQuery: expected object"))
  }
  IlmRemovePolicyQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IlmRemovePolicyQuery::new() -> IlmRemovePolicyQuery {
  IlmRemovePolicyQuery::{  }
}

///|
pub fn IlmRemovePolicyQuery::to_pairs(
  _self : IlmRemovePolicyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IlmRemovePolicyResponse {
  failed_indexes : Array[Json]
  has_failures : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IlmRemovePolicyResponse with fn to_json(
  self : IlmRemovePolicyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["failed_indexes"] = self.failed_indexes.to_json()
  obj["has_failures"] = self.has_failures.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IlmRemovePolicyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmRemovePolicyResponse: expected object"))
  }
  {
    failed_indexes: @json.from_json(
      obj.get("failed_indexes").unwrap_or(Json::null()),
      path=path.add_key("failed_indexes"),
    ),
    has_failures: @json.from_json(
      obj.get("has_failures").unwrap_or(Json::null()),
      path=path.add_key("has_failures"),
    ),
  }
}

///|
pub(all) struct IlmRemovePolicyRequest {
  index : String
  query : IlmRemovePolicyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmRemovePolicyRequest::new(
  index : String,
  query? : IlmRemovePolicyQuery = IlmRemovePolicyQuery::new(),
) -> IlmRemovePolicyRequest {
  { index, query }
}

///|
pub async fn Client::ilm_remove_policy(
  self : Client,
  request : IlmRemovePolicyRequest,
) -> EsResponse[IlmRemovePolicyResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ilm/remove", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IlmRetryQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IlmRetryQuery with fn to_json(_self : IlmRetryQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IlmRetryQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IlmRetryQuery: expected object"))
  }
  IlmRetryQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IlmRetryQuery::new() -> IlmRetryQuery {
  IlmRetryQuery::{  }
}

///|
pub fn IlmRetryQuery::to_pairs(
  _self : IlmRetryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type IlmRetryResponse = Json

///|
pub(all) struct IlmRetryRequest {
  index : String
  query : IlmRetryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmRetryRequest::new(
  index : String,
  query? : IlmRetryQuery = IlmRetryQuery::new(),
) -> IlmRetryRequest {
  { index, query }
}

///|
pub async fn Client::ilm_retry(
  self : Client,
  request : IlmRetryRequest,
) -> EsResponse[IlmRetryResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_ilm/retry", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IlmStartQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmStartQuery with fn to_json(self : IlmStartQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmStartQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmStartQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IlmStartQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IlmStartQuery {
  { master_timeout, timeout }
}

///|
pub fn IlmStartQuery::to_pairs(self : IlmStartQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IlmStartResponse = Json

///|
pub(all) struct IlmStartRequest {
  query : IlmStartQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmStartRequest::new(
  query? : IlmStartQuery = IlmStartQuery::new(),
) -> IlmStartRequest {
  { query, }
}

///|
pub async fn Client::ilm_start(
  self : Client,
  request : IlmStartRequest,
) -> EsResponse[IlmStartResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ilm/start", [])], params)
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IlmStopQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IlmStopQuery with fn to_json(self : IlmStopQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IlmStopQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IlmStopQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IlmStopQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IlmStopQuery {
  { master_timeout, timeout }
}

///|
pub fn IlmStopQuery::to_pairs(self : IlmStopQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IlmStopResponse = Json

///|
pub(all) struct IlmStopRequest {
  query : IlmStopQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IlmStopRequest::new(
  query? : IlmStopQuery = IlmStopQuery::new(),
) -> IlmStopRequest {
  { query, }
}

///|
pub async fn Client::ilm_stop(
  self : Client,
  request : IlmStopRequest,
) -> EsResponse[IlmStopResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ilm/stop", [])], params)
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndexQuery {
  if_primary_term : Int?
  if_seq_no : String?
  include_source_on_error : Bool?
  op_type : String?
  pipeline : String?
  refresh : String?
  routing : String?
  timeout : String?
  version : String?
  version_type : String?
  wait_for_active_shards : String?
  require_alias : Bool?
  require_data_stream : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndexQuery with fn to_json(self : IndexQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.if_primary_term {
    Some(value) => obj["if_primary_term"] = value.to_json()
    None => ()
  }
  match self.if_seq_no {
    Some(value) => obj["if_seq_no"] = value.to_json()
    None => ()
  }
  match self.include_source_on_error {
    Some(value) => obj["include_source_on_error"] = value.to_json()
    None => ()
  }
  match self.op_type {
    Some(value) => obj["op_type"] = value.to_json()
    None => ()
  }
  match self.pipeline {
    Some(value) => obj["pipeline"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.require_alias {
    Some(value) => obj["require_alias"] = value.to_json()
    None => ()
  }
  match self.require_data_stream {
    Some(value) => obj["require_data_stream"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndexQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndexQuery: expected object"))
  }
  {
    if_primary_term: match obj.get("if_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_primary_term")))
    },
    if_seq_no: match obj.get("if_seq_no") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_seq_no")))
    },
    include_source_on_error: match obj.get("include_source_on_error") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_source_on_error")),
        )
    },
    op_type: match obj.get("op_type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("op_type")))
    },
    pipeline: match obj.get("pipeline") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pipeline")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    require_alias: match obj.get("require_alias") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_alias")))
    },
    require_data_stream: match obj.get("require_data_stream") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_data_stream")))
    },
  }
}

///|
pub fn IndexQuery::new(
  if_primary_term? : Int,
  if_seq_no? : String,
  include_source_on_error? : Bool,
  op_type? : String,
  pipeline? : String,
  refresh? : String,
  routing? : String,
  timeout? : String,
  version? : String,
  version_type? : String,
  wait_for_active_shards? : String,
  require_alias? : Bool,
  require_data_stream? : Bool,
) -> IndexQuery {
  {
    if_primary_term,
    if_seq_no,
    include_source_on_error,
    op_type,
    pipeline,
    refresh,
    routing,
    timeout,
    version,
    version_type,
    wait_for_active_shards,
    require_alias,
    require_data_stream,
  }
}

///|
pub fn IndexQuery::to_pairs(self : IndexQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.if_primary_term {
    Some(value) => push_query_json(pairs, "if_primary_term", value.to_json())
    None => ()
  }
  match self.if_seq_no {
    Some(value) => push_query_json(pairs, "if_seq_no", value.to_json())
    None => ()
  }
  match self.include_source_on_error {
    Some(value) =>
      push_query_json(pairs, "include_source_on_error", value.to_json())
    None => ()
  }
  match self.op_type {
    Some(value) => push_query_json(pairs, "op_type", value.to_json())
    None => ()
  }
  match self.pipeline {
    Some(value) => push_query_json(pairs, "pipeline", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.require_alias {
    Some(value) => push_query_json(pairs, "require_alias", value.to_json())
    None => ()
  }
  match self.require_data_stream {
    Some(value) =>
      push_query_json(pairs, "require_data_stream", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndexBody = Json

///|
pub type IndexResponse = Json

///|
pub(all) struct IndexRequest {
  index : String
  id : String?
  query : IndexQuery
  body : IndexBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndexRequest::new(
  index : String,
  body : IndexBody,
  id? : String,
  query? : IndexQuery = IndexQuery::new(),
) -> IndexRequest {
  { index, id, query, body }
}

///|
pub async fn Client::index(
  self : Client,
  request : IndexRequest,
) -> EsResponse[IndexResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_doc/{id}", ["index", "id"]),
      PathVariant::new("/{index}/_doc", ["index"]),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesAddBlockQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesAddBlockQuery with fn to_json(
  self : IndicesAddBlockQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesAddBlockQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesAddBlockQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesAddBlockQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> IndicesAddBlockQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    master_timeout,
    timeout,
  }
}

///|
pub fn IndicesAddBlockQuery::to_pairs(
  self : IndicesAddBlockQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesAddBlockResponse {
  acknowledged : Bool
  shards_acknowledged : Bool
  indices : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesAddBlockResponse with fn to_json(
  self : IndicesAddBlockResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesAddBlockResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesAddBlockResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct IndicesAddBlockRequest {
  index : String
  block : String
  query : IndicesAddBlockQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesAddBlockRequest::new(
  index : String,
  block : String,
  query? : IndicesAddBlockQuery = IndicesAddBlockQuery::new(),
) -> IndicesAddBlockRequest {
  { index, block, query }
}

///|
pub async fn Client::indices_add_block(
  self : Client,
  request : IndicesAddBlockRequest,
) -> EsResponse[IndicesAddBlockResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["block"] = request.block
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_block/{block}", ["index", "block"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct IndicesAnalyzeQuery {
  index : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesAnalyzeQuery with fn to_json(
  self : IndicesAnalyzeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesAnalyzeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesAnalyzeQuery: expected object"))
  }
  {
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
  }
}

///|
pub fn IndicesAnalyzeQuery::new(index? : String) -> IndicesAnalyzeQuery {
  { index, }
}

///|
pub fn IndicesAnalyzeQuery::to_pairs(
  self : IndicesAnalyzeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.index {
    Some(value) => push_query_json(pairs, "index", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesAnalyzeBody {
  analyzer : String?
  attributes : Array[String]?
  char_filter : Array[Json]?
  explain : Bool?
  field : Json?
  filter : Array[Json]?
  normalizer : String?
  text : Json?
  tokenizer : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesAnalyzeBody with fn to_json(
  self : IndicesAnalyzeBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.attributes {
    Some(value) => obj["attributes"] = value.to_json()
    None => ()
  }
  match self.char_filter {
    Some(value) => obj["char_filter"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.field {
    Some(value) => obj["field"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.normalizer {
    Some(value) => obj["normalizer"] = value.to_json()
    None => ()
  }
  match self.text {
    Some(value) => obj["text"] = value.to_json()
    None => ()
  }
  match self.tokenizer {
    Some(value) => obj["tokenizer"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesAnalyzeBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesAnalyzeBody: expected object"))
  }
  {
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    attributes: match obj.get("attributes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("attributes")))
    },
    char_filter: match obj.get("char_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("char_filter")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    field: match obj.get("field") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("field")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    normalizer: match obj.get("normalizer") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("normalizer")))
    },
    text: match obj.get("text") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("text")))
    },
    tokenizer: match obj.get("tokenizer") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("tokenizer")))
    },
  }
}

///|
pub fn IndicesAnalyzeBody::new(
  analyzer? : String,
  attributes? : Array[String],
  char_filter? : Array[Json],
  explain? : Bool,
  field? : Json,
  filter? : Array[Json],
  normalizer? : String,
  text? : Json,
  tokenizer? : Json,
) -> IndicesAnalyzeBody {
  {
    analyzer,
    attributes,
    char_filter,
    explain,
    field,
    filter,
    normalizer,
    text,
    tokenizer,
  }
}

///|
pub(all) struct IndicesAnalyzeResponse {
  detail : Json?
  tokens : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesAnalyzeResponse with fn to_json(
  self : IndicesAnalyzeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.detail {
    Some(value) => obj["detail"] = value.to_json()
    None => ()
  }
  match self.tokens {
    Some(value) => obj["tokens"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesAnalyzeResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesAnalyzeResponse: expected object"))
  }
  {
    detail: match obj.get("detail") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detail")))
    },
    tokens: match obj.get("tokens") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("tokens")))
    },
  }
}

///|
pub(all) struct IndicesAnalyzeRequest {
  index : String?
  query : IndicesAnalyzeQuery
  body : IndicesAnalyzeBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesAnalyzeRequest::new(
  body : IndicesAnalyzeBody,
  index? : String,
  query? : IndicesAnalyzeQuery = IndicesAnalyzeQuery::new(),
) -> IndicesAnalyzeRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_analyze(
  self : Client,
  request : IndicesAnalyzeRequest,
) -> EsResponse[IndicesAnalyzeResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_analyze", ["index"]),
      PathVariant::new("/_analyze", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesCancelMigrateReindexQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCancelMigrateReindexQuery with fn to_json(
  _self : IndicesCancelMigrateReindexQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesCancelMigrateReindexQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "IndicesCancelMigrateReindexQuery: expected object"),
    )
  }
  IndicesCancelMigrateReindexQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesCancelMigrateReindexQuery::new() -> IndicesCancelMigrateReindexQuery {
  IndicesCancelMigrateReindexQuery::{  }
}

///|
pub fn IndicesCancelMigrateReindexQuery::to_pairs(
  _self : IndicesCancelMigrateReindexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type IndicesCancelMigrateReindexBody = Json

///|
pub type IndicesCancelMigrateReindexResponse = Json

///|
pub(all) struct IndicesCancelMigrateReindexRequest {
  index : String
  query : IndicesCancelMigrateReindexQuery
  body : IndicesCancelMigrateReindexBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesCancelMigrateReindexRequest::new(
  index : String,
  query? : IndicesCancelMigrateReindexQuery = IndicesCancelMigrateReindexQuery::new(),
  body? : IndicesCancelMigrateReindexBody,
) -> IndicesCancelMigrateReindexRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_cancel_migrate_reindex(
  self : Client,
  request : IndicesCancelMigrateReindexRequest,
) -> EsResponse[IndicesCancelMigrateReindexResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_migration/reindex/{index}/_cancel", ["index"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesClearCacheQuery {
  index : String?
  allow_no_indices : Bool?
  expand_wildcards : String?
  fielddata : Bool?
  fields : String?
  ignore_unavailable : Bool?
  query : Bool?
  request : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesClearCacheQuery with fn to_json(
  self : IndicesClearCacheQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.fielddata {
    Some(value) => obj["fielddata"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.request {
    Some(value) => obj["request"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesClearCacheQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesClearCacheQuery: expected object"))
  }
  {
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    fielddata: match obj.get("fielddata") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("fielddata")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    request: match obj.get("request") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("request")))
    },
  }
}

///|
pub fn IndicesClearCacheQuery::new(
  index? : String,
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  fielddata? : Bool,
  fields? : String,
  ignore_unavailable? : Bool,
  query? : Bool,
  request? : Bool,
) -> IndicesClearCacheQuery {
  {
    index,
    allow_no_indices,
    expand_wildcards,
    fielddata,
    fields,
    ignore_unavailable,
    query,
    request,
  }
}

///|
pub fn IndicesClearCacheQuery::to_pairs(
  self : IndicesClearCacheQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.index {
    Some(value) => push_query_json(pairs, "index", value.to_json())
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.fielddata {
    Some(value) => push_query_json(pairs, "fielddata", value.to_json())
    None => ()
  }
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.query {
    Some(value) => push_query_json(pairs, "query", value.to_json())
    None => ()
  }
  match self.request {
    Some(value) => push_query_json(pairs, "request", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesClearCacheResponse = Json

///|
pub(all) struct IndicesClearCacheRequest {
  index : String?
  query : IndicesClearCacheQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesClearCacheRequest::new(
  index? : String,
  query? : IndicesClearCacheQuery = IndicesClearCacheQuery::new(),
) -> IndicesClearCacheRequest {
  { index, query }
}

///|
pub async fn Client::indices_clear_cache(
  self : Client,
  request : IndicesClearCacheRequest,
) -> EsResponse[IndicesClearCacheResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_cache/clear", ["index"]),
      PathVariant::new("/_cache/clear", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesCloneQuery {
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCloneQuery with fn to_json(self : IndicesCloneQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCloneQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCloneQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn IndicesCloneQuery::new(
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
) -> IndicesCloneQuery {
  { master_timeout, timeout, wait_for_active_shards }
}

///|
pub fn IndicesCloneQuery::to_pairs(
  self : IndicesCloneQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesCloneBody {
  aliases : Map[String, Json]?
  settings : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCloneBody with fn to_json(self : IndicesCloneBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aliases {
    Some(value) => obj["aliases"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCloneBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCloneBody: expected object"))
  }
  {
    aliases: match obj.get("aliases") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aliases")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
  }
}

///|
pub fn IndicesCloneBody::new(
  aliases? : Map[String, Json],
  settings? : Map[String, Json],
) -> IndicesCloneBody {
  { aliases, settings }
}

///|
pub(all) struct IndicesCloneResponse {
  acknowledged : Bool
  index : Json
  shards_acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCloneResponse with fn to_json(
  self : IndicesCloneResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["index"] = self.index.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCloneResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCloneResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
  }
}

///|
pub(all) struct IndicesCloneRequest {
  index : String
  target : String
  query : IndicesCloneQuery
  body : IndicesCloneBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesCloneRequest::new(
  index : String,
  target : String,
  query? : IndicesCloneQuery = IndicesCloneQuery::new(),
  body? : IndicesCloneBody,
) -> IndicesCloneRequest {
  { index, target, query, body }
}

///|
pub async fn Client::indices_clone(
  self : Client,
  request : IndicesCloneRequest,
) -> EsResponse[IndicesCloneResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["target"] = request.target
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_clone/{target}", ["index", "target"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesCloseQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCloseQuery with fn to_json(self : IndicesCloseQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCloseQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCloseQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn IndicesCloseQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
) -> IndicesCloseQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    master_timeout,
    timeout,
    wait_for_active_shards,
  }
}

///|
pub fn IndicesCloseQuery::to_pairs(
  self : IndicesCloseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesCloseResponse {
  acknowledged : Bool
  indices : Map[String, Json]
  shards_acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCloseResponse with fn to_json(
  self : IndicesCloseResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["indices"] = self.indices.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCloseResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCloseResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
  }
}

///|
pub(all) struct IndicesCloseRequest {
  index : String
  query : IndicesCloseQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesCloseRequest::new(
  index : String,
  query? : IndicesCloseQuery = IndicesCloseQuery::new(),
) -> IndicesCloseRequest {
  { index, query }
}

///|
pub async fn Client::indices_close(
  self : Client,
  request : IndicesCloseRequest,
) -> EsResponse[IndicesCloseResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_close", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesCreateQuery {
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCreateQuery with fn to_json(
  self : IndicesCreateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCreateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCreateQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn IndicesCreateQuery::new(
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
) -> IndicesCreateQuery {
  { master_timeout, timeout, wait_for_active_shards }
}

///|
pub fn IndicesCreateQuery::to_pairs(
  self : IndicesCreateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesCreateBody {
  aliases : Map[String, Json]?
  mappings : Json?
  settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCreateBody with fn to_json(self : IndicesCreateBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aliases {
    Some(value) => obj["aliases"] = value.to_json()
    None => ()
  }
  match self.mappings {
    Some(value) => obj["mappings"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCreateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCreateBody: expected object"))
  }
  {
    aliases: match obj.get("aliases") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aliases")))
    },
    mappings: match obj.get("mappings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("mappings")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
  }
}

///|
pub fn IndicesCreateBody::new(
  aliases? : Map[String, Json],
  mappings? : Json,
  settings? : Json,
) -> IndicesCreateBody {
  { aliases, mappings, settings }
}

///|
pub(all) struct IndicesCreateResponse {
  index : Json
  shards_acknowledged : Bool
  acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCreateResponse with fn to_json(
  self : IndicesCreateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["index"] = self.index.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  obj["acknowledged"] = self.acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCreateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCreateResponse: expected object"))
  }
  {
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
  }
}

///|
pub(all) struct IndicesCreateRequest {
  index : String
  query : IndicesCreateQuery
  body : IndicesCreateBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesCreateRequest::new(
  index : String,
  query? : IndicesCreateQuery = IndicesCreateQuery::new(),
  body? : IndicesCreateBody,
) -> IndicesCreateRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_create(
  self : Client,
  request : IndicesCreateRequest,
) -> EsResponse[IndicesCreateResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/{index}", ["index"])], params)
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IndicesCreateDataStreamQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCreateDataStreamQuery with fn to_json(
  self : IndicesCreateDataStreamQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCreateDataStreamQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesCreateDataStreamQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesCreateDataStreamQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesCreateDataStreamQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesCreateDataStreamQuery::to_pairs(
  self : IndicesCreateDataStreamQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesCreateDataStreamResponse = Json

///|
pub(all) struct IndicesCreateDataStreamRequest {
  name : String
  query : IndicesCreateDataStreamQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesCreateDataStreamRequest::new(
  name : String,
  query? : IndicesCreateDataStreamQuery = IndicesCreateDataStreamQuery::new(),
) -> IndicesCreateDataStreamRequest {
  { name, query }
}

///|
pub async fn Client::indices_create_data_stream(
  self : Client,
  request : IndicesCreateDataStreamRequest,
) -> EsResponse[IndicesCreateDataStreamResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct IndicesCreateFromQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCreateFromQuery with fn to_json(
  _self : IndicesCreateFromQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesCreateFromQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IndicesCreateFromQuery: expected object"))
  }
  IndicesCreateFromQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesCreateFromQuery::new() -> IndicesCreateFromQuery {
  IndicesCreateFromQuery::{  }
}

///|
pub fn IndicesCreateFromQuery::to_pairs(
  _self : IndicesCreateFromQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type IndicesCreateFromBody = Json

///|
pub(all) struct IndicesCreateFromResponse {
  acknowledged : Bool
  index : Json
  shards_acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesCreateFromResponse with fn to_json(
  self : IndicesCreateFromResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["index"] = self.index.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesCreateFromResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesCreateFromResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
  }
}

///|
pub(all) struct IndicesCreateFromRequest {
  source : String
  dest : String
  query : IndicesCreateFromQuery
  body : IndicesCreateFromBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesCreateFromRequest::new(
  source : String,
  dest : String,
  query? : IndicesCreateFromQuery = IndicesCreateFromQuery::new(),
  body? : IndicesCreateFromBody,
) -> IndicesCreateFromRequest {
  { source, dest, query, body }
}

///|
pub async fn Client::indices_create_from(
  self : Client,
  request : IndicesCreateFromRequest,
) -> EsResponse[IndicesCreateFromResponse] {
  let params : Map[String, String] = Map([])
  params["source"] = request.source
  params["dest"] = request.dest
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_create_from/{source}/{dest}", ["source", "dest"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesDataStreamsStatsQuery {
  expand_wildcards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDataStreamsStatsQuery with fn to_json(
  self : IndicesDataStreamsStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDataStreamsStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesDataStreamsStatsQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
  }
}

///|
pub fn IndicesDataStreamsStatsQuery::new(
  expand_wildcards? : String,
) -> IndicesDataStreamsStatsQuery {
  { expand_wildcards, }
}

///|
pub fn IndicesDataStreamsStatsQuery::to_pairs(
  self : IndicesDataStreamsStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesDataStreamsStatsResponse {
  _shards : Json
  backing_indices : Int
  data_stream_count : Int
  data_streams : Array[Json]
  total_store_sizes : Json?
  total_store_size_bytes : Int
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDataStreamsStatsResponse with fn to_json(
  self : IndicesDataStreamsStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_shards"] = self._shards.to_json()
  obj["backing_indices"] = self.backing_indices.to_json()
  obj["data_stream_count"] = self.data_stream_count.to_json()
  obj["data_streams"] = self.data_streams.to_json()
  match self.total_store_sizes {
    Some(value) => obj["total_store_sizes"] = value.to_json()
    None => ()
  }
  obj["total_store_size_bytes"] = self.total_store_size_bytes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDataStreamsStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesDataStreamsStatsResponse: expected object"),
    )
  }
  {
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    backing_indices: @json.from_json(
      obj.get("backing_indices").unwrap_or(Json::null()),
      path=path.add_key("backing_indices"),
    ),
    data_stream_count: @json.from_json(
      obj.get("data_stream_count").unwrap_or(Json::null()),
      path=path.add_key("data_stream_count"),
    ),
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
    total_store_sizes: match obj.get("total_store_sizes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("total_store_sizes")))
    },
    total_store_size_bytes: @json.from_json(
      obj.get("total_store_size_bytes").unwrap_or(Json::null()),
      path=path.add_key("total_store_size_bytes"),
    ),
  }
}

///|
pub(all) struct IndicesDataStreamsStatsRequest {
  name : String?
  query : IndicesDataStreamsStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDataStreamsStatsRequest::new(
  name? : String,
  query? : IndicesDataStreamsStatsQuery = IndicesDataStreamsStatsQuery::new(),
) -> IndicesDataStreamsStatsRequest {
  { name, query }
}

///|
pub async fn Client::indices_data_streams_stats(
  self : Client,
  request : IndicesDataStreamsStatsRequest,
) -> EsResponse[IndicesDataStreamsStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_data_stream/{name}/_stats", ["name"]),
      PathVariant::new("/_data_stream/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesDeleteQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteQuery with fn to_json(
  self : IndicesDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesDeleteQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesDeleteQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> IndicesDeleteQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    master_timeout,
    timeout,
  }
}

///|
pub fn IndicesDeleteQuery::to_pairs(
  self : IndicesDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteResponse = Json

///|
pub(all) struct IndicesDeleteRequest {
  index : String
  query : IndicesDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteRequest::new(
  index : String,
  query? : IndicesDeleteQuery = IndicesDeleteQuery::new(),
) -> IndicesDeleteRequest {
  { index, query }
}

///|
pub async fn Client::indices_delete(
  self : Client,
  request : IndicesDeleteRequest,
) -> EsResponse[IndicesDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/{index}", ["index"])], params)
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDeleteAliasQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteAliasQuery with fn to_json(
  self : IndicesDeleteAliasQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteAliasQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesDeleteAliasQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesDeleteAliasQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesDeleteAliasQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesDeleteAliasQuery::to_pairs(
  self : IndicesDeleteAliasQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteAliasResponse = Json

///|
pub(all) struct IndicesDeleteAliasRequest {
  index : String
  name : String
  query : IndicesDeleteAliasQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteAliasRequest::new(
  index : String,
  name : String,
  query? : IndicesDeleteAliasQuery = IndicesDeleteAliasQuery::new(),
) -> IndicesDeleteAliasRequest {
  { index, name, query }
}

///|
pub async fn Client::indices_delete_alias(
  self : Client,
  request : IndicesDeleteAliasRequest,
) -> EsResponse[IndicesDeleteAliasResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_alias/{name}", ["index", "name"]),
      PathVariant::new("/{index}/_aliases/{name}", ["index", "name"]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDeleteDataLifecycleQuery {
  expand_wildcards : String?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteDataLifecycleQuery with fn to_json(
  self : IndicesDeleteDataLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteDataLifecycleQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesDeleteDataLifecycleQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesDeleteDataLifecycleQuery::new(
  expand_wildcards? : String,
  master_timeout? : String,
  timeout? : String,
) -> IndicesDeleteDataLifecycleQuery {
  { expand_wildcards, master_timeout, timeout }
}

///|
pub fn IndicesDeleteDataLifecycleQuery::to_pairs(
  self : IndicesDeleteDataLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteDataLifecycleResponse = Json

///|
pub(all) struct IndicesDeleteDataLifecycleRequest {
  name : String
  query : IndicesDeleteDataLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteDataLifecycleRequest::new(
  name : String,
  query? : IndicesDeleteDataLifecycleQuery = IndicesDeleteDataLifecycleQuery::new(),
) -> IndicesDeleteDataLifecycleRequest {
  { name, query }
}

///|
pub async fn Client::indices_delete_data_lifecycle(
  self : Client,
  request : IndicesDeleteDataLifecycleRequest,
) -> EsResponse[IndicesDeleteDataLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_lifecycle", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDeleteDataStreamQuery {
  master_timeout : String?
  expand_wildcards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteDataStreamQuery with fn to_json(
  self : IndicesDeleteDataStreamQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteDataStreamQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesDeleteDataStreamQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
  }
}

///|
pub fn IndicesDeleteDataStreamQuery::new(
  master_timeout? : String,
  expand_wildcards? : String,
) -> IndicesDeleteDataStreamQuery {
  { master_timeout, expand_wildcards }
}

///|
pub fn IndicesDeleteDataStreamQuery::to_pairs(
  self : IndicesDeleteDataStreamQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteDataStreamResponse = Json

///|
pub(all) struct IndicesDeleteDataStreamRequest {
  name : String
  query : IndicesDeleteDataStreamQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteDataStreamRequest::new(
  name : String,
  query? : IndicesDeleteDataStreamQuery = IndicesDeleteDataStreamQuery::new(),
) -> IndicesDeleteDataStreamRequest {
  { name, query }
}

///|
pub async fn Client::indices_delete_data_stream(
  self : Client,
  request : IndicesDeleteDataStreamRequest,
) -> EsResponse[IndicesDeleteDataStreamResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDeleteDataStreamOptionsQuery {
  expand_wildcards : String?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteDataStreamOptionsQuery with fn to_json(
  self : IndicesDeleteDataStreamOptionsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteDataStreamOptionsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesDeleteDataStreamOptionsQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesDeleteDataStreamOptionsQuery::new(
  expand_wildcards? : String,
  master_timeout? : String,
  timeout? : String,
) -> IndicesDeleteDataStreamOptionsQuery {
  { expand_wildcards, master_timeout, timeout }
}

///|
pub fn IndicesDeleteDataStreamOptionsQuery::to_pairs(
  self : IndicesDeleteDataStreamOptionsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteDataStreamOptionsResponse = Json

///|
pub(all) struct IndicesDeleteDataStreamOptionsRequest {
  name : String
  query : IndicesDeleteDataStreamOptionsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteDataStreamOptionsRequest::new(
  name : String,
  query? : IndicesDeleteDataStreamOptionsQuery = IndicesDeleteDataStreamOptionsQuery::new(),
) -> IndicesDeleteDataStreamOptionsRequest {
  { name, query }
}

///|
pub async fn Client::indices_delete_data_stream_options(
  self : Client,
  request : IndicesDeleteDataStreamOptionsRequest,
) -> EsResponse[IndicesDeleteDataStreamOptionsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_options", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDeleteIndexTemplateQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteIndexTemplateQuery with fn to_json(
  self : IndicesDeleteIndexTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteIndexTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesDeleteIndexTemplateQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesDeleteIndexTemplateQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesDeleteIndexTemplateQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesDeleteIndexTemplateQuery::to_pairs(
  self : IndicesDeleteIndexTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteIndexTemplateResponse = Json

///|
pub(all) struct IndicesDeleteIndexTemplateRequest {
  name : String
  query : IndicesDeleteIndexTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteIndexTemplateRequest::new(
  name : String,
  query? : IndicesDeleteIndexTemplateQuery = IndicesDeleteIndexTemplateQuery::new(),
) -> IndicesDeleteIndexTemplateRequest {
  { name, query }
}

///|
pub async fn Client::indices_delete_index_template(
  self : Client,
  request : IndicesDeleteIndexTemplateRequest,
) -> EsResponse[IndicesDeleteIndexTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_index_template/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDeleteTemplateQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDeleteTemplateQuery with fn to_json(
  self : IndicesDeleteTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDeleteTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesDeleteTemplateQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesDeleteTemplateQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesDeleteTemplateQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesDeleteTemplateQuery::to_pairs(
  self : IndicesDeleteTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDeleteTemplateResponse = Json

///|
pub(all) struct IndicesDeleteTemplateRequest {
  name : String
  query : IndicesDeleteTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDeleteTemplateRequest::new(
  name : String,
  query? : IndicesDeleteTemplateQuery = IndicesDeleteTemplateQuery::new(),
) -> IndicesDeleteTemplateRequest {
  { name, query }
}

///|
pub async fn Client::indices_delete_template(
  self : Client,
  request : IndicesDeleteTemplateRequest,
) -> EsResponse[IndicesDeleteTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_template/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesDiskUsageQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flush : Bool?
  ignore_unavailable : Bool?
  run_expensive_tasks : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDiskUsageQuery with fn to_json(
  self : IndicesDiskUsageQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flush {
    Some(value) => obj["flush"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.run_expensive_tasks {
    Some(value) => obj["run_expensive_tasks"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesDiskUsageQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesDiskUsageQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flush: match obj.get("flush") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("flush")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    run_expensive_tasks: match obj.get("run_expensive_tasks") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("run_expensive_tasks")))
    },
  }
}

///|
pub fn IndicesDiskUsageQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flush? : Bool,
  ignore_unavailable? : Bool,
  run_expensive_tasks? : Bool,
) -> IndicesDiskUsageQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flush,
    ignore_unavailable,
    run_expensive_tasks,
  }
}

///|
pub fn IndicesDiskUsageQuery::to_pairs(
  self : IndicesDiskUsageQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flush {
    Some(value) => push_query_json(pairs, "flush", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.run_expensive_tasks {
    Some(value) =>
      push_query_json(pairs, "run_expensive_tasks", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesDiskUsageResponse = Json

///|
pub(all) struct IndicesDiskUsageRequest {
  index : String
  query : IndicesDiskUsageQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDiskUsageRequest::new(
  index : String,
  query? : IndicesDiskUsageQuery = IndicesDiskUsageQuery::new(),
) -> IndicesDiskUsageRequest {
  { index, query }
}

///|
pub async fn Client::indices_disk_usage(
  self : Client,
  request : IndicesDiskUsageRequest,
) -> EsResponse[IndicesDiskUsageResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_disk_usage", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesDownsampleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesDownsampleQuery with fn to_json(
  _self : IndicesDownsampleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesDownsampleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IndicesDownsampleQuery: expected object"))
  }
  IndicesDownsampleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesDownsampleQuery::new() -> IndicesDownsampleQuery {
  IndicesDownsampleQuery::{  }
}

///|
pub fn IndicesDownsampleQuery::to_pairs(
  _self : IndicesDownsampleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type IndicesDownsampleBody = Json

///|
pub type IndicesDownsampleResponse = Json

///|
pub(all) struct IndicesDownsampleRequest {
  index : String
  target_index : String
  query : IndicesDownsampleQuery
  body : IndicesDownsampleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesDownsampleRequest::new(
  index : String,
  target_index : String,
  body : IndicesDownsampleBody,
  query? : IndicesDownsampleQuery = IndicesDownsampleQuery::new(),
) -> IndicesDownsampleRequest {
  { index, target_index, query, body }
}

///|
pub async fn Client::indices_downsample(
  self : Client,
  request : IndicesDownsampleRequest,
) -> EsResponse[IndicesDownsampleResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["target_index"] = request.target_index
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_downsample/{target_index}", [
        "index", "target_index",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesExistsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flat_settings : Bool?
  ignore_unavailable : Bool?
  include_defaults : Bool?
  local_ : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesExistsQuery with fn to_json(
  self : IndicesExistsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesExistsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesExistsQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
  }
}

///|
pub fn IndicesExistsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flat_settings? : Bool,
  ignore_unavailable? : Bool,
  include_defaults? : Bool,
  local_? : Bool,
) -> IndicesExistsQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flat_settings,
    ignore_unavailable,
    include_defaults,
    local_,
  }
}

///|
pub fn IndicesExistsQuery::to_pairs(
  self : IndicesExistsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesExistsResponse = Json

///|
pub(all) struct IndicesExistsRequest {
  index : String
  query : IndicesExistsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesExistsRequest::new(
  index : String,
  query? : IndicesExistsQuery = IndicesExistsQuery::new(),
) -> IndicesExistsRequest {
  { index, query }
}

///|
pub async fn Client::indices_exists(
  self : Client,
  request : IndicesExistsRequest,
) -> EsResponse[IndicesExistsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/{index}", ["index"])], params)
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct IndicesExistsAliasQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesExistsAliasQuery with fn to_json(
  self : IndicesExistsAliasQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesExistsAliasQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesExistsAliasQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesExistsAliasQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
) -> IndicesExistsAliasQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, master_timeout }
}

///|
pub fn IndicesExistsAliasQuery::to_pairs(
  self : IndicesExistsAliasQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesExistsAliasResponse = Json

///|
pub(all) struct IndicesExistsAliasRequest {
  index : String?
  name : String
  query : IndicesExistsAliasQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesExistsAliasRequest::new(
  name : String,
  index? : String,
  query? : IndicesExistsAliasQuery = IndicesExistsAliasQuery::new(),
) -> IndicesExistsAliasRequest {
  { index, name, query }
}

///|
pub async fn Client::indices_exists_alias(
  self : Client,
  request : IndicesExistsAliasRequest,
) -> EsResponse[IndicesExistsAliasResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_alias/{name}", ["index", "name"]),
      PathVariant::new("/_alias/{name}", ["name"]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct IndicesExistsIndexTemplateQuery {
  local_ : Bool?
  flat_settings : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesExistsIndexTemplateQuery with fn to_json(
  self : IndicesExistsIndexTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesExistsIndexTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesExistsIndexTemplateQuery: expected object"),
    )
  }
  {
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesExistsIndexTemplateQuery::new(
  local_? : Bool,
  flat_settings? : Bool,
  master_timeout? : String,
) -> IndicesExistsIndexTemplateQuery {
  { local_, flat_settings, master_timeout }
}

///|
pub fn IndicesExistsIndexTemplateQuery::to_pairs(
  self : IndicesExistsIndexTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesExistsIndexTemplateResponse = Json

///|
pub(all) struct IndicesExistsIndexTemplateRequest {
  name : String
  query : IndicesExistsIndexTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesExistsIndexTemplateRequest::new(
  name : String,
  query? : IndicesExistsIndexTemplateQuery = IndicesExistsIndexTemplateQuery::new(),
) -> IndicesExistsIndexTemplateRequest {
  { name, query }
}

///|
pub async fn Client::indices_exists_index_template(
  self : Client,
  request : IndicesExistsIndexTemplateRequest,
) -> EsResponse[IndicesExistsIndexTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_index_template/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct IndicesExistsTemplateQuery {
  flat_settings : Bool?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesExistsTemplateQuery with fn to_json(
  self : IndicesExistsTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesExistsTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesExistsTemplateQuery: expected object"))
  }
  {
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesExistsTemplateQuery::new(
  flat_settings? : Bool,
  local_? : Bool,
  master_timeout? : String,
) -> IndicesExistsTemplateQuery {
  { flat_settings, local_, master_timeout }
}

///|
pub fn IndicesExistsTemplateQuery::to_pairs(
  self : IndicesExistsTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesExistsTemplateResponse = Json

///|
pub(all) struct IndicesExistsTemplateRequest {
  name : String
  query : IndicesExistsTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesExistsTemplateRequest::new(
  name : String,
  query? : IndicesExistsTemplateQuery = IndicesExistsTemplateQuery::new(),
) -> IndicesExistsTemplateRequest {
  { name, query }
}

///|
pub async fn Client::indices_exists_template(
  self : Client,
  request : IndicesExistsTemplateRequest,
) -> EsResponse[IndicesExistsTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_template/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct IndicesExplainDataLifecycleQuery {
  include_defaults : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesExplainDataLifecycleQuery with fn to_json(
  self : IndicesExplainDataLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesExplainDataLifecycleQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesExplainDataLifecycleQuery: expected object"),
    )
  }
  {
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesExplainDataLifecycleQuery::new(
  include_defaults? : Bool,
  master_timeout? : String,
) -> IndicesExplainDataLifecycleQuery {
  { include_defaults, master_timeout }
}

///|
pub fn IndicesExplainDataLifecycleQuery::to_pairs(
  self : IndicesExplainDataLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesExplainDataLifecycleResponse {
  indices : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesExplainDataLifecycleResponse with fn to_json(
  self : IndicesExplainDataLifecycleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesExplainDataLifecycleResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesExplainDataLifecycleResponse: expected object"),
    )
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct IndicesExplainDataLifecycleRequest {
  index : String
  query : IndicesExplainDataLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesExplainDataLifecycleRequest::new(
  index : String,
  query? : IndicesExplainDataLifecycleQuery = IndicesExplainDataLifecycleQuery::new(),
) -> IndicesExplainDataLifecycleRequest {
  { index, query }
}

///|
pub async fn Client::indices_explain_data_lifecycle(
  self : Client,
  request : IndicesExplainDataLifecycleRequest,
) -> EsResponse[IndicesExplainDataLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_lifecycle/explain", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesFieldUsageStatsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  fields : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesFieldUsageStatsQuery with fn to_json(
  self : IndicesFieldUsageStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesFieldUsageStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesFieldUsageStatsQuery: expected object"),
    )
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
  }
}

///|
pub fn IndicesFieldUsageStatsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  fields? : String,
) -> IndicesFieldUsageStatsQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, fields }
}

///|
pub fn IndicesFieldUsageStatsQuery::to_pairs(
  self : IndicesFieldUsageStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesFieldUsageStatsResponse = Json

///|
pub(all) struct IndicesFieldUsageStatsRequest {
  index : String
  query : IndicesFieldUsageStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesFieldUsageStatsRequest::new(
  index : String,
  query? : IndicesFieldUsageStatsQuery = IndicesFieldUsageStatsQuery::new(),
) -> IndicesFieldUsageStatsRequest {
  { index, query }
}

///|
pub async fn Client::indices_field_usage_stats(
  self : Client,
  request : IndicesFieldUsageStatsRequest,
) -> EsResponse[IndicesFieldUsageStatsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_field_usage_stats", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesFlushQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  force : Bool?
  ignore_unavailable : Bool?
  wait_if_ongoing : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesFlushQuery with fn to_json(self : IndicesFlushQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.wait_if_ongoing {
    Some(value) => obj["wait_if_ongoing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesFlushQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesFlushQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    wait_if_ongoing: match obj.get("wait_if_ongoing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_if_ongoing")))
    },
  }
}

///|
pub fn IndicesFlushQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  force? : Bool,
  ignore_unavailable? : Bool,
  wait_if_ongoing? : Bool,
) -> IndicesFlushQuery {
  {
    allow_no_indices,
    expand_wildcards,
    force,
    ignore_unavailable,
    wait_if_ongoing,
  }
}

///|
pub fn IndicesFlushQuery::to_pairs(
  self : IndicesFlushQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.wait_if_ongoing {
    Some(value) => push_query_json(pairs, "wait_if_ongoing", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesFlushResponse = Json

///|
pub(all) struct IndicesFlushRequest {
  index : String?
  query : IndicesFlushQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesFlushRequest::new(
  index? : String,
  query? : IndicesFlushQuery = IndicesFlushQuery::new(),
) -> IndicesFlushRequest {
  { index, query }
}

///|
pub async fn Client::indices_flush(
  self : Client,
  request : IndicesFlushRequest,
) -> EsResponse[IndicesFlushResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_flush", ["index"]),
      PathVariant::new("/_flush", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesForcemergeQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flush : Bool?
  ignore_unavailable : Bool?
  max_num_segments : Int?
  only_expunge_deletes : Bool?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesForcemergeQuery with fn to_json(
  self : IndicesForcemergeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flush {
    Some(value) => obj["flush"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.max_num_segments {
    Some(value) => obj["max_num_segments"] = value.to_json()
    None => ()
  }
  match self.only_expunge_deletes {
    Some(value) => obj["only_expunge_deletes"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesForcemergeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesForcemergeQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flush: match obj.get("flush") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("flush")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    max_num_segments: match obj.get("max_num_segments") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_num_segments")))
    },
    only_expunge_deletes: match obj.get("only_expunge_deletes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("only_expunge_deletes")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn IndicesForcemergeQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flush? : Bool,
  ignore_unavailable? : Bool,
  max_num_segments? : Int,
  only_expunge_deletes? : Bool,
  wait_for_completion? : Bool,
) -> IndicesForcemergeQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flush,
    ignore_unavailable,
    max_num_segments,
    only_expunge_deletes,
    wait_for_completion,
  }
}

///|
pub fn IndicesForcemergeQuery::to_pairs(
  self : IndicesForcemergeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flush {
    Some(value) => push_query_json(pairs, "flush", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.max_num_segments {
    Some(value) => push_query_json(pairs, "max_num_segments", value.to_json())
    None => ()
  }
  match self.only_expunge_deletes {
    Some(value) =>
      push_query_json(pairs, "only_expunge_deletes", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesForcemergeResponse = Json

///|
pub(all) struct IndicesForcemergeRequest {
  index : String?
  query : IndicesForcemergeQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesForcemergeRequest::new(
  index? : String,
  query? : IndicesForcemergeQuery = IndicesForcemergeQuery::new(),
) -> IndicesForcemergeRequest {
  { index, query }
}

///|
pub async fn Client::indices_forcemerge(
  self : Client,
  request : IndicesForcemergeRequest,
) -> EsResponse[IndicesForcemergeResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_forcemerge", ["index"]),
      PathVariant::new("/_forcemerge", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesGetQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flat_settings : Bool?
  ignore_unavailable : Bool?
  include_defaults : Bool?
  local_ : Bool?
  master_timeout : String?
  features : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetQuery with fn to_json(self : IndicesGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.features {
    Some(value) => obj["features"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesGetQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    features: match obj.get("features") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("features")))
    },
  }
}

///|
pub fn IndicesGetQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flat_settings? : Bool,
  ignore_unavailable? : Bool,
  include_defaults? : Bool,
  local_? : Bool,
  master_timeout? : String,
  features? : String,
) -> IndicesGetQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flat_settings,
    ignore_unavailable,
    include_defaults,
    local_,
    master_timeout,
    features,
  }
}

///|
pub fn IndicesGetQuery::to_pairs(
  self : IndicesGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.features {
    Some(value) => push_query_json(pairs, "features", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesGetResponse = Json

///|
pub(all) struct IndicesGetRequest {
  index : String
  query : IndicesGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetRequest::new(
  index : String,
  query? : IndicesGetQuery = IndicesGetQuery::new(),
) -> IndicesGetRequest {
  { index, query }
}

///|
pub async fn Client::indices_get(
  self : Client,
  request : IndicesGetRequest,
) -> EsResponse[IndicesGetResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/{index}", ["index"])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetAliasQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetAliasQuery with fn to_json(
  self : IndicesGetAliasQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetAliasQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesGetAliasQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetAliasQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
) -> IndicesGetAliasQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, master_timeout }
}

///|
pub fn IndicesGetAliasQuery::to_pairs(
  self : IndicesGetAliasQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesGetAliasResponse = Json

///|
pub(all) struct IndicesGetAliasRequest {
  index : String?
  name : String?
  query : IndicesGetAliasQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetAliasRequest::new(
  index? : String,
  name? : String,
  query? : IndicesGetAliasQuery = IndicesGetAliasQuery::new(),
) -> IndicesGetAliasRequest {
  { index, name, query }
}

///|
pub async fn Client::indices_get_alias(
  self : Client,
  request : IndicesGetAliasRequest,
) -> EsResponse[IndicesGetAliasResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_alias/{name}", ["index", "name"]),
      PathVariant::new("/_alias/{name}", ["name"]),
      PathVariant::new("/{index}/_alias", ["index"]),
      PathVariant::new("/_alias", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetDataLifecycleQuery {
  expand_wildcards : String?
  include_defaults : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataLifecycleQuery with fn to_json(
  self : IndicesGetDataLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataLifecycleQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetDataLifecycleQuery::new(
  expand_wildcards? : String,
  include_defaults? : Bool,
  master_timeout? : String,
) -> IndicesGetDataLifecycleQuery {
  { expand_wildcards, include_defaults, master_timeout }
}

///|
pub fn IndicesGetDataLifecycleQuery::to_pairs(
  self : IndicesGetDataLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesGetDataLifecycleResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataLifecycleResponse with fn to_json(
  self : IndicesGetDataLifecycleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataLifecycleResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataLifecycleResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesGetDataLifecycleRequest {
  name : String
  query : IndicesGetDataLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetDataLifecycleRequest::new(
  name : String,
  query? : IndicesGetDataLifecycleQuery = IndicesGetDataLifecycleQuery::new(),
) -> IndicesGetDataLifecycleRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_data_lifecycle(
  self : Client,
  request : IndicesGetDataLifecycleRequest,
) -> EsResponse[IndicesGetDataLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_lifecycle", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetDataLifecycleStatsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataLifecycleStatsQuery with fn to_json(
  _self : IndicesGetDataLifecycleStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesGetDataLifecycleStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "IndicesGetDataLifecycleStatsQuery: expected object"),
    )
  }
  IndicesGetDataLifecycleStatsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesGetDataLifecycleStatsQuery::new() -> IndicesGetDataLifecycleStatsQuery {
  IndicesGetDataLifecycleStatsQuery::{  }
}

///|
pub fn IndicesGetDataLifecycleStatsQuery::to_pairs(
  _self : IndicesGetDataLifecycleStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IndicesGetDataLifecycleStatsResponse {
  data_stream_count : Int
  data_streams : Array[Json]
  last_run_duration_in_millis : Json?
  time_between_starts_in_millis : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataLifecycleStatsResponse with fn to_json(
  self : IndicesGetDataLifecycleStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_stream_count"] = self.data_stream_count.to_json()
  obj["data_streams"] = self.data_streams.to_json()
  match self.last_run_duration_in_millis {
    Some(value) => obj["last_run_duration_in_millis"] = value.to_json()
    None => ()
  }
  match self.time_between_starts_in_millis {
    Some(value) => obj["time_between_starts_in_millis"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataLifecycleStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataLifecycleStatsResponse: expected object"),
    )
  }
  {
    data_stream_count: @json.from_json(
      obj.get("data_stream_count").unwrap_or(Json::null()),
      path=path.add_key("data_stream_count"),
    ),
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
    last_run_duration_in_millis: match obj.get("last_run_duration_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("last_run_duration_in_millis"),
          ),
        )
    },
    time_between_starts_in_millis: match
      obj.get("time_between_starts_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("time_between_starts_in_millis"),
          ),
        )
    },
  }
}

///|
pub(all) struct IndicesGetDataLifecycleStatsRequest {
  query : IndicesGetDataLifecycleStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetDataLifecycleStatsRequest::new(
  query? : IndicesGetDataLifecycleStatsQuery = IndicesGetDataLifecycleStatsQuery::new(),
) -> IndicesGetDataLifecycleStatsRequest {
  { query, }
}

///|
pub async fn Client::indices_get_data_lifecycle_stats(
  self : Client,
  request : IndicesGetDataLifecycleStatsRequest,
) -> EsResponse[IndicesGetDataLifecycleStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_lifecycle/stats", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetDataStreamQuery {
  expand_wildcards : String?
  include_defaults : Bool?
  master_timeout : String?
  verbose : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamQuery with fn to_json(
  self : IndicesGetDataStreamQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.verbose {
    Some(value) => obj["verbose"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesGetDataStreamQuery: expected object"))
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    verbose: match obj.get("verbose") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("verbose")))
    },
  }
}

///|
pub fn IndicesGetDataStreamQuery::new(
  expand_wildcards? : String,
  include_defaults? : Bool,
  master_timeout? : String,
  verbose? : Bool,
) -> IndicesGetDataStreamQuery {
  { expand_wildcards, include_defaults, master_timeout, verbose }
}

///|
pub fn IndicesGetDataStreamQuery::to_pairs(
  self : IndicesGetDataStreamQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.verbose {
    Some(value) => push_query_json(pairs, "verbose", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesGetDataStreamResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamResponse with fn to_json(
  self : IndicesGetDataStreamResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesGetDataStreamRequest {
  name : String?
  query : IndicesGetDataStreamQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetDataStreamRequest::new(
  name? : String,
  query? : IndicesGetDataStreamQuery = IndicesGetDataStreamQuery::new(),
) -> IndicesGetDataStreamRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_data_stream(
  self : Client,
  request : IndicesGetDataStreamRequest,
) -> EsResponse[IndicesGetDataStreamResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_data_stream/{name}", ["name"]),
      PathVariant::new("/_data_stream", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetDataStreamMappingsQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamMappingsQuery with fn to_json(
  self : IndicesGetDataStreamMappingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamMappingsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamMappingsQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetDataStreamMappingsQuery::new(
  master_timeout? : String,
) -> IndicesGetDataStreamMappingsQuery {
  { master_timeout, }
}

///|
pub fn IndicesGetDataStreamMappingsQuery::to_pairs(
  self : IndicesGetDataStreamMappingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesGetDataStreamMappingsResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamMappingsResponse with fn to_json(
  self : IndicesGetDataStreamMappingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamMappingsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamMappingsResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesGetDataStreamMappingsRequest {
  name : String
  query : IndicesGetDataStreamMappingsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetDataStreamMappingsRequest::new(
  name : String,
  query? : IndicesGetDataStreamMappingsQuery = IndicesGetDataStreamMappingsQuery::new(),
) -> IndicesGetDataStreamMappingsRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_data_stream_mappings(
  self : Client,
  request : IndicesGetDataStreamMappingsRequest,
) -> EsResponse[IndicesGetDataStreamMappingsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_mappings", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetDataStreamOptionsQuery {
  expand_wildcards : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamOptionsQuery with fn to_json(
  self : IndicesGetDataStreamOptionsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamOptionsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamOptionsQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetDataStreamOptionsQuery::new(
  expand_wildcards? : String,
  master_timeout? : String,
) -> IndicesGetDataStreamOptionsQuery {
  { expand_wildcards, master_timeout }
}

///|
pub fn IndicesGetDataStreamOptionsQuery::to_pairs(
  self : IndicesGetDataStreamOptionsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesGetDataStreamOptionsResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamOptionsResponse with fn to_json(
  self : IndicesGetDataStreamOptionsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamOptionsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamOptionsResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesGetDataStreamOptionsRequest {
  name : String
  query : IndicesGetDataStreamOptionsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetDataStreamOptionsRequest::new(
  name : String,
  query? : IndicesGetDataStreamOptionsQuery = IndicesGetDataStreamOptionsQuery::new(),
) -> IndicesGetDataStreamOptionsRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_data_stream_options(
  self : Client,
  request : IndicesGetDataStreamOptionsRequest,
) -> EsResponse[IndicesGetDataStreamOptionsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_options", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetDataStreamSettingsQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamSettingsQuery with fn to_json(
  self : IndicesGetDataStreamSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamSettingsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamSettingsQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetDataStreamSettingsQuery::new(
  master_timeout? : String,
) -> IndicesGetDataStreamSettingsQuery {
  { master_timeout, }
}

///|
pub fn IndicesGetDataStreamSettingsQuery::to_pairs(
  self : IndicesGetDataStreamSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesGetDataStreamSettingsResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetDataStreamSettingsResponse with fn to_json(
  self : IndicesGetDataStreamSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetDataStreamSettingsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetDataStreamSettingsResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesGetDataStreamSettingsRequest {
  name : String
  query : IndicesGetDataStreamSettingsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetDataStreamSettingsRequest::new(
  name : String,
  query? : IndicesGetDataStreamSettingsQuery = IndicesGetDataStreamSettingsQuery::new(),
) -> IndicesGetDataStreamSettingsRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_data_stream_settings(
  self : Client,
  request : IndicesGetDataStreamSettingsRequest,
) -> EsResponse[IndicesGetDataStreamSettingsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_settings", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetFieldMappingQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  include_defaults : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetFieldMappingQuery with fn to_json(
  self : IndicesGetFieldMappingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetFieldMappingQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetFieldMappingQuery: expected object"),
    )
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
  }
}

///|
pub fn IndicesGetFieldMappingQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  include_defaults? : Bool,
) -> IndicesGetFieldMappingQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, include_defaults }
}

///|
pub fn IndicesGetFieldMappingQuery::to_pairs(
  self : IndicesGetFieldMappingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesGetFieldMappingResponse = Json

///|
pub(all) struct IndicesGetFieldMappingRequest {
  index : String?
  fields : String
  query : IndicesGetFieldMappingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetFieldMappingRequest::new(
  fields : String,
  index? : String,
  query? : IndicesGetFieldMappingQuery = IndicesGetFieldMappingQuery::new(),
) -> IndicesGetFieldMappingRequest {
  { index, fields, query }
}

///|
pub async fn Client::indices_get_field_mapping(
  self : Client,
  request : IndicesGetFieldMappingRequest,
) -> EsResponse[IndicesGetFieldMappingResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  params["fields"] = request.fields
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_mapping/field/{fields}", ["index", "fields"]),
      PathVariant::new("/_mapping/field/{fields}", ["fields"]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetIndexTemplateQuery {
  local_ : Bool?
  flat_settings : Bool?
  master_timeout : String?
  include_defaults : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetIndexTemplateQuery with fn to_json(
  self : IndicesGetIndexTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetIndexTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetIndexTemplateQuery: expected object"),
    )
  }
  {
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
  }
}

///|
pub fn IndicesGetIndexTemplateQuery::new(
  local_? : Bool,
  flat_settings? : Bool,
  master_timeout? : String,
  include_defaults? : Bool,
) -> IndicesGetIndexTemplateQuery {
  { local_, flat_settings, master_timeout, include_defaults }
}

///|
pub fn IndicesGetIndexTemplateQuery::to_pairs(
  self : IndicesGetIndexTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesGetIndexTemplateResponse {
  index_templates : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetIndexTemplateResponse with fn to_json(
  self : IndicesGetIndexTemplateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["index_templates"] = self.index_templates.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetIndexTemplateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetIndexTemplateResponse: expected object"),
    )
  }
  {
    index_templates: @json.from_json(
      obj.get("index_templates").unwrap_or(Json::null()),
      path=path.add_key("index_templates"),
    ),
  }
}

///|
pub(all) struct IndicesGetIndexTemplateRequest {
  name : String?
  query : IndicesGetIndexTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetIndexTemplateRequest::new(
  name? : String,
  query? : IndicesGetIndexTemplateQuery = IndicesGetIndexTemplateQuery::new(),
) -> IndicesGetIndexTemplateRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_index_template(
  self : Client,
  request : IndicesGetIndexTemplateRequest,
) -> EsResponse[IndicesGetIndexTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_index_template/{name}", ["name"]),
      PathVariant::new("/_index_template", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetMappingQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetMappingQuery with fn to_json(
  self : IndicesGetMappingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetMappingQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesGetMappingQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetMappingQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  local_? : Bool,
  master_timeout? : String,
) -> IndicesGetMappingQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    local_,
    master_timeout,
  }
}

///|
pub fn IndicesGetMappingQuery::to_pairs(
  self : IndicesGetMappingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesGetMappingResponse = Json

///|
pub(all) struct IndicesGetMappingRequest {
  index : String?
  query : IndicesGetMappingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetMappingRequest::new(
  index? : String,
  query? : IndicesGetMappingQuery = IndicesGetMappingQuery::new(),
) -> IndicesGetMappingRequest {
  { index, query }
}

///|
pub async fn Client::indices_get_mapping(
  self : Client,
  request : IndicesGetMappingRequest,
) -> EsResponse[IndicesGetMappingResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_mapping", ["index"]),
      PathVariant::new("/_mapping", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetMigrateReindexStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetMigrateReindexStatusQuery with fn to_json(
  _self : IndicesGetMigrateReindexStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesGetMigrateReindexStatusQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "IndicesGetMigrateReindexStatusQuery: expected object"),
    )
  }
  IndicesGetMigrateReindexStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesGetMigrateReindexStatusQuery::new() -> IndicesGetMigrateReindexStatusQuery {
  IndicesGetMigrateReindexStatusQuery::{  }
}

///|
pub fn IndicesGetMigrateReindexStatusQuery::to_pairs(
  _self : IndicesGetMigrateReindexStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type IndicesGetMigrateReindexStatusBody = Json

///|
pub(all) struct IndicesGetMigrateReindexStatusResponse {
  start_time : Json?
  start_time_millis : Json
  complete : Bool
  total_indices_in_data_stream : Int
  total_indices_requiring_upgrade : Int
  successes : Int
  in_progress : Array[Json]
  pending : Int
  errors : Array[Json]
  exception : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetMigrateReindexStatusResponse with fn to_json(
  self : IndicesGetMigrateReindexStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.start_time {
    Some(value) => obj["start_time"] = value.to_json()
    None => ()
  }
  obj["start_time_millis"] = self.start_time_millis.to_json()
  obj["complete"] = self.complete.to_json()
  obj["total_indices_in_data_stream"] = self.total_indices_in_data_stream.to_json()
  obj["total_indices_requiring_upgrade"] = self.total_indices_requiring_upgrade.to_json()
  obj["successes"] = self.successes.to_json()
  obj["in_progress"] = self.in_progress.to_json()
  obj["pending"] = self.pending.to_json()
  obj["errors"] = self.errors.to_json()
  match self.exception {
    Some(value) => obj["exception"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetMigrateReindexStatusResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesGetMigrateReindexStatusResponse: expected object"),
    )
  }
  {
    start_time: match obj.get("start_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("start_time")))
    },
    start_time_millis: @json.from_json(
      obj.get("start_time_millis").unwrap_or(Json::null()),
      path=path.add_key("start_time_millis"),
    ),
    complete: @json.from_json(
      obj.get("complete").unwrap_or(Json::null()),
      path=path.add_key("complete"),
    ),
    total_indices_in_data_stream: @json.from_json(
      obj.get("total_indices_in_data_stream").unwrap_or(Json::null()),
      path=path.add_key("total_indices_in_data_stream"),
    ),
    total_indices_requiring_upgrade: @json.from_json(
      obj.get("total_indices_requiring_upgrade").unwrap_or(Json::null()),
      path=path.add_key("total_indices_requiring_upgrade"),
    ),
    successes: @json.from_json(
      obj.get("successes").unwrap_or(Json::null()),
      path=path.add_key("successes"),
    ),
    in_progress: @json.from_json(
      obj.get("in_progress").unwrap_or(Json::null()),
      path=path.add_key("in_progress"),
    ),
    pending: @json.from_json(
      obj.get("pending").unwrap_or(Json::null()),
      path=path.add_key("pending"),
    ),
    errors: @json.from_json(
      obj.get("errors").unwrap_or(Json::null()),
      path=path.add_key("errors"),
    ),
    exception: match obj.get("exception") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exception")))
    },
  }
}

///|
pub(all) struct IndicesGetMigrateReindexStatusRequest {
  index : String
  query : IndicesGetMigrateReindexStatusQuery
  body : IndicesGetMigrateReindexStatusBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetMigrateReindexStatusRequest::new(
  index : String,
  query? : IndicesGetMigrateReindexStatusQuery = IndicesGetMigrateReindexStatusQuery::new(),
  body? : IndicesGetMigrateReindexStatusBody,
) -> IndicesGetMigrateReindexStatusRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_get_migrate_reindex_status(
  self : Client,
  request : IndicesGetMigrateReindexStatusRequest,
) -> EsResponse[IndicesGetMigrateReindexStatusResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_migration/reindex/{index}/_status", ["index"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct IndicesGetSettingsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flat_settings : Bool?
  ignore_unavailable : Bool?
  include_defaults : Bool?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetSettingsQuery with fn to_json(
  self : IndicesGetSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesGetSettingsQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetSettingsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flat_settings? : Bool,
  ignore_unavailable? : Bool,
  include_defaults? : Bool,
  local_? : Bool,
  master_timeout? : String,
) -> IndicesGetSettingsQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flat_settings,
    ignore_unavailable,
    include_defaults,
    local_,
    master_timeout,
  }
}

///|
pub fn IndicesGetSettingsQuery::to_pairs(
  self : IndicesGetSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesGetSettingsResponse = Json

///|
pub(all) struct IndicesGetSettingsRequest {
  index : String?
  name : String?
  query : IndicesGetSettingsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetSettingsRequest::new(
  index? : String,
  name? : String,
  query? : IndicesGetSettingsQuery = IndicesGetSettingsQuery::new(),
) -> IndicesGetSettingsRequest {
  { index, name, query }
}

///|
pub async fn Client::indices_get_settings(
  self : Client,
  request : IndicesGetSettingsRequest,
) -> EsResponse[IndicesGetSettingsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_settings/{name}", ["index", "name"]),
      PathVariant::new("/{index}/_settings", ["index"]),
      PathVariant::new("/_settings/{name}", ["name"]),
      PathVariant::new("/_settings", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesGetTemplateQuery {
  flat_settings : Bool?
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesGetTemplateQuery with fn to_json(
  self : IndicesGetTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesGetTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesGetTemplateQuery: expected object"))
  }
  {
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesGetTemplateQuery::new(
  flat_settings? : Bool,
  local_? : Bool,
  master_timeout? : String,
) -> IndicesGetTemplateQuery {
  { flat_settings, local_, master_timeout }
}

///|
pub fn IndicesGetTemplateQuery::to_pairs(
  self : IndicesGetTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesGetTemplateResponse = Json

///|
pub(all) struct IndicesGetTemplateRequest {
  name : String?
  query : IndicesGetTemplateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesGetTemplateRequest::new(
  name? : String,
  query? : IndicesGetTemplateQuery = IndicesGetTemplateQuery::new(),
) -> IndicesGetTemplateRequest {
  { name, query }
}

///|
pub async fn Client::indices_get_template(
  self : Client,
  request : IndicesGetTemplateRequest,
) -> EsResponse[IndicesGetTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_template/{name}", ["name"]),
      PathVariant::new("/_template", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesMigrateReindexQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesMigrateReindexQuery with fn to_json(
  _self : IndicesMigrateReindexQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesMigrateReindexQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IndicesMigrateReindexQuery: expected object"))
  }
  IndicesMigrateReindexQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesMigrateReindexQuery::new() -> IndicesMigrateReindexQuery {
  IndicesMigrateReindexQuery::{  }
}

///|
pub fn IndicesMigrateReindexQuery::to_pairs(
  _self : IndicesMigrateReindexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type IndicesMigrateReindexBody = Json

///|
pub type IndicesMigrateReindexResponse = Json

///|
pub(all) struct IndicesMigrateReindexRequest {
  query : IndicesMigrateReindexQuery
  body : IndicesMigrateReindexBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesMigrateReindexRequest::new(
  body : IndicesMigrateReindexBody,
  query? : IndicesMigrateReindexQuery = IndicesMigrateReindexQuery::new(),
) -> IndicesMigrateReindexRequest {
  { query, body }
}

///|
pub async fn Client::indices_migrate_reindex(
  self : Client,
  request : IndicesMigrateReindexRequest,
) -> EsResponse[IndicesMigrateReindexResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_migration/reindex", [])], params)
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesMigrateToDataStreamQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesMigrateToDataStreamQuery with fn to_json(
  self : IndicesMigrateToDataStreamQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesMigrateToDataStreamQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesMigrateToDataStreamQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesMigrateToDataStreamQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesMigrateToDataStreamQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesMigrateToDataStreamQuery::to_pairs(
  self : IndicesMigrateToDataStreamQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesMigrateToDataStreamResponse = Json

///|
pub(all) struct IndicesMigrateToDataStreamRequest {
  name : String
  query : IndicesMigrateToDataStreamQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesMigrateToDataStreamRequest::new(
  name : String,
  query? : IndicesMigrateToDataStreamQuery = IndicesMigrateToDataStreamQuery::new(),
) -> IndicesMigrateToDataStreamRequest {
  { name, query }
}

///|
pub async fn Client::indices_migrate_to_data_stream(
  self : Client,
  request : IndicesMigrateToDataStreamRequest,
) -> EsResponse[IndicesMigrateToDataStreamResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/_migrate/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesModifyDataStreamQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IndicesModifyDataStreamQuery with fn to_json(
  _self : IndicesModifyDataStreamQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IndicesModifyDataStreamQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "IndicesModifyDataStreamQuery: expected object"),
    )
  }
  IndicesModifyDataStreamQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IndicesModifyDataStreamQuery::new() -> IndicesModifyDataStreamQuery {
  IndicesModifyDataStreamQuery::{  }
}

///|
pub fn IndicesModifyDataStreamQuery::to_pairs(
  _self : IndicesModifyDataStreamQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IndicesModifyDataStreamBody {
  actions : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesModifyDataStreamBody with fn to_json(
  self : IndicesModifyDataStreamBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["actions"] = self.actions.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesModifyDataStreamBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesModifyDataStreamBody: expected object"),
    )
  }
  {
    actions: @json.from_json(
      obj.get("actions").unwrap_or(Json::null()),
      path=path.add_key("actions"),
    ),
  }
}

///|
pub fn IndicesModifyDataStreamBody::new(
  actions : Array[Json],
) -> IndicesModifyDataStreamBody {
  { actions, }
}

///|
pub type IndicesModifyDataStreamResponse = Json

///|
pub(all) struct IndicesModifyDataStreamRequest {
  query : IndicesModifyDataStreamQuery
  body : IndicesModifyDataStreamBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesModifyDataStreamRequest::new(
  body : IndicesModifyDataStreamBody,
  query? : IndicesModifyDataStreamQuery = IndicesModifyDataStreamQuery::new(),
) -> IndicesModifyDataStreamRequest {
  { query, body }
}

///|
pub async fn Client::indices_modify_data_stream(
  self : Client,
  request : IndicesModifyDataStreamRequest,
) -> EsResponse[IndicesModifyDataStreamResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/_modify", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesOpenQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesOpenQuery with fn to_json(self : IndicesOpenQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesOpenQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesOpenQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn IndicesOpenQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
) -> IndicesOpenQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    master_timeout,
    timeout,
    wait_for_active_shards,
  }
}

///|
pub fn IndicesOpenQuery::to_pairs(
  self : IndicesOpenQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesOpenResponse {
  acknowledged : Bool
  shards_acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesOpenResponse with fn to_json(
  self : IndicesOpenResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesOpenResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesOpenResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
  }
}

///|
pub(all) struct IndicesOpenRequest {
  index : String
  query : IndicesOpenQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesOpenRequest::new(
  index : String,
  query? : IndicesOpenQuery = IndicesOpenQuery::new(),
) -> IndicesOpenRequest {
  { index, query }
}

///|
pub async fn Client::indices_open(
  self : Client,
  request : IndicesOpenRequest,
) -> EsResponse[IndicesOpenResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_open", ["index"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesPromoteDataStreamQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPromoteDataStreamQuery with fn to_json(
  self : IndicesPromoteDataStreamQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPromoteDataStreamQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPromoteDataStreamQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn IndicesPromoteDataStreamQuery::new(
  master_timeout? : String,
) -> IndicesPromoteDataStreamQuery {
  { master_timeout, }
}

///|
pub fn IndicesPromoteDataStreamQuery::to_pairs(
  self : IndicesPromoteDataStreamQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesPromoteDataStreamResponse = Json

///|
pub(all) struct IndicesPromoteDataStreamRequest {
  name : String
  query : IndicesPromoteDataStreamQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPromoteDataStreamRequest::new(
  name : String,
  query? : IndicesPromoteDataStreamQuery = IndicesPromoteDataStreamQuery::new(),
) -> IndicesPromoteDataStreamRequest {
  { name, query }
}

///|
pub async fn Client::indices_promote_data_stream(
  self : Client,
  request : IndicesPromoteDataStreamRequest,
) -> EsResponse[IndicesPromoteDataStreamResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/_promote/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesPutAliasQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutAliasQuery with fn to_json(
  self : IndicesPutAliasQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutAliasQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutAliasQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesPutAliasQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesPutAliasQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesPutAliasQuery::to_pairs(
  self : IndicesPutAliasQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutAliasBody {
  filter : Json?
  index_routing : String?
  is_write_index : Bool?
  routing : String?
  search_routing : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutAliasBody with fn to_json(
  self : IndicesPutAliasBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.index_routing {
    Some(value) => obj["index_routing"] = value.to_json()
    None => ()
  }
  match self.is_write_index {
    Some(value) => obj["is_write_index"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.search_routing {
    Some(value) => obj["search_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutAliasBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutAliasBody: expected object"))
  }
  {
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    index_routing: match obj.get("index_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_routing")))
    },
    is_write_index: match obj.get("is_write_index") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("is_write_index")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    search_routing: match obj.get("search_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_routing")))
    },
  }
}

///|
pub fn IndicesPutAliasBody::new(
  filter? : Json,
  index_routing? : String,
  is_write_index? : Bool,
  routing? : String,
  search_routing? : String,
) -> IndicesPutAliasBody {
  { filter, index_routing, is_write_index, routing, search_routing }
}

///|
pub type IndicesPutAliasResponse = Json

///|
pub(all) struct IndicesPutAliasRequest {
  index : String
  name : String
  query : IndicesPutAliasQuery
  body : IndicesPutAliasBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutAliasRequest::new(
  index : String,
  name : String,
  query? : IndicesPutAliasQuery = IndicesPutAliasQuery::new(),
  body? : IndicesPutAliasBody,
) -> IndicesPutAliasRequest {
  { index, name, query, body }
}

///|
pub async fn Client::indices_put_alias(
  self : Client,
  request : IndicesPutAliasRequest,
) -> EsResponse[IndicesPutAliasResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_alias/{name}", ["index", "name"]),
      PathVariant::new("/{index}/_aliases/{name}", ["index", "name"]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesPutDataLifecycleQuery {
  expand_wildcards : String?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataLifecycleQuery with fn to_json(
  self : IndicesPutDataLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataLifecycleQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesPutDataLifecycleQuery::new(
  expand_wildcards? : String,
  master_timeout? : String,
  timeout? : String,
) -> IndicesPutDataLifecycleQuery {
  { expand_wildcards, master_timeout, timeout }
}

///|
pub fn IndicesPutDataLifecycleQuery::to_pairs(
  self : IndicesPutDataLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutDataLifecycleBody {
  data_retention : Json?
  downsampling : Array[Json]?
  downsampling_method : Json?
  enabled : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataLifecycleBody with fn to_json(
  self : IndicesPutDataLifecycleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.data_retention {
    Some(value) => obj["data_retention"] = value.to_json()
    None => ()
  }
  match self.downsampling {
    Some(value) => obj["downsampling"] = value.to_json()
    None => ()
  }
  match self.downsampling_method {
    Some(value) => obj["downsampling_method"] = value.to_json()
    None => ()
  }
  match self.enabled {
    Some(value) => obj["enabled"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataLifecycleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataLifecycleBody: expected object"),
    )
  }
  {
    data_retention: match obj.get("data_retention") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_retention")))
    },
    downsampling: match obj.get("downsampling") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("downsampling")))
    },
    downsampling_method: match obj.get("downsampling_method") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("downsampling_method")))
    },
    enabled: match obj.get("enabled") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("enabled")))
    },
  }
}

///|
pub fn IndicesPutDataLifecycleBody::new(
  data_retention? : Json,
  downsampling? : Array[Json],
  downsampling_method? : Json,
  enabled? : Bool,
) -> IndicesPutDataLifecycleBody {
  { data_retention, downsampling, downsampling_method, enabled }
}

///|
pub type IndicesPutDataLifecycleResponse = Json

///|
pub(all) struct IndicesPutDataLifecycleRequest {
  name : String
  query : IndicesPutDataLifecycleQuery
  body : IndicesPutDataLifecycleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutDataLifecycleRequest::new(
  name : String,
  body : IndicesPutDataLifecycleBody,
  query? : IndicesPutDataLifecycleQuery = IndicesPutDataLifecycleQuery::new(),
) -> IndicesPutDataLifecycleRequest {
  { name, query, body }
}

///|
pub async fn Client::indices_put_data_lifecycle(
  self : Client,
  request : IndicesPutDataLifecycleRequest,
) -> EsResponse[IndicesPutDataLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_lifecycle", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IndicesPutDataStreamMappingsQuery {
  dry_run : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataStreamMappingsQuery with fn to_json(
  self : IndicesPutDataStreamMappingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataStreamMappingsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataStreamMappingsQuery: expected object"),
    )
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesPutDataStreamMappingsQuery::new(
  dry_run? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> IndicesPutDataStreamMappingsQuery {
  { dry_run, master_timeout, timeout }
}

///|
pub fn IndicesPutDataStreamMappingsQuery::to_pairs(
  self : IndicesPutDataStreamMappingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutDataStreamMappingsResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataStreamMappingsResponse with fn to_json(
  self : IndicesPutDataStreamMappingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataStreamMappingsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataStreamMappingsResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesPutDataStreamMappingsRequest {
  name : String
  query : IndicesPutDataStreamMappingsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutDataStreamMappingsRequest::new(
  name : String,
  query? : IndicesPutDataStreamMappingsQuery = IndicesPutDataStreamMappingsQuery::new(),
) -> IndicesPutDataStreamMappingsRequest {
  { name, query }
}

///|
pub async fn Client::indices_put_data_stream_mappings(
  self : Client,
  request : IndicesPutDataStreamMappingsRequest,
) -> EsResponse[IndicesPutDataStreamMappingsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_mappings", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct IndicesPutDataStreamOptionsQuery {
  expand_wildcards : String?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataStreamOptionsQuery with fn to_json(
  self : IndicesPutDataStreamOptionsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataStreamOptionsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataStreamOptionsQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesPutDataStreamOptionsQuery::new(
  expand_wildcards? : String,
  master_timeout? : String,
  timeout? : String,
) -> IndicesPutDataStreamOptionsQuery {
  { expand_wildcards, master_timeout, timeout }
}

///|
pub fn IndicesPutDataStreamOptionsQuery::to_pairs(
  self : IndicesPutDataStreamOptionsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutDataStreamOptionsBody {
  failure_store : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataStreamOptionsBody with fn to_json(
  self : IndicesPutDataStreamOptionsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.failure_store {
    Some(value) => obj["failure_store"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataStreamOptionsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataStreamOptionsBody: expected object"),
    )
  }
  {
    failure_store: match obj.get("failure_store") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("failure_store")))
    },
  }
}

///|
pub fn IndicesPutDataStreamOptionsBody::new(
  failure_store? : Json,
) -> IndicesPutDataStreamOptionsBody {
  { failure_store, }
}

///|
pub type IndicesPutDataStreamOptionsResponse = Json

///|
pub(all) struct IndicesPutDataStreamOptionsRequest {
  name : String
  query : IndicesPutDataStreamOptionsQuery
  body : IndicesPutDataStreamOptionsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutDataStreamOptionsRequest::new(
  name : String,
  body : IndicesPutDataStreamOptionsBody,
  query? : IndicesPutDataStreamOptionsQuery = IndicesPutDataStreamOptionsQuery::new(),
) -> IndicesPutDataStreamOptionsRequest {
  { name, query, body }
}

///|
pub async fn Client::indices_put_data_stream_options(
  self : Client,
  request : IndicesPutDataStreamOptionsRequest,
) -> EsResponse[IndicesPutDataStreamOptionsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_options", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IndicesPutDataStreamSettingsQuery {
  dry_run : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataStreamSettingsQuery with fn to_json(
  self : IndicesPutDataStreamSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataStreamSettingsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataStreamSettingsQuery: expected object"),
    )
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesPutDataStreamSettingsQuery::new(
  dry_run? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> IndicesPutDataStreamSettingsQuery {
  { dry_run, master_timeout, timeout }
}

///|
pub fn IndicesPutDataStreamSettingsQuery::to_pairs(
  self : IndicesPutDataStreamSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutDataStreamSettingsResponse {
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutDataStreamSettingsResponse with fn to_json(
  self : IndicesPutDataStreamSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutDataStreamSettingsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutDataStreamSettingsResponse: expected object"),
    )
  }
  {
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesPutDataStreamSettingsRequest {
  name : String
  query : IndicesPutDataStreamSettingsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutDataStreamSettingsRequest::new(
  name : String,
  query? : IndicesPutDataStreamSettingsQuery = IndicesPutDataStreamSettingsQuery::new(),
) -> IndicesPutDataStreamSettingsRequest {
  { name, query }
}

///|
pub async fn Client::indices_put_data_stream_settings(
  self : Client,
  request : IndicesPutDataStreamSettingsRequest,
) -> EsResponse[IndicesPutDataStreamSettingsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_data_stream/{name}/_settings", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct IndicesPutIndexTemplateQuery {
  create : Bool?
  master_timeout : String?
  cause : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutIndexTemplateQuery with fn to_json(
  self : IndicesPutIndexTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.create {
    Some(value) => obj["create"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.cause {
    Some(value) => obj["cause"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutIndexTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutIndexTemplateQuery: expected object"),
    )
  }
  {
    create: match obj.get("create") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("create")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    cause: match obj.get("cause") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cause")))
    },
  }
}

///|
pub fn IndicesPutIndexTemplateQuery::new(
  create? : Bool,
  master_timeout? : String,
  cause? : String,
) -> IndicesPutIndexTemplateQuery {
  { create, master_timeout, cause }
}

///|
pub fn IndicesPutIndexTemplateQuery::to_pairs(
  self : IndicesPutIndexTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.create {
    Some(value) => push_query_json(pairs, "create", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.cause {
    Some(value) => push_query_json(pairs, "cause", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutIndexTemplateBody {
  index_patterns : Json?
  composed_of : Array[Json]?
  template : Json?
  data_stream : Json?
  priority : Int?
  version : Json?
  _meta : Json?
  allow_auto_create : Bool?
  ignore_missing_component_templates : Array[String]?
  deprecated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutIndexTemplateBody with fn to_json(
  self : IndicesPutIndexTemplateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index_patterns {
    Some(value) => obj["index_patterns"] = value.to_json()
    None => ()
  }
  match self.composed_of {
    Some(value) => obj["composed_of"] = value.to_json()
    None => ()
  }
  match self.template {
    Some(value) => obj["template"] = value.to_json()
    None => ()
  }
  match self.data_stream {
    Some(value) => obj["data_stream"] = value.to_json()
    None => ()
  }
  match self.priority {
    Some(value) => obj["priority"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.allow_auto_create {
    Some(value) => obj["allow_auto_create"] = value.to_json()
    None => ()
  }
  match self.ignore_missing_component_templates {
    Some(value) => obj["ignore_missing_component_templates"] = value.to_json()
    None => ()
  }
  match self.deprecated {
    Some(value) => obj["deprecated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutIndexTemplateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesPutIndexTemplateBody: expected object"),
    )
  }
  {
    index_patterns: match obj.get("index_patterns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_patterns")))
    },
    composed_of: match obj.get("composed_of") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("composed_of")))
    },
    template: match obj.get("template") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("template")))
    },
    data_stream: match obj.get("data_stream") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_stream")))
    },
    priority: match obj.get("priority") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("priority")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    allow_auto_create: match obj.get("allow_auto_create") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_auto_create")))
    },
    ignore_missing_component_templates: match
      obj.get("ignore_missing_component_templates") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("ignore_missing_component_templates"),
          ),
        )
    },
    deprecated: match obj.get("deprecated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("deprecated")))
    },
  }
}

///|
pub fn IndicesPutIndexTemplateBody::new(
  index_patterns? : Json,
  composed_of? : Array[Json],
  template? : Json,
  data_stream? : Json,
  priority? : Int,
  version? : Json,
  _meta? : Json,
  allow_auto_create? : Bool,
  ignore_missing_component_templates? : Array[String],
  deprecated? : Bool,
) -> IndicesPutIndexTemplateBody {
  {
    index_patterns,
    composed_of,
    template,
    data_stream,
    priority,
    version,
    _meta,
    allow_auto_create,
    ignore_missing_component_templates,
    deprecated,
  }
}

///|
pub type IndicesPutIndexTemplateResponse = Json

///|
pub(all) struct IndicesPutIndexTemplateRequest {
  name : String
  query : IndicesPutIndexTemplateQuery
  body : IndicesPutIndexTemplateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutIndexTemplateRequest::new(
  name : String,
  body : IndicesPutIndexTemplateBody,
  query? : IndicesPutIndexTemplateQuery = IndicesPutIndexTemplateQuery::new(),
) -> IndicesPutIndexTemplateRequest {
  { name, query, body }
}

///|
pub async fn Client::indices_put_index_template(
  self : Client,
  request : IndicesPutIndexTemplateRequest,
) -> EsResponse[IndicesPutIndexTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_index_template/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesPutMappingQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
  timeout : String?
  write_index_only : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutMappingQuery with fn to_json(
  self : IndicesPutMappingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.write_index_only {
    Some(value) => obj["write_index_only"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutMappingQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutMappingQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    write_index_only: match obj.get("write_index_only") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("write_index_only")))
    },
  }
}

///|
pub fn IndicesPutMappingQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  timeout? : String,
  write_index_only? : Bool,
) -> IndicesPutMappingQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    master_timeout,
    timeout,
    write_index_only,
  }
}

///|
pub fn IndicesPutMappingQuery::to_pairs(
  self : IndicesPutMappingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.write_index_only {
    Some(value) => push_query_json(pairs, "write_index_only", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutMappingBody {
  date_detection : Bool?
  dynamic : Json?
  dynamic_date_formats : Array[String]?
  dynamic_templates : Array[Map[String, Json]]?
  _field_names : Json?
  _meta : Json?
  numeric_detection : Bool?
  properties : Map[String, Json]?
  _routing : Json?
  _source : Json?
  runtime : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutMappingBody with fn to_json(
  self : IndicesPutMappingBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.date_detection {
    Some(value) => obj["date_detection"] = value.to_json()
    None => ()
  }
  match self.dynamic {
    Some(value) => obj["dynamic"] = value.to_json()
    None => ()
  }
  match self.dynamic_date_formats {
    Some(value) => obj["dynamic_date_formats"] = value.to_json()
    None => ()
  }
  match self.dynamic_templates {
    Some(value) => obj["dynamic_templates"] = value.to_json()
    None => ()
  }
  match self._field_names {
    Some(value) => obj["_field_names"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.numeric_detection {
    Some(value) => obj["numeric_detection"] = value.to_json()
    None => ()
  }
  match self.properties {
    Some(value) => obj["properties"] = value.to_json()
    None => ()
  }
  match self._routing {
    Some(value) => obj["_routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.runtime {
    Some(value) => obj["runtime"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutMappingBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutMappingBody: expected object"))
  }
  {
    date_detection: match obj.get("date_detection") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("date_detection")))
    },
    dynamic: match obj.get("dynamic") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dynamic")))
    },
    dynamic_date_formats: match obj.get("dynamic_date_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("dynamic_date_formats")))
    },
    dynamic_templates: match obj.get("dynamic_templates") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("dynamic_templates")))
    },
    _field_names: match obj.get("_field_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_field_names")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    numeric_detection: match obj.get("numeric_detection") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("numeric_detection")))
    },
    properties: match obj.get("properties") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("properties")))
    },
    _routing: match obj.get("_routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    runtime: match obj.get("runtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("runtime")))
    },
  }
}

///|
pub fn IndicesPutMappingBody::new(
  date_detection? : Bool,
  dynamic? : Json,
  dynamic_date_formats? : Array[String],
  dynamic_templates? : Array[Map[String, Json]],
  _field_names? : Json,
  _meta? : Json,
  numeric_detection? : Bool,
  properties? : Map[String, Json],
  _routing? : Json,
  _source? : Json,
  runtime? : Json,
) -> IndicesPutMappingBody {
  {
    date_detection,
    dynamic,
    dynamic_date_formats,
    dynamic_templates,
    _field_names,
    _meta,
    numeric_detection,
    properties,
    _routing,
    _source,
    runtime,
  }
}

///|
pub type IndicesPutMappingResponse = Json

///|
pub(all) struct IndicesPutMappingRequest {
  index : String
  query : IndicesPutMappingQuery
  body : IndicesPutMappingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutMappingRequest::new(
  index : String,
  body : IndicesPutMappingBody,
  query? : IndicesPutMappingQuery = IndicesPutMappingQuery::new(),
) -> IndicesPutMappingRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_put_mapping(
  self : Client,
  request : IndicesPutMappingRequest,
) -> EsResponse[IndicesPutMappingResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_mapping", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesPutSettingsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  flat_settings : Bool?
  ignore_unavailable : Bool?
  master_timeout : String?
  preserve_existing : Bool?
  reopen : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutSettingsQuery with fn to_json(
  self : IndicesPutSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.preserve_existing {
    Some(value) => obj["preserve_existing"] = value.to_json()
    None => ()
  }
  match self.reopen {
    Some(value) => obj["reopen"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutSettingsQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    preserve_existing: match obj.get("preserve_existing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preserve_existing")))
    },
    reopen: match obj.get("reopen") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("reopen")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesPutSettingsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  flat_settings? : Bool,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  preserve_existing? : Bool,
  reopen? : Bool,
  timeout? : String,
) -> IndicesPutSettingsQuery {
  {
    allow_no_indices,
    expand_wildcards,
    flat_settings,
    ignore_unavailable,
    master_timeout,
    preserve_existing,
    reopen,
    timeout,
  }
}

///|
pub fn IndicesPutSettingsQuery::to_pairs(
  self : IndicesPutSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.preserve_existing {
    Some(value) => push_query_json(pairs, "preserve_existing", value.to_json())
    None => ()
  }
  match self.reopen {
    Some(value) => push_query_json(pairs, "reopen", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesPutSettingsBody = Json

///|
pub type IndicesPutSettingsResponse = Json

///|
pub(all) struct IndicesPutSettingsRequest {
  index : String?
  query : IndicesPutSettingsQuery
  body : IndicesPutSettingsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutSettingsRequest::new(
  body : IndicesPutSettingsBody,
  index? : String,
  query? : IndicesPutSettingsQuery = IndicesPutSettingsQuery::new(),
) -> IndicesPutSettingsRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_put_settings(
  self : Client,
  request : IndicesPutSettingsRequest,
) -> EsResponse[IndicesPutSettingsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_settings", ["index"]),
      PathVariant::new("/_settings", []),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IndicesPutTemplateQuery {
  create : Bool?
  master_timeout : String?
  order : Int?
  cause : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutTemplateQuery with fn to_json(
  self : IndicesPutTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.create {
    Some(value) => obj["create"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.order {
    Some(value) => obj["order"] = value.to_json()
    None => ()
  }
  match self.cause {
    Some(value) => obj["cause"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutTemplateQuery: expected object"))
  }
  {
    create: match obj.get("create") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("create")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    order: match obj.get("order") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("order")))
    },
    cause: match obj.get("cause") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cause")))
    },
  }
}

///|
pub fn IndicesPutTemplateQuery::new(
  create? : Bool,
  master_timeout? : String,
  order? : Int,
  cause? : String,
) -> IndicesPutTemplateQuery {
  { create, master_timeout, order, cause }
}

///|
pub fn IndicesPutTemplateQuery::to_pairs(
  self : IndicesPutTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.create {
    Some(value) => push_query_json(pairs, "create", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.order {
    Some(value) => push_query_json(pairs, "order", value.to_json())
    None => ()
  }
  match self.cause {
    Some(value) => push_query_json(pairs, "cause", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesPutTemplateBody {
  aliases : Map[String, Json]?
  index_patterns : Json?
  mappings : Json?
  order : Int?
  settings : Json?
  version : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesPutTemplateBody with fn to_json(
  self : IndicesPutTemplateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aliases {
    Some(value) => obj["aliases"] = value.to_json()
    None => ()
  }
  match self.index_patterns {
    Some(value) => obj["index_patterns"] = value.to_json()
    None => ()
  }
  match self.mappings {
    Some(value) => obj["mappings"] = value.to_json()
    None => ()
  }
  match self.order {
    Some(value) => obj["order"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesPutTemplateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesPutTemplateBody: expected object"))
  }
  {
    aliases: match obj.get("aliases") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aliases")))
    },
    index_patterns: match obj.get("index_patterns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_patterns")))
    },
    mappings: match obj.get("mappings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("mappings")))
    },
    order: match obj.get("order") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("order")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
  }
}

///|
pub fn IndicesPutTemplateBody::new(
  aliases? : Map[String, Json],
  index_patterns? : Json,
  mappings? : Json,
  order? : Int,
  settings? : Json,
  version? : Json,
) -> IndicesPutTemplateBody {
  { aliases, index_patterns, mappings, order, settings, version }
}

///|
pub type IndicesPutTemplateResponse = Json

///|
pub(all) struct IndicesPutTemplateRequest {
  name : String
  query : IndicesPutTemplateQuery
  body : IndicesPutTemplateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesPutTemplateRequest::new(
  name : String,
  body : IndicesPutTemplateBody,
  query? : IndicesPutTemplateQuery = IndicesPutTemplateQuery::new(),
) -> IndicesPutTemplateRequest {
  { name, query, body }
}

///|
pub async fn Client::indices_put_template(
  self : Client,
  request : IndicesPutTemplateRequest,
) -> EsResponse[IndicesPutTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_template/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesRecoveryQuery {
  active_only : Bool?
  detailed : Bool?
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRecoveryQuery with fn to_json(
  self : IndicesRecoveryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.active_only {
    Some(value) => obj["active_only"] = value.to_json()
    None => ()
  }
  match self.detailed {
    Some(value) => obj["detailed"] = value.to_json()
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRecoveryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRecoveryQuery: expected object"))
  }
  {
    active_only: match obj.get("active_only") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("active_only")))
    },
    detailed: match obj.get("detailed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detailed")))
    },
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn IndicesRecoveryQuery::new(
  active_only? : Bool,
  detailed? : Bool,
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
) -> IndicesRecoveryQuery {
  {
    active_only,
    detailed,
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
  }
}

///|
pub fn IndicesRecoveryQuery::to_pairs(
  self : IndicesRecoveryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.active_only {
    Some(value) => push_query_json(pairs, "active_only", value.to_json())
    None => ()
  }
  match self.detailed {
    Some(value) => push_query_json(pairs, "detailed", value.to_json())
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesRecoveryResponse = Json

///|
pub(all) struct IndicesRecoveryRequest {
  index : String?
  query : IndicesRecoveryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesRecoveryRequest::new(
  index? : String,
  query? : IndicesRecoveryQuery = IndicesRecoveryQuery::new(),
) -> IndicesRecoveryRequest {
  { index, query }
}

///|
pub async fn Client::indices_recovery(
  self : Client,
  request : IndicesRecoveryRequest,
) -> EsResponse[IndicesRecoveryResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_recovery", ["index"]),
      PathVariant::new("/_recovery", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesRefreshQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRefreshQuery with fn to_json(
  self : IndicesRefreshQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRefreshQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRefreshQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn IndicesRefreshQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
) -> IndicesRefreshQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable }
}

///|
pub fn IndicesRefreshQuery::to_pairs(
  self : IndicesRefreshQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesRefreshResponse = Json

///|
pub(all) struct IndicesRefreshRequest {
  index : String?
  query : IndicesRefreshQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesRefreshRequest::new(
  index? : String,
  query? : IndicesRefreshQuery = IndicesRefreshQuery::new(),
) -> IndicesRefreshRequest {
  { index, query }
}

///|
pub async fn Client::indices_refresh(
  self : Client,
  request : IndicesRefreshRequest,
) -> EsResponse[IndicesRefreshResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_refresh", ["index"]),
      PathVariant::new("/_refresh", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct IndicesReloadSearchAnalyzersQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  resource : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesReloadSearchAnalyzersQuery with fn to_json(
  self : IndicesReloadSearchAnalyzersQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.resource {
    Some(value) => obj["resource"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesReloadSearchAnalyzersQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesReloadSearchAnalyzersQuery: expected object"),
    )
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    resource: match obj.get("resource") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("resource")))
    },
  }
}

///|
pub fn IndicesReloadSearchAnalyzersQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  resource? : String,
) -> IndicesReloadSearchAnalyzersQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, resource }
}

///|
pub fn IndicesReloadSearchAnalyzersQuery::to_pairs(
  self : IndicesReloadSearchAnalyzersQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.resource {
    Some(value) => push_query_json(pairs, "resource", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesReloadSearchAnalyzersResponse = Json

///|
pub(all) struct IndicesReloadSearchAnalyzersRequest {
  index : String
  query : IndicesReloadSearchAnalyzersQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesReloadSearchAnalyzersRequest::new(
  index : String,
  query? : IndicesReloadSearchAnalyzersQuery = IndicesReloadSearchAnalyzersQuery::new(),
) -> IndicesReloadSearchAnalyzersRequest {
  { index, query }
}

///|
pub async fn Client::indices_reload_search_analyzers(
  self : Client,
  request : IndicesReloadSearchAnalyzersRequest,
) -> EsResponse[IndicesReloadSearchAnalyzersResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_reload_search_analyzers", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesRemoveBlockQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRemoveBlockQuery with fn to_json(
  self : IndicesRemoveBlockQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRemoveBlockQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRemoveBlockQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesRemoveBlockQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> IndicesRemoveBlockQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    master_timeout,
    timeout,
  }
}

///|
pub fn IndicesRemoveBlockQuery::to_pairs(
  self : IndicesRemoveBlockQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesRemoveBlockResponse {
  acknowledged : Bool
  indices : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRemoveBlockResponse with fn to_json(
  self : IndicesRemoveBlockResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRemoveBlockResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRemoveBlockResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct IndicesRemoveBlockRequest {
  index : String
  block : String
  query : IndicesRemoveBlockQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesRemoveBlockRequest::new(
  index : String,
  block : String,
  query? : IndicesRemoveBlockQuery = IndicesRemoveBlockQuery::new(),
) -> IndicesRemoveBlockRequest {
  { index, block, query }
}

///|
pub async fn Client::indices_remove_block(
  self : Client,
  request : IndicesRemoveBlockRequest,
) -> EsResponse[IndicesRemoveBlockResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["block"] = request.block
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_block/{block}", ["index", "block"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IndicesResolveClusterQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesResolveClusterQuery with fn to_json(
  self : IndicesResolveClusterQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesResolveClusterQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesResolveClusterQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesResolveClusterQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  timeout? : String,
) -> IndicesResolveClusterQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_throttled,
    ignore_unavailable,
    timeout,
  }
}

///|
pub fn IndicesResolveClusterQuery::to_pairs(
  self : IndicesResolveClusterQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesResolveClusterResponse = Json

///|
pub(all) struct IndicesResolveClusterRequest {
  name : String?
  query : IndicesResolveClusterQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesResolveClusterRequest::new(
  name? : String,
  query? : IndicesResolveClusterQuery = IndicesResolveClusterQuery::new(),
) -> IndicesResolveClusterRequest {
  { name, query }
}

///|
pub async fn Client::indices_resolve_cluster(
  self : Client,
  request : IndicesResolveClusterRequest,
) -> EsResponse[IndicesResolveClusterResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_resolve/cluster/{name}", ["name"]),
      PathVariant::new("/_resolve/cluster", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesResolveIndexQuery {
  expand_wildcards : String?
  ignore_unavailable : Bool?
  allow_no_indices : Bool?
  mode : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesResolveIndexQuery with fn to_json(
  self : IndicesResolveIndexQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.mode {
    Some(value) => obj["mode"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesResolveIndexQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesResolveIndexQuery: expected object"))
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    mode: match obj.get("mode") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("mode")))
    },
  }
}

///|
pub fn IndicesResolveIndexQuery::new(
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  allow_no_indices? : Bool,
  mode? : Json,
) -> IndicesResolveIndexQuery {
  { expand_wildcards, ignore_unavailable, allow_no_indices, mode }
}

///|
pub fn IndicesResolveIndexQuery::to_pairs(
  self : IndicesResolveIndexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.mode {
    Some(value) => push_query_json(pairs, "mode", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesResolveIndexResponse {
  indices : Array[Json]
  aliases : Array[Json]
  data_streams : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesResolveIndexResponse with fn to_json(
  self : IndicesResolveIndexResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  obj["aliases"] = self.aliases.to_json()
  obj["data_streams"] = self.data_streams.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesResolveIndexResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesResolveIndexResponse: expected object"),
    )
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    aliases: @json.from_json(
      obj.get("aliases").unwrap_or(Json::null()),
      path=path.add_key("aliases"),
    ),
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
  }
}

///|
pub(all) struct IndicesResolveIndexRequest {
  name : String
  query : IndicesResolveIndexQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesResolveIndexRequest::new(
  name : String,
  query? : IndicesResolveIndexQuery = IndicesResolveIndexQuery::new(),
) -> IndicesResolveIndexRequest {
  { name, query }
}

///|
pub async fn Client::indices_resolve_index(
  self : Client,
  request : IndicesResolveIndexRequest,
) -> EsResponse[IndicesResolveIndexResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_resolve/index/{name}", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesRolloverQuery {
  dry_run : Bool?
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
  lazy_ : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRolloverQuery with fn to_json(
  self : IndicesRolloverQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.lazy_ {
    Some(value) => obj["lazy"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRolloverQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRolloverQuery: expected object"))
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    lazy_: match obj.get("lazy") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lazy")))
    },
  }
}

///|
pub fn IndicesRolloverQuery::new(
  dry_run? : Bool,
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
  lazy_? : Bool,
) -> IndicesRolloverQuery {
  { dry_run, master_timeout, timeout, wait_for_active_shards, lazy_ }
}

///|
pub fn IndicesRolloverQuery::to_pairs(
  self : IndicesRolloverQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.lazy_ {
    Some(value) => push_query_json(pairs, "lazy", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesRolloverBody {
  aliases : Map[String, Json]?
  conditions : Json?
  mappings : Json?
  settings : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRolloverBody with fn to_json(
  self : IndicesRolloverBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aliases {
    Some(value) => obj["aliases"] = value.to_json()
    None => ()
  }
  match self.conditions {
    Some(value) => obj["conditions"] = value.to_json()
    None => ()
  }
  match self.mappings {
    Some(value) => obj["mappings"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRolloverBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRolloverBody: expected object"))
  }
  {
    aliases: match obj.get("aliases") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aliases")))
    },
    conditions: match obj.get("conditions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("conditions")))
    },
    mappings: match obj.get("mappings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("mappings")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
  }
}

///|
pub fn IndicesRolloverBody::new(
  aliases? : Map[String, Json],
  conditions? : Json,
  mappings? : Json,
  settings? : Map[String, Json],
) -> IndicesRolloverBody {
  { aliases, conditions, mappings, settings }
}

///|
pub(all) struct IndicesRolloverResponse {
  acknowledged : Bool
  conditions : Map[String, Json]
  dry_run : Bool
  new_index : String
  old_index : String
  rolled_over : Bool
  shards_acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesRolloverResponse with fn to_json(
  self : IndicesRolloverResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["conditions"] = self.conditions.to_json()
  obj["dry_run"] = self.dry_run.to_json()
  obj["new_index"] = self.new_index.to_json()
  obj["old_index"] = self.old_index.to_json()
  obj["rolled_over"] = self.rolled_over.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesRolloverResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesRolloverResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    conditions: @json.from_json(
      obj.get("conditions").unwrap_or(Json::null()),
      path=path.add_key("conditions"),
    ),
    dry_run: @json.from_json(
      obj.get("dry_run").unwrap_or(Json::null()),
      path=path.add_key("dry_run"),
    ),
    new_index: @json.from_json(
      obj.get("new_index").unwrap_or(Json::null()),
      path=path.add_key("new_index"),
    ),
    old_index: @json.from_json(
      obj.get("old_index").unwrap_or(Json::null()),
      path=path.add_key("old_index"),
    ),
    rolled_over: @json.from_json(
      obj.get("rolled_over").unwrap_or(Json::null()),
      path=path.add_key("rolled_over"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
  }
}

///|
pub(all) struct IndicesRolloverRequest {
  alias_ : String
  new_index : String?
  query : IndicesRolloverQuery
  body : IndicesRolloverBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesRolloverRequest::new(
  alias_ : String,
  new_index? : String,
  query? : IndicesRolloverQuery = IndicesRolloverQuery::new(),
  body? : IndicesRolloverBody,
) -> IndicesRolloverRequest {
  { alias_, new_index, query, body }
}

///|
pub async fn Client::indices_rollover(
  self : Client,
  request : IndicesRolloverRequest,
) -> EsResponse[IndicesRolloverResponse] {
  let params : Map[String, String] = Map([])
  params["alias"] = request.alias_
  match request.new_index {
    Some(value) => params["new_index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{alias}/_rollover/{new_index}", ["alias", "new_index"]),
      PathVariant::new("/{alias}/_rollover", ["alias"]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesSegmentsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSegmentsQuery with fn to_json(
  self : IndicesSegmentsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSegmentsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesSegmentsQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn IndicesSegmentsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
) -> IndicesSegmentsQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable }
}

///|
pub fn IndicesSegmentsQuery::to_pairs(
  self : IndicesSegmentsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesSegmentsResponse {
  indices : Map[String, Json]
  _shards : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSegmentsResponse with fn to_json(
  self : IndicesSegmentsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  obj["_shards"] = self._shards.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSegmentsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesSegmentsResponse: expected object"))
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
  }
}

///|
pub(all) struct IndicesSegmentsRequest {
  index : String?
  query : IndicesSegmentsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesSegmentsRequest::new(
  index? : String,
  query? : IndicesSegmentsQuery = IndicesSegmentsQuery::new(),
) -> IndicesSegmentsRequest {
  { index, query }
}

///|
pub async fn Client::indices_segments(
  self : Client,
  request : IndicesSegmentsRequest,
) -> EsResponse[IndicesSegmentsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_segments", ["index"]),
      PathVariant::new("/_segments", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesShardStoresQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  status : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesShardStoresQuery with fn to_json(
  self : IndicesShardStoresQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesShardStoresQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesShardStoresQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
  }
}

///|
pub fn IndicesShardStoresQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  status? : Json,
) -> IndicesShardStoresQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, status }
}

///|
pub fn IndicesShardStoresQuery::to_pairs(
  self : IndicesShardStoresQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.status {
    Some(value) => push_query_json(pairs, "status", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesShardStoresResponse {
  indices : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesShardStoresResponse with fn to_json(
  self : IndicesShardStoresResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesShardStoresResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesShardStoresResponse: expected object"))
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct IndicesShardStoresRequest {
  index : String?
  query : IndicesShardStoresQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesShardStoresRequest::new(
  index? : String,
  query? : IndicesShardStoresQuery = IndicesShardStoresQuery::new(),
) -> IndicesShardStoresRequest {
  { index, query }
}

///|
pub async fn Client::indices_shard_stores(
  self : Client,
  request : IndicesShardStoresRequest,
) -> EsResponse[IndicesShardStoresResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_shard_stores", ["index"]),
      PathVariant::new("/_shard_stores", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesShrinkQuery {
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesShrinkQuery with fn to_json(
  self : IndicesShrinkQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesShrinkQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesShrinkQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn IndicesShrinkQuery::new(
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
) -> IndicesShrinkQuery {
  { master_timeout, timeout, wait_for_active_shards }
}

///|
pub fn IndicesShrinkQuery::to_pairs(
  self : IndicesShrinkQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesShrinkBody {
  aliases : Map[String, Json]?
  settings : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesShrinkBody with fn to_json(self : IndicesShrinkBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aliases {
    Some(value) => obj["aliases"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesShrinkBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesShrinkBody: expected object"))
  }
  {
    aliases: match obj.get("aliases") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aliases")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
  }
}

///|
pub fn IndicesShrinkBody::new(
  aliases? : Map[String, Json],
  settings? : Map[String, Json],
) -> IndicesShrinkBody {
  { aliases, settings }
}

///|
pub(all) struct IndicesShrinkResponse {
  acknowledged : Bool
  shards_acknowledged : Bool
  index : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesShrinkResponse with fn to_json(
  self : IndicesShrinkResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  obj["index"] = self.index.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesShrinkResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesShrinkResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
  }
}

///|
pub(all) struct IndicesShrinkRequest {
  index : String
  target : String
  query : IndicesShrinkQuery
  body : IndicesShrinkBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesShrinkRequest::new(
  index : String,
  target : String,
  body : IndicesShrinkBody,
  query? : IndicesShrinkQuery = IndicesShrinkQuery::new(),
) -> IndicesShrinkRequest {
  { index, target, query, body }
}

///|
pub async fn Client::indices_shrink(
  self : Client,
  request : IndicesShrinkRequest,
) -> EsResponse[IndicesShrinkResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["target"] = request.target
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_shrink/{target}", ["index", "target"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesSimulateIndexTemplateQuery {
  create : Bool?
  cause : String?
  master_timeout : String?
  include_defaults : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSimulateIndexTemplateQuery with fn to_json(
  self : IndicesSimulateIndexTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.create {
    Some(value) => obj["create"] = value.to_json()
    None => ()
  }
  match self.cause {
    Some(value) => obj["cause"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSimulateIndexTemplateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesSimulateIndexTemplateQuery: expected object"),
    )
  }
  {
    create: match obj.get("create") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("create")))
    },
    cause: match obj.get("cause") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cause")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
  }
}

///|
pub fn IndicesSimulateIndexTemplateQuery::new(
  create? : Bool,
  cause? : String,
  master_timeout? : String,
  include_defaults? : Bool,
) -> IndicesSimulateIndexTemplateQuery {
  { create, cause, master_timeout, include_defaults }
}

///|
pub fn IndicesSimulateIndexTemplateQuery::to_pairs(
  self : IndicesSimulateIndexTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.create {
    Some(value) => push_query_json(pairs, "create", value.to_json())
    None => ()
  }
  match self.cause {
    Some(value) => push_query_json(pairs, "cause", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IndicesSimulateIndexTemplateBody = Json

///|
pub(all) struct IndicesSimulateIndexTemplateResponse {
  overlapping : Array[Json]?
  template : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSimulateIndexTemplateResponse with fn to_json(
  self : IndicesSimulateIndexTemplateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.overlapping {
    Some(value) => obj["overlapping"] = value.to_json()
    None => ()
  }
  obj["template"] = self.template.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSimulateIndexTemplateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesSimulateIndexTemplateResponse: expected object"),
    )
  }
  {
    overlapping: match obj.get("overlapping") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("overlapping")))
    },
    template: @json.from_json(
      obj.get("template").unwrap_or(Json::null()),
      path=path.add_key("template"),
    ),
  }
}

///|
pub(all) struct IndicesSimulateIndexTemplateRequest {
  name : String
  query : IndicesSimulateIndexTemplateQuery
  body : IndicesSimulateIndexTemplateBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesSimulateIndexTemplateRequest::new(
  name : String,
  query? : IndicesSimulateIndexTemplateQuery = IndicesSimulateIndexTemplateQuery::new(),
  body? : IndicesSimulateIndexTemplateBody,
) -> IndicesSimulateIndexTemplateRequest {
  { name, query, body }
}

///|
pub async fn Client::indices_simulate_index_template(
  self : Client,
  request : IndicesSimulateIndexTemplateRequest,
) -> EsResponse[IndicesSimulateIndexTemplateResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_index_template/_simulate_index/{name}", ["name"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesSimulateTemplateQuery {
  create : Bool?
  cause : String?
  master_timeout : String?
  include_defaults : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSimulateTemplateQuery with fn to_json(
  self : IndicesSimulateTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.create {
    Some(value) => obj["create"] = value.to_json()
    None => ()
  }
  match self.cause {
    Some(value) => obj["cause"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.include_defaults {
    Some(value) => obj["include_defaults"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSimulateTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesSimulateTemplateQuery: expected object"),
    )
  }
  {
    create: match obj.get("create") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("create")))
    },
    cause: match obj.get("cause") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cause")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    include_defaults: match obj.get("include_defaults") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_defaults")))
    },
  }
}

///|
pub fn IndicesSimulateTemplateQuery::new(
  create? : Bool,
  cause? : String,
  master_timeout? : String,
  include_defaults? : Bool,
) -> IndicesSimulateTemplateQuery {
  { create, cause, master_timeout, include_defaults }
}

///|
pub fn IndicesSimulateTemplateQuery::to_pairs(
  self : IndicesSimulateTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.create {
    Some(value) => push_query_json(pairs, "create", value.to_json())
    None => ()
  }
  match self.cause {
    Some(value) => push_query_json(pairs, "cause", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.include_defaults {
    Some(value) => push_query_json(pairs, "include_defaults", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesSimulateTemplateBody {
  allow_auto_create : Bool?
  index_patterns : Json?
  composed_of : Array[Json]?
  template : Json?
  data_stream : Json?
  priority : Int?
  version : Json?
  _meta : Json?
  ignore_missing_component_templates : Array[String]?
  deprecated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSimulateTemplateBody with fn to_json(
  self : IndicesSimulateTemplateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_auto_create {
    Some(value) => obj["allow_auto_create"] = value.to_json()
    None => ()
  }
  match self.index_patterns {
    Some(value) => obj["index_patterns"] = value.to_json()
    None => ()
  }
  match self.composed_of {
    Some(value) => obj["composed_of"] = value.to_json()
    None => ()
  }
  match self.template {
    Some(value) => obj["template"] = value.to_json()
    None => ()
  }
  match self.data_stream {
    Some(value) => obj["data_stream"] = value.to_json()
    None => ()
  }
  match self.priority {
    Some(value) => obj["priority"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.ignore_missing_component_templates {
    Some(value) => obj["ignore_missing_component_templates"] = value.to_json()
    None => ()
  }
  match self.deprecated {
    Some(value) => obj["deprecated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSimulateTemplateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesSimulateTemplateBody: expected object"),
    )
  }
  {
    allow_auto_create: match obj.get("allow_auto_create") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_auto_create")))
    },
    index_patterns: match obj.get("index_patterns") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_patterns")))
    },
    composed_of: match obj.get("composed_of") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("composed_of")))
    },
    template: match obj.get("template") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("template")))
    },
    data_stream: match obj.get("data_stream") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_stream")))
    },
    priority: match obj.get("priority") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("priority")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    ignore_missing_component_templates: match
      obj.get("ignore_missing_component_templates") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("ignore_missing_component_templates"),
          ),
        )
    },
    deprecated: match obj.get("deprecated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("deprecated")))
    },
  }
}

///|
pub fn IndicesSimulateTemplateBody::new(
  allow_auto_create? : Bool,
  index_patterns? : Json,
  composed_of? : Array[Json],
  template? : Json,
  data_stream? : Json,
  priority? : Int,
  version? : Json,
  _meta? : Json,
  ignore_missing_component_templates? : Array[String],
  deprecated? : Bool,
) -> IndicesSimulateTemplateBody {
  {
    allow_auto_create,
    index_patterns,
    composed_of,
    template,
    data_stream,
    priority,
    version,
    _meta,
    ignore_missing_component_templates,
    deprecated,
  }
}

///|
pub(all) struct IndicesSimulateTemplateResponse {
  overlapping : Array[Json]?
  template : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSimulateTemplateResponse with fn to_json(
  self : IndicesSimulateTemplateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.overlapping {
    Some(value) => obj["overlapping"] = value.to_json()
    None => ()
  }
  obj["template"] = self.template.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSimulateTemplateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesSimulateTemplateResponse: expected object"),
    )
  }
  {
    overlapping: match obj.get("overlapping") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("overlapping")))
    },
    template: @json.from_json(
      obj.get("template").unwrap_or(Json::null()),
      path=path.add_key("template"),
    ),
  }
}

///|
pub(all) struct IndicesSimulateTemplateRequest {
  name : String?
  query : IndicesSimulateTemplateQuery
  body : IndicesSimulateTemplateBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesSimulateTemplateRequest::new(
  name? : String,
  query? : IndicesSimulateTemplateQuery = IndicesSimulateTemplateQuery::new(),
  body? : IndicesSimulateTemplateBody,
) -> IndicesSimulateTemplateRequest {
  { name, query, body }
}

///|
pub async fn Client::indices_simulate_template(
  self : Client,
  request : IndicesSimulateTemplateRequest,
) -> EsResponse[IndicesSimulateTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_index_template/_simulate/{name}", ["name"]),
      PathVariant::new("/_index_template/_simulate", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesSplitQuery {
  master_timeout : String?
  timeout : String?
  wait_for_active_shards : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSplitQuery with fn to_json(self : IndicesSplitQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSplitQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesSplitQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
  }
}

///|
pub fn IndicesSplitQuery::new(
  master_timeout? : String,
  timeout? : String,
  wait_for_active_shards? : String,
) -> IndicesSplitQuery {
  { master_timeout, timeout, wait_for_active_shards }
}

///|
pub fn IndicesSplitQuery::to_pairs(
  self : IndicesSplitQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesSplitBody {
  aliases : Map[String, Json]?
  settings : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSplitBody with fn to_json(self : IndicesSplitBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aliases {
    Some(value) => obj["aliases"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSplitBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesSplitBody: expected object"))
  }
  {
    aliases: match obj.get("aliases") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aliases")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
  }
}

///|
pub fn IndicesSplitBody::new(
  aliases? : Map[String, Json],
  settings? : Map[String, Json],
) -> IndicesSplitBody {
  { aliases, settings }
}

///|
pub(all) struct IndicesSplitResponse {
  acknowledged : Bool
  shards_acknowledged : Bool
  index : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesSplitResponse with fn to_json(
  self : IndicesSplitResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["shards_acknowledged"] = self.shards_acknowledged.to_json()
  obj["index"] = self.index.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesSplitResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesSplitResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    shards_acknowledged: @json.from_json(
      obj.get("shards_acknowledged").unwrap_or(Json::null()),
      path=path.add_key("shards_acknowledged"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
  }
}

///|
pub(all) struct IndicesSplitRequest {
  index : String
  target : String
  query : IndicesSplitQuery
  body : IndicesSplitBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesSplitRequest::new(
  index : String,
  target : String,
  body : IndicesSplitBody,
  query? : IndicesSplitQuery = IndicesSplitQuery::new(),
) -> IndicesSplitRequest {
  { index, target, query, body }
}

///|
pub async fn Client::indices_split(
  self : Client,
  request : IndicesSplitRequest,
) -> EsResponse[IndicesSplitResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["target"] = request.target
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_split/{target}", ["index", "target"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesStatsQuery {
  completion_fields : String?
  expand_wildcards : String?
  fielddata_fields : String?
  fields : String?
  forbid_closed_indices : Bool?
  groups : Json?
  include_segment_file_sizes : Bool?
  include_unloaded_segments : Bool?
  level : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesStatsQuery with fn to_json(self : IndicesStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.completion_fields {
    Some(value) => obj["completion_fields"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.fielddata_fields {
    Some(value) => obj["fielddata_fields"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.forbid_closed_indices {
    Some(value) => obj["forbid_closed_indices"] = value.to_json()
    None => ()
  }
  match self.groups {
    Some(value) => obj["groups"] = value.to_json()
    None => ()
  }
  match self.include_segment_file_sizes {
    Some(value) => obj["include_segment_file_sizes"] = value.to_json()
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) => obj["include_unloaded_segments"] = value.to_json()
    None => ()
  }
  match self.level {
    Some(value) => obj["level"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesStatsQuery: expected object"))
  }
  {
    completion_fields: match obj.get("completion_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("completion_fields")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    fielddata_fields: match obj.get("fielddata_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("fielddata_fields")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    forbid_closed_indices: match obj.get("forbid_closed_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("forbid_closed_indices")))
    },
    groups: match obj.get("groups") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("groups")))
    },
    include_segment_file_sizes: match obj.get("include_segment_file_sizes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("include_segment_file_sizes"),
          ),
        )
    },
    include_unloaded_segments: match obj.get("include_unloaded_segments") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_unloaded_segments")),
        )
    },
    level: match obj.get("level") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("level")))
    },
  }
}

///|
pub fn IndicesStatsQuery::new(
  completion_fields? : String,
  expand_wildcards? : String,
  fielddata_fields? : String,
  fields? : String,
  forbid_closed_indices? : Bool,
  groups? : Json,
  include_segment_file_sizes? : Bool,
  include_unloaded_segments? : Bool,
  level? : String,
) -> IndicesStatsQuery {
  {
    completion_fields,
    expand_wildcards,
    fielddata_fields,
    fields,
    forbid_closed_indices,
    groups,
    include_segment_file_sizes,
    include_unloaded_segments,
    level,
  }
}

///|
pub fn IndicesStatsQuery::to_pairs(
  self : IndicesStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.completion_fields {
    Some(value) => push_query_json(pairs, "completion_fields", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.fielddata_fields {
    Some(value) => push_query_json(pairs, "fielddata_fields", value.to_json())
    None => ()
  }
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.forbid_closed_indices {
    Some(value) =>
      push_query_json(pairs, "forbid_closed_indices", value.to_json())
    None => ()
  }
  match self.groups {
    Some(value) => push_query_json(pairs, "groups", value.to_json())
    None => ()
  }
  match self.include_segment_file_sizes {
    Some(value) =>
      push_query_json(pairs, "include_segment_file_sizes", value.to_json())
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) =>
      push_query_json(pairs, "include_unloaded_segments", value.to_json())
    None => ()
  }
  match self.level {
    Some(value) => push_query_json(pairs, "level", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesStatsResponse {
  indices : Map[String, Json]?
  _shards : Json
  _all : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesStatsResponse with fn to_json(
  self : IndicesStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.indices {
    Some(value) => obj["indices"] = value.to_json()
    None => ()
  }
  obj["_shards"] = self._shards.to_json()
  obj["_all"] = self._all.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IndicesStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesStatsResponse: expected object"))
  }
  {
    indices: match obj.get("indices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("indices")))
    },
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    _all: @json.from_json(
      obj.get("_all").unwrap_or(Json::null()),
      path=path.add_key("_all"),
    ),
  }
}

///|
pub(all) struct IndicesStatsRequest {
  index : String?
  metric : String?
  query : IndicesStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesStatsRequest::new(
  index? : String,
  metric? : String,
  query? : IndicesStatsQuery = IndicesStatsQuery::new(),
) -> IndicesStatsRequest {
  { index, metric, query }
}

///|
pub async fn Client::indices_stats(
  self : Client,
  request : IndicesStatsRequest,
) -> EsResponse[IndicesStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  match request.metric {
    Some(value) => params["metric"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_stats/{metric}", ["index", "metric"]),
      PathVariant::new("/_stats/{metric}", ["metric"]),
      PathVariant::new("/{index}/_stats", ["index"]),
      PathVariant::new("/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IndicesUpdateAliasesQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesUpdateAliasesQuery with fn to_json(
  self : IndicesUpdateAliasesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesUpdateAliasesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesUpdateAliasesQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IndicesUpdateAliasesQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IndicesUpdateAliasesQuery {
  { master_timeout, timeout }
}

///|
pub fn IndicesUpdateAliasesQuery::to_pairs(
  self : IndicesUpdateAliasesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesUpdateAliasesBody {
  actions : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesUpdateAliasesBody with fn to_json(
  self : IndicesUpdateAliasesBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.actions {
    Some(value) => obj["actions"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesUpdateAliasesBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesUpdateAliasesBody: expected object"))
  }
  {
    actions: match obj.get("actions") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("actions")))
    },
  }
}

///|
pub fn IndicesUpdateAliasesBody::new(
  actions? : Array[Json],
) -> IndicesUpdateAliasesBody {
  { actions, }
}

///|
pub type IndicesUpdateAliasesResponse = Json

///|
pub(all) struct IndicesUpdateAliasesRequest {
  query : IndicesUpdateAliasesQuery
  body : IndicesUpdateAliasesBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesUpdateAliasesRequest::new(
  body : IndicesUpdateAliasesBody,
  query? : IndicesUpdateAliasesQuery = IndicesUpdateAliasesQuery::new(),
) -> IndicesUpdateAliasesRequest {
  { query, body }
}

///|
pub async fn Client::indices_update_aliases(
  self : Client,
  request : IndicesUpdateAliasesRequest,
) -> EsResponse[IndicesUpdateAliasesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_aliases", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct IndicesValidateQueryQuery {
  allow_no_indices : Bool?
  all_shards : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  default_operator : String?
  df : String?
  expand_wildcards : String?
  explain : Bool?
  ignore_unavailable : Bool?
  lenient : Bool?
  rewrite : Bool?
  q : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesValidateQueryQuery with fn to_json(
  self : IndicesValidateQueryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.all_shards {
    Some(value) => obj["all_shards"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.rewrite {
    Some(value) => obj["rewrite"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesValidateQueryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesValidateQueryQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    all_shards: match obj.get("all_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("all_shards")))
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    rewrite: match obj.get("rewrite") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rewrite")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
  }
}

///|
pub fn IndicesValidateQueryQuery::new(
  allow_no_indices? : Bool,
  all_shards? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  default_operator? : String,
  df? : String,
  expand_wildcards? : String,
  explain? : Bool,
  ignore_unavailable? : Bool,
  lenient? : Bool,
  rewrite? : Bool,
  q? : String,
) -> IndicesValidateQueryQuery {
  {
    allow_no_indices,
    all_shards,
    analyzer,
    analyze_wildcard,
    default_operator,
    df,
    expand_wildcards,
    explain,
    ignore_unavailable,
    lenient,
    rewrite,
    q,
  }
}

///|
pub fn IndicesValidateQueryQuery::to_pairs(
  self : IndicesValidateQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.all_shards {
    Some(value) => push_query_json(pairs, "all_shards", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.rewrite {
    Some(value) => push_query_json(pairs, "rewrite", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IndicesValidateQueryBody {
  query : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesValidateQueryBody with fn to_json(
  self : IndicesValidateQueryBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesValidateQueryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IndicesValidateQueryBody: expected object"))
  }
  {
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
  }
}

///|
pub fn IndicesValidateQueryBody::new(query? : Json) -> IndicesValidateQueryBody {
  { query, }
}

///|
pub(all) struct IndicesValidateQueryResponse {
  explanations : Array[Json]?
  _shards : Json?
  valid : Bool
  error : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IndicesValidateQueryResponse with fn to_json(
  self : IndicesValidateQueryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.explanations {
    Some(value) => obj["explanations"] = value.to_json()
    None => ()
  }
  match self._shards {
    Some(value) => obj["_shards"] = value.to_json()
    None => ()
  }
  obj["valid"] = self.valid.to_json()
  match self.error {
    Some(value) => obj["error"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IndicesValidateQueryResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IndicesValidateQueryResponse: expected object"),
    )
  }
  {
    explanations: match obj.get("explanations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("explanations")))
    },
    _shards: match obj.get("_shards") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_shards")))
    },
    valid: @json.from_json(
      obj.get("valid").unwrap_or(Json::null()),
      path=path.add_key("valid"),
    ),
    error: match obj.get("error") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("error")))
    },
  }
}

///|
pub(all) struct IndicesValidateQueryRequest {
  index : String?
  query : IndicesValidateQueryQuery
  body : IndicesValidateQueryBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IndicesValidateQueryRequest::new(
  index? : String,
  query? : IndicesValidateQueryQuery = IndicesValidateQueryQuery::new(),
  body? : IndicesValidateQueryBody,
) -> IndicesValidateQueryRequest {
  { index, query, body }
}

///|
pub async fn Client::indices_validate_query(
  self : Client,
  request : IndicesValidateQueryRequest,
) -> EsResponse[IndicesValidateQueryResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_validate/query", ["index"]),
      PathVariant::new("/_validate/query", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceChatCompletionUnifiedQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceChatCompletionUnifiedQuery with fn to_json(
  self : InferenceChatCompletionUnifiedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceChatCompletionUnifiedQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferenceChatCompletionUnifiedQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceChatCompletionUnifiedQuery::new(
  timeout? : String,
) -> InferenceChatCompletionUnifiedQuery {
  { timeout, }
}

///|
pub fn InferenceChatCompletionUnifiedQuery::to_pairs(
  self : InferenceChatCompletionUnifiedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type InferenceChatCompletionUnifiedBody = Json

///|
pub type InferenceChatCompletionUnifiedResponse = Json

///|
pub(all) struct InferenceChatCompletionUnifiedRequest {
  inference_id : String
  query : InferenceChatCompletionUnifiedQuery
  body : InferenceChatCompletionUnifiedBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceChatCompletionUnifiedRequest::new(
  inference_id : String,
  body : InferenceChatCompletionUnifiedBody,
  query? : InferenceChatCompletionUnifiedQuery = InferenceChatCompletionUnifiedQuery::new(),
) -> InferenceChatCompletionUnifiedRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_chat_completion_unified(
  self : Client,
  request : InferenceChatCompletionUnifiedRequest,
) -> EsResponse[InferenceChatCompletionUnifiedResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/chat_completion/{inference_id}/_stream", [
        "inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceCompletionQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceCompletionQuery with fn to_json(
  self : InferenceCompletionQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceCompletionQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceCompletionQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceCompletionQuery::new(
  timeout? : String,
) -> InferenceCompletionQuery {
  { timeout, }
}

///|
pub fn InferenceCompletionQuery::to_pairs(
  self : InferenceCompletionQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferenceCompletionBody {
  input : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceCompletionBody with fn to_json(
  self : InferenceCompletionBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["input"] = self.input.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceCompletionBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceCompletionBody: expected object"))
  }
  {
    input: @json.from_json(
      obj.get("input").unwrap_or(Json::null()),
      path=path.add_key("input"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferenceCompletionBody::new(
  input : Json,
  task_settings? : Json,
) -> InferenceCompletionBody {
  { input, task_settings }
}

///|
pub type InferenceCompletionResponse = Json

///|
pub(all) struct InferenceCompletionRequest {
  inference_id : String
  query : InferenceCompletionQuery
  body : InferenceCompletionBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceCompletionRequest::new(
  inference_id : String,
  body : InferenceCompletionBody,
  query? : InferenceCompletionQuery = InferenceCompletionQuery::new(),
) -> InferenceCompletionRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_completion(
  self : Client,
  request : InferenceCompletionRequest,
) -> EsResponse[InferenceCompletionResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/completion/{inference_id}", ["inference_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceDeleteQuery {
  dry_run : Bool?
  force : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceDeleteQuery with fn to_json(
  self : InferenceDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceDeleteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceDeleteQuery: expected object"))
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
  }
}

///|
pub fn InferenceDeleteQuery::new(
  dry_run? : Bool,
  force? : Bool,
) -> InferenceDeleteQuery {
  { dry_run, force }
}

///|
pub fn InferenceDeleteQuery::to_pairs(
  self : InferenceDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type InferenceDeleteResponse = Json

///|
pub(all) struct InferenceDeleteRequest {
  task_type : String?
  inference_id : String
  query : InferenceDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceDeleteRequest::new(
  inference_id : String,
  task_type? : String,
  query? : InferenceDeleteQuery = InferenceDeleteQuery::new(),
) -> InferenceDeleteRequest {
  { task_type, inference_id, query }
}

///|
pub async fn Client::inference_delete(
  self : Client,
  request : InferenceDeleteRequest,
) -> EsResponse[InferenceDeleteResponse] {
  let params : Map[String, String] = Map([])
  match request.task_type {
    Some(value) => params["task_type"] = value
    None => ()
  }
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{inference_id}", [
        "task_type", "inference_id",
      ]),
      PathVariant::new("/_inference/{inference_id}", ["inference_id"]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct InferenceEmbeddingQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceEmbeddingQuery with fn to_json(
  self : InferenceEmbeddingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceEmbeddingQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceEmbeddingQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceEmbeddingQuery::new(
  timeout? : String,
) -> InferenceEmbeddingQuery {
  { timeout, }
}

///|
pub fn InferenceEmbeddingQuery::to_pairs(
  self : InferenceEmbeddingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type InferenceEmbeddingBody = Json

///|
pub type InferenceEmbeddingResponse = Json

///|
pub(all) struct InferenceEmbeddingRequest {
  inference_id : String
  query : InferenceEmbeddingQuery
  body : InferenceEmbeddingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceEmbeddingRequest::new(
  inference_id : String,
  body : InferenceEmbeddingBody,
  query? : InferenceEmbeddingQuery = InferenceEmbeddingQuery::new(),
) -> InferenceEmbeddingRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_embedding(
  self : Client,
  request : InferenceEmbeddingRequest,
) -> EsResponse[InferenceEmbeddingResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_inference/embedding/{inference_id}", ["inference_id"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceGetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for InferenceGetQuery with fn to_json(_self : InferenceGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for InferenceGetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "InferenceGetQuery: expected object"))
  }
  InferenceGetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn InferenceGetQuery::new() -> InferenceGetQuery {
  InferenceGetQuery::{  }
}

///|
pub fn InferenceGetQuery::to_pairs(
  _self : InferenceGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct InferenceGetResponse {
  endpoints : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceGetResponse with fn to_json(
  self : InferenceGetResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["endpoints"] = self.endpoints.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferenceGetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceGetResponse: expected object"))
  }
  {
    endpoints: @json.from_json(
      obj.get("endpoints").unwrap_or(Json::null()),
      path=path.add_key("endpoints"),
    ),
  }
}

///|
pub(all) struct InferenceGetRequest {
  task_type : String?
  inference_id : String?
  query : InferenceGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceGetRequest::new(
  task_type? : String,
  inference_id? : String,
  query? : InferenceGetQuery = InferenceGetQuery::new(),
) -> InferenceGetRequest {
  { task_type, inference_id, query }
}

///|
pub async fn Client::inference_get(
  self : Client,
  request : InferenceGetRequest,
) -> EsResponse[InferenceGetResponse] {
  let params : Map[String, String] = Map([])
  match request.task_type {
    Some(value) => params["task_type"] = value
    None => ()
  }
  match request.inference_id {
    Some(value) => params["inference_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{inference_id}", [
        "task_type", "inference_id",
      ]),
      PathVariant::new("/_inference/{inference_id}", ["inference_id"]),
      PathVariant::new("/_inference/{task_type}/_all", ["task_type"]),
      PathVariant::new("/_inference", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct InferenceInferenceQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceInferenceQuery with fn to_json(
  self : InferenceInferenceQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceInferenceQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceInferenceQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceInferenceQuery::new(
  timeout? : String,
) -> InferenceInferenceQuery {
  { timeout, }
}

///|
pub fn InferenceInferenceQuery::to_pairs(
  self : InferenceInferenceQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferenceInferenceBody {
  query : String?
  input : Json
  input_type : String?
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceInferenceBody with fn to_json(
  self : InferenceInferenceBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  obj["input"] = self.input.to_json()
  match self.input_type {
    Some(value) => obj["input_type"] = value.to_json()
    None => ()
  }
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceInferenceBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceInferenceBody: expected object"))
  }
  {
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    input: @json.from_json(
      obj.get("input").unwrap_or(Json::null()),
      path=path.add_key("input"),
    ),
    input_type: match obj.get("input_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("input_type")))
    },
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferenceInferenceBody::new(
  input : Json,
  query? : String,
  input_type? : String,
  task_settings? : Json,
) -> InferenceInferenceBody {
  { query, input, input_type, task_settings }
}

///|
pub type InferenceInferenceResponse = Json

///|
pub(all) struct InferenceInferenceRequest {
  task_type : String?
  inference_id : String
  query : InferenceInferenceQuery
  body : InferenceInferenceBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceInferenceRequest::new(
  inference_id : String,
  body : InferenceInferenceBody,
  task_type? : String,
  query? : InferenceInferenceQuery = InferenceInferenceQuery::new(),
) -> InferenceInferenceRequest {
  { task_type, inference_id, query, body }
}

///|
pub async fn Client::inference_inference(
  self : Client,
  request : InferenceInferenceRequest,
) -> EsResponse[InferenceInferenceResponse] {
  let params : Map[String, String] = Map([])
  match request.task_type {
    Some(value) => params["task_type"] = value
    None => ()
  }
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{inference_id}", [
        "task_type", "inference_id",
      ]),
      PathVariant::new("/_inference/{inference_id}", ["inference_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferencePutQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutQuery with fn to_json(self : InferencePutQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutQuery::new(timeout? : String) -> InferencePutQuery {
  { timeout, }
}

///|
pub fn InferencePutQuery::to_pairs(
  self : InferencePutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type InferencePutBody = Json

///|
pub type InferencePutResponse = Json

///|
pub(all) struct InferencePutRequest {
  task_type : String?
  inference_id : String
  query : InferencePutQuery
  body : InferencePutBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutRequest::new(
  inference_id : String,
  body : InferencePutBody,
  task_type? : String,
  query? : InferencePutQuery = InferencePutQuery::new(),
) -> InferencePutRequest {
  { task_type, inference_id, query, body }
}

///|
pub async fn Client::inference_put(
  self : Client,
  request : InferencePutRequest,
) -> EsResponse[InferencePutResponse] {
  let params : Map[String, String] = Map([])
  match request.task_type {
    Some(value) => params["task_type"] = value
    None => ()
  }
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{inference_id}", [
        "task_type", "inference_id",
      ]),
      PathVariant::new("/_inference/{inference_id}", ["inference_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAi21Query {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAi21Query with fn to_json(
  self : InferencePutAi21Query,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAi21Query with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutAi21Query: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAi21Query::new(timeout? : String) -> InferencePutAi21Query {
  { timeout, }
}

///|
pub fn InferencePutAi21Query::to_pairs(
  self : InferencePutAi21Query,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAi21Body {
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAi21Body with fn to_json(
  self : InferencePutAi21Body,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAi21Body with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutAi21Body: expected object"))
  }
  {
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutAi21Body::new(
  service : Json,
  service_settings : Json,
) -> InferencePutAi21Body {
  { service, service_settings }
}

///|
pub type InferencePutAi21Response = Json

///|
pub(all) struct InferencePutAi21Request {
  task_type : String
  ai21_inference_id : String
  query : InferencePutAi21Query
  body : InferencePutAi21Body
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAi21Request::new(
  task_type : String,
  ai21_inference_id : String,
  body : InferencePutAi21Body,
  query? : InferencePutAi21Query = InferencePutAi21Query::new(),
) -> InferencePutAi21Request {
  { task_type, ai21_inference_id, query, body }
}

///|
pub async fn Client::inference_put_ai21(
  self : Client,
  request : InferencePutAi21Request,
) -> EsResponse[InferencePutAi21Response] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["ai21_inference_id"] = request.ai21_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{ai21_inference_id}", [
        "task_type", "ai21_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAlibabacloudQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAlibabacloudQuery with fn to_json(
  self : InferencePutAlibabacloudQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAlibabacloudQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAlibabacloudQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAlibabacloudQuery::new(
  timeout? : String,
) -> InferencePutAlibabacloudQuery {
  { timeout, }
}

///|
pub fn InferencePutAlibabacloudQuery::to_pairs(
  self : InferencePutAlibabacloudQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAlibabacloudBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAlibabacloudBody with fn to_json(
  self : InferencePutAlibabacloudBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAlibabacloudBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAlibabacloudBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutAlibabacloudBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutAlibabacloudBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutAlibabacloudResponse = Json

///|
pub(all) struct InferencePutAlibabacloudRequest {
  task_type : String
  alibabacloud_inference_id : String
  query : InferencePutAlibabacloudQuery
  body : InferencePutAlibabacloudBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAlibabacloudRequest::new(
  task_type : String,
  alibabacloud_inference_id : String,
  body : InferencePutAlibabacloudBody,
  query? : InferencePutAlibabacloudQuery = InferencePutAlibabacloudQuery::new(),
) -> InferencePutAlibabacloudRequest {
  { task_type, alibabacloud_inference_id, query, body }
}

///|
pub async fn Client::inference_put_alibabacloud(
  self : Client,
  request : InferencePutAlibabacloudRequest,
) -> EsResponse[InferencePutAlibabacloudResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["alibabacloud_inference_id"] = request.alibabacloud_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{alibabacloud_inference_id}", [
        "task_type", "alibabacloud_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAmazonbedrockQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAmazonbedrockQuery with fn to_json(
  self : InferencePutAmazonbedrockQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAmazonbedrockQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAmazonbedrockQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAmazonbedrockQuery::new(
  timeout? : String,
) -> InferencePutAmazonbedrockQuery {
  { timeout, }
}

///|
pub fn InferencePutAmazonbedrockQuery::to_pairs(
  self : InferencePutAmazonbedrockQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAmazonbedrockBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAmazonbedrockBody with fn to_json(
  self : InferencePutAmazonbedrockBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAmazonbedrockBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAmazonbedrockBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutAmazonbedrockBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutAmazonbedrockBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutAmazonbedrockResponse = Json

///|
pub(all) struct InferencePutAmazonbedrockRequest {
  task_type : String
  amazonbedrock_inference_id : String
  query : InferencePutAmazonbedrockQuery
  body : InferencePutAmazonbedrockBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAmazonbedrockRequest::new(
  task_type : String,
  amazonbedrock_inference_id : String,
  body : InferencePutAmazonbedrockBody,
  query? : InferencePutAmazonbedrockQuery = InferencePutAmazonbedrockQuery::new(),
) -> InferencePutAmazonbedrockRequest {
  { task_type, amazonbedrock_inference_id, query, body }
}

///|
pub async fn Client::inference_put_amazonbedrock(
  self : Client,
  request : InferencePutAmazonbedrockRequest,
) -> EsResponse[InferencePutAmazonbedrockResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["amazonbedrock_inference_id"] = request.amazonbedrock_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{amazonbedrock_inference_id}", [
        "task_type", "amazonbedrock_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAmazonsagemakerQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAmazonsagemakerQuery with fn to_json(
  self : InferencePutAmazonsagemakerQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAmazonsagemakerQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAmazonsagemakerQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAmazonsagemakerQuery::new(
  timeout? : String,
) -> InferencePutAmazonsagemakerQuery {
  { timeout, }
}

///|
pub fn InferencePutAmazonsagemakerQuery::to_pairs(
  self : InferencePutAmazonsagemakerQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAmazonsagemakerBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAmazonsagemakerBody with fn to_json(
  self : InferencePutAmazonsagemakerBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAmazonsagemakerBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAmazonsagemakerBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutAmazonsagemakerBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutAmazonsagemakerBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutAmazonsagemakerResponse = Json

///|
pub(all) struct InferencePutAmazonsagemakerRequest {
  task_type : String
  amazonsagemaker_inference_id : String
  query : InferencePutAmazonsagemakerQuery
  body : InferencePutAmazonsagemakerBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAmazonsagemakerRequest::new(
  task_type : String,
  amazonsagemaker_inference_id : String,
  body : InferencePutAmazonsagemakerBody,
  query? : InferencePutAmazonsagemakerQuery = InferencePutAmazonsagemakerQuery::new(),
) -> InferencePutAmazonsagemakerRequest {
  { task_type, amazonsagemaker_inference_id, query, body }
}

///|
pub async fn Client::inference_put_amazonsagemaker(
  self : Client,
  request : InferencePutAmazonsagemakerRequest,
) -> EsResponse[InferencePutAmazonsagemakerResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["amazonsagemaker_inference_id"] = request.amazonsagemaker_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_inference/{task_type}/{amazonsagemaker_inference_id}",
        ["task_type", "amazonsagemaker_inference_id"],
      ),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAnthropicQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAnthropicQuery with fn to_json(
  self : InferencePutAnthropicQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAnthropicQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutAnthropicQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAnthropicQuery::new(
  timeout? : String,
) -> InferencePutAnthropicQuery {
  { timeout, }
}

///|
pub fn InferencePutAnthropicQuery::to_pairs(
  self : InferencePutAnthropicQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAnthropicBody {
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAnthropicBody with fn to_json(
  self : InferencePutAnthropicBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAnthropicBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutAnthropicBody: expected object"))
  }
  {
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutAnthropicBody::new(
  service : Json,
  service_settings : Json,
  task_settings? : Json,
) -> InferencePutAnthropicBody {
  { service, service_settings, task_settings }
}

///|
pub type InferencePutAnthropicResponse = Json

///|
pub(all) struct InferencePutAnthropicRequest {
  task_type : String
  anthropic_inference_id : String
  query : InferencePutAnthropicQuery
  body : InferencePutAnthropicBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAnthropicRequest::new(
  task_type : String,
  anthropic_inference_id : String,
  body : InferencePutAnthropicBody,
  query? : InferencePutAnthropicQuery = InferencePutAnthropicQuery::new(),
) -> InferencePutAnthropicRequest {
  { task_type, anthropic_inference_id, query, body }
}

///|
pub async fn Client::inference_put_anthropic(
  self : Client,
  request : InferencePutAnthropicRequest,
) -> EsResponse[InferencePutAnthropicResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["anthropic_inference_id"] = request.anthropic_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{anthropic_inference_id}", [
        "task_type", "anthropic_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAzureaistudioQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAzureaistudioQuery with fn to_json(
  self : InferencePutAzureaistudioQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAzureaistudioQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAzureaistudioQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAzureaistudioQuery::new(
  timeout? : String,
) -> InferencePutAzureaistudioQuery {
  { timeout, }
}

///|
pub fn InferencePutAzureaistudioQuery::to_pairs(
  self : InferencePutAzureaistudioQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAzureaistudioBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAzureaistudioBody with fn to_json(
  self : InferencePutAzureaistudioBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAzureaistudioBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAzureaistudioBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutAzureaistudioBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutAzureaistudioBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutAzureaistudioResponse = Json

///|
pub(all) struct InferencePutAzureaistudioRequest {
  task_type : String
  azureaistudio_inference_id : String
  query : InferencePutAzureaistudioQuery
  body : InferencePutAzureaistudioBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAzureaistudioRequest::new(
  task_type : String,
  azureaistudio_inference_id : String,
  body : InferencePutAzureaistudioBody,
  query? : InferencePutAzureaistudioQuery = InferencePutAzureaistudioQuery::new(),
) -> InferencePutAzureaistudioRequest {
  { task_type, azureaistudio_inference_id, query, body }
}

///|
pub async fn Client::inference_put_azureaistudio(
  self : Client,
  request : InferencePutAzureaistudioRequest,
) -> EsResponse[InferencePutAzureaistudioResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["azureaistudio_inference_id"] = request.azureaistudio_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{azureaistudio_inference_id}", [
        "task_type", "azureaistudio_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutAzureopenaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAzureopenaiQuery with fn to_json(
  self : InferencePutAzureopenaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAzureopenaiQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAzureopenaiQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutAzureopenaiQuery::new(
  timeout? : String,
) -> InferencePutAzureopenaiQuery {
  { timeout, }
}

///|
pub fn InferencePutAzureopenaiQuery::to_pairs(
  self : InferencePutAzureopenaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutAzureopenaiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutAzureopenaiBody with fn to_json(
  self : InferencePutAzureopenaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutAzureopenaiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutAzureopenaiBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutAzureopenaiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutAzureopenaiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutAzureopenaiResponse = Json

///|
pub(all) struct InferencePutAzureopenaiRequest {
  task_type : String
  azureopenai_inference_id : String
  query : InferencePutAzureopenaiQuery
  body : InferencePutAzureopenaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutAzureopenaiRequest::new(
  task_type : String,
  azureopenai_inference_id : String,
  body : InferencePutAzureopenaiBody,
  query? : InferencePutAzureopenaiQuery = InferencePutAzureopenaiQuery::new(),
) -> InferencePutAzureopenaiRequest {
  { task_type, azureopenai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_azureopenai(
  self : Client,
  request : InferencePutAzureopenaiRequest,
) -> EsResponse[InferencePutAzureopenaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["azureopenai_inference_id"] = request.azureopenai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{azureopenai_inference_id}", [
        "task_type", "azureopenai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutCohereQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutCohereQuery with fn to_json(
  self : InferencePutCohereQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutCohereQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutCohereQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutCohereQuery::new(
  timeout? : String,
) -> InferencePutCohereQuery {
  { timeout, }
}

///|
pub fn InferencePutCohereQuery::to_pairs(
  self : InferencePutCohereQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutCohereBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutCohereBody with fn to_json(
  self : InferencePutCohereBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutCohereBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutCohereBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutCohereBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutCohereBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutCohereResponse = Json

///|
pub(all) struct InferencePutCohereRequest {
  task_type : String
  cohere_inference_id : String
  query : InferencePutCohereQuery
  body : InferencePutCohereBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutCohereRequest::new(
  task_type : String,
  cohere_inference_id : String,
  body : InferencePutCohereBody,
  query? : InferencePutCohereQuery = InferencePutCohereQuery::new(),
) -> InferencePutCohereRequest {
  { task_type, cohere_inference_id, query, body }
}

///|
pub async fn Client::inference_put_cohere(
  self : Client,
  request : InferencePutCohereRequest,
) -> EsResponse[InferencePutCohereResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["cohere_inference_id"] = request.cohere_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{cohere_inference_id}", [
        "task_type", "cohere_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutContextualaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutContextualaiQuery with fn to_json(
  self : InferencePutContextualaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutContextualaiQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutContextualaiQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutContextualaiQuery::new(
  timeout? : String,
) -> InferencePutContextualaiQuery {
  { timeout, }
}

///|
pub fn InferencePutContextualaiQuery::to_pairs(
  self : InferencePutContextualaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutContextualaiBody {
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutContextualaiBody with fn to_json(
  self : InferencePutContextualaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutContextualaiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutContextualaiBody: expected object"),
    )
  }
  {
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutContextualaiBody::new(
  service : Json,
  service_settings : Json,
  task_settings? : Json,
) -> InferencePutContextualaiBody {
  { service, service_settings, task_settings }
}

///|
pub type InferencePutContextualaiResponse = Json

///|
pub(all) struct InferencePutContextualaiRequest {
  task_type : String
  contextualai_inference_id : String
  query : InferencePutContextualaiQuery
  body : InferencePutContextualaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutContextualaiRequest::new(
  task_type : String,
  contextualai_inference_id : String,
  body : InferencePutContextualaiBody,
  query? : InferencePutContextualaiQuery = InferencePutContextualaiQuery::new(),
) -> InferencePutContextualaiRequest {
  { task_type, contextualai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_contextualai(
  self : Client,
  request : InferencePutContextualaiRequest,
) -> EsResponse[InferencePutContextualaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["contextualai_inference_id"] = request.contextualai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{contextualai_inference_id}", [
        "task_type", "contextualai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutCustomQuery {} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutCustomQuery with fn to_json(
  _self : InferencePutCustomQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for InferencePutCustomQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "InferencePutCustomQuery: expected object"))
  }
  InferencePutCustomQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn InferencePutCustomQuery::new() -> InferencePutCustomQuery {
  InferencePutCustomQuery::{  }
}

///|
pub fn InferencePutCustomQuery::to_pairs(
  _self : InferencePutCustomQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct InferencePutCustomBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutCustomBody with fn to_json(
  self : InferencePutCustomBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutCustomBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutCustomBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutCustomBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutCustomBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutCustomResponse = Json

///|
pub(all) struct InferencePutCustomRequest {
  task_type : String
  custom_inference_id : String
  query : InferencePutCustomQuery
  body : InferencePutCustomBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutCustomRequest::new(
  task_type : String,
  custom_inference_id : String,
  body : InferencePutCustomBody,
  query? : InferencePutCustomQuery = InferencePutCustomQuery::new(),
) -> InferencePutCustomRequest {
  { task_type, custom_inference_id, query, body }
}

///|
pub async fn Client::inference_put_custom(
  self : Client,
  request : InferencePutCustomRequest,
) -> EsResponse[InferencePutCustomResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["custom_inference_id"] = request.custom_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{custom_inference_id}", [
        "task_type", "custom_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutDeepseekQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutDeepseekQuery with fn to_json(
  self : InferencePutDeepseekQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutDeepseekQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutDeepseekQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutDeepseekQuery::new(
  timeout? : String,
) -> InferencePutDeepseekQuery {
  { timeout, }
}

///|
pub fn InferencePutDeepseekQuery::to_pairs(
  self : InferencePutDeepseekQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutDeepseekBody {
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutDeepseekBody with fn to_json(
  self : InferencePutDeepseekBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutDeepseekBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutDeepseekBody: expected object"))
  }
  {
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutDeepseekBody::new(
  service : Json,
  service_settings : Json,
) -> InferencePutDeepseekBody {
  { service, service_settings }
}

///|
pub type InferencePutDeepseekResponse = Json

///|
pub(all) struct InferencePutDeepseekRequest {
  task_type : String
  deepseek_inference_id : String
  query : InferencePutDeepseekQuery
  body : InferencePutDeepseekBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutDeepseekRequest::new(
  task_type : String,
  deepseek_inference_id : String,
  body : InferencePutDeepseekBody,
  query? : InferencePutDeepseekQuery = InferencePutDeepseekQuery::new(),
) -> InferencePutDeepseekRequest {
  { task_type, deepseek_inference_id, query, body }
}

///|
pub async fn Client::inference_put_deepseek(
  self : Client,
  request : InferencePutDeepseekRequest,
) -> EsResponse[InferencePutDeepseekResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["deepseek_inference_id"] = request.deepseek_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{deepseek_inference_id}", [
        "task_type", "deepseek_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutElasticsearchQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutElasticsearchQuery with fn to_json(
  self : InferencePutElasticsearchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutElasticsearchQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutElasticsearchQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutElasticsearchQuery::new(
  timeout? : String,
) -> InferencePutElasticsearchQuery {
  { timeout, }
}

///|
pub fn InferencePutElasticsearchQuery::to_pairs(
  self : InferencePutElasticsearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutElasticsearchBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutElasticsearchBody with fn to_json(
  self : InferencePutElasticsearchBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutElasticsearchBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutElasticsearchBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutElasticsearchBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutElasticsearchBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutElasticsearchResponse = Json

///|
pub(all) struct InferencePutElasticsearchRequest {
  task_type : String
  elasticsearch_inference_id : String
  query : InferencePutElasticsearchQuery
  body : InferencePutElasticsearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutElasticsearchRequest::new(
  task_type : String,
  elasticsearch_inference_id : String,
  body : InferencePutElasticsearchBody,
  query? : InferencePutElasticsearchQuery = InferencePutElasticsearchQuery::new(),
) -> InferencePutElasticsearchRequest {
  { task_type, elasticsearch_inference_id, query, body }
}

///|
pub async fn Client::inference_put_elasticsearch(
  self : Client,
  request : InferencePutElasticsearchRequest,
) -> EsResponse[InferencePutElasticsearchResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["elasticsearch_inference_id"] = request.elasticsearch_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{elasticsearch_inference_id}", [
        "task_type", "elasticsearch_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutElserQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutElserQuery with fn to_json(
  self : InferencePutElserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutElserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutElserQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutElserQuery::new(timeout? : String) -> InferencePutElserQuery {
  { timeout, }
}

///|
pub fn InferencePutElserQuery::to_pairs(
  self : InferencePutElserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutElserBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutElserBody with fn to_json(
  self : InferencePutElserBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutElserBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutElserBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutElserBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
) -> InferencePutElserBody {
  { chunking_settings, service, service_settings }
}

///|
pub type InferencePutElserResponse = Json

///|
pub(all) struct InferencePutElserRequest {
  task_type : String
  elser_inference_id : String
  query : InferencePutElserQuery
  body : InferencePutElserBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutElserRequest::new(
  task_type : String,
  elser_inference_id : String,
  body : InferencePutElserBody,
  query? : InferencePutElserQuery = InferencePutElserQuery::new(),
) -> InferencePutElserRequest {
  { task_type, elser_inference_id, query, body }
}

///|
pub async fn Client::inference_put_elser(
  self : Client,
  request : InferencePutElserRequest,
) -> EsResponse[InferencePutElserResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["elser_inference_id"] = request.elser_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{elser_inference_id}", [
        "task_type", "elser_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutFireworksaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutFireworksaiQuery with fn to_json(
  self : InferencePutFireworksaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutFireworksaiQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutFireworksaiQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutFireworksaiQuery::new(
  timeout? : String,
) -> InferencePutFireworksaiQuery {
  { timeout, }
}

///|
pub fn InferencePutFireworksaiQuery::to_pairs(
  self : InferencePutFireworksaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutFireworksaiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutFireworksaiBody with fn to_json(
  self : InferencePutFireworksaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutFireworksaiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutFireworksaiBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutFireworksaiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutFireworksaiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutFireworksaiResponse = Json

///|
pub(all) struct InferencePutFireworksaiRequest {
  task_type : String
  fireworksai_inference_id : String
  query : InferencePutFireworksaiQuery
  body : InferencePutFireworksaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutFireworksaiRequest::new(
  task_type : String,
  fireworksai_inference_id : String,
  body : InferencePutFireworksaiBody,
  query? : InferencePutFireworksaiQuery = InferencePutFireworksaiQuery::new(),
) -> InferencePutFireworksaiRequest {
  { task_type, fireworksai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_fireworksai(
  self : Client,
  request : InferencePutFireworksaiRequest,
) -> EsResponse[InferencePutFireworksaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["fireworksai_inference_id"] = request.fireworksai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{fireworksai_inference_id}", [
        "task_type", "fireworksai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutGoogleaistudioQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutGoogleaistudioQuery with fn to_json(
  self : InferencePutGoogleaistudioQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutGoogleaistudioQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutGoogleaistudioQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutGoogleaistudioQuery::new(
  timeout? : String,
) -> InferencePutGoogleaistudioQuery {
  { timeout, }
}

///|
pub fn InferencePutGoogleaistudioQuery::to_pairs(
  self : InferencePutGoogleaistudioQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutGoogleaistudioBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutGoogleaistudioBody with fn to_json(
  self : InferencePutGoogleaistudioBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutGoogleaistudioBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutGoogleaistudioBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutGoogleaistudioBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
) -> InferencePutGoogleaistudioBody {
  { chunking_settings, service, service_settings }
}

///|
pub type InferencePutGoogleaistudioResponse = Json

///|
pub(all) struct InferencePutGoogleaistudioRequest {
  task_type : String
  googleaistudio_inference_id : String
  query : InferencePutGoogleaistudioQuery
  body : InferencePutGoogleaistudioBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutGoogleaistudioRequest::new(
  task_type : String,
  googleaistudio_inference_id : String,
  body : InferencePutGoogleaistudioBody,
  query? : InferencePutGoogleaistudioQuery = InferencePutGoogleaistudioQuery::new(),
) -> InferencePutGoogleaistudioRequest {
  { task_type, googleaistudio_inference_id, query, body }
}

///|
pub async fn Client::inference_put_googleaistudio(
  self : Client,
  request : InferencePutGoogleaistudioRequest,
) -> EsResponse[InferencePutGoogleaistudioResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["googleaistudio_inference_id"] = request.googleaistudio_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_inference/{task_type}/{googleaistudio_inference_id}",
        ["task_type", "googleaistudio_inference_id"],
      ),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutGooglevertexaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutGooglevertexaiQuery with fn to_json(
  self : InferencePutGooglevertexaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutGooglevertexaiQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutGooglevertexaiQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutGooglevertexaiQuery::new(
  timeout? : String,
) -> InferencePutGooglevertexaiQuery {
  { timeout, }
}

///|
pub fn InferencePutGooglevertexaiQuery::to_pairs(
  self : InferencePutGooglevertexaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutGooglevertexaiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutGooglevertexaiBody with fn to_json(
  self : InferencePutGooglevertexaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutGooglevertexaiBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutGooglevertexaiBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutGooglevertexaiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutGooglevertexaiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutGooglevertexaiResponse = Json

///|
pub(all) struct InferencePutGooglevertexaiRequest {
  task_type : String
  googlevertexai_inference_id : String
  query : InferencePutGooglevertexaiQuery
  body : InferencePutGooglevertexaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutGooglevertexaiRequest::new(
  task_type : String,
  googlevertexai_inference_id : String,
  body : InferencePutGooglevertexaiBody,
  query? : InferencePutGooglevertexaiQuery = InferencePutGooglevertexaiQuery::new(),
) -> InferencePutGooglevertexaiRequest {
  { task_type, googlevertexai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_googlevertexai(
  self : Client,
  request : InferencePutGooglevertexaiRequest,
) -> EsResponse[InferencePutGooglevertexaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["googlevertexai_inference_id"] = request.googlevertexai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_inference/{task_type}/{googlevertexai_inference_id}",
        ["task_type", "googlevertexai_inference_id"],
      ),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutGroqQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutGroqQuery with fn to_json(
  self : InferencePutGroqQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutGroqQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutGroqQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutGroqQuery::new(timeout? : String) -> InferencePutGroqQuery {
  { timeout, }
}

///|
pub fn InferencePutGroqQuery::to_pairs(
  self : InferencePutGroqQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutGroqBody {
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutGroqBody with fn to_json(
  self : InferencePutGroqBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutGroqBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutGroqBody: expected object"))
  }
  {
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutGroqBody::new(
  service : Json,
  service_settings : Json,
) -> InferencePutGroqBody {
  { service, service_settings }
}

///|
pub type InferencePutGroqResponse = Json

///|
pub(all) struct InferencePutGroqRequest {
  task_type : String
  groq_inference_id : String
  query : InferencePutGroqQuery
  body : InferencePutGroqBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutGroqRequest::new(
  task_type : String,
  groq_inference_id : String,
  body : InferencePutGroqBody,
  query? : InferencePutGroqQuery = InferencePutGroqQuery::new(),
) -> InferencePutGroqRequest {
  { task_type, groq_inference_id, query, body }
}

///|
pub async fn Client::inference_put_groq(
  self : Client,
  request : InferencePutGroqRequest,
) -> EsResponse[InferencePutGroqResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["groq_inference_id"] = request.groq_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{groq_inference_id}", [
        "task_type", "groq_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutHuggingFaceQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutHuggingFaceQuery with fn to_json(
  self : InferencePutHuggingFaceQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutHuggingFaceQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutHuggingFaceQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutHuggingFaceQuery::new(
  timeout? : String,
) -> InferencePutHuggingFaceQuery {
  { timeout, }
}

///|
pub fn InferencePutHuggingFaceQuery::to_pairs(
  self : InferencePutHuggingFaceQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutHuggingFaceBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutHuggingFaceBody with fn to_json(
  self : InferencePutHuggingFaceBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutHuggingFaceBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutHuggingFaceBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutHuggingFaceBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutHuggingFaceBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutHuggingFaceResponse = Json

///|
pub(all) struct InferencePutHuggingFaceRequest {
  task_type : String
  huggingface_inference_id : String
  query : InferencePutHuggingFaceQuery
  body : InferencePutHuggingFaceBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutHuggingFaceRequest::new(
  task_type : String,
  huggingface_inference_id : String,
  body : InferencePutHuggingFaceBody,
  query? : InferencePutHuggingFaceQuery = InferencePutHuggingFaceQuery::new(),
) -> InferencePutHuggingFaceRequest {
  { task_type, huggingface_inference_id, query, body }
}

///|
pub async fn Client::inference_put_hugging_face(
  self : Client,
  request : InferencePutHuggingFaceRequest,
) -> EsResponse[InferencePutHuggingFaceResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["huggingface_inference_id"] = request.huggingface_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{huggingface_inference_id}", [
        "task_type", "huggingface_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutJinaaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutJinaaiQuery with fn to_json(
  self : InferencePutJinaaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutJinaaiQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutJinaaiQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutJinaaiQuery::new(
  timeout? : String,
) -> InferencePutJinaaiQuery {
  { timeout, }
}

///|
pub fn InferencePutJinaaiQuery::to_pairs(
  self : InferencePutJinaaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutJinaaiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutJinaaiBody with fn to_json(
  self : InferencePutJinaaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutJinaaiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutJinaaiBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutJinaaiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutJinaaiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutJinaaiResponse = Json

///|
pub(all) struct InferencePutJinaaiRequest {
  task_type : String
  jinaai_inference_id : String
  query : InferencePutJinaaiQuery
  body : InferencePutJinaaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutJinaaiRequest::new(
  task_type : String,
  jinaai_inference_id : String,
  body : InferencePutJinaaiBody,
  query? : InferencePutJinaaiQuery = InferencePutJinaaiQuery::new(),
) -> InferencePutJinaaiRequest {
  { task_type, jinaai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_jinaai(
  self : Client,
  request : InferencePutJinaaiRequest,
) -> EsResponse[InferencePutJinaaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["jinaai_inference_id"] = request.jinaai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{jinaai_inference_id}", [
        "task_type", "jinaai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutLlamaQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutLlamaQuery with fn to_json(
  self : InferencePutLlamaQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutLlamaQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutLlamaQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutLlamaQuery::new(timeout? : String) -> InferencePutLlamaQuery {
  { timeout, }
}

///|
pub fn InferencePutLlamaQuery::to_pairs(
  self : InferencePutLlamaQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutLlamaBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutLlamaBody with fn to_json(
  self : InferencePutLlamaBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutLlamaBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutLlamaBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutLlamaBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
) -> InferencePutLlamaBody {
  { chunking_settings, service, service_settings }
}

///|
pub type InferencePutLlamaResponse = Json

///|
pub(all) struct InferencePutLlamaRequest {
  task_type : String
  llama_inference_id : String
  query : InferencePutLlamaQuery
  body : InferencePutLlamaBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutLlamaRequest::new(
  task_type : String,
  llama_inference_id : String,
  body : InferencePutLlamaBody,
  query? : InferencePutLlamaQuery = InferencePutLlamaQuery::new(),
) -> InferencePutLlamaRequest {
  { task_type, llama_inference_id, query, body }
}

///|
pub async fn Client::inference_put_llama(
  self : Client,
  request : InferencePutLlamaRequest,
) -> EsResponse[InferencePutLlamaResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["llama_inference_id"] = request.llama_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{llama_inference_id}", [
        "task_type", "llama_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutMistralQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutMistralQuery with fn to_json(
  self : InferencePutMistralQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutMistralQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutMistralQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutMistralQuery::new(
  timeout? : String,
) -> InferencePutMistralQuery {
  { timeout, }
}

///|
pub fn InferencePutMistralQuery::to_pairs(
  self : InferencePutMistralQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutMistralBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutMistralBody with fn to_json(
  self : InferencePutMistralBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutMistralBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutMistralBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutMistralBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
) -> InferencePutMistralBody {
  { chunking_settings, service, service_settings }
}

///|
pub type InferencePutMistralResponse = Json

///|
pub(all) struct InferencePutMistralRequest {
  task_type : String
  mistral_inference_id : String
  query : InferencePutMistralQuery
  body : InferencePutMistralBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutMistralRequest::new(
  task_type : String,
  mistral_inference_id : String,
  body : InferencePutMistralBody,
  query? : InferencePutMistralQuery = InferencePutMistralQuery::new(),
) -> InferencePutMistralRequest {
  { task_type, mistral_inference_id, query, body }
}

///|
pub async fn Client::inference_put_mistral(
  self : Client,
  request : InferencePutMistralRequest,
) -> EsResponse[InferencePutMistralResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["mistral_inference_id"] = request.mistral_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{mistral_inference_id}", [
        "task_type", "mistral_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutNvidiaQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutNvidiaQuery with fn to_json(
  self : InferencePutNvidiaQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutNvidiaQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutNvidiaQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutNvidiaQuery::new(
  timeout? : String,
) -> InferencePutNvidiaQuery {
  { timeout, }
}

///|
pub fn InferencePutNvidiaQuery::to_pairs(
  self : InferencePutNvidiaQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutNvidiaBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutNvidiaBody with fn to_json(
  self : InferencePutNvidiaBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutNvidiaBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutNvidiaBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutNvidiaBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutNvidiaBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutNvidiaResponse = Json

///|
pub(all) struct InferencePutNvidiaRequest {
  task_type : String
  nvidia_inference_id : String
  query : InferencePutNvidiaQuery
  body : InferencePutNvidiaBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutNvidiaRequest::new(
  task_type : String,
  nvidia_inference_id : String,
  body : InferencePutNvidiaBody,
  query? : InferencePutNvidiaQuery = InferencePutNvidiaQuery::new(),
) -> InferencePutNvidiaRequest {
  { task_type, nvidia_inference_id, query, body }
}

///|
pub async fn Client::inference_put_nvidia(
  self : Client,
  request : InferencePutNvidiaRequest,
) -> EsResponse[InferencePutNvidiaResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["nvidia_inference_id"] = request.nvidia_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{nvidia_inference_id}", [
        "task_type", "nvidia_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutOpenaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutOpenaiQuery with fn to_json(
  self : InferencePutOpenaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutOpenaiQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutOpenaiQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutOpenaiQuery::new(
  timeout? : String,
) -> InferencePutOpenaiQuery {
  { timeout, }
}

///|
pub fn InferencePutOpenaiQuery::to_pairs(
  self : InferencePutOpenaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutOpenaiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutOpenaiBody with fn to_json(
  self : InferencePutOpenaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutOpenaiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutOpenaiBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutOpenaiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutOpenaiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutOpenaiResponse = Json

///|
pub(all) struct InferencePutOpenaiRequest {
  task_type : String
  openai_inference_id : String
  query : InferencePutOpenaiQuery
  body : InferencePutOpenaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutOpenaiRequest::new(
  task_type : String,
  openai_inference_id : String,
  body : InferencePutOpenaiBody,
  query? : InferencePutOpenaiQuery = InferencePutOpenaiQuery::new(),
) -> InferencePutOpenaiRequest {
  { task_type, openai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_openai(
  self : Client,
  request : InferencePutOpenaiRequest,
) -> EsResponse[InferencePutOpenaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["openai_inference_id"] = request.openai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{openai_inference_id}", [
        "task_type", "openai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutOpenshiftAiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutOpenshiftAiQuery with fn to_json(
  self : InferencePutOpenshiftAiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutOpenshiftAiQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutOpenshiftAiQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutOpenshiftAiQuery::new(
  timeout? : String,
) -> InferencePutOpenshiftAiQuery {
  { timeout, }
}

///|
pub fn InferencePutOpenshiftAiQuery::to_pairs(
  self : InferencePutOpenshiftAiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutOpenshiftAiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutOpenshiftAiBody with fn to_json(
  self : InferencePutOpenshiftAiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutOpenshiftAiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferencePutOpenshiftAiBody: expected object"),
    )
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutOpenshiftAiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutOpenshiftAiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutOpenshiftAiResponse = Json

///|
pub(all) struct InferencePutOpenshiftAiRequest {
  task_type : String
  openshiftai_inference_id : String
  query : InferencePutOpenshiftAiQuery
  body : InferencePutOpenshiftAiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutOpenshiftAiRequest::new(
  task_type : String,
  openshiftai_inference_id : String,
  body : InferencePutOpenshiftAiBody,
  query? : InferencePutOpenshiftAiQuery = InferencePutOpenshiftAiQuery::new(),
) -> InferencePutOpenshiftAiRequest {
  { task_type, openshiftai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_openshift_ai(
  self : Client,
  request : InferencePutOpenshiftAiRequest,
) -> EsResponse[InferencePutOpenshiftAiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["openshiftai_inference_id"] = request.openshiftai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{openshiftai_inference_id}", [
        "task_type", "openshiftai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutVoyageaiQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutVoyageaiQuery with fn to_json(
  self : InferencePutVoyageaiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutVoyageaiQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutVoyageaiQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutVoyageaiQuery::new(
  timeout? : String,
) -> InferencePutVoyageaiQuery {
  { timeout, }
}

///|
pub fn InferencePutVoyageaiQuery::to_pairs(
  self : InferencePutVoyageaiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutVoyageaiBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutVoyageaiBody with fn to_json(
  self : InferencePutVoyageaiBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutVoyageaiBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutVoyageaiBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferencePutVoyageaiBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
  task_settings? : Json,
) -> InferencePutVoyageaiBody {
  { chunking_settings, service, service_settings, task_settings }
}

///|
pub type InferencePutVoyageaiResponse = Json

///|
pub(all) struct InferencePutVoyageaiRequest {
  task_type : String
  voyageai_inference_id : String
  query : InferencePutVoyageaiQuery
  body : InferencePutVoyageaiBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutVoyageaiRequest::new(
  task_type : String,
  voyageai_inference_id : String,
  body : InferencePutVoyageaiBody,
  query? : InferencePutVoyageaiQuery = InferencePutVoyageaiQuery::new(),
) -> InferencePutVoyageaiRequest {
  { task_type, voyageai_inference_id, query, body }
}

///|
pub async fn Client::inference_put_voyageai(
  self : Client,
  request : InferencePutVoyageaiRequest,
) -> EsResponse[InferencePutVoyageaiResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["voyageai_inference_id"] = request.voyageai_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{voyageai_inference_id}", [
        "task_type", "voyageai_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferencePutWatsonxQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutWatsonxQuery with fn to_json(
  self : InferencePutWatsonxQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutWatsonxQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutWatsonxQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferencePutWatsonxQuery::new(
  timeout? : String,
) -> InferencePutWatsonxQuery {
  { timeout, }
}

///|
pub fn InferencePutWatsonxQuery::to_pairs(
  self : InferencePutWatsonxQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferencePutWatsonxBody {
  chunking_settings : Json?
  service : Json
  service_settings : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InferencePutWatsonxBody with fn to_json(
  self : InferencePutWatsonxBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.chunking_settings {
    Some(value) => obj["chunking_settings"] = value.to_json()
    None => ()
  }
  obj["service"] = self.service.to_json()
  obj["service_settings"] = self.service_settings.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InferencePutWatsonxBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferencePutWatsonxBody: expected object"))
  }
  {
    chunking_settings: match obj.get("chunking_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_settings")))
    },
    service: @json.from_json(
      obj.get("service").unwrap_or(Json::null()),
      path=path.add_key("service"),
    ),
    service_settings: @json.from_json(
      obj.get("service_settings").unwrap_or(Json::null()),
      path=path.add_key("service_settings"),
    ),
  }
}

///|
pub fn InferencePutWatsonxBody::new(
  service : Json,
  service_settings : Json,
  chunking_settings? : Json,
) -> InferencePutWatsonxBody {
  { chunking_settings, service, service_settings }
}

///|
pub type InferencePutWatsonxResponse = Json

///|
pub(all) struct InferencePutWatsonxRequest {
  task_type : String
  watsonx_inference_id : String
  query : InferencePutWatsonxQuery
  body : InferencePutWatsonxBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferencePutWatsonxRequest::new(
  task_type : String,
  watsonx_inference_id : String,
  body : InferencePutWatsonxBody,
  query? : InferencePutWatsonxQuery = InferencePutWatsonxQuery::new(),
) -> InferencePutWatsonxRequest {
  { task_type, watsonx_inference_id, query, body }
}

///|
pub async fn Client::inference_put_watsonx(
  self : Client,
  request : InferencePutWatsonxRequest,
) -> EsResponse[InferencePutWatsonxResponse] {
  let params : Map[String, String] = Map([])
  params["task_type"] = request.task_type
  params["watsonx_inference_id"] = request.watsonx_inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{watsonx_inference_id}", [
        "task_type", "watsonx_inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InferenceRerankQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceRerankQuery with fn to_json(
  self : InferenceRerankQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceRerankQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceRerankQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceRerankQuery::new(timeout? : String) -> InferenceRerankQuery {
  { timeout, }
}

///|
pub fn InferenceRerankQuery::to_pairs(
  self : InferenceRerankQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferenceRerankBody {
  query : String
  input : Array[String]
  return_documents : Bool?
  top_n : Int?
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceRerankBody with fn to_json(
  self : InferenceRerankBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["query"] = self.query.to_json()
  obj["input"] = self.input.to_json()
  match self.return_documents {
    Some(value) => obj["return_documents"] = value.to_json()
    None => ()
  }
  match self.top_n {
    Some(value) => obj["top_n"] = value.to_json()
    None => ()
  }
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceRerankBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceRerankBody: expected object"))
  }
  {
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    input: @json.from_json(
      obj.get("input").unwrap_or(Json::null()),
      path=path.add_key("input"),
    ),
    return_documents: match obj.get("return_documents") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("return_documents")))
    },
    top_n: match obj.get("top_n") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("top_n")))
    },
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferenceRerankBody::new(
  query : String,
  input : Array[String],
  return_documents? : Bool,
  top_n? : Int,
  task_settings? : Json,
) -> InferenceRerankBody {
  { query, input, return_documents, top_n, task_settings }
}

///|
pub type InferenceRerankResponse = Json

///|
pub(all) struct InferenceRerankRequest {
  inference_id : String
  query : InferenceRerankQuery
  body : InferenceRerankBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceRerankRequest::new(
  inference_id : String,
  body : InferenceRerankBody,
  query? : InferenceRerankQuery = InferenceRerankQuery::new(),
) -> InferenceRerankRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_rerank(
  self : Client,
  request : InferenceRerankRequest,
) -> EsResponse[InferenceRerankResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_inference/rerank/{inference_id}", ["inference_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceSparseEmbeddingQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceSparseEmbeddingQuery with fn to_json(
  self : InferenceSparseEmbeddingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceSparseEmbeddingQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferenceSparseEmbeddingQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceSparseEmbeddingQuery::new(
  timeout? : String,
) -> InferenceSparseEmbeddingQuery {
  { timeout, }
}

///|
pub fn InferenceSparseEmbeddingQuery::to_pairs(
  self : InferenceSparseEmbeddingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferenceSparseEmbeddingBody {
  input : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceSparseEmbeddingBody with fn to_json(
  self : InferenceSparseEmbeddingBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["input"] = self.input.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceSparseEmbeddingBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferenceSparseEmbeddingBody: expected object"),
    )
  }
  {
    input: @json.from_json(
      obj.get("input").unwrap_or(Json::null()),
      path=path.add_key("input"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferenceSparseEmbeddingBody::new(
  input : Json,
  task_settings? : Json,
) -> InferenceSparseEmbeddingBody {
  { input, task_settings }
}

///|
pub type InferenceSparseEmbeddingResponse = Json

///|
pub(all) struct InferenceSparseEmbeddingRequest {
  inference_id : String
  query : InferenceSparseEmbeddingQuery
  body : InferenceSparseEmbeddingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceSparseEmbeddingRequest::new(
  inference_id : String,
  body : InferenceSparseEmbeddingBody,
  query? : InferenceSparseEmbeddingQuery = InferenceSparseEmbeddingQuery::new(),
) -> InferenceSparseEmbeddingRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_sparse_embedding(
  self : Client,
  request : InferenceSparseEmbeddingRequest,
) -> EsResponse[InferenceSparseEmbeddingResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/sparse_embedding/{inference_id}", [
        "inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceStreamCompletionQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceStreamCompletionQuery with fn to_json(
  self : InferenceStreamCompletionQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceStreamCompletionQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferenceStreamCompletionQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceStreamCompletionQuery::new(
  timeout? : String,
) -> InferenceStreamCompletionQuery {
  { timeout, }
}

///|
pub fn InferenceStreamCompletionQuery::to_pairs(
  self : InferenceStreamCompletionQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferenceStreamCompletionBody {
  input : Json
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceStreamCompletionBody with fn to_json(
  self : InferenceStreamCompletionBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["input"] = self.input.to_json()
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceStreamCompletionBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferenceStreamCompletionBody: expected object"),
    )
  }
  {
    input: @json.from_json(
      obj.get("input").unwrap_or(Json::null()),
      path=path.add_key("input"),
    ),
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferenceStreamCompletionBody::new(
  input : Json,
  task_settings? : Json,
) -> InferenceStreamCompletionBody {
  { input, task_settings }
}

///|
pub type InferenceStreamCompletionResponse = Json

///|
pub(all) struct InferenceStreamCompletionRequest {
  inference_id : String
  query : InferenceStreamCompletionQuery
  body : InferenceStreamCompletionBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceStreamCompletionRequest::new(
  inference_id : String,
  body : InferenceStreamCompletionBody,
  query? : InferenceStreamCompletionQuery = InferenceStreamCompletionQuery::new(),
) -> InferenceStreamCompletionRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_stream_completion(
  self : Client,
  request : InferenceStreamCompletionRequest,
) -> EsResponse[InferenceStreamCompletionResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/completion/{inference_id}/_stream", [
        "inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceTextEmbeddingQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceTextEmbeddingQuery with fn to_json(
  self : InferenceTextEmbeddingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceTextEmbeddingQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "InferenceTextEmbeddingQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn InferenceTextEmbeddingQuery::new(
  timeout? : String,
) -> InferenceTextEmbeddingQuery {
  { timeout, }
}

///|
pub fn InferenceTextEmbeddingQuery::to_pairs(
  self : InferenceTextEmbeddingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct InferenceTextEmbeddingBody {
  input : Json
  input_type : String?
  task_settings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for InferenceTextEmbeddingBody with fn to_json(
  self : InferenceTextEmbeddingBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["input"] = self.input.to_json()
  match self.input_type {
    Some(value) => obj["input_type"] = value.to_json()
    None => ()
  }
  match self.task_settings {
    Some(value) => obj["task_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for InferenceTextEmbeddingBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InferenceTextEmbeddingBody: expected object"))
  }
  {
    input: @json.from_json(
      obj.get("input").unwrap_or(Json::null()),
      path=path.add_key("input"),
    ),
    input_type: match obj.get("input_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("input_type")))
    },
    task_settings: match obj.get("task_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_settings")))
    },
  }
}

///|
pub fn InferenceTextEmbeddingBody::new(
  input : Json,
  input_type? : String,
  task_settings? : Json,
) -> InferenceTextEmbeddingBody {
  { input, input_type, task_settings }
}

///|
pub type InferenceTextEmbeddingResponse = Json

///|
pub(all) struct InferenceTextEmbeddingRequest {
  inference_id : String
  query : InferenceTextEmbeddingQuery
  body : InferenceTextEmbeddingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceTextEmbeddingRequest::new(
  inference_id : String,
  body : InferenceTextEmbeddingBody,
  query? : InferenceTextEmbeddingQuery = InferenceTextEmbeddingQuery::new(),
) -> InferenceTextEmbeddingRequest {
  { inference_id, query, body }
}

///|
pub async fn Client::inference_text_embedding(
  self : Client,
  request : InferenceTextEmbeddingRequest,
) -> EsResponse[InferenceTextEmbeddingResponse] {
  let params : Map[String, String] = Map([])
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/text_embedding/{inference_id}", [
        "inference_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct InferenceUpdateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for InferenceUpdateQuery with fn to_json(
  _self : InferenceUpdateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for InferenceUpdateQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "InferenceUpdateQuery: expected object"))
  }
  InferenceUpdateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn InferenceUpdateQuery::new() -> InferenceUpdateQuery {
  InferenceUpdateQuery::{  }
}

///|
pub fn InferenceUpdateQuery::to_pairs(
  _self : InferenceUpdateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type InferenceUpdateBody = Json

///|
pub type InferenceUpdateResponse = Json

///|
pub(all) struct InferenceUpdateRequest {
  task_type : String?
  inference_id : String
  query : InferenceUpdateQuery
  body : InferenceUpdateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InferenceUpdateRequest::new(
  inference_id : String,
  body : InferenceUpdateBody,
  task_type? : String,
  query? : InferenceUpdateQuery = InferenceUpdateQuery::new(),
) -> InferenceUpdateRequest {
  { task_type, inference_id, query, body }
}

///|
pub async fn Client::inference_update(
  self : Client,
  request : InferenceUpdateRequest,
) -> EsResponse[InferenceUpdateResponse] {
  let params : Map[String, String] = Map([])
  match request.task_type {
    Some(value) => params["task_type"] = value
    None => ()
  }
  params["inference_id"] = request.inference_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_inference/{task_type}/{inference_id}/_update", [
        "task_type", "inference_id",
      ]),
      PathVariant::new("/_inference/{inference_id}/_update", ["inference_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct InfoQuery {} derive(Eq, Debug)

///|
pub impl ToJson for InfoQuery with fn to_json(_self : InfoQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for InfoQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "InfoQuery: expected object"))
  }
  InfoQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn InfoQuery::new() -> InfoQuery {
  InfoQuery::{  }
}

///|
pub fn InfoQuery::to_pairs(_self : InfoQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct InfoResponse {
  cluster_name : Json
  cluster_uuid : Json
  name : Json
  tagline : String
  version : Json
} derive(Eq, Debug)

///|
pub impl ToJson for InfoResponse with fn to_json(self : InfoResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["cluster_uuid"] = self.cluster_uuid.to_json()
  obj["name"] = self.name.to_json()
  obj["tagline"] = self.tagline.to_json()
  obj["version"] = self.version.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for InfoResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "InfoResponse: expected object"))
  }
  {
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    cluster_uuid: @json.from_json(
      obj.get("cluster_uuid").unwrap_or(Json::null()),
      path=path.add_key("cluster_uuid"),
    ),
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    tagline: @json.from_json(
      obj.get("tagline").unwrap_or(Json::null()),
      path=path.add_key("tagline"),
    ),
    version: @json.from_json(
      obj.get("version").unwrap_or(Json::null()),
      path=path.add_key("version"),
    ),
  }
}

///|
pub(all) struct InfoRequest {
  query : InfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn InfoRequest::new(query? : InfoQuery = InfoQuery::new()) -> InfoRequest {
  { query, }
}

///|
pub async fn Client::info(
  self : Client,
  request : InfoRequest,
) -> EsResponse[InfoResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IngestDeleteGeoipDatabaseQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestDeleteGeoipDatabaseQuery with fn to_json(
  self : IngestDeleteGeoipDatabaseQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestDeleteGeoipDatabaseQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestDeleteGeoipDatabaseQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IngestDeleteGeoipDatabaseQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IngestDeleteGeoipDatabaseQuery {
  { master_timeout, timeout }
}

///|
pub fn IngestDeleteGeoipDatabaseQuery::to_pairs(
  self : IngestDeleteGeoipDatabaseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IngestDeleteGeoipDatabaseResponse = Json

///|
pub(all) struct IngestDeleteGeoipDatabaseRequest {
  id : String
  query : IngestDeleteGeoipDatabaseQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestDeleteGeoipDatabaseRequest::new(
  id : String,
  query? : IngestDeleteGeoipDatabaseQuery = IngestDeleteGeoipDatabaseQuery::new(),
) -> IngestDeleteGeoipDatabaseRequest {
  { id, query }
}

///|
pub async fn Client::ingest_delete_geoip_database(
  self : Client,
  request : IngestDeleteGeoipDatabaseRequest,
) -> EsResponse[IngestDeleteGeoipDatabaseResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/geoip/database/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IngestDeleteIpLocationDatabaseQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestDeleteIpLocationDatabaseQuery with fn to_json(
  self : IngestDeleteIpLocationDatabaseQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestDeleteIpLocationDatabaseQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestDeleteIpLocationDatabaseQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IngestDeleteIpLocationDatabaseQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IngestDeleteIpLocationDatabaseQuery {
  { master_timeout, timeout }
}

///|
pub fn IngestDeleteIpLocationDatabaseQuery::to_pairs(
  self : IngestDeleteIpLocationDatabaseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IngestDeleteIpLocationDatabaseResponse = Json

///|
pub(all) struct IngestDeleteIpLocationDatabaseRequest {
  id : String
  query : IngestDeleteIpLocationDatabaseQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestDeleteIpLocationDatabaseRequest::new(
  id : String,
  query? : IngestDeleteIpLocationDatabaseQuery = IngestDeleteIpLocationDatabaseQuery::new(),
) -> IngestDeleteIpLocationDatabaseRequest {
  { id, query }
}

///|
pub async fn Client::ingest_delete_ip_location_database(
  self : Client,
  request : IngestDeleteIpLocationDatabaseRequest,
) -> EsResponse[IngestDeleteIpLocationDatabaseResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/ip_location/database/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IngestDeletePipelineQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestDeletePipelineQuery with fn to_json(
  self : IngestDeletePipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestDeletePipelineQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestDeletePipelineQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IngestDeletePipelineQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IngestDeletePipelineQuery {
  { master_timeout, timeout }
}

///|
pub fn IngestDeletePipelineQuery::to_pairs(
  self : IngestDeletePipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IngestDeletePipelineResponse = Json

///|
pub(all) struct IngestDeletePipelineRequest {
  id : String
  query : IngestDeletePipelineQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestDeletePipelineRequest::new(
  id : String,
  query? : IngestDeletePipelineQuery = IngestDeletePipelineQuery::new(),
) -> IngestDeletePipelineRequest {
  { id, query }
}

///|
pub async fn Client::ingest_delete_pipeline(
  self : Client,
  request : IngestDeletePipelineRequest,
) -> EsResponse[IngestDeletePipelineResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/pipeline/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct IngestGeoIpStatsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IngestGeoIpStatsQuery with fn to_json(
  _self : IngestGeoIpStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IngestGeoIpStatsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IngestGeoIpStatsQuery: expected object"))
  }
  IngestGeoIpStatsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IngestGeoIpStatsQuery::new() -> IngestGeoIpStatsQuery {
  IngestGeoIpStatsQuery::{  }
}

///|
pub fn IngestGeoIpStatsQuery::to_pairs(
  _self : IngestGeoIpStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IngestGeoIpStatsResponse {
  stats : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IngestGeoIpStatsResponse with fn to_json(
  self : IngestGeoIpStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["stats"] = self.stats.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IngestGeoIpStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestGeoIpStatsResponse: expected object"))
  }
  {
    stats: @json.from_json(
      obj.get("stats").unwrap_or(Json::null()),
      path=path.add_key("stats"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct IngestGeoIpStatsRequest {
  query : IngestGeoIpStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestGeoIpStatsRequest::new(
  query? : IngestGeoIpStatsQuery = IngestGeoIpStatsQuery::new(),
) -> IngestGeoIpStatsRequest {
  { query, }
}

///|
pub async fn Client::ingest_geo_ip_stats(
  self : Client,
  request : IngestGeoIpStatsRequest,
) -> EsResponse[IngestGeoIpStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ingest/geoip/stats", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IngestGetGeoipDatabaseQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IngestGetGeoipDatabaseQuery with fn to_json(
  _self : IngestGetGeoipDatabaseQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IngestGetGeoipDatabaseQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "IngestGetGeoipDatabaseQuery: expected object"),
    )
  }
  IngestGetGeoipDatabaseQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IngestGetGeoipDatabaseQuery::new() -> IngestGetGeoipDatabaseQuery {
  IngestGetGeoipDatabaseQuery::{  }
}

///|
pub fn IngestGetGeoipDatabaseQuery::to_pairs(
  _self : IngestGetGeoipDatabaseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IngestGetGeoipDatabaseResponse {
  databases : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IngestGetGeoipDatabaseResponse with fn to_json(
  self : IngestGetGeoipDatabaseResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["databases"] = self.databases.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IngestGetGeoipDatabaseResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestGetGeoipDatabaseResponse: expected object"),
    )
  }
  {
    databases: @json.from_json(
      obj.get("databases").unwrap_or(Json::null()),
      path=path.add_key("databases"),
    ),
  }
}

///|
pub(all) struct IngestGetGeoipDatabaseRequest {
  id : String?
  query : IngestGetGeoipDatabaseQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestGetGeoipDatabaseRequest::new(
  id? : String,
  query? : IngestGetGeoipDatabaseQuery = IngestGetGeoipDatabaseQuery::new(),
) -> IngestGetGeoipDatabaseRequest {
  { id, query }
}

///|
pub async fn Client::ingest_get_geoip_database(
  self : Client,
  request : IngestGetGeoipDatabaseRequest,
) -> EsResponse[IngestGetGeoipDatabaseResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ingest/geoip/database/{id}", ["id"]),
      PathVariant::new("/_ingest/geoip/database", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IngestGetIpLocationDatabaseQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IngestGetIpLocationDatabaseQuery with fn to_json(
  _self : IngestGetIpLocationDatabaseQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IngestGetIpLocationDatabaseQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "IngestGetIpLocationDatabaseQuery: expected object"),
    )
  }
  IngestGetIpLocationDatabaseQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IngestGetIpLocationDatabaseQuery::new() -> IngestGetIpLocationDatabaseQuery {
  IngestGetIpLocationDatabaseQuery::{  }
}

///|
pub fn IngestGetIpLocationDatabaseQuery::to_pairs(
  _self : IngestGetIpLocationDatabaseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IngestGetIpLocationDatabaseResponse {
  databases : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IngestGetIpLocationDatabaseResponse with fn to_json(
  self : IngestGetIpLocationDatabaseResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["databases"] = self.databases.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IngestGetIpLocationDatabaseResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestGetIpLocationDatabaseResponse: expected object"),
    )
  }
  {
    databases: @json.from_json(
      obj.get("databases").unwrap_or(Json::null()),
      path=path.add_key("databases"),
    ),
  }
}

///|
pub(all) struct IngestGetIpLocationDatabaseRequest {
  id : String?
  query : IngestGetIpLocationDatabaseQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestGetIpLocationDatabaseRequest::new(
  id? : String,
  query? : IngestGetIpLocationDatabaseQuery = IngestGetIpLocationDatabaseQuery::new(),
) -> IngestGetIpLocationDatabaseRequest {
  { id, query }
}

///|
pub async fn Client::ingest_get_ip_location_database(
  self : Client,
  request : IngestGetIpLocationDatabaseRequest,
) -> EsResponse[IngestGetIpLocationDatabaseResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ingest/ip_location/database/{id}", ["id"]),
      PathVariant::new("/_ingest/ip_location/database", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IngestGetPipelineQuery {
  master_timeout : String?
  summary : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestGetPipelineQuery with fn to_json(
  self : IngestGetPipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.summary {
    Some(value) => obj["summary"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestGetPipelineQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestGetPipelineQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    summary: match obj.get("summary") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("summary")))
    },
  }
}

///|
pub fn IngestGetPipelineQuery::new(
  master_timeout? : String,
  summary? : Bool,
) -> IngestGetPipelineQuery {
  { master_timeout, summary }
}

///|
pub fn IngestGetPipelineQuery::to_pairs(
  self : IngestGetPipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.summary {
    Some(value) => push_query_json(pairs, "summary", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IngestGetPipelineResponse = Json

///|
pub(all) struct IngestGetPipelineRequest {
  id : String?
  query : IngestGetPipelineQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestGetPipelineRequest::new(
  id? : String,
  query? : IngestGetPipelineQuery = IngestGetPipelineQuery::new(),
) -> IngestGetPipelineRequest {
  { id, query }
}

///|
pub async fn Client::ingest_get_pipeline(
  self : Client,
  request : IngestGetPipelineRequest,
) -> EsResponse[IngestGetPipelineResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ingest/pipeline/{id}", ["id"]),
      PathVariant::new("/_ingest/pipeline", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IngestProcessorGrokQuery {} derive(Eq, Debug)

///|
pub impl ToJson for IngestProcessorGrokQuery with fn to_json(
  _self : IngestProcessorGrokQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for IngestProcessorGrokQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "IngestProcessorGrokQuery: expected object"))
  }
  IngestProcessorGrokQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn IngestProcessorGrokQuery::new() -> IngestProcessorGrokQuery {
  IngestProcessorGrokQuery::{  }
}

///|
pub fn IngestProcessorGrokQuery::to_pairs(
  _self : IngestProcessorGrokQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct IngestProcessorGrokResponse {
  patterns : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IngestProcessorGrokResponse with fn to_json(
  self : IngestProcessorGrokResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["patterns"] = self.patterns.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IngestProcessorGrokResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestProcessorGrokResponse: expected object"),
    )
  }
  {
    patterns: @json.from_json(
      obj.get("patterns").unwrap_or(Json::null()),
      path=path.add_key("patterns"),
    ),
  }
}

///|
pub(all) struct IngestProcessorGrokRequest {
  query : IngestProcessorGrokQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestProcessorGrokRequest::new(
  query? : IngestProcessorGrokQuery = IngestProcessorGrokQuery::new(),
) -> IngestProcessorGrokRequest {
  { query, }
}

///|
pub async fn Client::ingest_processor_grok(
  self : Client,
  request : IngestProcessorGrokRequest,
) -> EsResponse[IngestProcessorGrokResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/processor/grok", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct IngestPutGeoipDatabaseQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestPutGeoipDatabaseQuery with fn to_json(
  self : IngestPutGeoipDatabaseQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestPutGeoipDatabaseQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestPutGeoipDatabaseQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IngestPutGeoipDatabaseQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IngestPutGeoipDatabaseQuery {
  { master_timeout, timeout }
}

///|
pub fn IngestPutGeoipDatabaseQuery::to_pairs(
  self : IngestPutGeoipDatabaseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IngestPutGeoipDatabaseBody {
  name : Json
  maxmind : Json
} derive(Eq, Debug)

///|
pub impl ToJson for IngestPutGeoipDatabaseBody with fn to_json(
  self : IngestPutGeoipDatabaseBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["name"] = self.name.to_json()
  obj["maxmind"] = self.maxmind.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IngestPutGeoipDatabaseBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestPutGeoipDatabaseBody: expected object"))
  }
  {
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    maxmind: @json.from_json(
      obj.get("maxmind").unwrap_or(Json::null()),
      path=path.add_key("maxmind"),
    ),
  }
}

///|
pub fn IngestPutGeoipDatabaseBody::new(
  name : Json,
  maxmind : Json,
) -> IngestPutGeoipDatabaseBody {
  { name, maxmind }
}

///|
pub type IngestPutGeoipDatabaseResponse = Json

///|
pub(all) struct IngestPutGeoipDatabaseRequest {
  id : String
  query : IngestPutGeoipDatabaseQuery
  body : IngestPutGeoipDatabaseBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestPutGeoipDatabaseRequest::new(
  id : String,
  body : IngestPutGeoipDatabaseBody,
  query? : IngestPutGeoipDatabaseQuery = IngestPutGeoipDatabaseQuery::new(),
) -> IngestPutGeoipDatabaseRequest {
  { id, query, body }
}

///|
pub async fn Client::ingest_put_geoip_database(
  self : Client,
  request : IngestPutGeoipDatabaseRequest,
) -> EsResponse[IngestPutGeoipDatabaseResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/geoip/database/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IngestPutIpLocationDatabaseQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestPutIpLocationDatabaseQuery with fn to_json(
  self : IngestPutIpLocationDatabaseQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestPutIpLocationDatabaseQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "IngestPutIpLocationDatabaseQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn IngestPutIpLocationDatabaseQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> IngestPutIpLocationDatabaseQuery {
  { master_timeout, timeout }
}

///|
pub fn IngestPutIpLocationDatabaseQuery::to_pairs(
  self : IngestPutIpLocationDatabaseQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type IngestPutIpLocationDatabaseBody = Json

///|
pub type IngestPutIpLocationDatabaseResponse = Json

///|
pub(all) struct IngestPutIpLocationDatabaseRequest {
  id : String
  query : IngestPutIpLocationDatabaseQuery
  body : IngestPutIpLocationDatabaseBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestPutIpLocationDatabaseRequest::new(
  id : String,
  body : IngestPutIpLocationDatabaseBody,
  query? : IngestPutIpLocationDatabaseQuery = IngestPutIpLocationDatabaseQuery::new(),
) -> IngestPutIpLocationDatabaseRequest {
  { id, query, body }
}

///|
pub async fn Client::ingest_put_ip_location_database(
  self : Client,
  request : IngestPutIpLocationDatabaseRequest,
) -> EsResponse[IngestPutIpLocationDatabaseResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/ip_location/database/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IngestPutPipelineQuery {
  master_timeout : String?
  timeout : String?
  if_version : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestPutPipelineQuery with fn to_json(
  self : IngestPutPipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.if_version {
    Some(value) => obj["if_version"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestPutPipelineQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestPutPipelineQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    if_version: match obj.get("if_version") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_version")))
    },
  }
}

///|
pub fn IngestPutPipelineQuery::new(
  master_timeout? : String,
  timeout? : String,
  if_version? : Int,
) -> IngestPutPipelineQuery {
  { master_timeout, timeout, if_version }
}

///|
pub fn IngestPutPipelineQuery::to_pairs(
  self : IngestPutPipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.if_version {
    Some(value) => push_query_json(pairs, "if_version", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IngestPutPipelineBody {
  _meta : Json?
  description : String?
  on_failure : Array[Json]?
  processors : Array[Json]?
  version : Json?
  deprecated : Bool?
  field_access_pattern : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestPutPipelineBody with fn to_json(
  self : IngestPutPipelineBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.on_failure {
    Some(value) => obj["on_failure"] = value.to_json()
    None => ()
  }
  match self.processors {
    Some(value) => obj["processors"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.deprecated {
    Some(value) => obj["deprecated"] = value.to_json()
    None => ()
  }
  match self.field_access_pattern {
    Some(value) => obj["field_access_pattern"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestPutPipelineBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestPutPipelineBody: expected object"))
  }
  {
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    on_failure: match obj.get("on_failure") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("on_failure")))
    },
    processors: match obj.get("processors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("processors")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    deprecated: match obj.get("deprecated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("deprecated")))
    },
    field_access_pattern: match obj.get("field_access_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("field_access_pattern")))
    },
  }
}

///|
pub fn IngestPutPipelineBody::new(
  _meta? : Json,
  description? : String,
  on_failure? : Array[Json],
  processors? : Array[Json],
  version? : Json,
  deprecated? : Bool,
  field_access_pattern? : Json,
) -> IngestPutPipelineBody {
  {
    _meta,
    description,
    on_failure,
    processors,
    version,
    deprecated,
    field_access_pattern,
  }
}

///|
pub type IngestPutPipelineResponse = Json

///|
pub(all) struct IngestPutPipelineRequest {
  id : String
  query : IngestPutPipelineQuery
  body : IngestPutPipelineBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestPutPipelineRequest::new(
  id : String,
  body : IngestPutPipelineBody,
  query? : IngestPutPipelineQuery = IngestPutPipelineQuery::new(),
) -> IngestPutPipelineRequest {
  { id, query, body }
}

///|
pub async fn Client::ingest_put_pipeline(
  self : Client,
  request : IngestPutPipelineRequest,
) -> EsResponse[IngestPutPipelineResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ingest/pipeline/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct IngestSimulateQuery {
  verbose : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestSimulateQuery with fn to_json(
  self : IngestSimulateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.verbose {
    Some(value) => obj["verbose"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestSimulateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestSimulateQuery: expected object"))
  }
  {
    verbose: match obj.get("verbose") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("verbose")))
    },
  }
}

///|
pub fn IngestSimulateQuery::new(verbose? : Bool) -> IngestSimulateQuery {
  { verbose, }
}

///|
pub fn IngestSimulateQuery::to_pairs(
  self : IngestSimulateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.verbose {
    Some(value) => push_query_json(pairs, "verbose", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct IngestSimulateBody {
  docs : Array[Json]
  pipeline : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for IngestSimulateBody with fn to_json(
  self : IngestSimulateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  match self.pipeline {
    Some(value) => obj["pipeline"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for IngestSimulateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestSimulateBody: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
    pipeline: match obj.get("pipeline") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pipeline")))
    },
  }
}

///|
pub fn IngestSimulateBody::new(
  docs : Array[Json],
  pipeline? : Json,
) -> IngestSimulateBody {
  { docs, pipeline }
}

///|
pub(all) struct IngestSimulateResponse {
  docs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for IngestSimulateResponse with fn to_json(
  self : IngestSimulateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for IngestSimulateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "IngestSimulateResponse: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
  }
}

///|
pub(all) struct IngestSimulateRequest {
  id : String?
  query : IngestSimulateQuery
  body : IngestSimulateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn IngestSimulateRequest::new(
  body : IngestSimulateBody,
  id? : String,
  query? : IngestSimulateQuery = IngestSimulateQuery::new(),
) -> IngestSimulateRequest {
  { id, query, body }
}

///|
pub async fn Client::ingest_simulate(
  self : Client,
  request : IngestSimulateRequest,
) -> EsResponse[IngestSimulateResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ingest/pipeline/{id}/_simulate", ["id"]),
      PathVariant::new("/_ingest/pipeline/_simulate", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct KnnSearchQuery {
  routing : String?
} derive(Eq, Debug)

///|
pub impl ToJson for KnnSearchQuery with fn to_json(self : KnnSearchQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for KnnSearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "KnnSearchQuery: expected object"))
  }
  {
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
  }
}

///|
pub fn KnnSearchQuery::new(routing? : String) -> KnnSearchQuery {
  { routing, }
}

///|
pub fn KnnSearchQuery::to_pairs(
  self : KnnSearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct KnnSearchBody {
  _source : Json?
  docvalue_fields : Array[Json]?
  stored_fields : Json?
  fields : Json?
  filter : Json?
  knn : Json
} derive(Eq, Debug)

///|
pub impl ToJson for KnnSearchBody with fn to_json(self : KnnSearchBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  obj["knn"] = self.knn.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for KnnSearchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "KnnSearchBody: expected object"))
  }
  {
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    knn: @json.from_json(
      obj.get("knn").unwrap_or(Json::null()),
      path=path.add_key("knn"),
    ),
  }
}

///|
pub fn KnnSearchBody::new(
  knn : Json,
  _source? : Json,
  docvalue_fields? : Array[Json],
  stored_fields? : Json,
  fields? : Json,
  filter? : Json,
) -> KnnSearchBody {
  { _source, docvalue_fields, stored_fields, fields, filter, knn }
}

///|
pub(all) struct KnnSearchResponse {
  took : Int
  timed_out : Bool
  _shards : Json
  hits : Json
  fields : Map[String, Json]?
  max_score : Double?
} derive(Eq, Debug)

///|
pub impl ToJson for KnnSearchResponse with fn to_json(self : KnnSearchResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["took"] = self.took.to_json()
  obj["timed_out"] = self.timed_out.to_json()
  obj["_shards"] = self._shards.to_json()
  obj["hits"] = self.hits.to_json()
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.max_score {
    Some(value) => obj["max_score"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for KnnSearchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "KnnSearchResponse: expected object"))
  }
  {
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    timed_out: @json.from_json(
      obj.get("timed_out").unwrap_or(Json::null()),
      path=path.add_key("timed_out"),
    ),
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    hits: @json.from_json(
      obj.get("hits").unwrap_or(Json::null()),
      path=path.add_key("hits"),
    ),
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    max_score: match obj.get("max_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_score")))
    },
  }
}

///|
pub(all) struct KnnSearchRequest {
  index : String
  query : KnnSearchQuery
  body : KnnSearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn KnnSearchRequest::new(
  index : String,
  body : KnnSearchBody,
  query? : KnnSearchQuery = KnnSearchQuery::new(),
) -> KnnSearchRequest {
  { index, query, body }
}

///|
pub async fn Client::knn_search(
  self : Client,
  request : KnnSearchRequest,
) -> EsResponse[KnnSearchResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_knn_search", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct LicenseDeleteQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for LicenseDeleteQuery with fn to_json(
  self : LicenseDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicenseDeleteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicenseDeleteQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn LicenseDeleteQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> LicenseDeleteQuery {
  { master_timeout, timeout }
}

///|
pub fn LicenseDeleteQuery::to_pairs(
  self : LicenseDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type LicenseDeleteResponse = Json

///|
pub(all) struct LicenseDeleteRequest {
  query : LicenseDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicenseDeleteRequest::new(
  query? : LicenseDeleteQuery = LicenseDeleteQuery::new(),
) -> LicenseDeleteRequest {
  { query, }
}

///|
pub async fn Client::license_delete(
  self : Client,
  request : LicenseDeleteRequest,
) -> EsResponse[LicenseDeleteResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_license", [])], params)
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct LicenseGetQuery {
  accept_enterprise : Bool?
  local_ : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for LicenseGetQuery with fn to_json(self : LicenseGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.accept_enterprise {
    Some(value) => obj["accept_enterprise"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicenseGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicenseGetQuery: expected object"))
  }
  {
    accept_enterprise: match obj.get("accept_enterprise") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("accept_enterprise")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
  }
}

///|
pub fn LicenseGetQuery::new(
  accept_enterprise? : Bool,
  local_? : Bool,
) -> LicenseGetQuery {
  { accept_enterprise, local_ }
}

///|
pub fn LicenseGetQuery::to_pairs(
  self : LicenseGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.accept_enterprise {
    Some(value) => push_query_json(pairs, "accept_enterprise", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct LicenseGetResponse {
  license : Json
} derive(Eq, Debug)

///|
pub impl ToJson for LicenseGetResponse with fn to_json(
  self : LicenseGetResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["license"] = self.license.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for LicenseGetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicenseGetResponse: expected object"))
  }
  {
    license: @json.from_json(
      obj.get("license").unwrap_or(Json::null()),
      path=path.add_key("license"),
    ),
  }
}

///|
pub(all) struct LicenseGetRequest {
  query : LicenseGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicenseGetRequest::new(
  query? : LicenseGetQuery = LicenseGetQuery::new(),
) -> LicenseGetRequest {
  { query, }
}

///|
pub async fn Client::license_get(
  self : Client,
  request : LicenseGetRequest,
) -> EsResponse[LicenseGetResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_license", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct LicenseGetBasicStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for LicenseGetBasicStatusQuery with fn to_json(
  _self : LicenseGetBasicStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for LicenseGetBasicStatusQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "LicenseGetBasicStatusQuery: expected object"))
  }
  LicenseGetBasicStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn LicenseGetBasicStatusQuery::new() -> LicenseGetBasicStatusQuery {
  LicenseGetBasicStatusQuery::{  }
}

///|
pub fn LicenseGetBasicStatusQuery::to_pairs(
  _self : LicenseGetBasicStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct LicenseGetBasicStatusResponse {
  eligible_to_start_basic : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for LicenseGetBasicStatusResponse with fn to_json(
  self : LicenseGetBasicStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["eligible_to_start_basic"] = self.eligible_to_start_basic.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for LicenseGetBasicStatusResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "LicenseGetBasicStatusResponse: expected object"),
    )
  }
  {
    eligible_to_start_basic: @json.from_json(
      obj.get("eligible_to_start_basic").unwrap_or(Json::null()),
      path=path.add_key("eligible_to_start_basic"),
    ),
  }
}

///|
pub(all) struct LicenseGetBasicStatusRequest {
  query : LicenseGetBasicStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicenseGetBasicStatusRequest::new(
  query? : LicenseGetBasicStatusQuery = LicenseGetBasicStatusQuery::new(),
) -> LicenseGetBasicStatusRequest {
  { query, }
}

///|
pub async fn Client::license_get_basic_status(
  self : Client,
  request : LicenseGetBasicStatusRequest,
) -> EsResponse[LicenseGetBasicStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_license/basic_status", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct LicenseGetTrialStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for LicenseGetTrialStatusQuery with fn to_json(
  _self : LicenseGetTrialStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for LicenseGetTrialStatusQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "LicenseGetTrialStatusQuery: expected object"))
  }
  LicenseGetTrialStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn LicenseGetTrialStatusQuery::new() -> LicenseGetTrialStatusQuery {
  LicenseGetTrialStatusQuery::{  }
}

///|
pub fn LicenseGetTrialStatusQuery::to_pairs(
  _self : LicenseGetTrialStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct LicenseGetTrialStatusResponse {
  eligible_to_start_trial : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for LicenseGetTrialStatusResponse with fn to_json(
  self : LicenseGetTrialStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["eligible_to_start_trial"] = self.eligible_to_start_trial.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for LicenseGetTrialStatusResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "LicenseGetTrialStatusResponse: expected object"),
    )
  }
  {
    eligible_to_start_trial: @json.from_json(
      obj.get("eligible_to_start_trial").unwrap_or(Json::null()),
      path=path.add_key("eligible_to_start_trial"),
    ),
  }
}

///|
pub(all) struct LicenseGetTrialStatusRequest {
  query : LicenseGetTrialStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicenseGetTrialStatusRequest::new(
  query? : LicenseGetTrialStatusQuery = LicenseGetTrialStatusQuery::new(),
) -> LicenseGetTrialStatusRequest {
  { query, }
}

///|
pub async fn Client::license_get_trial_status(
  self : Client,
  request : LicenseGetTrialStatusRequest,
) -> EsResponse[LicenseGetTrialStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_license/trial_status", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct LicensePostQuery {
  acknowledge : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostQuery with fn to_json(self : LicensePostQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acknowledge {
    Some(value) => obj["acknowledge"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicensePostQuery: expected object"))
  }
  {
    acknowledge: match obj.get("acknowledge") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("acknowledge")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn LicensePostQuery::new(
  acknowledge? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> LicensePostQuery {
  { acknowledge, master_timeout, timeout }
}

///|
pub fn LicensePostQuery::to_pairs(
  self : LicensePostQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.acknowledge {
    Some(value) => push_query_json(pairs, "acknowledge", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct LicensePostBody {
  license : Json?
  licenses : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostBody with fn to_json(self : LicensePostBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.license {
    Some(value) => obj["license"] = value.to_json()
    None => ()
  }
  match self.licenses {
    Some(value) => obj["licenses"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicensePostBody: expected object"))
  }
  {
    license: match obj.get("license") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("license")))
    },
    licenses: match obj.get("licenses") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("licenses")))
    },
  }
}

///|
pub fn LicensePostBody::new(
  license? : Json,
  licenses? : Array[Json],
) -> LicensePostBody {
  { license, licenses }
}

///|
pub(all) struct LicensePostResponse {
  acknowledge : Json?
  acknowledged : Bool
  license_status : Json
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostResponse with fn to_json(
  self : LicensePostResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acknowledge {
    Some(value) => obj["acknowledge"] = value.to_json()
    None => ()
  }
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["license_status"] = self.license_status.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicensePostResponse: expected object"))
  }
  {
    acknowledge: match obj.get("acknowledge") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("acknowledge")))
    },
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    license_status: @json.from_json(
      obj.get("license_status").unwrap_or(Json::null()),
      path=path.add_key("license_status"),
    ),
  }
}

///|
pub(all) struct LicensePostRequest {
  query : LicensePostQuery
  body : LicensePostBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicensePostRequest::new(
  query? : LicensePostQuery = LicensePostQuery::new(),
  body? : LicensePostBody,
) -> LicensePostRequest {
  { query, body }
}

///|
pub async fn Client::license_post(
  self : Client,
  request : LicensePostRequest,
) -> EsResponse[LicensePostResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_license", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct LicensePostStartBasicQuery {
  acknowledge : Bool?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostStartBasicQuery with fn to_json(
  self : LicensePostStartBasicQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acknowledge {
    Some(value) => obj["acknowledge"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostStartBasicQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicensePostStartBasicQuery: expected object"))
  }
  {
    acknowledge: match obj.get("acknowledge") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("acknowledge")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn LicensePostStartBasicQuery::new(
  acknowledge? : Bool,
  master_timeout? : String,
  timeout? : String,
) -> LicensePostStartBasicQuery {
  { acknowledge, master_timeout, timeout }
}

///|
pub fn LicensePostStartBasicQuery::to_pairs(
  self : LicensePostStartBasicQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.acknowledge {
    Some(value) => push_query_json(pairs, "acknowledge", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct LicensePostStartBasicResponse {
  acknowledged : Bool
  basic_was_started : Bool
  error_message : String?
  type_ : Json?
  acknowledge : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostStartBasicResponse with fn to_json(
  self : LicensePostStartBasicResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["basic_was_started"] = self.basic_was_started.to_json()
  match self.error_message {
    Some(value) => obj["error_message"] = value.to_json()
    None => ()
  }
  match self.type_ {
    Some(value) => obj["type"] = value.to_json()
    None => ()
  }
  match self.acknowledge {
    Some(value) => obj["acknowledge"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostStartBasicResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "LicensePostStartBasicResponse: expected object"),
    )
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    basic_was_started: @json.from_json(
      obj.get("basic_was_started").unwrap_or(Json::null()),
      path=path.add_key("basic_was_started"),
    ),
    error_message: match obj.get("error_message") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("error_message")))
    },
    type_: match obj.get("type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("type")))
    },
    acknowledge: match obj.get("acknowledge") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("acknowledge")))
    },
  }
}

///|
pub(all) struct LicensePostStartBasicRequest {
  query : LicensePostStartBasicQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicensePostStartBasicRequest::new(
  query? : LicensePostStartBasicQuery = LicensePostStartBasicQuery::new(),
) -> LicensePostStartBasicRequest {
  { query, }
}

///|
pub async fn Client::license_post_start_basic(
  self : Client,
  request : LicensePostStartBasicRequest,
) -> EsResponse[LicensePostStartBasicResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_license/start_basic", [])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct LicensePostStartTrialQuery {
  acknowledge : Bool?
  type_ : String?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostStartTrialQuery with fn to_json(
  self : LicensePostStartTrialQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acknowledge {
    Some(value) => obj["acknowledge"] = value.to_json()
    None => ()
  }
  match self.type_ {
    Some(value) => obj["type"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostStartTrialQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "LicensePostStartTrialQuery: expected object"))
  }
  {
    acknowledge: match obj.get("acknowledge") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("acknowledge")))
    },
    type_: match obj.get("type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("type")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn LicensePostStartTrialQuery::new(
  acknowledge? : Bool,
  type_? : String,
  master_timeout? : String,
) -> LicensePostStartTrialQuery {
  { acknowledge, type_, master_timeout }
}

///|
pub fn LicensePostStartTrialQuery::to_pairs(
  self : LicensePostStartTrialQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.acknowledge {
    Some(value) => push_query_json(pairs, "acknowledge", value.to_json())
    None => ()
  }
  match self.type_ {
    Some(value) => push_query_json(pairs, "type", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct LicensePostStartTrialResponse {
  acknowledged : Bool
  error_message : String?
  trial_was_started : Bool
  type_ : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for LicensePostStartTrialResponse with fn to_json(
  self : LicensePostStartTrialResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  match self.error_message {
    Some(value) => obj["error_message"] = value.to_json()
    None => ()
  }
  obj["trial_was_started"] = self.trial_was_started.to_json()
  match self.type_ {
    Some(value) => obj["type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for LicensePostStartTrialResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "LicensePostStartTrialResponse: expected object"),
    )
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    error_message: match obj.get("error_message") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("error_message")))
    },
    trial_was_started: @json.from_json(
      obj.get("trial_was_started").unwrap_or(Json::null()),
      path=path.add_key("trial_was_started"),
    ),
    type_: match obj.get("type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("type")))
    },
  }
}

///|
pub(all) struct LicensePostStartTrialRequest {
  query : LicensePostStartTrialQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LicensePostStartTrialRequest::new(
  query? : LicensePostStartTrialQuery = LicensePostStartTrialQuery::new(),
) -> LicensePostStartTrialRequest {
  { query, }
}

///|
pub async fn Client::license_post_start_trial(
  self : Client,
  request : LicensePostStartTrialRequest,
) -> EsResponse[LicensePostStartTrialResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_license/start_trial", [])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct ListReindexQuery {
  detailed : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ListReindexQuery with fn to_json(self : ListReindexQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.detailed {
    Some(value) => obj["detailed"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ListReindexQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ListReindexQuery: expected object"))
  }
  {
    detailed: match obj.get("detailed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detailed")))
    },
  }
}

///|
pub fn ListReindexQuery::new(detailed? : Bool) -> ListReindexQuery {
  { detailed, }
}

///|
pub fn ListReindexQuery::to_pairs(
  self : ListReindexQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.detailed {
    Some(value) => push_query_json(pairs, "detailed", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ListReindexResponse {
  reindex : Array[Json]
  task_failures : Array[Json]?
  node_failures : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for ListReindexResponse with fn to_json(
  self : ListReindexResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["reindex"] = self.reindex.to_json()
  match self.task_failures {
    Some(value) => obj["task_failures"] = value.to_json()
    None => ()
  }
  match self.node_failures {
    Some(value) => obj["node_failures"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ListReindexResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ListReindexResponse: expected object"))
  }
  {
    reindex: @json.from_json(
      obj.get("reindex").unwrap_or(Json::null()),
      path=path.add_key("reindex"),
    ),
    task_failures: match obj.get("task_failures") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_failures")))
    },
    node_failures: match obj.get("node_failures") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("node_failures")))
    },
  }
}

///|
pub(all) struct ListReindexRequest {
  query : ListReindexQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ListReindexRequest::new(
  query? : ListReindexQuery = ListReindexQuery::new(),
) -> ListReindexRequest {
  { query, }
}

///|
pub async fn Client::list_reindex(
  self : Client,
  request : ListReindexRequest,
) -> EsResponse[ListReindexResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_reindex", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct LogstashDeletePipelineQuery {} derive(Eq, Debug)

///|
pub impl ToJson for LogstashDeletePipelineQuery with fn to_json(
  _self : LogstashDeletePipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for LogstashDeletePipelineQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "LogstashDeletePipelineQuery: expected object"),
    )
  }
  LogstashDeletePipelineQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn LogstashDeletePipelineQuery::new() -> LogstashDeletePipelineQuery {
  LogstashDeletePipelineQuery::{  }
}

///|
pub fn LogstashDeletePipelineQuery::to_pairs(
  _self : LogstashDeletePipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type LogstashDeletePipelineResponse = Json

///|
pub(all) struct LogstashDeletePipelineRequest {
  id : String
  query : LogstashDeletePipelineQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LogstashDeletePipelineRequest::new(
  id : String,
  query? : LogstashDeletePipelineQuery = LogstashDeletePipelineQuery::new(),
) -> LogstashDeletePipelineRequest {
  { id, query }
}

///|
pub async fn Client::logstash_delete_pipeline(
  self : Client,
  request : LogstashDeletePipelineRequest,
) -> EsResponse[LogstashDeletePipelineResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_logstash/pipeline/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct LogstashGetPipelineQuery {} derive(Eq, Debug)

///|
pub impl ToJson for LogstashGetPipelineQuery with fn to_json(
  _self : LogstashGetPipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for LogstashGetPipelineQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "LogstashGetPipelineQuery: expected object"))
  }
  LogstashGetPipelineQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn LogstashGetPipelineQuery::new() -> LogstashGetPipelineQuery {
  LogstashGetPipelineQuery::{  }
}

///|
pub fn LogstashGetPipelineQuery::to_pairs(
  _self : LogstashGetPipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type LogstashGetPipelineResponse = Json

///|
pub(all) struct LogstashGetPipelineRequest {
  id : String?
  query : LogstashGetPipelineQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LogstashGetPipelineRequest::new(
  id? : String,
  query? : LogstashGetPipelineQuery = LogstashGetPipelineQuery::new(),
) -> LogstashGetPipelineRequest {
  { id, query }
}

///|
pub async fn Client::logstash_get_pipeline(
  self : Client,
  request : LogstashGetPipelineRequest,
) -> EsResponse[LogstashGetPipelineResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_logstash/pipeline/{id}", ["id"]),
      PathVariant::new("/_logstash/pipeline", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct LogstashPutPipelineQuery {} derive(Eq, Debug)

///|
pub impl ToJson for LogstashPutPipelineQuery with fn to_json(
  _self : LogstashPutPipelineQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for LogstashPutPipelineQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "LogstashPutPipelineQuery: expected object"))
  }
  LogstashPutPipelineQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn LogstashPutPipelineQuery::new() -> LogstashPutPipelineQuery {
  LogstashPutPipelineQuery::{  }
}

///|
pub fn LogstashPutPipelineQuery::to_pairs(
  _self : LogstashPutPipelineQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type LogstashPutPipelineBody = Json

///|
pub type LogstashPutPipelineResponse = Json

///|
pub(all) struct LogstashPutPipelineRequest {
  id : String
  query : LogstashPutPipelineQuery
  body : LogstashPutPipelineBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn LogstashPutPipelineRequest::new(
  id : String,
  body : LogstashPutPipelineBody,
  query? : LogstashPutPipelineQuery = LogstashPutPipelineQuery::new(),
) -> LogstashPutPipelineRequest {
  { id, query, body }
}

///|
pub async fn Client::logstash_put_pipeline(
  self : Client,
  request : LogstashPutPipelineRequest,
) -> EsResponse[LogstashPutPipelineResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_logstash/pipeline/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MgetQuery {
  force_synthetic_source : Bool?
  preference : String?
  realtime : Bool?
  refresh : Bool?
  routing : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
  stored_fields : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MgetQuery with fn to_json(self : MgetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force_synthetic_source {
    Some(value) => obj["force_synthetic_source"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MgetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MgetQuery: expected object"))
  }
  {
    force_synthetic_source: match obj.get("force_synthetic_source") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("force_synthetic_source")),
        )
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
  }
}

///|
pub fn MgetQuery::new(
  force_synthetic_source? : Bool,
  preference? : String,
  realtime? : Bool,
  refresh? : Bool,
  routing? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
  stored_fields? : String,
) -> MgetQuery {
  {
    force_synthetic_source,
    preference,
    realtime,
    refresh,
    routing,
    _source,
    _source_excludes,
    _source_includes,
    stored_fields,
  }
}

///|
pub fn MgetQuery::to_pairs(self : MgetQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force_synthetic_source {
    Some(value) =>
      push_query_json(pairs, "force_synthetic_source", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MgetBody {
  docs : Array[Json]?
  ids : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MgetBody with fn to_json(self : MgetBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.docs {
    Some(value) => obj["docs"] = value.to_json()
    None => ()
  }
  match self.ids {
    Some(value) => obj["ids"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MgetBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MgetBody: expected object"))
  }
  {
    docs: match obj.get("docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("docs")))
    },
    ids: match obj.get("ids") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ids")))
    },
  }
}

///|
pub fn MgetBody::new(docs? : Array[Json], ids? : Json) -> MgetBody {
  { docs, ids }
}

///|
pub(all) struct MgetResponse {
  docs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MgetResponse with fn to_json(self : MgetResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MgetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MgetResponse: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
  }
}

///|
pub(all) struct MgetRequest {
  index : String?
  query : MgetQuery
  body : MgetBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MgetRequest::new(
  body : MgetBody,
  index? : String,
  query? : MgetQuery = MgetQuery::new(),
) -> MgetRequest {
  { index, query, body }
}

///|
pub async fn Client::mget(
  self : Client,
  request : MgetRequest,
) -> EsResponse[MgetResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_mget", ["index"]),
      PathVariant::new("/_mget", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MigrationDeprecationsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MigrationDeprecationsQuery with fn to_json(
  _self : MigrationDeprecationsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MigrationDeprecationsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MigrationDeprecationsQuery: expected object"))
  }
  MigrationDeprecationsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MigrationDeprecationsQuery::new() -> MigrationDeprecationsQuery {
  MigrationDeprecationsQuery::{  }
}

///|
pub fn MigrationDeprecationsQuery::to_pairs(
  _self : MigrationDeprecationsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MigrationDeprecationsResponse {
  cluster_settings : Array[Json]
  index_settings : Map[String, Json]
  data_streams : Map[String, Json]
  node_settings : Array[Json]
  ml_settings : Array[Json]
  templates : Map[String, Json]
  ilm_policies : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MigrationDeprecationsResponse with fn to_json(
  self : MigrationDeprecationsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cluster_settings"] = self.cluster_settings.to_json()
  obj["index_settings"] = self.index_settings.to_json()
  obj["data_streams"] = self.data_streams.to_json()
  obj["node_settings"] = self.node_settings.to_json()
  obj["ml_settings"] = self.ml_settings.to_json()
  obj["templates"] = self.templates.to_json()
  obj["ilm_policies"] = self.ilm_policies.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MigrationDeprecationsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MigrationDeprecationsResponse: expected object"),
    )
  }
  {
    cluster_settings: @json.from_json(
      obj.get("cluster_settings").unwrap_or(Json::null()),
      path=path.add_key("cluster_settings"),
    ),
    index_settings: @json.from_json(
      obj.get("index_settings").unwrap_or(Json::null()),
      path=path.add_key("index_settings"),
    ),
    data_streams: @json.from_json(
      obj.get("data_streams").unwrap_or(Json::null()),
      path=path.add_key("data_streams"),
    ),
    node_settings: @json.from_json(
      obj.get("node_settings").unwrap_or(Json::null()),
      path=path.add_key("node_settings"),
    ),
    ml_settings: @json.from_json(
      obj.get("ml_settings").unwrap_or(Json::null()),
      path=path.add_key("ml_settings"),
    ),
    templates: @json.from_json(
      obj.get("templates").unwrap_or(Json::null()),
      path=path.add_key("templates"),
    ),
    ilm_policies: @json.from_json(
      obj.get("ilm_policies").unwrap_or(Json::null()),
      path=path.add_key("ilm_policies"),
    ),
  }
}

///|
pub(all) struct MigrationDeprecationsRequest {
  index : String?
  query : MigrationDeprecationsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MigrationDeprecationsRequest::new(
  index? : String,
  query? : MigrationDeprecationsQuery = MigrationDeprecationsQuery::new(),
) -> MigrationDeprecationsRequest {
  { index, query }
}

///|
pub async fn Client::migration_deprecations(
  self : Client,
  request : MigrationDeprecationsRequest,
) -> EsResponse[MigrationDeprecationsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_migration/deprecations", ["index"]),
      PathVariant::new("/_migration/deprecations", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MigrationGetFeatureUpgradeStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MigrationGetFeatureUpgradeStatusQuery with fn to_json(
  _self : MigrationGetFeatureUpgradeStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MigrationGetFeatureUpgradeStatusQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MigrationGetFeatureUpgradeStatusQuery: expected object"),
    )
  }
  MigrationGetFeatureUpgradeStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MigrationGetFeatureUpgradeStatusQuery::new() -> MigrationGetFeatureUpgradeStatusQuery {
  MigrationGetFeatureUpgradeStatusQuery::{  }
}

///|
pub fn MigrationGetFeatureUpgradeStatusQuery::to_pairs(
  _self : MigrationGetFeatureUpgradeStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MigrationGetFeatureUpgradeStatusResponse {
  features : Array[Json]
  migration_status : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MigrationGetFeatureUpgradeStatusResponse with fn to_json(
  self : MigrationGetFeatureUpgradeStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["features"] = self.features.to_json()
  obj["migration_status"] = self.migration_status.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MigrationGetFeatureUpgradeStatusResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MigrationGetFeatureUpgradeStatusResponse: expected object"),
    )
  }
  {
    features: @json.from_json(
      obj.get("features").unwrap_or(Json::null()),
      path=path.add_key("features"),
    ),
    migration_status: @json.from_json(
      obj.get("migration_status").unwrap_or(Json::null()),
      path=path.add_key("migration_status"),
    ),
  }
}

///|
pub(all) struct MigrationGetFeatureUpgradeStatusRequest {
  query : MigrationGetFeatureUpgradeStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MigrationGetFeatureUpgradeStatusRequest::new(
  query? : MigrationGetFeatureUpgradeStatusQuery = MigrationGetFeatureUpgradeStatusQuery::new(),
) -> MigrationGetFeatureUpgradeStatusRequest {
  { query, }
}

///|
pub async fn Client::migration_get_feature_upgrade_status(
  self : Client,
  request : MigrationGetFeatureUpgradeStatusRequest,
) -> EsResponse[MigrationGetFeatureUpgradeStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_migration/system_features", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MigrationPostFeatureUpgradeQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MigrationPostFeatureUpgradeQuery with fn to_json(
  _self : MigrationPostFeatureUpgradeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MigrationPostFeatureUpgradeQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MigrationPostFeatureUpgradeQuery: expected object"),
    )
  }
  MigrationPostFeatureUpgradeQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MigrationPostFeatureUpgradeQuery::new() -> MigrationPostFeatureUpgradeQuery {
  MigrationPostFeatureUpgradeQuery::{  }
}

///|
pub fn MigrationPostFeatureUpgradeQuery::to_pairs(
  _self : MigrationPostFeatureUpgradeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MigrationPostFeatureUpgradeResponse {
  accepted : Bool
  features : Array[Json]?
  reason : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MigrationPostFeatureUpgradeResponse with fn to_json(
  self : MigrationPostFeatureUpgradeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["accepted"] = self.accepted.to_json()
  match self.features {
    Some(value) => obj["features"] = value.to_json()
    None => ()
  }
  match self.reason {
    Some(value) => obj["reason"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MigrationPostFeatureUpgradeResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MigrationPostFeatureUpgradeResponse: expected object"),
    )
  }
  {
    accepted: @json.from_json(
      obj.get("accepted").unwrap_or(Json::null()),
      path=path.add_key("accepted"),
    ),
    features: match obj.get("features") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("features")))
    },
    reason: match obj.get("reason") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("reason")))
    },
  }
}

///|
pub(all) struct MigrationPostFeatureUpgradeRequest {
  query : MigrationPostFeatureUpgradeQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MigrationPostFeatureUpgradeRequest::new(
  query? : MigrationPostFeatureUpgradeQuery = MigrationPostFeatureUpgradeQuery::new(),
) -> MigrationPostFeatureUpgradeRequest {
  { query, }
}

///|
pub async fn Client::migration_post_feature_upgrade(
  self : Client,
  request : MigrationPostFeatureUpgradeRequest,
) -> EsResponse[MigrationPostFeatureUpgradeResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_migration/system_features", [])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct MlClearTrainedModelDeploymentCacheQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlClearTrainedModelDeploymentCacheQuery with fn to_json(
  _self : MlClearTrainedModelDeploymentCacheQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlClearTrainedModelDeploymentCacheQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlClearTrainedModelDeploymentCacheQuery: expected object"),
    )
  }
  MlClearTrainedModelDeploymentCacheQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlClearTrainedModelDeploymentCacheQuery::new() -> MlClearTrainedModelDeploymentCacheQuery {
  MlClearTrainedModelDeploymentCacheQuery::{  }
}

///|
pub fn MlClearTrainedModelDeploymentCacheQuery::to_pairs(
  _self : MlClearTrainedModelDeploymentCacheQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlClearTrainedModelDeploymentCacheBody = Json

///|
pub(all) struct MlClearTrainedModelDeploymentCacheResponse {
  cleared : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlClearTrainedModelDeploymentCacheResponse with fn to_json(
  self : MlClearTrainedModelDeploymentCacheResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cleared"] = self.cleared.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlClearTrainedModelDeploymentCacheResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlClearTrainedModelDeploymentCacheResponse: expected object"),
    )
  }
  {
    cleared: @json.from_json(
      obj.get("cleared").unwrap_or(Json::null()),
      path=path.add_key("cleared"),
    ),
  }
}

///|
pub(all) struct MlClearTrainedModelDeploymentCacheRequest {
  model_id : String
  query : MlClearTrainedModelDeploymentCacheQuery
  body : MlClearTrainedModelDeploymentCacheBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlClearTrainedModelDeploymentCacheRequest::new(
  model_id : String,
  query? : MlClearTrainedModelDeploymentCacheQuery = MlClearTrainedModelDeploymentCacheQuery::new(),
  body? : MlClearTrainedModelDeploymentCacheBody,
) -> MlClearTrainedModelDeploymentCacheRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_clear_trained_model_deployment_cache(
  self : Client,
  request : MlClearTrainedModelDeploymentCacheRequest,
) -> EsResponse[MlClearTrainedModelDeploymentCacheResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/trained_models/{model_id}/deployment/cache/_clear",
        ["model_id"],
      ),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlCloseJobQuery {
  allow_no_match : Bool?
  force : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlCloseJobQuery with fn to_json(self : MlCloseJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlCloseJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlCloseJobQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlCloseJobQuery::new(
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : String,
) -> MlCloseJobQuery {
  { allow_no_match, force, timeout }
}

///|
pub fn MlCloseJobQuery::to_pairs(
  self : MlCloseJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlCloseJobBody {
  allow_no_match : Bool?
  force : Bool?
  timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlCloseJobBody with fn to_json(self : MlCloseJobBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlCloseJobBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlCloseJobBody: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlCloseJobBody::new(
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : Json,
) -> MlCloseJobBody {
  { allow_no_match, force, timeout }
}

///|
pub(all) struct MlCloseJobResponse {
  closed : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlCloseJobResponse with fn to_json(
  self : MlCloseJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["closed"] = self.closed.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlCloseJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlCloseJobResponse: expected object"))
  }
  {
    closed: @json.from_json(
      obj.get("closed").unwrap_or(Json::null()),
      path=path.add_key("closed"),
    ),
  }
}

///|
pub(all) struct MlCloseJobRequest {
  job_id : String
  query : MlCloseJobQuery
  body : MlCloseJobBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlCloseJobRequest::new(
  job_id : String,
  query? : MlCloseJobQuery = MlCloseJobQuery::new(),
  body? : MlCloseJobBody,
) -> MlCloseJobRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_close_job(
  self : Client,
  request : MlCloseJobRequest,
) -> EsResponse[MlCloseJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_close", ["job_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlDeleteCalendarQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteCalendarQuery with fn to_json(
  _self : MlDeleteCalendarQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlDeleteCalendarQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlDeleteCalendarQuery: expected object"))
  }
  MlDeleteCalendarQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlDeleteCalendarQuery::new() -> MlDeleteCalendarQuery {
  MlDeleteCalendarQuery::{  }
}

///|
pub fn MlDeleteCalendarQuery::to_pairs(
  _self : MlDeleteCalendarQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlDeleteCalendarResponse = Json

///|
pub(all) struct MlDeleteCalendarRequest {
  calendar_id : String
  query : MlDeleteCalendarQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteCalendarRequest::new(
  calendar_id : String,
  query? : MlDeleteCalendarQuery = MlDeleteCalendarQuery::new(),
) -> MlDeleteCalendarRequest {
  { calendar_id, query }
}

///|
pub async fn Client::ml_delete_calendar(
  self : Client,
  request : MlDeleteCalendarRequest,
) -> EsResponse[MlDeleteCalendarResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/calendars/{calendar_id}", ["calendar_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteCalendarEventQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteCalendarEventQuery with fn to_json(
  _self : MlDeleteCalendarEventQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlDeleteCalendarEventQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlDeleteCalendarEventQuery: expected object"))
  }
  MlDeleteCalendarEventQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlDeleteCalendarEventQuery::new() -> MlDeleteCalendarEventQuery {
  MlDeleteCalendarEventQuery::{  }
}

///|
pub fn MlDeleteCalendarEventQuery::to_pairs(
  _self : MlDeleteCalendarEventQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlDeleteCalendarEventResponse = Json

///|
pub(all) struct MlDeleteCalendarEventRequest {
  calendar_id : String
  event_id : String
  query : MlDeleteCalendarEventQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteCalendarEventRequest::new(
  calendar_id : String,
  event_id : String,
  query? : MlDeleteCalendarEventQuery = MlDeleteCalendarEventQuery::new(),
) -> MlDeleteCalendarEventRequest {
  { calendar_id, event_id, query }
}

///|
pub async fn Client::ml_delete_calendar_event(
  self : Client,
  request : MlDeleteCalendarEventRequest,
) -> EsResponse[MlDeleteCalendarEventResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  params["event_id"] = request.event_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/calendars/{calendar_id}/events/{event_id}", [
        "calendar_id", "event_id",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteCalendarJobQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteCalendarJobQuery with fn to_json(
  _self : MlDeleteCalendarJobQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlDeleteCalendarJobQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlDeleteCalendarJobQuery: expected object"))
  }
  MlDeleteCalendarJobQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlDeleteCalendarJobQuery::new() -> MlDeleteCalendarJobQuery {
  MlDeleteCalendarJobQuery::{  }
}

///|
pub fn MlDeleteCalendarJobQuery::to_pairs(
  _self : MlDeleteCalendarJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlDeleteCalendarJobResponse {
  calendar_id : Json
  description : String?
  job_ids : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteCalendarJobResponse with fn to_json(
  self : MlDeleteCalendarJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["calendar_id"] = self.calendar_id.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["job_ids"] = self.job_ids.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteCalendarJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlDeleteCalendarJobResponse: expected object"),
    )
  }
  {
    calendar_id: @json.from_json(
      obj.get("calendar_id").unwrap_or(Json::null()),
      path=path.add_key("calendar_id"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    job_ids: @json.from_json(
      obj.get("job_ids").unwrap_or(Json::null()),
      path=path.add_key("job_ids"),
    ),
  }
}

///|
pub(all) struct MlDeleteCalendarJobRequest {
  calendar_id : String
  job_id : String
  query : MlDeleteCalendarJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteCalendarJobRequest::new(
  calendar_id : String,
  job_id : String,
  query? : MlDeleteCalendarJobQuery = MlDeleteCalendarJobQuery::new(),
) -> MlDeleteCalendarJobRequest {
  { calendar_id, job_id, query }
}

///|
pub async fn Client::ml_delete_calendar_job(
  self : Client,
  request : MlDeleteCalendarJobRequest,
) -> EsResponse[MlDeleteCalendarJobResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/calendars/{calendar_id}/jobs/{job_id}", [
        "calendar_id", "job_id",
      ]),
    ],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteDataFrameAnalyticsQuery {
  force : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteDataFrameAnalyticsQuery with fn to_json(
  self : MlDeleteDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteDataFrameAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlDeleteDataFrameAnalyticsQuery: expected object"),
    )
  }
  {
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlDeleteDataFrameAnalyticsQuery::new(
  force? : Bool,
  timeout? : String,
) -> MlDeleteDataFrameAnalyticsQuery {
  { force, timeout }
}

///|
pub fn MlDeleteDataFrameAnalyticsQuery::to_pairs(
  self : MlDeleteDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlDeleteDataFrameAnalyticsResponse = Json

///|
pub(all) struct MlDeleteDataFrameAnalyticsRequest {
  id : String
  query : MlDeleteDataFrameAnalyticsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteDataFrameAnalyticsRequest::new(
  id : String,
  query? : MlDeleteDataFrameAnalyticsQuery = MlDeleteDataFrameAnalyticsQuery::new(),
) -> MlDeleteDataFrameAnalyticsRequest {
  { id, query }
}

///|
pub async fn Client::ml_delete_data_frame_analytics(
  self : Client,
  request : MlDeleteDataFrameAnalyticsRequest,
) -> EsResponse[MlDeleteDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/data_frame/analytics/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteDatafeedQuery {
  force : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteDatafeedQuery with fn to_json(
  self : MlDeleteDatafeedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteDatafeedQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlDeleteDatafeedQuery: expected object"))
  }
  {
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
  }
}

///|
pub fn MlDeleteDatafeedQuery::new(force? : Bool) -> MlDeleteDatafeedQuery {
  { force, }
}

///|
pub fn MlDeleteDatafeedQuery::to_pairs(
  self : MlDeleteDatafeedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlDeleteDatafeedResponse = Json

///|
pub(all) struct MlDeleteDatafeedRequest {
  datafeed_id : String
  query : MlDeleteDatafeedQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteDatafeedRequest::new(
  datafeed_id : String,
  query? : MlDeleteDatafeedQuery = MlDeleteDatafeedQuery::new(),
) -> MlDeleteDatafeedRequest {
  { datafeed_id, query }
}

///|
pub async fn Client::ml_delete_datafeed(
  self : Client,
  request : MlDeleteDatafeedRequest,
) -> EsResponse[MlDeleteDatafeedResponse] {
  let params : Map[String, String] = Map([])
  params["datafeed_id"] = request.datafeed_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/datafeeds/{datafeed_id}", ["datafeed_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteExpiredDataQuery {
  requests_per_second : Double?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteExpiredDataQuery with fn to_json(
  self : MlDeleteExpiredDataQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteExpiredDataQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlDeleteExpiredDataQuery: expected object"))
  }
  {
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlDeleteExpiredDataQuery::new(
  requests_per_second? : Double,
  timeout? : String,
) -> MlDeleteExpiredDataQuery {
  { requests_per_second, timeout }
}

///|
pub fn MlDeleteExpiredDataQuery::to_pairs(
  self : MlDeleteExpiredDataQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.requests_per_second {
    Some(value) =>
      push_query_json(pairs, "requests_per_second", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlDeleteExpiredDataBody {
  requests_per_second : Double?
  timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteExpiredDataBody with fn to_json(
  self : MlDeleteExpiredDataBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteExpiredDataBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlDeleteExpiredDataBody: expected object"))
  }
  {
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlDeleteExpiredDataBody::new(
  requests_per_second? : Double,
  timeout? : Json,
) -> MlDeleteExpiredDataBody {
  { requests_per_second, timeout }
}

///|
pub(all) struct MlDeleteExpiredDataResponse {
  deleted : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteExpiredDataResponse with fn to_json(
  self : MlDeleteExpiredDataResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["deleted"] = self.deleted.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteExpiredDataResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlDeleteExpiredDataResponse: expected object"),
    )
  }
  {
    deleted: @json.from_json(
      obj.get("deleted").unwrap_or(Json::null()),
      path=path.add_key("deleted"),
    ),
  }
}

///|
pub(all) struct MlDeleteExpiredDataRequest {
  job_id : String?
  query : MlDeleteExpiredDataQuery
  body : MlDeleteExpiredDataBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteExpiredDataRequest::new(
  job_id? : String,
  query? : MlDeleteExpiredDataQuery = MlDeleteExpiredDataQuery::new(),
  body? : MlDeleteExpiredDataBody,
) -> MlDeleteExpiredDataRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_delete_expired_data(
  self : Client,
  request : MlDeleteExpiredDataRequest,
) -> EsResponse[MlDeleteExpiredDataResponse] {
  let params : Map[String, String] = Map([])
  match request.job_id {
    Some(value) => params["job_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/_delete_expired_data/{job_id}", ["job_id"]),
      PathVariant::new("/_ml/_delete_expired_data", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct MlDeleteFilterQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteFilterQuery with fn to_json(
  _self : MlDeleteFilterQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlDeleteFilterQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlDeleteFilterQuery: expected object"))
  }
  MlDeleteFilterQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlDeleteFilterQuery::new() -> MlDeleteFilterQuery {
  MlDeleteFilterQuery::{  }
}

///|
pub fn MlDeleteFilterQuery::to_pairs(
  _self : MlDeleteFilterQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlDeleteFilterResponse = Json

///|
pub(all) struct MlDeleteFilterRequest {
  filter_id : String
  query : MlDeleteFilterQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteFilterRequest::new(
  filter_id : String,
  query? : MlDeleteFilterQuery = MlDeleteFilterQuery::new(),
) -> MlDeleteFilterRequest {
  { filter_id, query }
}

///|
pub async fn Client::ml_delete_filter(
  self : Client,
  request : MlDeleteFilterRequest,
) -> EsResponse[MlDeleteFilterResponse] {
  let params : Map[String, String] = Map([])
  params["filter_id"] = request.filter_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/filters/{filter_id}", ["filter_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteForecastQuery {
  allow_no_forecasts : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteForecastQuery with fn to_json(
  self : MlDeleteForecastQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_forecasts {
    Some(value) => obj["allow_no_forecasts"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteForecastQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlDeleteForecastQuery: expected object"))
  }
  {
    allow_no_forecasts: match obj.get("allow_no_forecasts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_forecasts")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlDeleteForecastQuery::new(
  allow_no_forecasts? : Bool,
  timeout? : String,
) -> MlDeleteForecastQuery {
  { allow_no_forecasts, timeout }
}

///|
pub fn MlDeleteForecastQuery::to_pairs(
  self : MlDeleteForecastQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_forecasts {
    Some(value) => push_query_json(pairs, "allow_no_forecasts", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlDeleteForecastResponse = Json

///|
pub(all) struct MlDeleteForecastRequest {
  job_id : String
  forecast_id : String?
  query : MlDeleteForecastQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteForecastRequest::new(
  job_id : String,
  forecast_id? : String,
  query? : MlDeleteForecastQuery = MlDeleteForecastQuery::new(),
) -> MlDeleteForecastRequest {
  { job_id, forecast_id, query }
}

///|
pub async fn Client::ml_delete_forecast(
  self : Client,
  request : MlDeleteForecastRequest,
) -> EsResponse[MlDeleteForecastResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  match request.forecast_id {
    Some(value) => params["forecast_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}",
        ["job_id", "forecast_id"],
      ),
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/_forecast", ["job_id"]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteJobQuery {
  force : Bool?
  delete_user_annotations : Bool?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteJobQuery with fn to_json(self : MlDeleteJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.delete_user_annotations {
    Some(value) => obj["delete_user_annotations"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlDeleteJobQuery: expected object"))
  }
  {
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    delete_user_annotations: match obj.get("delete_user_annotations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("delete_user_annotations")),
        )
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn MlDeleteJobQuery::new(
  force? : Bool,
  delete_user_annotations? : Bool,
  wait_for_completion? : Bool,
) -> MlDeleteJobQuery {
  { force, delete_user_annotations, wait_for_completion }
}

///|
pub fn MlDeleteJobQuery::to_pairs(
  self : MlDeleteJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.delete_user_annotations {
    Some(value) =>
      push_query_json(pairs, "delete_user_annotations", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlDeleteJobResponse = Json

///|
pub(all) struct MlDeleteJobRequest {
  job_id : String
  query : MlDeleteJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteJobRequest::new(
  job_id : String,
  query? : MlDeleteJobQuery = MlDeleteJobQuery::new(),
) -> MlDeleteJobRequest {
  { job_id, query }
}

///|
pub async fn Client::ml_delete_job(
  self : Client,
  request : MlDeleteJobRequest,
) -> EsResponse[MlDeleteJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}", ["job_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteModelSnapshotQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteModelSnapshotQuery with fn to_json(
  _self : MlDeleteModelSnapshotQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlDeleteModelSnapshotQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlDeleteModelSnapshotQuery: expected object"))
  }
  MlDeleteModelSnapshotQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlDeleteModelSnapshotQuery::new() -> MlDeleteModelSnapshotQuery {
  MlDeleteModelSnapshotQuery::{  }
}

///|
pub fn MlDeleteModelSnapshotQuery::to_pairs(
  _self : MlDeleteModelSnapshotQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlDeleteModelSnapshotResponse = Json

///|
pub(all) struct MlDeleteModelSnapshotRequest {
  job_id : String
  snapshot_id : String
  query : MlDeleteModelSnapshotQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteModelSnapshotRequest::new(
  job_id : String,
  snapshot_id : String,
  query? : MlDeleteModelSnapshotQuery = MlDeleteModelSnapshotQuery::new(),
) -> MlDeleteModelSnapshotRequest {
  { job_id, snapshot_id, query }
}

///|
pub async fn Client::ml_delete_model_snapshot(
  self : Client,
  request : MlDeleteModelSnapshotRequest,
) -> EsResponse[MlDeleteModelSnapshotResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  params["snapshot_id"] = request.snapshot_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}",
        ["job_id", "snapshot_id"],
      ),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteTrainedModelQuery {
  force : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteTrainedModelQuery with fn to_json(
  self : MlDeleteTrainedModelQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlDeleteTrainedModelQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlDeleteTrainedModelQuery: expected object"))
  }
  {
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlDeleteTrainedModelQuery::new(
  force? : Bool,
  timeout? : String,
) -> MlDeleteTrainedModelQuery {
  { force, timeout }
}

///|
pub fn MlDeleteTrainedModelQuery::to_pairs(
  self : MlDeleteTrainedModelQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlDeleteTrainedModelResponse = Json

///|
pub(all) struct MlDeleteTrainedModelRequest {
  model_id : String
  query : MlDeleteTrainedModelQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteTrainedModelRequest::new(
  model_id : String,
  query? : MlDeleteTrainedModelQuery = MlDeleteTrainedModelQuery::new(),
) -> MlDeleteTrainedModelRequest {
  { model_id, query }
}

///|
pub async fn Client::ml_delete_trained_model(
  self : Client,
  request : MlDeleteTrainedModelRequest,
) -> EsResponse[MlDeleteTrainedModelResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/trained_models/{model_id}", ["model_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct MlDeleteTrainedModelAliasQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlDeleteTrainedModelAliasQuery with fn to_json(
  _self : MlDeleteTrainedModelAliasQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlDeleteTrainedModelAliasQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlDeleteTrainedModelAliasQuery: expected object"),
    )
  }
  MlDeleteTrainedModelAliasQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlDeleteTrainedModelAliasQuery::new() -> MlDeleteTrainedModelAliasQuery {
  MlDeleteTrainedModelAliasQuery::{  }
}

///|
pub fn MlDeleteTrainedModelAliasQuery::to_pairs(
  _self : MlDeleteTrainedModelAliasQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlDeleteTrainedModelAliasBody = Json

///|
pub type MlDeleteTrainedModelAliasResponse = Json

///|
pub(all) struct MlDeleteTrainedModelAliasRequest {
  model_id : String
  model_alias : String
  query : MlDeleteTrainedModelAliasQuery
  body : MlDeleteTrainedModelAliasBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlDeleteTrainedModelAliasRequest::new(
  model_id : String,
  model_alias : String,
  query? : MlDeleteTrainedModelAliasQuery = MlDeleteTrainedModelAliasQuery::new(),
  body? : MlDeleteTrainedModelAliasBody,
) -> MlDeleteTrainedModelAliasRequest {
  { model_id, model_alias, query, body }
}

///|
pub async fn Client::ml_delete_trained_model_alias(
  self : Client,
  request : MlDeleteTrainedModelAliasRequest,
) -> EsResponse[MlDeleteTrainedModelAliasResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  params["model_alias"] = request.model_alias
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/trained_models/{model_id}/model_aliases/{model_alias}",
        ["model_id", "model_alias"],
      ),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct MlEstimateModelMemoryQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlEstimateModelMemoryQuery with fn to_json(
  _self : MlEstimateModelMemoryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlEstimateModelMemoryQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlEstimateModelMemoryQuery: expected object"))
  }
  MlEstimateModelMemoryQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlEstimateModelMemoryQuery::new() -> MlEstimateModelMemoryQuery {
  MlEstimateModelMemoryQuery::{  }
}

///|
pub fn MlEstimateModelMemoryQuery::to_pairs(
  _self : MlEstimateModelMemoryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlEstimateModelMemoryBody {
  analysis_config : Json?
  max_bucket_cardinality : Map[String, Json]?
  overall_cardinality : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for MlEstimateModelMemoryBody with fn to_json(
  self : MlEstimateModelMemoryBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.analysis_config {
    Some(value) => obj["analysis_config"] = value.to_json()
    None => ()
  }
  match self.max_bucket_cardinality {
    Some(value) => obj["max_bucket_cardinality"] = value.to_json()
    None => ()
  }
  match self.overall_cardinality {
    Some(value) => obj["overall_cardinality"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlEstimateModelMemoryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlEstimateModelMemoryBody: expected object"))
  }
  {
    analysis_config: match obj.get("analysis_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analysis_config")))
    },
    max_bucket_cardinality: match obj.get("max_bucket_cardinality") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_bucket_cardinality")),
        )
    },
    overall_cardinality: match obj.get("overall_cardinality") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("overall_cardinality")))
    },
  }
}

///|
pub fn MlEstimateModelMemoryBody::new(
  analysis_config? : Json,
  max_bucket_cardinality? : Map[String, Json],
  overall_cardinality? : Map[String, Json],
) -> MlEstimateModelMemoryBody {
  { analysis_config, max_bucket_cardinality, overall_cardinality }
}

///|
pub(all) struct MlEstimateModelMemoryResponse {
  model_memory_estimate : String
} derive(Eq, Debug)

///|
pub impl ToJson for MlEstimateModelMemoryResponse with fn to_json(
  self : MlEstimateModelMemoryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["model_memory_estimate"] = self.model_memory_estimate.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlEstimateModelMemoryResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlEstimateModelMemoryResponse: expected object"),
    )
  }
  {
    model_memory_estimate: @json.from_json(
      obj.get("model_memory_estimate").unwrap_or(Json::null()),
      path=path.add_key("model_memory_estimate"),
    ),
  }
}

///|
pub(all) struct MlEstimateModelMemoryRequest {
  query : MlEstimateModelMemoryQuery
  body : MlEstimateModelMemoryBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlEstimateModelMemoryRequest::new(
  body : MlEstimateModelMemoryBody,
  query? : MlEstimateModelMemoryQuery = MlEstimateModelMemoryQuery::new(),
) -> MlEstimateModelMemoryRequest {
  { query, body }
}

///|
pub async fn Client::ml_estimate_model_memory(
  self : Client,
  request : MlEstimateModelMemoryRequest,
) -> EsResponse[MlEstimateModelMemoryResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/_estimate_model_memory", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlEvaluateDataFrameQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlEvaluateDataFrameQuery with fn to_json(
  _self : MlEvaluateDataFrameQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlEvaluateDataFrameQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlEvaluateDataFrameQuery: expected object"))
  }
  MlEvaluateDataFrameQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlEvaluateDataFrameQuery::new() -> MlEvaluateDataFrameQuery {
  MlEvaluateDataFrameQuery::{  }
}

///|
pub fn MlEvaluateDataFrameQuery::to_pairs(
  _self : MlEvaluateDataFrameQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlEvaluateDataFrameBody {
  evaluation : Json
  index : Json
  query : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlEvaluateDataFrameBody with fn to_json(
  self : MlEvaluateDataFrameBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["evaluation"] = self.evaluation.to_json()
  obj["index"] = self.index.to_json()
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlEvaluateDataFrameBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlEvaluateDataFrameBody: expected object"))
  }
  {
    evaluation: @json.from_json(
      obj.get("evaluation").unwrap_or(Json::null()),
      path=path.add_key("evaluation"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
  }
}

///|
pub fn MlEvaluateDataFrameBody::new(
  evaluation : Json,
  index : Json,
  query? : Json,
) -> MlEvaluateDataFrameBody {
  { evaluation, index, query }
}

///|
pub(all) struct MlEvaluateDataFrameResponse {
  classification : Json?
  outlier_detection : Json?
  regression : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlEvaluateDataFrameResponse with fn to_json(
  self : MlEvaluateDataFrameResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.classification {
    Some(value) => obj["classification"] = value.to_json()
    None => ()
  }
  match self.outlier_detection {
    Some(value) => obj["outlier_detection"] = value.to_json()
    None => ()
  }
  match self.regression {
    Some(value) => obj["regression"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlEvaluateDataFrameResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlEvaluateDataFrameResponse: expected object"),
    )
  }
  {
    classification: match obj.get("classification") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("classification")))
    },
    outlier_detection: match obj.get("outlier_detection") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("outlier_detection")))
    },
    regression: match obj.get("regression") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("regression")))
    },
  }
}

///|
pub(all) struct MlEvaluateDataFrameRequest {
  query : MlEvaluateDataFrameQuery
  body : MlEvaluateDataFrameBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlEvaluateDataFrameRequest::new(
  body : MlEvaluateDataFrameBody,
  query? : MlEvaluateDataFrameQuery = MlEvaluateDataFrameQuery::new(),
) -> MlEvaluateDataFrameRequest {
  { query, body }
}

///|
pub async fn Client::ml_evaluate_data_frame(
  self : Client,
  request : MlEvaluateDataFrameRequest,
) -> EsResponse[MlEvaluateDataFrameResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/data_frame/_evaluate", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlExplainDataFrameAnalyticsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlExplainDataFrameAnalyticsQuery with fn to_json(
  _self : MlExplainDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlExplainDataFrameAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlExplainDataFrameAnalyticsQuery: expected object"),
    )
  }
  MlExplainDataFrameAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlExplainDataFrameAnalyticsQuery::new() -> MlExplainDataFrameAnalyticsQuery {
  MlExplainDataFrameAnalyticsQuery::{  }
}

///|
pub fn MlExplainDataFrameAnalyticsQuery::to_pairs(
  _self : MlExplainDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlExplainDataFrameAnalyticsBody {
  source : Json?
  dest : Json?
  analysis : Json?
  description : String?
  model_memory_limit : String?
  max_num_threads : Int?
  analyzed_fields : Json?
  allow_lazy_start : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlExplainDataFrameAnalyticsBody with fn to_json(
  self : MlExplainDataFrameAnalyticsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.source {
    Some(value) => obj["source"] = value.to_json()
    None => ()
  }
  match self.dest {
    Some(value) => obj["dest"] = value.to_json()
    None => ()
  }
  match self.analysis {
    Some(value) => obj["analysis"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.model_memory_limit {
    Some(value) => obj["model_memory_limit"] = value.to_json()
    None => ()
  }
  match self.max_num_threads {
    Some(value) => obj["max_num_threads"] = value.to_json()
    None => ()
  }
  match self.analyzed_fields {
    Some(value) => obj["analyzed_fields"] = value.to_json()
    None => ()
  }
  match self.allow_lazy_start {
    Some(value) => obj["allow_lazy_start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlExplainDataFrameAnalyticsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlExplainDataFrameAnalyticsBody: expected object"),
    )
  }
  {
    source: match obj.get("source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("source")))
    },
    dest: match obj.get("dest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dest")))
    },
    analysis: match obj.get("analysis") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analysis")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    model_memory_limit: match obj.get("model_memory_limit") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_memory_limit")))
    },
    max_num_threads: match obj.get("max_num_threads") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_num_threads")))
    },
    analyzed_fields: match obj.get("analyzed_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyzed_fields")))
    },
    allow_lazy_start: match obj.get("allow_lazy_start") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_lazy_start")))
    },
  }
}

///|
pub fn MlExplainDataFrameAnalyticsBody::new(
  source? : Json,
  dest? : Json,
  analysis? : Json,
  description? : String,
  model_memory_limit? : String,
  max_num_threads? : Int,
  analyzed_fields? : Json,
  allow_lazy_start? : Bool,
) -> MlExplainDataFrameAnalyticsBody {
  {
    source,
    dest,
    analysis,
    description,
    model_memory_limit,
    max_num_threads,
    analyzed_fields,
    allow_lazy_start,
  }
}

///|
pub(all) struct MlExplainDataFrameAnalyticsResponse {
  field_selection : Array[Json]
  memory_estimation : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlExplainDataFrameAnalyticsResponse with fn to_json(
  self : MlExplainDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["field_selection"] = self.field_selection.to_json()
  obj["memory_estimation"] = self.memory_estimation.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlExplainDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlExplainDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    field_selection: @json.from_json(
      obj.get("field_selection").unwrap_or(Json::null()),
      path=path.add_key("field_selection"),
    ),
    memory_estimation: @json.from_json(
      obj.get("memory_estimation").unwrap_or(Json::null()),
      path=path.add_key("memory_estimation"),
    ),
  }
}

///|
pub(all) struct MlExplainDataFrameAnalyticsRequest {
  id : String?
  query : MlExplainDataFrameAnalyticsQuery
  body : MlExplainDataFrameAnalyticsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlExplainDataFrameAnalyticsRequest::new(
  id? : String,
  query? : MlExplainDataFrameAnalyticsQuery = MlExplainDataFrameAnalyticsQuery::new(),
  body? : MlExplainDataFrameAnalyticsBody,
) -> MlExplainDataFrameAnalyticsRequest {
  { id, query, body }
}

///|
pub async fn Client::ml_explain_data_frame_analytics(
  self : Client,
  request : MlExplainDataFrameAnalyticsRequest,
) -> EsResponse[MlExplainDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/data_frame/analytics/{id}/_explain", ["id"]),
      PathVariant::new("/_ml/data_frame/analytics/_explain", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlFlushJobQuery {
  advance_time : String?
  calc_interim : Bool?
  end : String?
  skip_time : String?
  start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlFlushJobQuery with fn to_json(self : MlFlushJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.advance_time {
    Some(value) => obj["advance_time"] = value.to_json()
    None => ()
  }
  match self.calc_interim {
    Some(value) => obj["calc_interim"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.skip_time {
    Some(value) => obj["skip_time"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlFlushJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlFlushJobQuery: expected object"))
  }
  {
    advance_time: match obj.get("advance_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("advance_time")))
    },
    calc_interim: match obj.get("calc_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("calc_interim")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    skip_time: match obj.get("skip_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("skip_time")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlFlushJobQuery::new(
  advance_time? : String,
  calc_interim? : Bool,
  end? : String,
  skip_time? : String,
  start? : String,
) -> MlFlushJobQuery {
  { advance_time, calc_interim, end, skip_time, start }
}

///|
pub fn MlFlushJobQuery::to_pairs(
  self : MlFlushJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.advance_time {
    Some(value) => push_query_json(pairs, "advance_time", value.to_json())
    None => ()
  }
  match self.calc_interim {
    Some(value) => push_query_json(pairs, "calc_interim", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.skip_time {
    Some(value) => push_query_json(pairs, "skip_time", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlFlushJobBody {
  advance_time : Json?
  calc_interim : Bool?
  end : Json?
  skip_time : Json?
  start : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlFlushJobBody with fn to_json(self : MlFlushJobBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.advance_time {
    Some(value) => obj["advance_time"] = value.to_json()
    None => ()
  }
  match self.calc_interim {
    Some(value) => obj["calc_interim"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.skip_time {
    Some(value) => obj["skip_time"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlFlushJobBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlFlushJobBody: expected object"))
  }
  {
    advance_time: match obj.get("advance_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("advance_time")))
    },
    calc_interim: match obj.get("calc_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("calc_interim")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    skip_time: match obj.get("skip_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("skip_time")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlFlushJobBody::new(
  advance_time? : Json,
  calc_interim? : Bool,
  end? : Json,
  skip_time? : Json,
  start? : Json,
) -> MlFlushJobBody {
  { advance_time, calc_interim, end, skip_time, start }
}

///|
pub(all) struct MlFlushJobResponse {
  flushed : Bool
  last_finalized_bucket_end : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlFlushJobResponse with fn to_json(
  self : MlFlushJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["flushed"] = self.flushed.to_json()
  match self.last_finalized_bucket_end {
    Some(value) => obj["last_finalized_bucket_end"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlFlushJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlFlushJobResponse: expected object"))
  }
  {
    flushed: @json.from_json(
      obj.get("flushed").unwrap_or(Json::null()),
      path=path.add_key("flushed"),
    ),
    last_finalized_bucket_end: match obj.get("last_finalized_bucket_end") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("last_finalized_bucket_end")),
        )
    },
  }
}

///|
pub(all) struct MlFlushJobRequest {
  job_id : String
  query : MlFlushJobQuery
  body : MlFlushJobBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlFlushJobRequest::new(
  job_id : String,
  query? : MlFlushJobQuery = MlFlushJobQuery::new(),
  body? : MlFlushJobBody,
) -> MlFlushJobRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_flush_job(
  self : Client,
  request : MlFlushJobRequest,
) -> EsResponse[MlFlushJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_flush", ["job_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlForecastQuery {
  duration : String?
  expires_in : String?
  max_model_memory : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlForecastQuery with fn to_json(self : MlForecastQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.duration {
    Some(value) => obj["duration"] = value.to_json()
    None => ()
  }
  match self.expires_in {
    Some(value) => obj["expires_in"] = value.to_json()
    None => ()
  }
  match self.max_model_memory {
    Some(value) => obj["max_model_memory"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlForecastQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlForecastQuery: expected object"))
  }
  {
    duration: match obj.get("duration") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("duration")))
    },
    expires_in: match obj.get("expires_in") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expires_in")))
    },
    max_model_memory: match obj.get("max_model_memory") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_model_memory")))
    },
  }
}

///|
pub fn MlForecastQuery::new(
  duration? : String,
  expires_in? : String,
  max_model_memory? : String,
) -> MlForecastQuery {
  { duration, expires_in, max_model_memory }
}

///|
pub fn MlForecastQuery::to_pairs(
  self : MlForecastQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.duration {
    Some(value) => push_query_json(pairs, "duration", value.to_json())
    None => ()
  }
  match self.expires_in {
    Some(value) => push_query_json(pairs, "expires_in", value.to_json())
    None => ()
  }
  match self.max_model_memory {
    Some(value) => push_query_json(pairs, "max_model_memory", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlForecastBody {
  duration : Json?
  expires_in : Json?
  max_model_memory : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlForecastBody with fn to_json(self : MlForecastBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.duration {
    Some(value) => obj["duration"] = value.to_json()
    None => ()
  }
  match self.expires_in {
    Some(value) => obj["expires_in"] = value.to_json()
    None => ()
  }
  match self.max_model_memory {
    Some(value) => obj["max_model_memory"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlForecastBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlForecastBody: expected object"))
  }
  {
    duration: match obj.get("duration") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("duration")))
    },
    expires_in: match obj.get("expires_in") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expires_in")))
    },
    max_model_memory: match obj.get("max_model_memory") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_model_memory")))
    },
  }
}

///|
pub fn MlForecastBody::new(
  duration? : Json,
  expires_in? : Json,
  max_model_memory? : String,
) -> MlForecastBody {
  { duration, expires_in, max_model_memory }
}

///|
pub(all) struct MlForecastResponse {
  acknowledged : Bool
  forecast_id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlForecastResponse with fn to_json(
  self : MlForecastResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["forecast_id"] = self.forecast_id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlForecastResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlForecastResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    forecast_id: @json.from_json(
      obj.get("forecast_id").unwrap_or(Json::null()),
      path=path.add_key("forecast_id"),
    ),
  }
}

///|
pub(all) struct MlForecastRequest {
  job_id : String
  query : MlForecastQuery
  body : MlForecastBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlForecastRequest::new(
  job_id : String,
  query? : MlForecastQuery = MlForecastQuery::new(),
  body? : MlForecastBody,
) -> MlForecastRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_forecast(
  self : Client,
  request : MlForecastRequest,
) -> EsResponse[MlForecastResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_forecast", ["job_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetBucketsQuery {
  anomaly_score : Double?
  desc : Bool?
  end : String?
  exclude_interim : Bool?
  expand : Bool?
  from : Int?
  size : Int?
  sort : String?
  start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetBucketsQuery with fn to_json(self : MlGetBucketsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.anomaly_score {
    Some(value) => obj["anomaly_score"] = value.to_json()
    None => ()
  }
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.expand {
    Some(value) => obj["expand"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetBucketsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetBucketsQuery: expected object"))
  }
  {
    anomaly_score: match obj.get("anomaly_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("anomaly_score")))
    },
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    expand: match obj.get("expand") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("expand")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetBucketsQuery::new(
  anomaly_score? : Double,
  desc? : Bool,
  end? : String,
  exclude_interim? : Bool,
  expand? : Bool,
  from? : Int,
  size? : Int,
  sort? : String,
  start? : String,
) -> MlGetBucketsQuery {
  { anomaly_score, desc, end, exclude_interim, expand, from, size, sort, start }
}

///|
pub fn MlGetBucketsQuery::to_pairs(
  self : MlGetBucketsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.anomaly_score {
    Some(value) => push_query_json(pairs, "anomaly_score", value.to_json())
    None => ()
  }
  match self.desc {
    Some(value) => push_query_json(pairs, "desc", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.exclude_interim {
    Some(value) => push_query_json(pairs, "exclude_interim", value.to_json())
    None => ()
  }
  match self.expand {
    Some(value) => push_query_json(pairs, "expand", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetBucketsBody {
  anomaly_score : Double?
  desc : Bool?
  end : Json?
  exclude_interim : Bool?
  expand : Bool?
  page : Json?
  sort : Json?
  start : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetBucketsBody with fn to_json(self : MlGetBucketsBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.anomaly_score {
    Some(value) => obj["anomaly_score"] = value.to_json()
    None => ()
  }
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.expand {
    Some(value) => obj["expand"] = value.to_json()
    None => ()
  }
  match self.page {
    Some(value) => obj["page"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetBucketsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetBucketsBody: expected object"))
  }
  {
    anomaly_score: match obj.get("anomaly_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("anomaly_score")))
    },
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    expand: match obj.get("expand") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("expand")))
    },
    page: match obj.get("page") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("page")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetBucketsBody::new(
  anomaly_score? : Double,
  desc? : Bool,
  end? : Json,
  exclude_interim? : Bool,
  expand? : Bool,
  page? : Json,
  sort? : Json,
  start? : Json,
) -> MlGetBucketsBody {
  { anomaly_score, desc, end, exclude_interim, expand, page, sort, start }
}

///|
pub(all) struct MlGetBucketsResponse {
  buckets : Array[Json]
  count : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetBucketsResponse with fn to_json(
  self : MlGetBucketsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["buckets"] = self.buckets.to_json()
  obj["count"] = self.count.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetBucketsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetBucketsResponse: expected object"))
  }
  {
    buckets: @json.from_json(
      obj.get("buckets").unwrap_or(Json::null()),
      path=path.add_key("buckets"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
  }
}

///|
pub(all) struct MlGetBucketsRequest {
  job_id : String
  timestamp : String?
  query : MlGetBucketsQuery
  body : MlGetBucketsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetBucketsRequest::new(
  job_id : String,
  timestamp? : String,
  query? : MlGetBucketsQuery = MlGetBucketsQuery::new(),
  body? : MlGetBucketsBody,
) -> MlGetBucketsRequest {
  { job_id, timestamp, query, body }
}

///|
pub async fn Client::ml_get_buckets(
  self : Client,
  request : MlGetBucketsRequest,
) -> EsResponse[MlGetBucketsResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  match request.timestamp {
    Some(value) => params["timestamp"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/results/buckets/{timestamp}",
        ["job_id", "timestamp"],
      ),
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/results/buckets", [
        "job_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetCalendarEventsQuery {
  end : String?
  from : Int?
  job_id : String?
  size : Int?
  start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCalendarEventsQuery with fn to_json(
  self : MlGetCalendarEventsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.job_id {
    Some(value) => obj["job_id"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCalendarEventsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCalendarEventsQuery: expected object"))
  }
  {
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    job_id: match obj.get("job_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_id")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetCalendarEventsQuery::new(
  end? : String,
  from? : Int,
  job_id? : String,
  size? : Int,
  start? : String,
) -> MlGetCalendarEventsQuery {
  { end, from, job_id, size, start }
}

///|
pub fn MlGetCalendarEventsQuery::to_pairs(
  self : MlGetCalendarEventsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.job_id {
    Some(value) => push_query_json(pairs, "job_id", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetCalendarEventsResponse {
  count : Int
  events : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCalendarEventsResponse with fn to_json(
  self : MlGetCalendarEventsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["events"] = self.events.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCalendarEventsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetCalendarEventsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    events: @json.from_json(
      obj.get("events").unwrap_or(Json::null()),
      path=path.add_key("events"),
    ),
  }
}

///|
pub(all) struct MlGetCalendarEventsRequest {
  calendar_id : String
  query : MlGetCalendarEventsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetCalendarEventsRequest::new(
  calendar_id : String,
  query? : MlGetCalendarEventsQuery = MlGetCalendarEventsQuery::new(),
) -> MlGetCalendarEventsRequest {
  { calendar_id, query }
}

///|
pub async fn Client::ml_get_calendar_events(
  self : Client,
  request : MlGetCalendarEventsRequest,
) -> EsResponse[MlGetCalendarEventsResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/calendars/{calendar_id}/events", ["calendar_id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetCalendarsQuery {
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCalendarsQuery with fn to_json(
  self : MlGetCalendarsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCalendarsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCalendarsQuery: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn MlGetCalendarsQuery::new(
  from? : Int,
  size? : Int,
) -> MlGetCalendarsQuery {
  { from, size }
}

///|
pub fn MlGetCalendarsQuery::to_pairs(
  self : MlGetCalendarsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetCalendarsBody {
  page : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCalendarsBody with fn to_json(
  self : MlGetCalendarsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.page {
    Some(value) => obj["page"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCalendarsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCalendarsBody: expected object"))
  }
  {
    page: match obj.get("page") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("page")))
    },
  }
}

///|
pub fn MlGetCalendarsBody::new(page? : Json) -> MlGetCalendarsBody {
  { page, }
}

///|
pub(all) struct MlGetCalendarsResponse {
  calendars : Array[Json]
  count : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCalendarsResponse with fn to_json(
  self : MlGetCalendarsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["calendars"] = self.calendars.to_json()
  obj["count"] = self.count.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCalendarsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCalendarsResponse: expected object"))
  }
  {
    calendars: @json.from_json(
      obj.get("calendars").unwrap_or(Json::null()),
      path=path.add_key("calendars"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
  }
}

///|
pub(all) struct MlGetCalendarsRequest {
  calendar_id : String?
  query : MlGetCalendarsQuery
  body : MlGetCalendarsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetCalendarsRequest::new(
  calendar_id? : String,
  query? : MlGetCalendarsQuery = MlGetCalendarsQuery::new(),
  body? : MlGetCalendarsBody,
) -> MlGetCalendarsRequest {
  { calendar_id, query, body }
}

///|
pub async fn Client::ml_get_calendars(
  self : Client,
  request : MlGetCalendarsRequest,
) -> EsResponse[MlGetCalendarsResponse] {
  let params : Map[String, String] = Map([])
  match request.calendar_id {
    Some(value) => params["calendar_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/calendars/{calendar_id}", ["calendar_id"]),
      PathVariant::new("/_ml/calendars", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetCategoriesQuery {
  from : Int?
  partition_field_value : String?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCategoriesQuery with fn to_json(
  self : MlGetCategoriesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.partition_field_value {
    Some(value) => obj["partition_field_value"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCategoriesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCategoriesQuery: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    partition_field_value: match obj.get("partition_field_value") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("partition_field_value")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn MlGetCategoriesQuery::new(
  from? : Int,
  partition_field_value? : String,
  size? : Int,
) -> MlGetCategoriesQuery {
  { from, partition_field_value, size }
}

///|
pub fn MlGetCategoriesQuery::to_pairs(
  self : MlGetCategoriesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.partition_field_value {
    Some(value) =>
      push_query_json(pairs, "partition_field_value", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetCategoriesBody {
  page : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCategoriesBody with fn to_json(
  self : MlGetCategoriesBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.page {
    Some(value) => obj["page"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCategoriesBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCategoriesBody: expected object"))
  }
  {
    page: match obj.get("page") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("page")))
    },
  }
}

///|
pub fn MlGetCategoriesBody::new(page? : Json) -> MlGetCategoriesBody {
  { page, }
}

///|
pub(all) struct MlGetCategoriesResponse {
  categories : Array[Json]
  count : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetCategoriesResponse with fn to_json(
  self : MlGetCategoriesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["categories"] = self.categories.to_json()
  obj["count"] = self.count.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetCategoriesResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetCategoriesResponse: expected object"))
  }
  {
    categories: @json.from_json(
      obj.get("categories").unwrap_or(Json::null()),
      path=path.add_key("categories"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
  }
}

///|
pub(all) struct MlGetCategoriesRequest {
  job_id : String
  category_id : String?
  query : MlGetCategoriesQuery
  body : MlGetCategoriesBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetCategoriesRequest::new(
  job_id : String,
  category_id? : String,
  query? : MlGetCategoriesQuery = MlGetCategoriesQuery::new(),
  body? : MlGetCategoriesBody,
) -> MlGetCategoriesRequest {
  { job_id, category_id, query, body }
}

///|
pub async fn Client::ml_get_categories(
  self : Client,
  request : MlGetCategoriesRequest,
) -> EsResponse[MlGetCategoriesResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  match request.category_id {
    Some(value) => params["category_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/results/categories/{category_id}",
        ["job_id", "category_id"],
      ),
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/results/categories", [
        "job_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetDataFrameAnalyticsQuery {
  allow_no_match : Bool?
  from : Int?
  size : Int?
  exclude_generated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDataFrameAnalyticsQuery with fn to_json(
  self : MlGetDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.exclude_generated {
    Some(value) => obj["exclude_generated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDataFrameAnalyticsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetDataFrameAnalyticsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    exclude_generated: match obj.get("exclude_generated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_generated")))
    },
  }
}

///|
pub fn MlGetDataFrameAnalyticsQuery::new(
  allow_no_match? : Bool,
  from? : Int,
  size? : Int,
  exclude_generated? : Bool,
) -> MlGetDataFrameAnalyticsQuery {
  { allow_no_match, from, size, exclude_generated }
}

///|
pub fn MlGetDataFrameAnalyticsQuery::to_pairs(
  self : MlGetDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.exclude_generated {
    Some(value) => push_query_json(pairs, "exclude_generated", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetDataFrameAnalyticsResponse {
  count : Int
  data_frame_analytics : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDataFrameAnalyticsResponse with fn to_json(
  self : MlGetDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["data_frame_analytics"] = self.data_frame_analytics.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    data_frame_analytics: @json.from_json(
      obj.get("data_frame_analytics").unwrap_or(Json::null()),
      path=path.add_key("data_frame_analytics"),
    ),
  }
}

///|
pub(all) struct MlGetDataFrameAnalyticsRequest {
  id : String?
  query : MlGetDataFrameAnalyticsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetDataFrameAnalyticsRequest::new(
  id? : String,
  query? : MlGetDataFrameAnalyticsQuery = MlGetDataFrameAnalyticsQuery::new(),
) -> MlGetDataFrameAnalyticsRequest {
  { id, query }
}

///|
pub async fn Client::ml_get_data_frame_analytics(
  self : Client,
  request : MlGetDataFrameAnalyticsRequest,
) -> EsResponse[MlGetDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/data_frame/analytics/{id}", ["id"]),
      PathVariant::new("/_ml/data_frame/analytics", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetDataFrameAnalyticsStatsQuery {
  allow_no_match : Bool?
  from : Int?
  size : Int?
  verbose : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDataFrameAnalyticsStatsQuery with fn to_json(
  self : MlGetDataFrameAnalyticsStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.verbose {
    Some(value) => obj["verbose"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDataFrameAnalyticsStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetDataFrameAnalyticsStatsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    verbose: match obj.get("verbose") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("verbose")))
    },
  }
}

///|
pub fn MlGetDataFrameAnalyticsStatsQuery::new(
  allow_no_match? : Bool,
  from? : Int,
  size? : Int,
  verbose? : Bool,
) -> MlGetDataFrameAnalyticsStatsQuery {
  { allow_no_match, from, size, verbose }
}

///|
pub fn MlGetDataFrameAnalyticsStatsQuery::to_pairs(
  self : MlGetDataFrameAnalyticsStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.verbose {
    Some(value) => push_query_json(pairs, "verbose", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetDataFrameAnalyticsStatsResponse {
  count : Int
  data_frame_analytics : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDataFrameAnalyticsStatsResponse with fn to_json(
  self : MlGetDataFrameAnalyticsStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["data_frame_analytics"] = self.data_frame_analytics.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDataFrameAnalyticsStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetDataFrameAnalyticsStatsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    data_frame_analytics: @json.from_json(
      obj.get("data_frame_analytics").unwrap_or(Json::null()),
      path=path.add_key("data_frame_analytics"),
    ),
  }
}

///|
pub(all) struct MlGetDataFrameAnalyticsStatsRequest {
  id : String?
  query : MlGetDataFrameAnalyticsStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetDataFrameAnalyticsStatsRequest::new(
  id? : String,
  query? : MlGetDataFrameAnalyticsStatsQuery = MlGetDataFrameAnalyticsStatsQuery::new(),
) -> MlGetDataFrameAnalyticsStatsRequest {
  { id, query }
}

///|
pub async fn Client::ml_get_data_frame_analytics_stats(
  self : Client,
  request : MlGetDataFrameAnalyticsStatsRequest,
) -> EsResponse[MlGetDataFrameAnalyticsStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/data_frame/analytics/{id}/_stats", ["id"]),
      PathVariant::new("/_ml/data_frame/analytics/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetDatafeedStatsQuery {
  allow_no_match : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDatafeedStatsQuery with fn to_json(
  self : MlGetDatafeedStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDatafeedStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetDatafeedStatsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
  }
}

///|
pub fn MlGetDatafeedStatsQuery::new(
  allow_no_match? : Bool,
) -> MlGetDatafeedStatsQuery {
  { allow_no_match, }
}

///|
pub fn MlGetDatafeedStatsQuery::to_pairs(
  self : MlGetDatafeedStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetDatafeedStatsResponse {
  count : Int
  datafeeds : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDatafeedStatsResponse with fn to_json(
  self : MlGetDatafeedStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["datafeeds"] = self.datafeeds.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDatafeedStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetDatafeedStatsResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    datafeeds: @json.from_json(
      obj.get("datafeeds").unwrap_or(Json::null()),
      path=path.add_key("datafeeds"),
    ),
  }
}

///|
pub(all) struct MlGetDatafeedStatsRequest {
  datafeed_id : String?
  query : MlGetDatafeedStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetDatafeedStatsRequest::new(
  datafeed_id? : String,
  query? : MlGetDatafeedStatsQuery = MlGetDatafeedStatsQuery::new(),
) -> MlGetDatafeedStatsRequest {
  { datafeed_id, query }
}

///|
pub async fn Client::ml_get_datafeed_stats(
  self : Client,
  request : MlGetDatafeedStatsRequest,
) -> EsResponse[MlGetDatafeedStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.datafeed_id {
    Some(value) => params["datafeed_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/datafeeds/{datafeed_id}/_stats", ["datafeed_id"]),
      PathVariant::new("/_ml/datafeeds/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetDatafeedsQuery {
  allow_no_match : Bool?
  exclude_generated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDatafeedsQuery with fn to_json(
  self : MlGetDatafeedsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.exclude_generated {
    Some(value) => obj["exclude_generated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDatafeedsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetDatafeedsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    exclude_generated: match obj.get("exclude_generated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_generated")))
    },
  }
}

///|
pub fn MlGetDatafeedsQuery::new(
  allow_no_match? : Bool,
  exclude_generated? : Bool,
) -> MlGetDatafeedsQuery {
  { allow_no_match, exclude_generated }
}

///|
pub fn MlGetDatafeedsQuery::to_pairs(
  self : MlGetDatafeedsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.exclude_generated {
    Some(value) => push_query_json(pairs, "exclude_generated", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetDatafeedsResponse {
  count : Int
  datafeeds : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetDatafeedsResponse with fn to_json(
  self : MlGetDatafeedsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["datafeeds"] = self.datafeeds.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetDatafeedsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetDatafeedsResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    datafeeds: @json.from_json(
      obj.get("datafeeds").unwrap_or(Json::null()),
      path=path.add_key("datafeeds"),
    ),
  }
}

///|
pub(all) struct MlGetDatafeedsRequest {
  datafeed_id : String?
  query : MlGetDatafeedsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetDatafeedsRequest::new(
  datafeed_id? : String,
  query? : MlGetDatafeedsQuery = MlGetDatafeedsQuery::new(),
) -> MlGetDatafeedsRequest {
  { datafeed_id, query }
}

///|
pub async fn Client::ml_get_datafeeds(
  self : Client,
  request : MlGetDatafeedsRequest,
) -> EsResponse[MlGetDatafeedsResponse] {
  let params : Map[String, String] = Map([])
  match request.datafeed_id {
    Some(value) => params["datafeed_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/datafeeds/{datafeed_id}", ["datafeed_id"]),
      PathVariant::new("/_ml/datafeeds", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetFiltersQuery {
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetFiltersQuery with fn to_json(self : MlGetFiltersQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetFiltersQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetFiltersQuery: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn MlGetFiltersQuery::new(from? : Int, size? : Int) -> MlGetFiltersQuery {
  { from, size }
}

///|
pub fn MlGetFiltersQuery::to_pairs(
  self : MlGetFiltersQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetFiltersResponse {
  count : Int
  filters : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetFiltersResponse with fn to_json(
  self : MlGetFiltersResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["filters"] = self.filters.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetFiltersResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetFiltersResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    filters: @json.from_json(
      obj.get("filters").unwrap_or(Json::null()),
      path=path.add_key("filters"),
    ),
  }
}

///|
pub(all) struct MlGetFiltersRequest {
  filter_id : String?
  query : MlGetFiltersQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetFiltersRequest::new(
  filter_id? : String,
  query? : MlGetFiltersQuery = MlGetFiltersQuery::new(),
) -> MlGetFiltersRequest {
  { filter_id, query }
}

///|
pub async fn Client::ml_get_filters(
  self : Client,
  request : MlGetFiltersRequest,
) -> EsResponse[MlGetFiltersResponse] {
  let params : Map[String, String] = Map([])
  match request.filter_id {
    Some(value) => params["filter_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/filters/{filter_id}", ["filter_id"]),
      PathVariant::new("/_ml/filters", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetInfluencersQuery {
  desc : Bool?
  end : String?
  exclude_interim : Bool?
  influencer_score : Double?
  from : Int?
  size : Int?
  sort : String?
  start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetInfluencersQuery with fn to_json(
  self : MlGetInfluencersQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.influencer_score {
    Some(value) => obj["influencer_score"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetInfluencersQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetInfluencersQuery: expected object"))
  }
  {
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    influencer_score: match obj.get("influencer_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("influencer_score")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetInfluencersQuery::new(
  desc? : Bool,
  end? : String,
  exclude_interim? : Bool,
  influencer_score? : Double,
  from? : Int,
  size? : Int,
  sort? : String,
  start? : String,
) -> MlGetInfluencersQuery {
  { desc, end, exclude_interim, influencer_score, from, size, sort, start }
}

///|
pub fn MlGetInfluencersQuery::to_pairs(
  self : MlGetInfluencersQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.desc {
    Some(value) => push_query_json(pairs, "desc", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.exclude_interim {
    Some(value) => push_query_json(pairs, "exclude_interim", value.to_json())
    None => ()
  }
  match self.influencer_score {
    Some(value) => push_query_json(pairs, "influencer_score", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetInfluencersBody {
  page : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetInfluencersBody with fn to_json(
  self : MlGetInfluencersBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.page {
    Some(value) => obj["page"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetInfluencersBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetInfluencersBody: expected object"))
  }
  {
    page: match obj.get("page") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("page")))
    },
  }
}

///|
pub fn MlGetInfluencersBody::new(page? : Json) -> MlGetInfluencersBody {
  { page, }
}

///|
pub(all) struct MlGetInfluencersResponse {
  count : Int
  influencers : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetInfluencersResponse with fn to_json(
  self : MlGetInfluencersResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["influencers"] = self.influencers.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetInfluencersResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetInfluencersResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    influencers: @json.from_json(
      obj.get("influencers").unwrap_or(Json::null()),
      path=path.add_key("influencers"),
    ),
  }
}

///|
pub(all) struct MlGetInfluencersRequest {
  job_id : String
  query : MlGetInfluencersQuery
  body : MlGetInfluencersBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetInfluencersRequest::new(
  job_id : String,
  query? : MlGetInfluencersQuery = MlGetInfluencersQuery::new(),
  body? : MlGetInfluencersBody,
) -> MlGetInfluencersRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_get_influencers(
  self : Client,
  request : MlGetInfluencersRequest,
) -> EsResponse[MlGetInfluencersResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/results/influencers", [
        "job_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetJobStatsQuery {
  allow_no_match : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetJobStatsQuery with fn to_json(
  self : MlGetJobStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetJobStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetJobStatsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
  }
}

///|
pub fn MlGetJobStatsQuery::new(allow_no_match? : Bool) -> MlGetJobStatsQuery {
  { allow_no_match, }
}

///|
pub fn MlGetJobStatsQuery::to_pairs(
  self : MlGetJobStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetJobStatsResponse {
  count : Int
  jobs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetJobStatsResponse with fn to_json(
  self : MlGetJobStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["jobs"] = self.jobs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetJobStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetJobStatsResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    jobs: @json.from_json(
      obj.get("jobs").unwrap_or(Json::null()),
      path=path.add_key("jobs"),
    ),
  }
}

///|
pub(all) struct MlGetJobStatsRequest {
  job_id : String?
  query : MlGetJobStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetJobStatsRequest::new(
  job_id? : String,
  query? : MlGetJobStatsQuery = MlGetJobStatsQuery::new(),
) -> MlGetJobStatsRequest {
  { job_id, query }
}

///|
pub async fn Client::ml_get_job_stats(
  self : Client,
  request : MlGetJobStatsRequest,
) -> EsResponse[MlGetJobStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.job_id {
    Some(value) => params["job_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/_stats", ["job_id"]),
      PathVariant::new("/_ml/anomaly_detectors/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetJobsQuery {
  allow_no_match : Bool?
  exclude_generated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetJobsQuery with fn to_json(self : MlGetJobsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.exclude_generated {
    Some(value) => obj["exclude_generated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetJobsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetJobsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    exclude_generated: match obj.get("exclude_generated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_generated")))
    },
  }
}

///|
pub fn MlGetJobsQuery::new(
  allow_no_match? : Bool,
  exclude_generated? : Bool,
) -> MlGetJobsQuery {
  { allow_no_match, exclude_generated }
}

///|
pub fn MlGetJobsQuery::to_pairs(
  self : MlGetJobsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.exclude_generated {
    Some(value) => push_query_json(pairs, "exclude_generated", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetJobsResponse {
  count : Int
  jobs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetJobsResponse with fn to_json(self : MlGetJobsResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["jobs"] = self.jobs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetJobsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetJobsResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    jobs: @json.from_json(
      obj.get("jobs").unwrap_or(Json::null()),
      path=path.add_key("jobs"),
    ),
  }
}

///|
pub(all) struct MlGetJobsRequest {
  job_id : String?
  query : MlGetJobsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetJobsRequest::new(
  job_id? : String,
  query? : MlGetJobsQuery = MlGetJobsQuery::new(),
) -> MlGetJobsRequest {
  { job_id, query }
}

///|
pub async fn Client::ml_get_jobs(
  self : Client,
  request : MlGetJobsRequest,
) -> EsResponse[MlGetJobsResponse] {
  let params : Map[String, String] = Map([])
  match request.job_id {
    Some(value) => params["job_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/anomaly_detectors/{job_id}", ["job_id"]),
      PathVariant::new("/_ml/anomaly_detectors", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetMemoryStatsQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetMemoryStatsQuery with fn to_json(
  self : MlGetMemoryStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetMemoryStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetMemoryStatsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlGetMemoryStatsQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> MlGetMemoryStatsQuery {
  { master_timeout, timeout }
}

///|
pub fn MlGetMemoryStatsQuery::to_pairs(
  self : MlGetMemoryStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetMemoryStatsResponse {
  _nodes : Json
  cluster_name : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetMemoryStatsResponse with fn to_json(
  self : MlGetMemoryStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetMemoryStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetMemoryStatsResponse: expected object"))
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct MlGetMemoryStatsRequest {
  node_id : String?
  query : MlGetMemoryStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetMemoryStatsRequest::new(
  node_id? : String,
  query? : MlGetMemoryStatsQuery = MlGetMemoryStatsQuery::new(),
) -> MlGetMemoryStatsRequest {
  { node_id, query }
}

///|
pub async fn Client::ml_get_memory_stats(
  self : Client,
  request : MlGetMemoryStatsRequest,
) -> EsResponse[MlGetMemoryStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/memory/{node_id}/_stats", ["node_id"]),
      PathVariant::new("/_ml/memory/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetModelSnapshotUpgradeStatsQuery {
  allow_no_match : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetModelSnapshotUpgradeStatsQuery with fn to_json(
  self : MlGetModelSnapshotUpgradeStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetModelSnapshotUpgradeStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetModelSnapshotUpgradeStatsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
  }
}

///|
pub fn MlGetModelSnapshotUpgradeStatsQuery::new(
  allow_no_match? : Bool,
) -> MlGetModelSnapshotUpgradeStatsQuery {
  { allow_no_match, }
}

///|
pub fn MlGetModelSnapshotUpgradeStatsQuery::to_pairs(
  self : MlGetModelSnapshotUpgradeStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetModelSnapshotUpgradeStatsResponse {
  count : Int
  model_snapshot_upgrades : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetModelSnapshotUpgradeStatsResponse with fn to_json(
  self : MlGetModelSnapshotUpgradeStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["model_snapshot_upgrades"] = self.model_snapshot_upgrades.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetModelSnapshotUpgradeStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetModelSnapshotUpgradeStatsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    model_snapshot_upgrades: @json.from_json(
      obj.get("model_snapshot_upgrades").unwrap_or(Json::null()),
      path=path.add_key("model_snapshot_upgrades"),
    ),
  }
}

///|
pub(all) struct MlGetModelSnapshotUpgradeStatsRequest {
  job_id : String
  snapshot_id : String
  query : MlGetModelSnapshotUpgradeStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetModelSnapshotUpgradeStatsRequest::new(
  job_id : String,
  snapshot_id : String,
  query? : MlGetModelSnapshotUpgradeStatsQuery = MlGetModelSnapshotUpgradeStatsQuery::new(),
) -> MlGetModelSnapshotUpgradeStatsRequest {
  { job_id, snapshot_id, query }
}

///|
pub async fn Client::ml_get_model_snapshot_upgrade_stats(
  self : Client,
  request : MlGetModelSnapshotUpgradeStatsRequest,
) -> EsResponse[MlGetModelSnapshotUpgradeStatsResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  params["snapshot_id"] = request.snapshot_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_upgrade/_stats",
        ["job_id", "snapshot_id"],
      ),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetModelSnapshotsQuery {
  desc : Bool?
  end : String?
  from : Int?
  size : Int?
  sort : String?
  start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetModelSnapshotsQuery with fn to_json(
  self : MlGetModelSnapshotsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetModelSnapshotsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetModelSnapshotsQuery: expected object"))
  }
  {
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetModelSnapshotsQuery::new(
  desc? : Bool,
  end? : String,
  from? : Int,
  size? : Int,
  sort? : String,
  start? : String,
) -> MlGetModelSnapshotsQuery {
  { desc, end, from, size, sort, start }
}

///|
pub fn MlGetModelSnapshotsQuery::to_pairs(
  self : MlGetModelSnapshotsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.desc {
    Some(value) => push_query_json(pairs, "desc", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetModelSnapshotsBody {
  desc : Bool?
  end : Json?
  page : Json?
  sort : Json?
  start : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetModelSnapshotsBody with fn to_json(
  self : MlGetModelSnapshotsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.page {
    Some(value) => obj["page"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetModelSnapshotsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetModelSnapshotsBody: expected object"))
  }
  {
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    page: match obj.get("page") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("page")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetModelSnapshotsBody::new(
  desc? : Bool,
  end? : Json,
  page? : Json,
  sort? : Json,
  start? : Json,
) -> MlGetModelSnapshotsBody {
  { desc, end, page, sort, start }
}

///|
pub(all) struct MlGetModelSnapshotsResponse {
  count : Int
  model_snapshots : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetModelSnapshotsResponse with fn to_json(
  self : MlGetModelSnapshotsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["model_snapshots"] = self.model_snapshots.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetModelSnapshotsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetModelSnapshotsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    model_snapshots: @json.from_json(
      obj.get("model_snapshots").unwrap_or(Json::null()),
      path=path.add_key("model_snapshots"),
    ),
  }
}

///|
pub(all) struct MlGetModelSnapshotsRequest {
  job_id : String
  snapshot_id : String?
  query : MlGetModelSnapshotsQuery
  body : MlGetModelSnapshotsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetModelSnapshotsRequest::new(
  job_id : String,
  snapshot_id? : String,
  query? : MlGetModelSnapshotsQuery = MlGetModelSnapshotsQuery::new(),
  body? : MlGetModelSnapshotsBody,
) -> MlGetModelSnapshotsRequest {
  { job_id, snapshot_id, query, body }
}

///|
pub async fn Client::ml_get_model_snapshots(
  self : Client,
  request : MlGetModelSnapshotsRequest,
) -> EsResponse[MlGetModelSnapshotsResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  match request.snapshot_id {
    Some(value) => params["snapshot_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}",
        ["job_id", "snapshot_id"],
      ),
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/model_snapshots", [
        "job_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetOverallBucketsQuery {
  allow_no_match : Bool?
  bucket_span : String?
  end : String?
  exclude_interim : Bool?
  overall_score : Double?
  start : String?
  top_n : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetOverallBucketsQuery with fn to_json(
  self : MlGetOverallBucketsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.bucket_span {
    Some(value) => obj["bucket_span"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.overall_score {
    Some(value) => obj["overall_score"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  match self.top_n {
    Some(value) => obj["top_n"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetOverallBucketsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetOverallBucketsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    bucket_span: match obj.get("bucket_span") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("bucket_span")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    overall_score: match obj.get("overall_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("overall_score")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
    top_n: match obj.get("top_n") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("top_n")))
    },
  }
}

///|
pub fn MlGetOverallBucketsQuery::new(
  allow_no_match? : Bool,
  bucket_span? : String,
  end? : String,
  exclude_interim? : Bool,
  overall_score? : Double,
  start? : String,
  top_n? : Int,
) -> MlGetOverallBucketsQuery {
  {
    allow_no_match,
    bucket_span,
    end,
    exclude_interim,
    overall_score,
    start,
    top_n,
  }
}

///|
pub fn MlGetOverallBucketsQuery::to_pairs(
  self : MlGetOverallBucketsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.bucket_span {
    Some(value) => push_query_json(pairs, "bucket_span", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.exclude_interim {
    Some(value) => push_query_json(pairs, "exclude_interim", value.to_json())
    None => ()
  }
  match self.overall_score {
    Some(value) => push_query_json(pairs, "overall_score", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  match self.top_n {
    Some(value) => push_query_json(pairs, "top_n", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetOverallBucketsBody {
  allow_no_match : Bool?
  bucket_span : Json?
  end : Json?
  exclude_interim : Bool?
  overall_score : Double?
  start : Json?
  top_n : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetOverallBucketsBody with fn to_json(
  self : MlGetOverallBucketsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.bucket_span {
    Some(value) => obj["bucket_span"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.overall_score {
    Some(value) => obj["overall_score"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  match self.top_n {
    Some(value) => obj["top_n"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetOverallBucketsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetOverallBucketsBody: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    bucket_span: match obj.get("bucket_span") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("bucket_span")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    overall_score: match obj.get("overall_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("overall_score")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
    top_n: match obj.get("top_n") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("top_n")))
    },
  }
}

///|
pub fn MlGetOverallBucketsBody::new(
  allow_no_match? : Bool,
  bucket_span? : Json,
  end? : Json,
  exclude_interim? : Bool,
  overall_score? : Double,
  start? : Json,
  top_n? : Int,
) -> MlGetOverallBucketsBody {
  {
    allow_no_match,
    bucket_span,
    end,
    exclude_interim,
    overall_score,
    start,
    top_n,
  }
}

///|
pub(all) struct MlGetOverallBucketsResponse {
  count : Int
  overall_buckets : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetOverallBucketsResponse with fn to_json(
  self : MlGetOverallBucketsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["overall_buckets"] = self.overall_buckets.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetOverallBucketsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetOverallBucketsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    overall_buckets: @json.from_json(
      obj.get("overall_buckets").unwrap_or(Json::null()),
      path=path.add_key("overall_buckets"),
    ),
  }
}

///|
pub(all) struct MlGetOverallBucketsRequest {
  job_id : String
  query : MlGetOverallBucketsQuery
  body : MlGetOverallBucketsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetOverallBucketsRequest::new(
  job_id : String,
  query? : MlGetOverallBucketsQuery = MlGetOverallBucketsQuery::new(),
  body? : MlGetOverallBucketsBody,
) -> MlGetOverallBucketsRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_get_overall_buckets(
  self : Client,
  request : MlGetOverallBucketsRequest,
) -> EsResponse[MlGetOverallBucketsResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/results/overall_buckets",
        ["job_id"],
      ),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetRecordsQuery {
  desc : Bool?
  end : String?
  exclude_interim : Bool?
  from : Int?
  record_score : Double?
  size : Int?
  sort : String?
  start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetRecordsQuery with fn to_json(self : MlGetRecordsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.record_score {
    Some(value) => obj["record_score"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetRecordsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetRecordsQuery: expected object"))
  }
  {
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    record_score: match obj.get("record_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("record_score")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetRecordsQuery::new(
  desc? : Bool,
  end? : String,
  exclude_interim? : Bool,
  from? : Int,
  record_score? : Double,
  size? : Int,
  sort? : String,
  start? : String,
) -> MlGetRecordsQuery {
  { desc, end, exclude_interim, from, record_score, size, sort, start }
}

///|
pub fn MlGetRecordsQuery::to_pairs(
  self : MlGetRecordsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.desc {
    Some(value) => push_query_json(pairs, "desc", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.exclude_interim {
    Some(value) => push_query_json(pairs, "exclude_interim", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.record_score {
    Some(value) => push_query_json(pairs, "record_score", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetRecordsBody {
  desc : Bool?
  end : Json?
  exclude_interim : Bool?
  page : Json?
  record_score : Double?
  sort : Json?
  start : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetRecordsBody with fn to_json(self : MlGetRecordsBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.desc {
    Some(value) => obj["desc"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.exclude_interim {
    Some(value) => obj["exclude_interim"] = value.to_json()
    None => ()
  }
  match self.page {
    Some(value) => obj["page"] = value.to_json()
    None => ()
  }
  match self.record_score {
    Some(value) => obj["record_score"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetRecordsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetRecordsBody: expected object"))
  }
  {
    desc: match obj.get("desc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("desc")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    exclude_interim: match obj.get("exclude_interim") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_interim")))
    },
    page: match obj.get("page") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("page")))
    },
    record_score: match obj.get("record_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("record_score")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
  }
}

///|
pub fn MlGetRecordsBody::new(
  desc? : Bool,
  end? : Json,
  exclude_interim? : Bool,
  page? : Json,
  record_score? : Double,
  sort? : Json,
  start? : Json,
) -> MlGetRecordsBody {
  { desc, end, exclude_interim, page, record_score, sort, start }
}

///|
pub(all) struct MlGetRecordsResponse {
  count : Int
  records : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetRecordsResponse with fn to_json(
  self : MlGetRecordsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["records"] = self.records.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetRecordsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetRecordsResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    records: @json.from_json(
      obj.get("records").unwrap_or(Json::null()),
      path=path.add_key("records"),
    ),
  }
}

///|
pub(all) struct MlGetRecordsRequest {
  job_id : String
  query : MlGetRecordsQuery
  body : MlGetRecordsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetRecordsRequest::new(
  job_id : String,
  query? : MlGetRecordsQuery = MlGetRecordsQuery::new(),
  body? : MlGetRecordsBody,
) -> MlGetRecordsRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_get_records(
  self : Client,
  request : MlGetRecordsRequest,
) -> EsResponse[MlGetRecordsResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/anomaly_detectors/{job_id}/results/records", [
        "job_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlGetTrainedModelsQuery {
  allow_no_match : Bool?
  decompress_definition : Bool?
  exclude_generated : Bool?
  from : Int?
  include_ : String?
  size : Int?
  tags : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetTrainedModelsQuery with fn to_json(
  self : MlGetTrainedModelsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.decompress_definition {
    Some(value) => obj["decompress_definition"] = value.to_json()
    None => ()
  }
  match self.exclude_generated {
    Some(value) => obj["exclude_generated"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.include_ {
    Some(value) => obj["include"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.tags {
    Some(value) => obj["tags"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetTrainedModelsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetTrainedModelsQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    decompress_definition: match obj.get("decompress_definition") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("decompress_definition")))
    },
    exclude_generated: match obj.get("exclude_generated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_generated")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    include_: match obj.get("include") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("include")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    tags: match obj.get("tags") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("tags")))
    },
  }
}

///|
pub fn MlGetTrainedModelsQuery::new(
  allow_no_match? : Bool,
  decompress_definition? : Bool,
  exclude_generated? : Bool,
  from? : Int,
  include_? : String,
  size? : Int,
  tags? : Json,
) -> MlGetTrainedModelsQuery {
  {
    allow_no_match,
    decompress_definition,
    exclude_generated,
    from,
    include_,
    size,
    tags,
  }
}

///|
pub fn MlGetTrainedModelsQuery::to_pairs(
  self : MlGetTrainedModelsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.decompress_definition {
    Some(value) =>
      push_query_json(pairs, "decompress_definition", value.to_json())
    None => ()
  }
  match self.exclude_generated {
    Some(value) => push_query_json(pairs, "exclude_generated", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.include_ {
    Some(value) => push_query_json(pairs, "include", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.tags {
    Some(value) => push_query_json(pairs, "tags", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetTrainedModelsResponse {
  count : Int
  trained_model_configs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetTrainedModelsResponse with fn to_json(
  self : MlGetTrainedModelsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["trained_model_configs"] = self.trained_model_configs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetTrainedModelsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlGetTrainedModelsResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    trained_model_configs: @json.from_json(
      obj.get("trained_model_configs").unwrap_or(Json::null()),
      path=path.add_key("trained_model_configs"),
    ),
  }
}

///|
pub(all) struct MlGetTrainedModelsRequest {
  model_id : String?
  query : MlGetTrainedModelsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetTrainedModelsRequest::new(
  model_id? : String,
  query? : MlGetTrainedModelsQuery = MlGetTrainedModelsQuery::new(),
) -> MlGetTrainedModelsRequest {
  { model_id, query }
}

///|
pub async fn Client::ml_get_trained_models(
  self : Client,
  request : MlGetTrainedModelsRequest,
) -> EsResponse[MlGetTrainedModelsResponse] {
  let params : Map[String, String] = Map([])
  match request.model_id {
    Some(value) => params["model_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}", ["model_id"]),
      PathVariant::new("/_ml/trained_models", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlGetTrainedModelsStatsQuery {
  allow_no_match : Bool?
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetTrainedModelsStatsQuery with fn to_json(
  self : MlGetTrainedModelsStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlGetTrainedModelsStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetTrainedModelsStatsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn MlGetTrainedModelsStatsQuery::new(
  allow_no_match? : Bool,
  from? : Int,
  size? : Int,
) -> MlGetTrainedModelsStatsQuery {
  { allow_no_match, from, size }
}

///|
pub fn MlGetTrainedModelsStatsQuery::to_pairs(
  self : MlGetTrainedModelsStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlGetTrainedModelsStatsResponse {
  count : Int
  trained_model_stats : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlGetTrainedModelsStatsResponse with fn to_json(
  self : MlGetTrainedModelsStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["trained_model_stats"] = self.trained_model_stats.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlGetTrainedModelsStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlGetTrainedModelsStatsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    trained_model_stats: @json.from_json(
      obj.get("trained_model_stats").unwrap_or(Json::null()),
      path=path.add_key("trained_model_stats"),
    ),
  }
}

///|
pub(all) struct MlGetTrainedModelsStatsRequest {
  model_id : String?
  query : MlGetTrainedModelsStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlGetTrainedModelsStatsRequest::new(
  model_id? : String,
  query? : MlGetTrainedModelsStatsQuery = MlGetTrainedModelsStatsQuery::new(),
) -> MlGetTrainedModelsStatsRequest {
  { model_id, query }
}

///|
pub async fn Client::ml_get_trained_models_stats(
  self : Client,
  request : MlGetTrainedModelsStatsRequest,
) -> EsResponse[MlGetTrainedModelsStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.model_id {
    Some(value) => params["model_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}/_stats", ["model_id"]),
      PathVariant::new("/_ml/trained_models/_stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlInferTrainedModelQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlInferTrainedModelQuery with fn to_json(
  self : MlInferTrainedModelQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlInferTrainedModelQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlInferTrainedModelQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlInferTrainedModelQuery::new(
  timeout? : String,
) -> MlInferTrainedModelQuery {
  { timeout, }
}

///|
pub fn MlInferTrainedModelQuery::to_pairs(
  self : MlInferTrainedModelQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlInferTrainedModelBody {
  docs : Array[Map[String, Json]]
  inference_config : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlInferTrainedModelBody with fn to_json(
  self : MlInferTrainedModelBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  match self.inference_config {
    Some(value) => obj["inference_config"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlInferTrainedModelBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlInferTrainedModelBody: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
    inference_config: match obj.get("inference_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("inference_config")))
    },
  }
}

///|
pub fn MlInferTrainedModelBody::new(
  docs : Array[Map[String, Json]],
  inference_config? : Json,
) -> MlInferTrainedModelBody {
  { docs, inference_config }
}

///|
pub(all) struct MlInferTrainedModelResponse {
  inference_results : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlInferTrainedModelResponse with fn to_json(
  self : MlInferTrainedModelResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["inference_results"] = self.inference_results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlInferTrainedModelResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlInferTrainedModelResponse: expected object"),
    )
  }
  {
    inference_results: @json.from_json(
      obj.get("inference_results").unwrap_or(Json::null()),
      path=path.add_key("inference_results"),
    ),
  }
}

///|
pub(all) struct MlInferTrainedModelRequest {
  model_id : String
  query : MlInferTrainedModelQuery
  body : MlInferTrainedModelBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlInferTrainedModelRequest::new(
  model_id : String,
  body : MlInferTrainedModelBody,
  query? : MlInferTrainedModelQuery = MlInferTrainedModelQuery::new(),
) -> MlInferTrainedModelRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_infer_trained_model(
  self : Client,
  request : MlInferTrainedModelRequest,
) -> EsResponse[MlInferTrainedModelResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/trained_models/{model_id}/_infer", ["model_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlInfoQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlInfoQuery with fn to_json(_self : MlInfoQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlInfoQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlInfoQuery: expected object"))
  }
  MlInfoQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlInfoQuery::new() -> MlInfoQuery {
  MlInfoQuery::{  }
}

///|
pub fn MlInfoQuery::to_pairs(_self : MlInfoQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlInfoResponse {
  defaults : Json
  limits : Json
  upgrade_mode : Bool
  native_code : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlInfoResponse with fn to_json(self : MlInfoResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["defaults"] = self.defaults.to_json()
  obj["limits"] = self.limits.to_json()
  obj["upgrade_mode"] = self.upgrade_mode.to_json()
  obj["native_code"] = self.native_code.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlInfoResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlInfoResponse: expected object"))
  }
  {
    defaults: @json.from_json(
      obj.get("defaults").unwrap_or(Json::null()),
      path=path.add_key("defaults"),
    ),
    limits: @json.from_json(
      obj.get("limits").unwrap_or(Json::null()),
      path=path.add_key("limits"),
    ),
    upgrade_mode: @json.from_json(
      obj.get("upgrade_mode").unwrap_or(Json::null()),
      path=path.add_key("upgrade_mode"),
    ),
    native_code: @json.from_json(
      obj.get("native_code").unwrap_or(Json::null()),
      path=path.add_key("native_code"),
    ),
  }
}

///|
pub(all) struct MlInfoRequest {
  query : MlInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlInfoRequest::new(
  query? : MlInfoQuery = MlInfoQuery::new(),
) -> MlInfoRequest {
  { query, }
}

///|
pub async fn Client::ml_info(
  self : Client,
  request : MlInfoRequest,
) -> EsResponse[MlInfoResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ml/info", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct MlOpenJobQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlOpenJobQuery with fn to_json(self : MlOpenJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlOpenJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlOpenJobQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlOpenJobQuery::new(timeout? : String) -> MlOpenJobQuery {
  { timeout, }
}

///|
pub fn MlOpenJobQuery::to_pairs(
  self : MlOpenJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlOpenJobBody {
  timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlOpenJobBody with fn to_json(self : MlOpenJobBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlOpenJobBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlOpenJobBody: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlOpenJobBody::new(timeout? : Json) -> MlOpenJobBody {
  { timeout, }
}

///|
pub(all) struct MlOpenJobResponse {
  opened : Bool
  node : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlOpenJobResponse with fn to_json(self : MlOpenJobResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["opened"] = self.opened.to_json()
  obj["node"] = self.node.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlOpenJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlOpenJobResponse: expected object"))
  }
  {
    opened: @json.from_json(
      obj.get("opened").unwrap_or(Json::null()),
      path=path.add_key("opened"),
    ),
    node: @json.from_json(
      obj.get("node").unwrap_or(Json::null()),
      path=path.add_key("node"),
    ),
  }
}

///|
pub(all) struct MlOpenJobRequest {
  job_id : String
  query : MlOpenJobQuery
  body : MlOpenJobBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlOpenJobRequest::new(
  job_id : String,
  query? : MlOpenJobQuery = MlOpenJobQuery::new(),
  body? : MlOpenJobBody,
) -> MlOpenJobRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_open_job(
  self : Client,
  request : MlOpenJobRequest,
) -> EsResponse[MlOpenJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_open", ["job_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlPostCalendarEventsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPostCalendarEventsQuery with fn to_json(
  _self : MlPostCalendarEventsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPostCalendarEventsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlPostCalendarEventsQuery: expected object"))
  }
  MlPostCalendarEventsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPostCalendarEventsQuery::new() -> MlPostCalendarEventsQuery {
  MlPostCalendarEventsQuery::{  }
}

///|
pub fn MlPostCalendarEventsQuery::to_pairs(
  _self : MlPostCalendarEventsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPostCalendarEventsBody {
  events : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlPostCalendarEventsBody with fn to_json(
  self : MlPostCalendarEventsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["events"] = self.events.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPostCalendarEventsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPostCalendarEventsBody: expected object"))
  }
  {
    events: @json.from_json(
      obj.get("events").unwrap_or(Json::null()),
      path=path.add_key("events"),
    ),
  }
}

///|
pub fn MlPostCalendarEventsBody::new(
  events : Array[Json],
) -> MlPostCalendarEventsBody {
  { events, }
}

///|
pub(all) struct MlPostCalendarEventsResponse {
  events : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MlPostCalendarEventsResponse with fn to_json(
  self : MlPostCalendarEventsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["events"] = self.events.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPostCalendarEventsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPostCalendarEventsResponse: expected object"),
    )
  }
  {
    events: @json.from_json(
      obj.get("events").unwrap_or(Json::null()),
      path=path.add_key("events"),
    ),
  }
}

///|
pub(all) struct MlPostCalendarEventsRequest {
  calendar_id : String
  query : MlPostCalendarEventsQuery
  body : MlPostCalendarEventsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPostCalendarEventsRequest::new(
  calendar_id : String,
  body : MlPostCalendarEventsBody,
  query? : MlPostCalendarEventsQuery = MlPostCalendarEventsQuery::new(),
) -> MlPostCalendarEventsRequest {
  { calendar_id, query, body }
}

///|
pub async fn Client::ml_post_calendar_events(
  self : Client,
  request : MlPostCalendarEventsRequest,
) -> EsResponse[MlPostCalendarEventsResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/calendars/{calendar_id}/events", ["calendar_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlPostDataQuery {
  reset_end : String?
  reset_start : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPostDataQuery with fn to_json(self : MlPostDataQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.reset_end {
    Some(value) => obj["reset_end"] = value.to_json()
    None => ()
  }
  match self.reset_start {
    Some(value) => obj["reset_start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPostDataQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPostDataQuery: expected object"))
  }
  {
    reset_end: match obj.get("reset_end") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("reset_end")))
    },
    reset_start: match obj.get("reset_start") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("reset_start")))
    },
  }
}

///|
pub fn MlPostDataQuery::new(
  reset_end? : String,
  reset_start? : String,
) -> MlPostDataQuery {
  { reset_end, reset_start }
}

///|
pub fn MlPostDataQuery::to_pairs(
  self : MlPostDataQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.reset_end {
    Some(value) => push_query_json(pairs, "reset_end", value.to_json())
    None => ()
  }
  match self.reset_start {
    Some(value) => push_query_json(pairs, "reset_start", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlPostDataBody = Array[Json]

///|
pub(all) struct MlPostDataResponse {
  job_id : Json
  processed_record_count : Int
  processed_field_count : Int
  input_bytes : Int
  input_field_count : Int
  invalid_date_count : Int
  missing_field_count : Int
  out_of_order_timestamp_count : Int
  empty_bucket_count : Int
  sparse_bucket_count : Int
  bucket_count : Int
  earliest_record_timestamp : Json?
  latest_record_timestamp : Json?
  last_data_time : Json?
  latest_empty_bucket_timestamp : Json?
  latest_sparse_bucket_timestamp : Json?
  input_record_count : Int
  log_time : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPostDataResponse with fn to_json(
  self : MlPostDataResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["job_id"] = self.job_id.to_json()
  obj["processed_record_count"] = self.processed_record_count.to_json()
  obj["processed_field_count"] = self.processed_field_count.to_json()
  obj["input_bytes"] = self.input_bytes.to_json()
  obj["input_field_count"] = self.input_field_count.to_json()
  obj["invalid_date_count"] = self.invalid_date_count.to_json()
  obj["missing_field_count"] = self.missing_field_count.to_json()
  obj["out_of_order_timestamp_count"] = self.out_of_order_timestamp_count.to_json()
  obj["empty_bucket_count"] = self.empty_bucket_count.to_json()
  obj["sparse_bucket_count"] = self.sparse_bucket_count.to_json()
  obj["bucket_count"] = self.bucket_count.to_json()
  match self.earliest_record_timestamp {
    Some(value) => obj["earliest_record_timestamp"] = value.to_json()
    None => ()
  }
  match self.latest_record_timestamp {
    Some(value) => obj["latest_record_timestamp"] = value.to_json()
    None => ()
  }
  match self.last_data_time {
    Some(value) => obj["last_data_time"] = value.to_json()
    None => ()
  }
  match self.latest_empty_bucket_timestamp {
    Some(value) => obj["latest_empty_bucket_timestamp"] = value.to_json()
    None => ()
  }
  match self.latest_sparse_bucket_timestamp {
    Some(value) => obj["latest_sparse_bucket_timestamp"] = value.to_json()
    None => ()
  }
  obj["input_record_count"] = self.input_record_count.to_json()
  match self.log_time {
    Some(value) => obj["log_time"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPostDataResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPostDataResponse: expected object"))
  }
  {
    job_id: @json.from_json(
      obj.get("job_id").unwrap_or(Json::null()),
      path=path.add_key("job_id"),
    ),
    processed_record_count: @json.from_json(
      obj.get("processed_record_count").unwrap_or(Json::null()),
      path=path.add_key("processed_record_count"),
    ),
    processed_field_count: @json.from_json(
      obj.get("processed_field_count").unwrap_or(Json::null()),
      path=path.add_key("processed_field_count"),
    ),
    input_bytes: @json.from_json(
      obj.get("input_bytes").unwrap_or(Json::null()),
      path=path.add_key("input_bytes"),
    ),
    input_field_count: @json.from_json(
      obj.get("input_field_count").unwrap_or(Json::null()),
      path=path.add_key("input_field_count"),
    ),
    invalid_date_count: @json.from_json(
      obj.get("invalid_date_count").unwrap_or(Json::null()),
      path=path.add_key("invalid_date_count"),
    ),
    missing_field_count: @json.from_json(
      obj.get("missing_field_count").unwrap_or(Json::null()),
      path=path.add_key("missing_field_count"),
    ),
    out_of_order_timestamp_count: @json.from_json(
      obj.get("out_of_order_timestamp_count").unwrap_or(Json::null()),
      path=path.add_key("out_of_order_timestamp_count"),
    ),
    empty_bucket_count: @json.from_json(
      obj.get("empty_bucket_count").unwrap_or(Json::null()),
      path=path.add_key("empty_bucket_count"),
    ),
    sparse_bucket_count: @json.from_json(
      obj.get("sparse_bucket_count").unwrap_or(Json::null()),
      path=path.add_key("sparse_bucket_count"),
    ),
    bucket_count: @json.from_json(
      obj.get("bucket_count").unwrap_or(Json::null()),
      path=path.add_key("bucket_count"),
    ),
    earliest_record_timestamp: match obj.get("earliest_record_timestamp") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("earliest_record_timestamp")),
        )
    },
    latest_record_timestamp: match obj.get("latest_record_timestamp") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("latest_record_timestamp")),
        )
    },
    last_data_time: match obj.get("last_data_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("last_data_time")))
    },
    latest_empty_bucket_timestamp: match
      obj.get("latest_empty_bucket_timestamp") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("latest_empty_bucket_timestamp"),
          ),
        )
    },
    latest_sparse_bucket_timestamp: match
      obj.get("latest_sparse_bucket_timestamp") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("latest_sparse_bucket_timestamp"),
          ),
        )
    },
    input_record_count: @json.from_json(
      obj.get("input_record_count").unwrap_or(Json::null()),
      path=path.add_key("input_record_count"),
    ),
    log_time: match obj.get("log_time") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("log_time")))
    },
  }
}

///|
pub(all) struct MlPostDataRequest {
  job_id : String
  query : MlPostDataQuery
  body : MlPostDataBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPostDataRequest::new(
  job_id : String,
  body : MlPostDataBody,
  query? : MlPostDataQuery = MlPostDataQuery::new(),
) -> MlPostDataRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_post_data(
  self : Client,
  request : MlPostDataRequest,
) -> EsResponse[MlPostDataResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_data", ["job_id"])],
    params,
  )
  let body = Ndjson(request.body)
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlPreviewDataFrameAnalyticsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPreviewDataFrameAnalyticsQuery with fn to_json(
  _self : MlPreviewDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPreviewDataFrameAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlPreviewDataFrameAnalyticsQuery: expected object"),
    )
  }
  MlPreviewDataFrameAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPreviewDataFrameAnalyticsQuery::new() -> MlPreviewDataFrameAnalyticsQuery {
  MlPreviewDataFrameAnalyticsQuery::{  }
}

///|
pub fn MlPreviewDataFrameAnalyticsQuery::to_pairs(
  _self : MlPreviewDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPreviewDataFrameAnalyticsBody {
  config : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPreviewDataFrameAnalyticsBody with fn to_json(
  self : MlPreviewDataFrameAnalyticsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.config {
    Some(value) => obj["config"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPreviewDataFrameAnalyticsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPreviewDataFrameAnalyticsBody: expected object"),
    )
  }
  {
    config: match obj.get("config") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("config")))
    },
  }
}

///|
pub fn MlPreviewDataFrameAnalyticsBody::new(
  config? : Json,
) -> MlPreviewDataFrameAnalyticsBody {
  { config, }
}

///|
pub(all) struct MlPreviewDataFrameAnalyticsResponse {
  feature_values : Array[Map[String, Json]]
} derive(Eq, Debug)

///|
pub impl ToJson for MlPreviewDataFrameAnalyticsResponse with fn to_json(
  self : MlPreviewDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["feature_values"] = self.feature_values.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPreviewDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPreviewDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    feature_values: @json.from_json(
      obj.get("feature_values").unwrap_or(Json::null()),
      path=path.add_key("feature_values"),
    ),
  }
}

///|
pub(all) struct MlPreviewDataFrameAnalyticsRequest {
  id : String?
  query : MlPreviewDataFrameAnalyticsQuery
  body : MlPreviewDataFrameAnalyticsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPreviewDataFrameAnalyticsRequest::new(
  id? : String,
  query? : MlPreviewDataFrameAnalyticsQuery = MlPreviewDataFrameAnalyticsQuery::new(),
  body? : MlPreviewDataFrameAnalyticsBody,
) -> MlPreviewDataFrameAnalyticsRequest {
  { id, query, body }
}

///|
pub async fn Client::ml_preview_data_frame_analytics(
  self : Client,
  request : MlPreviewDataFrameAnalyticsRequest,
) -> EsResponse[MlPreviewDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/data_frame/analytics/{id}/_preview", ["id"]),
      PathVariant::new("/_ml/data_frame/analytics/_preview", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlPreviewDatafeedQuery {
  start : String?
  end : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPreviewDatafeedQuery with fn to_json(
  self : MlPreviewDatafeedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPreviewDatafeedQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPreviewDatafeedQuery: expected object"))
  }
  {
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
  }
}

///|
pub fn MlPreviewDatafeedQuery::new(
  start? : String,
  end? : String,
) -> MlPreviewDatafeedQuery {
  { start, end }
}

///|
pub fn MlPreviewDatafeedQuery::to_pairs(
  self : MlPreviewDatafeedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlPreviewDatafeedBody {
  datafeed_config : Json?
  job_config : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPreviewDatafeedBody with fn to_json(
  self : MlPreviewDatafeedBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.datafeed_config {
    Some(value) => obj["datafeed_config"] = value.to_json()
    None => ()
  }
  match self.job_config {
    Some(value) => obj["job_config"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPreviewDatafeedBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPreviewDatafeedBody: expected object"))
  }
  {
    datafeed_config: match obj.get("datafeed_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("datafeed_config")))
    },
    job_config: match obj.get("job_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("job_config")))
    },
  }
}

///|
pub fn MlPreviewDatafeedBody::new(
  datafeed_config? : Json,
  job_config? : Json,
) -> MlPreviewDatafeedBody {
  { datafeed_config, job_config }
}

///|
pub type MlPreviewDatafeedResponse = Json

///|
pub(all) struct MlPreviewDatafeedRequest {
  datafeed_id : String?
  query : MlPreviewDatafeedQuery
  body : MlPreviewDatafeedBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPreviewDatafeedRequest::new(
  datafeed_id? : String,
  query? : MlPreviewDatafeedQuery = MlPreviewDatafeedQuery::new(),
  body? : MlPreviewDatafeedBody,
) -> MlPreviewDatafeedRequest {
  { datafeed_id, query, body }
}

///|
pub async fn Client::ml_preview_datafeed(
  self : Client,
  request : MlPreviewDatafeedRequest,
) -> EsResponse[MlPreviewDatafeedResponse] {
  let params : Map[String, String] = Map([])
  match request.datafeed_id {
    Some(value) => params["datafeed_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/datafeeds/{datafeed_id}/_preview", ["datafeed_id"]),
      PathVariant::new("/_ml/datafeeds/_preview", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlPutCalendarQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPutCalendarQuery with fn to_json(
  _self : MlPutCalendarQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPutCalendarQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlPutCalendarQuery: expected object"))
  }
  MlPutCalendarQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPutCalendarQuery::new() -> MlPutCalendarQuery {
  MlPutCalendarQuery::{  }
}

///|
pub fn MlPutCalendarQuery::to_pairs(
  _self : MlPutCalendarQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPutCalendarBody {
  job_ids : Array[Json]?
  description : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutCalendarBody with fn to_json(self : MlPutCalendarBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.job_ids {
    Some(value) => obj["job_ids"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutCalendarBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutCalendarBody: expected object"))
  }
  {
    job_ids: match obj.get("job_ids") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_ids")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
  }
}

///|
pub fn MlPutCalendarBody::new(
  job_ids? : Array[Json],
  description? : String,
) -> MlPutCalendarBody {
  { job_ids, description }
}

///|
pub(all) struct MlPutCalendarResponse {
  calendar_id : Json
  description : String?
  job_ids : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutCalendarResponse with fn to_json(
  self : MlPutCalendarResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["calendar_id"] = self.calendar_id.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["job_ids"] = self.job_ids.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPutCalendarResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutCalendarResponse: expected object"))
  }
  {
    calendar_id: @json.from_json(
      obj.get("calendar_id").unwrap_or(Json::null()),
      path=path.add_key("calendar_id"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    job_ids: @json.from_json(
      obj.get("job_ids").unwrap_or(Json::null()),
      path=path.add_key("job_ids"),
    ),
  }
}

///|
pub(all) struct MlPutCalendarRequest {
  calendar_id : String
  query : MlPutCalendarQuery
  body : MlPutCalendarBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutCalendarRequest::new(
  calendar_id : String,
  query? : MlPutCalendarQuery = MlPutCalendarQuery::new(),
  body? : MlPutCalendarBody,
) -> MlPutCalendarRequest {
  { calendar_id, query, body }
}

///|
pub async fn Client::ml_put_calendar(
  self : Client,
  request : MlPutCalendarRequest,
) -> EsResponse[MlPutCalendarResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/calendars/{calendar_id}", ["calendar_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutCalendarJobQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPutCalendarJobQuery with fn to_json(
  _self : MlPutCalendarJobQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPutCalendarJobQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlPutCalendarJobQuery: expected object"))
  }
  MlPutCalendarJobQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPutCalendarJobQuery::new() -> MlPutCalendarJobQuery {
  MlPutCalendarJobQuery::{  }
}

///|
pub fn MlPutCalendarJobQuery::to_pairs(
  _self : MlPutCalendarJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPutCalendarJobResponse {
  calendar_id : Json
  description : String?
  job_ids : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutCalendarJobResponse with fn to_json(
  self : MlPutCalendarJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["calendar_id"] = self.calendar_id.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["job_ids"] = self.job_ids.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPutCalendarJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutCalendarJobResponse: expected object"))
  }
  {
    calendar_id: @json.from_json(
      obj.get("calendar_id").unwrap_or(Json::null()),
      path=path.add_key("calendar_id"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    job_ids: @json.from_json(
      obj.get("job_ids").unwrap_or(Json::null()),
      path=path.add_key("job_ids"),
    ),
  }
}

///|
pub(all) struct MlPutCalendarJobRequest {
  calendar_id : String
  job_id : String
  query : MlPutCalendarJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutCalendarJobRequest::new(
  calendar_id : String,
  job_id : String,
  query? : MlPutCalendarJobQuery = MlPutCalendarJobQuery::new(),
) -> MlPutCalendarJobRequest {
  { calendar_id, job_id, query }
}

///|
pub async fn Client::ml_put_calendar_job(
  self : Client,
  request : MlPutCalendarJobRequest,
) -> EsResponse[MlPutCalendarJobResponse] {
  let params : Map[String, String] = Map([])
  params["calendar_id"] = request.calendar_id
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/calendars/{calendar_id}/jobs/{job_id}", [
        "calendar_id", "job_id",
      ]),
    ],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct MlPutDataFrameAnalyticsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPutDataFrameAnalyticsQuery with fn to_json(
  _self : MlPutDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPutDataFrameAnalyticsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlPutDataFrameAnalyticsQuery: expected object"),
    )
  }
  MlPutDataFrameAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPutDataFrameAnalyticsQuery::new() -> MlPutDataFrameAnalyticsQuery {
  MlPutDataFrameAnalyticsQuery::{  }
}

///|
pub fn MlPutDataFrameAnalyticsQuery::to_pairs(
  _self : MlPutDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPutDataFrameAnalyticsBody {
  allow_lazy_start : Bool?
  analysis : Json
  analyzed_fields : Json?
  description : String?
  dest : Json
  max_num_threads : Int?
  _meta : Json?
  model_memory_limit : String?
  source : Json
  headers : Json?
  version : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutDataFrameAnalyticsBody with fn to_json(
  self : MlPutDataFrameAnalyticsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_lazy_start {
    Some(value) => obj["allow_lazy_start"] = value.to_json()
    None => ()
  }
  obj["analysis"] = self.analysis.to_json()
  match self.analyzed_fields {
    Some(value) => obj["analyzed_fields"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["dest"] = self.dest.to_json()
  match self.max_num_threads {
    Some(value) => obj["max_num_threads"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.model_memory_limit {
    Some(value) => obj["model_memory_limit"] = value.to_json()
    None => ()
  }
  obj["source"] = self.source.to_json()
  match self.headers {
    Some(value) => obj["headers"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutDataFrameAnalyticsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPutDataFrameAnalyticsBody: expected object"),
    )
  }
  {
    allow_lazy_start: match obj.get("allow_lazy_start") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_lazy_start")))
    },
    analysis: @json.from_json(
      obj.get("analysis").unwrap_or(Json::null()),
      path=path.add_key("analysis"),
    ),
    analyzed_fields: match obj.get("analyzed_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyzed_fields")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    dest: @json.from_json(
      obj.get("dest").unwrap_or(Json::null()),
      path=path.add_key("dest"),
    ),
    max_num_threads: match obj.get("max_num_threads") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_num_threads")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    model_memory_limit: match obj.get("model_memory_limit") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_memory_limit")))
    },
    source: @json.from_json(
      obj.get("source").unwrap_or(Json::null()),
      path=path.add_key("source"),
    ),
    headers: match obj.get("headers") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("headers")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
  }
}

///|
pub fn MlPutDataFrameAnalyticsBody::new(
  analysis : Json,
  dest : Json,
  source : Json,
  allow_lazy_start? : Bool,
  analyzed_fields? : Json,
  description? : String,
  max_num_threads? : Int,
  _meta? : Json,
  model_memory_limit? : String,
  headers? : Json,
  version? : Json,
) -> MlPutDataFrameAnalyticsBody {
  {
    allow_lazy_start,
    analysis,
    analyzed_fields,
    description,
    dest,
    max_num_threads,
    _meta,
    model_memory_limit,
    source,
    headers,
    version,
  }
}

///|
pub(all) struct MlPutDataFrameAnalyticsResponse {
  authorization : Json?
  allow_lazy_start : Bool
  analysis : Json
  analyzed_fields : Json?
  create_time : Json
  description : String?
  dest : Json
  id : Json
  max_num_threads : Int
  _meta : Json?
  model_memory_limit : String
  source : Json
  version : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutDataFrameAnalyticsResponse with fn to_json(
  self : MlPutDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.authorization {
    Some(value) => obj["authorization"] = value.to_json()
    None => ()
  }
  obj["allow_lazy_start"] = self.allow_lazy_start.to_json()
  obj["analysis"] = self.analysis.to_json()
  match self.analyzed_fields {
    Some(value) => obj["analyzed_fields"] = value.to_json()
    None => ()
  }
  obj["create_time"] = self.create_time.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["dest"] = self.dest.to_json()
  obj["id"] = self.id.to_json()
  obj["max_num_threads"] = self.max_num_threads.to_json()
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  obj["model_memory_limit"] = self.model_memory_limit.to_json()
  obj["source"] = self.source.to_json()
  obj["version"] = self.version.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPutDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPutDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    authorization: match obj.get("authorization") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("authorization")))
    },
    allow_lazy_start: @json.from_json(
      obj.get("allow_lazy_start").unwrap_or(Json::null()),
      path=path.add_key("allow_lazy_start"),
    ),
    analysis: @json.from_json(
      obj.get("analysis").unwrap_or(Json::null()),
      path=path.add_key("analysis"),
    ),
    analyzed_fields: match obj.get("analyzed_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyzed_fields")))
    },
    create_time: @json.from_json(
      obj.get("create_time").unwrap_or(Json::null()),
      path=path.add_key("create_time"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    dest: @json.from_json(
      obj.get("dest").unwrap_or(Json::null()),
      path=path.add_key("dest"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    max_num_threads: @json.from_json(
      obj.get("max_num_threads").unwrap_or(Json::null()),
      path=path.add_key("max_num_threads"),
    ),
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    model_memory_limit: @json.from_json(
      obj.get("model_memory_limit").unwrap_or(Json::null()),
      path=path.add_key("model_memory_limit"),
    ),
    source: @json.from_json(
      obj.get("source").unwrap_or(Json::null()),
      path=path.add_key("source"),
    ),
    version: @json.from_json(
      obj.get("version").unwrap_or(Json::null()),
      path=path.add_key("version"),
    ),
  }
}

///|
pub(all) struct MlPutDataFrameAnalyticsRequest {
  id : String
  query : MlPutDataFrameAnalyticsQuery
  body : MlPutDataFrameAnalyticsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutDataFrameAnalyticsRequest::new(
  id : String,
  body : MlPutDataFrameAnalyticsBody,
  query? : MlPutDataFrameAnalyticsQuery = MlPutDataFrameAnalyticsQuery::new(),
) -> MlPutDataFrameAnalyticsRequest {
  { id, query, body }
}

///|
pub async fn Client::ml_put_data_frame_analytics(
  self : Client,
  request : MlPutDataFrameAnalyticsRequest,
) -> EsResponse[MlPutDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/data_frame/analytics/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutDatafeedQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutDatafeedQuery with fn to_json(
  self : MlPutDatafeedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutDatafeedQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutDatafeedQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn MlPutDatafeedQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
) -> MlPutDatafeedQuery {
  { allow_no_indices, expand_wildcards, ignore_throttled, ignore_unavailable }
}

///|
pub fn MlPutDatafeedQuery::to_pairs(
  self : MlPutDatafeedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlPutDatafeedBody {
  aggregations : Map[String, Json]?
  chunking_config : Json?
  delayed_data_check_config : Json?
  frequency : Json?
  indices : Json?
  indices_options : Json?
  job_id : Json?
  max_empty_searches : Int?
  query : Json?
  query_delay : Json?
  runtime_mappings : Json?
  script_fields : Map[String, Json]?
  scroll_size : Int?
  headers : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutDatafeedBody with fn to_json(self : MlPutDatafeedBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.chunking_config {
    Some(value) => obj["chunking_config"] = value.to_json()
    None => ()
  }
  match self.delayed_data_check_config {
    Some(value) => obj["delayed_data_check_config"] = value.to_json()
    None => ()
  }
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  match self.indices {
    Some(value) => obj["indices"] = value.to_json()
    None => ()
  }
  match self.indices_options {
    Some(value) => obj["indices_options"] = value.to_json()
    None => ()
  }
  match self.job_id {
    Some(value) => obj["job_id"] = value.to_json()
    None => ()
  }
  match self.max_empty_searches {
    Some(value) => obj["max_empty_searches"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.query_delay {
    Some(value) => obj["query_delay"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  match self.scroll_size {
    Some(value) => obj["scroll_size"] = value.to_json()
    None => ()
  }
  match self.headers {
    Some(value) => obj["headers"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutDatafeedBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutDatafeedBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    chunking_config: match obj.get("chunking_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_config")))
    },
    delayed_data_check_config: match obj.get("delayed_data_check_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("delayed_data_check_config")),
        )
    },
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    indices: match obj.get("indices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("indices")))
    },
    indices_options: match obj.get("indices_options") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_options")))
    },
    job_id: match obj.get("job_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_id")))
    },
    max_empty_searches: match obj.get("max_empty_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_empty_searches")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    query_delay: match obj.get("query_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("query_delay")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    scroll_size: match obj.get("scroll_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("scroll_size")))
    },
    headers: match obj.get("headers") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("headers")))
    },
  }
}

///|
pub fn MlPutDatafeedBody::new(
  aggregations? : Map[String, Json],
  chunking_config? : Json,
  delayed_data_check_config? : Json,
  frequency? : Json,
  indices? : Json,
  indices_options? : Json,
  job_id? : Json,
  max_empty_searches? : Int,
  query? : Json,
  query_delay? : Json,
  runtime_mappings? : Json,
  script_fields? : Map[String, Json],
  scroll_size? : Int,
  headers? : Json,
) -> MlPutDatafeedBody {
  {
    aggregations,
    chunking_config,
    delayed_data_check_config,
    frequency,
    indices,
    indices_options,
    job_id,
    max_empty_searches,
    query,
    query_delay,
    runtime_mappings,
    script_fields,
    scroll_size,
    headers,
  }
}

///|
pub(all) struct MlPutDatafeedResponse {
  aggregations : Map[String, Json]?
  authorization : Json?
  chunking_config : Json
  delayed_data_check_config : Json?
  datafeed_id : Json
  frequency : Json?
  indices : Array[String]
  job_id : Json
  indices_options : Json?
  max_empty_searches : Int?
  query : Json
  query_delay : Json
  runtime_mappings : Json?
  script_fields : Map[String, Json]?
  scroll_size : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutDatafeedResponse with fn to_json(
  self : MlPutDatafeedResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.authorization {
    Some(value) => obj["authorization"] = value.to_json()
    None => ()
  }
  obj["chunking_config"] = self.chunking_config.to_json()
  match self.delayed_data_check_config {
    Some(value) => obj["delayed_data_check_config"] = value.to_json()
    None => ()
  }
  obj["datafeed_id"] = self.datafeed_id.to_json()
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  obj["indices"] = self.indices.to_json()
  obj["job_id"] = self.job_id.to_json()
  match self.indices_options {
    Some(value) => obj["indices_options"] = value.to_json()
    None => ()
  }
  match self.max_empty_searches {
    Some(value) => obj["max_empty_searches"] = value.to_json()
    None => ()
  }
  obj["query"] = self.query.to_json()
  obj["query_delay"] = self.query_delay.to_json()
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  obj["scroll_size"] = self.scroll_size.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPutDatafeedResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutDatafeedResponse: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    authorization: match obj.get("authorization") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("authorization")))
    },
    chunking_config: @json.from_json(
      obj.get("chunking_config").unwrap_or(Json::null()),
      path=path.add_key("chunking_config"),
    ),
    delayed_data_check_config: match obj.get("delayed_data_check_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("delayed_data_check_config")),
        )
    },
    datafeed_id: @json.from_json(
      obj.get("datafeed_id").unwrap_or(Json::null()),
      path=path.add_key("datafeed_id"),
    ),
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    job_id: @json.from_json(
      obj.get("job_id").unwrap_or(Json::null()),
      path=path.add_key("job_id"),
    ),
    indices_options: match obj.get("indices_options") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_options")))
    },
    max_empty_searches: match obj.get("max_empty_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_empty_searches")))
    },
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    query_delay: @json.from_json(
      obj.get("query_delay").unwrap_or(Json::null()),
      path=path.add_key("query_delay"),
    ),
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    scroll_size: @json.from_json(
      obj.get("scroll_size").unwrap_or(Json::null()),
      path=path.add_key("scroll_size"),
    ),
  }
}

///|
pub(all) struct MlPutDatafeedRequest {
  datafeed_id : String
  query : MlPutDatafeedQuery
  body : MlPutDatafeedBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutDatafeedRequest::new(
  datafeed_id : String,
  body : MlPutDatafeedBody,
  query? : MlPutDatafeedQuery = MlPutDatafeedQuery::new(),
) -> MlPutDatafeedRequest {
  { datafeed_id, query, body }
}

///|
pub async fn Client::ml_put_datafeed(
  self : Client,
  request : MlPutDatafeedRequest,
) -> EsResponse[MlPutDatafeedResponse] {
  let params : Map[String, String] = Map([])
  params["datafeed_id"] = request.datafeed_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/datafeeds/{datafeed_id}", ["datafeed_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutFilterQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPutFilterQuery with fn to_json(_self : MlPutFilterQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPutFilterQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlPutFilterQuery: expected object"))
  }
  MlPutFilterQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPutFilterQuery::new() -> MlPutFilterQuery {
  MlPutFilterQuery::{  }
}

///|
pub fn MlPutFilterQuery::to_pairs(
  _self : MlPutFilterQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPutFilterBody {
  description : String?
  items : Array[String]?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutFilterBody with fn to_json(self : MlPutFilterBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.items {
    Some(value) => obj["items"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutFilterBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutFilterBody: expected object"))
  }
  {
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    items: match obj.get("items") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("items")))
    },
  }
}

///|
pub fn MlPutFilterBody::new(
  description? : String,
  items? : Array[String],
) -> MlPutFilterBody {
  { description, items }
}

///|
pub(all) struct MlPutFilterResponse {
  description : String
  filter_id : Json
  items : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutFilterResponse with fn to_json(
  self : MlPutFilterResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["description"] = self.description.to_json()
  obj["filter_id"] = self.filter_id.to_json()
  obj["items"] = self.items.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPutFilterResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutFilterResponse: expected object"))
  }
  {
    description: @json.from_json(
      obj.get("description").unwrap_or(Json::null()),
      path=path.add_key("description"),
    ),
    filter_id: @json.from_json(
      obj.get("filter_id").unwrap_or(Json::null()),
      path=path.add_key("filter_id"),
    ),
    items: @json.from_json(
      obj.get("items").unwrap_or(Json::null()),
      path=path.add_key("items"),
    ),
  }
}

///|
pub(all) struct MlPutFilterRequest {
  filter_id : String
  query : MlPutFilterQuery
  body : MlPutFilterBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutFilterRequest::new(
  filter_id : String,
  body : MlPutFilterBody,
  query? : MlPutFilterQuery = MlPutFilterQuery::new(),
) -> MlPutFilterRequest {
  { filter_id, query, body }
}

///|
pub async fn Client::ml_put_filter(
  self : Client,
  request : MlPutFilterRequest,
) -> EsResponse[MlPutFilterResponse] {
  let params : Map[String, String] = Map([])
  params["filter_id"] = request.filter_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/filters/{filter_id}", ["filter_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutJobQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutJobQuery with fn to_json(self : MlPutJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutJobQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn MlPutJobQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
) -> MlPutJobQuery {
  { allow_no_indices, expand_wildcards, ignore_throttled, ignore_unavailable }
}

///|
pub fn MlPutJobQuery::to_pairs(self : MlPutJobQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlPutJobBody {
  allow_lazy_open : Bool?
  analysis_config : Json
  analysis_limits : Json?
  background_persist_interval : Json?
  custom_settings : Json?
  daily_model_snapshot_retention_after_days : Int?
  data_description : Json
  datafeed_config : Json?
  description : String?
  job_id : Json?
  groups : Array[String]?
  model_plot_config : Json?
  model_snapshot_retention_days : Int?
  renormalization_window_days : Int?
  results_index_name : Json?
  results_retention_days : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutJobBody with fn to_json(self : MlPutJobBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_lazy_open {
    Some(value) => obj["allow_lazy_open"] = value.to_json()
    None => ()
  }
  obj["analysis_config"] = self.analysis_config.to_json()
  match self.analysis_limits {
    Some(value) => obj["analysis_limits"] = value.to_json()
    None => ()
  }
  match self.background_persist_interval {
    Some(value) => obj["background_persist_interval"] = value.to_json()
    None => ()
  }
  match self.custom_settings {
    Some(value) => obj["custom_settings"] = value.to_json()
    None => ()
  }
  match self.daily_model_snapshot_retention_after_days {
    Some(value) =>
      obj["daily_model_snapshot_retention_after_days"] = value.to_json()
    None => ()
  }
  obj["data_description"] = self.data_description.to_json()
  match self.datafeed_config {
    Some(value) => obj["datafeed_config"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.job_id {
    Some(value) => obj["job_id"] = value.to_json()
    None => ()
  }
  match self.groups {
    Some(value) => obj["groups"] = value.to_json()
    None => ()
  }
  match self.model_plot_config {
    Some(value) => obj["model_plot_config"] = value.to_json()
    None => ()
  }
  match self.model_snapshot_retention_days {
    Some(value) => obj["model_snapshot_retention_days"] = value.to_json()
    None => ()
  }
  match self.renormalization_window_days {
    Some(value) => obj["renormalization_window_days"] = value.to_json()
    None => ()
  }
  match self.results_index_name {
    Some(value) => obj["results_index_name"] = value.to_json()
    None => ()
  }
  match self.results_retention_days {
    Some(value) => obj["results_retention_days"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutJobBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutJobBody: expected object"))
  }
  {
    allow_lazy_open: match obj.get("allow_lazy_open") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_lazy_open")))
    },
    analysis_config: @json.from_json(
      obj.get("analysis_config").unwrap_or(Json::null()),
      path=path.add_key("analysis_config"),
    ),
    analysis_limits: match obj.get("analysis_limits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analysis_limits")))
    },
    background_persist_interval: match obj.get("background_persist_interval") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("background_persist_interval"),
          ),
        )
    },
    custom_settings: match obj.get("custom_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("custom_settings")))
    },
    daily_model_snapshot_retention_after_days: match
      obj.get("daily_model_snapshot_retention_after_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("daily_model_snapshot_retention_after_days"),
          ),
        )
    },
    data_description: @json.from_json(
      obj.get("data_description").unwrap_or(Json::null()),
      path=path.add_key("data_description"),
    ),
    datafeed_config: match obj.get("datafeed_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("datafeed_config")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    job_id: match obj.get("job_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_id")))
    },
    groups: match obj.get("groups") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("groups")))
    },
    model_plot_config: match obj.get("model_plot_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_plot_config")))
    },
    model_snapshot_retention_days: match
      obj.get("model_snapshot_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("model_snapshot_retention_days"),
          ),
        )
    },
    renormalization_window_days: match obj.get("renormalization_window_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("renormalization_window_days"),
          ),
        )
    },
    results_index_name: match obj.get("results_index_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("results_index_name")))
    },
    results_retention_days: match obj.get("results_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("results_retention_days")),
        )
    },
  }
}

///|
pub fn MlPutJobBody::new(
  analysis_config : Json,
  data_description : Json,
  allow_lazy_open? : Bool,
  analysis_limits? : Json,
  background_persist_interval? : Json,
  custom_settings? : Json,
  daily_model_snapshot_retention_after_days? : Int,
  datafeed_config? : Json,
  description? : String,
  job_id? : Json,
  groups? : Array[String],
  model_plot_config? : Json,
  model_snapshot_retention_days? : Int,
  renormalization_window_days? : Int,
  results_index_name? : Json,
  results_retention_days? : Int,
) -> MlPutJobBody {
  {
    allow_lazy_open,
    analysis_config,
    analysis_limits,
    background_persist_interval,
    custom_settings,
    daily_model_snapshot_retention_after_days,
    data_description,
    datafeed_config,
    description,
    job_id,
    groups,
    model_plot_config,
    model_snapshot_retention_days,
    renormalization_window_days,
    results_index_name,
    results_retention_days,
  }
}

///|
pub(all) struct MlPutJobResponse {
  allow_lazy_open : Bool
  analysis_config : Json
  analysis_limits : Json
  background_persist_interval : Json?
  create_time : Json
  custom_settings : Json?
  daily_model_snapshot_retention_after_days : Int
  data_description : Json
  datafeed_config : Json?
  description : String?
  groups : Array[String]?
  job_id : Json
  job_type : String
  job_version : String
  model_plot_config : Json?
  model_snapshot_id : Json?
  model_snapshot_retention_days : Int
  renormalization_window_days : Int?
  results_index_name : String
  results_retention_days : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutJobResponse with fn to_json(self : MlPutJobResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["allow_lazy_open"] = self.allow_lazy_open.to_json()
  obj["analysis_config"] = self.analysis_config.to_json()
  obj["analysis_limits"] = self.analysis_limits.to_json()
  match self.background_persist_interval {
    Some(value) => obj["background_persist_interval"] = value.to_json()
    None => ()
  }
  obj["create_time"] = self.create_time.to_json()
  match self.custom_settings {
    Some(value) => obj["custom_settings"] = value.to_json()
    None => ()
  }
  obj["daily_model_snapshot_retention_after_days"] = self.daily_model_snapshot_retention_after_days.to_json()
  obj["data_description"] = self.data_description.to_json()
  match self.datafeed_config {
    Some(value) => obj["datafeed_config"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.groups {
    Some(value) => obj["groups"] = value.to_json()
    None => ()
  }
  obj["job_id"] = self.job_id.to_json()
  obj["job_type"] = self.job_type.to_json()
  obj["job_version"] = self.job_version.to_json()
  match self.model_plot_config {
    Some(value) => obj["model_plot_config"] = value.to_json()
    None => ()
  }
  match self.model_snapshot_id {
    Some(value) => obj["model_snapshot_id"] = value.to_json()
    None => ()
  }
  obj["model_snapshot_retention_days"] = self.model_snapshot_retention_days.to_json()
  match self.renormalization_window_days {
    Some(value) => obj["renormalization_window_days"] = value.to_json()
    None => ()
  }
  obj["results_index_name"] = self.results_index_name.to_json()
  match self.results_retention_days {
    Some(value) => obj["results_retention_days"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutJobResponse: expected object"))
  }
  {
    allow_lazy_open: @json.from_json(
      obj.get("allow_lazy_open").unwrap_or(Json::null()),
      path=path.add_key("allow_lazy_open"),
    ),
    analysis_config: @json.from_json(
      obj.get("analysis_config").unwrap_or(Json::null()),
      path=path.add_key("analysis_config"),
    ),
    analysis_limits: @json.from_json(
      obj.get("analysis_limits").unwrap_or(Json::null()),
      path=path.add_key("analysis_limits"),
    ),
    background_persist_interval: match obj.get("background_persist_interval") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("background_persist_interval"),
          ),
        )
    },
    create_time: @json.from_json(
      obj.get("create_time").unwrap_or(Json::null()),
      path=path.add_key("create_time"),
    ),
    custom_settings: match obj.get("custom_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("custom_settings")))
    },
    daily_model_snapshot_retention_after_days: @json.from_json(
      obj
      .get("daily_model_snapshot_retention_after_days")
      .unwrap_or(Json::null()),
      path=path.add_key("daily_model_snapshot_retention_after_days"),
    ),
    data_description: @json.from_json(
      obj.get("data_description").unwrap_or(Json::null()),
      path=path.add_key("data_description"),
    ),
    datafeed_config: match obj.get("datafeed_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("datafeed_config")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    groups: match obj.get("groups") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("groups")))
    },
    job_id: @json.from_json(
      obj.get("job_id").unwrap_or(Json::null()),
      path=path.add_key("job_id"),
    ),
    job_type: @json.from_json(
      obj.get("job_type").unwrap_or(Json::null()),
      path=path.add_key("job_type"),
    ),
    job_version: @json.from_json(
      obj.get("job_version").unwrap_or(Json::null()),
      path=path.add_key("job_version"),
    ),
    model_plot_config: match obj.get("model_plot_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_plot_config")))
    },
    model_snapshot_id: match obj.get("model_snapshot_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_snapshot_id")))
    },
    model_snapshot_retention_days: @json.from_json(
      obj.get("model_snapshot_retention_days").unwrap_or(Json::null()),
      path=path.add_key("model_snapshot_retention_days"),
    ),
    renormalization_window_days: match obj.get("renormalization_window_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("renormalization_window_days"),
          ),
        )
    },
    results_index_name: @json.from_json(
      obj.get("results_index_name").unwrap_or(Json::null()),
      path=path.add_key("results_index_name"),
    ),
    results_retention_days: match obj.get("results_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("results_retention_days")),
        )
    },
  }
}

///|
pub(all) struct MlPutJobRequest {
  job_id : String
  query : MlPutJobQuery
  body : MlPutJobBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutJobRequest::new(
  job_id : String,
  body : MlPutJobBody,
  query? : MlPutJobQuery = MlPutJobQuery::new(),
) -> MlPutJobRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_put_job(
  self : Client,
  request : MlPutJobRequest,
) -> EsResponse[MlPutJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}", ["job_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutTrainedModelQuery {
  defer_definition_decompression : Bool?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelQuery with fn to_json(
  self : MlPutTrainedModelQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.defer_definition_decompression {
    Some(value) => obj["defer_definition_decompression"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutTrainedModelQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutTrainedModelQuery: expected object"))
  }
  {
    defer_definition_decompression: match
      obj.get("defer_definition_decompression") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("defer_definition_decompression"),
          ),
        )
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn MlPutTrainedModelQuery::new(
  defer_definition_decompression? : Bool,
  wait_for_completion? : Bool,
) -> MlPutTrainedModelQuery {
  { defer_definition_decompression, wait_for_completion }
}

///|
pub fn MlPutTrainedModelQuery::to_pairs(
  self : MlPutTrainedModelQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.defer_definition_decompression {
    Some(value) =>
      push_query_json(pairs, "defer_definition_decompression", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlPutTrainedModelBody {
  compressed_definition : String?
  definition : Json?
  description : String?
  inference_config : Json?
  input : Json?
  metadata : Json?
  model_type : Json?
  model_size_bytes : Int?
  platform_architecture : String?
  tags : Array[String]?
  prefix_strings : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelBody with fn to_json(
  self : MlPutTrainedModelBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.compressed_definition {
    Some(value) => obj["compressed_definition"] = value.to_json()
    None => ()
  }
  match self.definition {
    Some(value) => obj["definition"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.inference_config {
    Some(value) => obj["inference_config"] = value.to_json()
    None => ()
  }
  match self.input {
    Some(value) => obj["input"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.model_type {
    Some(value) => obj["model_type"] = value.to_json()
    None => ()
  }
  match self.model_size_bytes {
    Some(value) => obj["model_size_bytes"] = value.to_json()
    None => ()
  }
  match self.platform_architecture {
    Some(value) => obj["platform_architecture"] = value.to_json()
    None => ()
  }
  match self.tags {
    Some(value) => obj["tags"] = value.to_json()
    None => ()
  }
  match self.prefix_strings {
    Some(value) => obj["prefix_strings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutTrainedModelBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlPutTrainedModelBody: expected object"))
  }
  {
    compressed_definition: match obj.get("compressed_definition") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("compressed_definition")))
    },
    definition: match obj.get("definition") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("definition")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    inference_config: match obj.get("inference_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("inference_config")))
    },
    input: match obj.get("input") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("input")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    model_type: match obj.get("model_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_type")))
    },
    model_size_bytes: match obj.get("model_size_bytes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_size_bytes")))
    },
    platform_architecture: match obj.get("platform_architecture") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("platform_architecture")))
    },
    tags: match obj.get("tags") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("tags")))
    },
    prefix_strings: match obj.get("prefix_strings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("prefix_strings")))
    },
  }
}

///|
pub fn MlPutTrainedModelBody::new(
  compressed_definition? : String,
  definition? : Json,
  description? : String,
  inference_config? : Json,
  input? : Json,
  metadata? : Json,
  model_type? : Json,
  model_size_bytes? : Int,
  platform_architecture? : String,
  tags? : Array[String],
  prefix_strings? : Json,
) -> MlPutTrainedModelBody {
  {
    compressed_definition,
    definition,
    description,
    inference_config,
    input,
    metadata,
    model_type,
    model_size_bytes,
    platform_architecture,
    tags,
    prefix_strings,
  }
}

///|
pub type MlPutTrainedModelResponse = Json

///|
pub(all) struct MlPutTrainedModelRequest {
  model_id : String
  query : MlPutTrainedModelQuery
  body : MlPutTrainedModelBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutTrainedModelRequest::new(
  model_id : String,
  body : MlPutTrainedModelBody,
  query? : MlPutTrainedModelQuery = MlPutTrainedModelQuery::new(),
) -> MlPutTrainedModelRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_put_trained_model(
  self : Client,
  request : MlPutTrainedModelRequest,
) -> EsResponse[MlPutTrainedModelResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/trained_models/{model_id}", ["model_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutTrainedModelAliasQuery {
  reassign : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelAliasQuery with fn to_json(
  self : MlPutTrainedModelAliasQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.reassign {
    Some(value) => obj["reassign"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutTrainedModelAliasQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPutTrainedModelAliasQuery: expected object"),
    )
  }
  {
    reassign: match obj.get("reassign") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("reassign")))
    },
  }
}

///|
pub fn MlPutTrainedModelAliasQuery::new(
  reassign? : Bool,
) -> MlPutTrainedModelAliasQuery {
  { reassign, }
}

///|
pub fn MlPutTrainedModelAliasQuery::to_pairs(
  self : MlPutTrainedModelAliasQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.reassign {
    Some(value) => push_query_json(pairs, "reassign", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlPutTrainedModelAliasBody = Json

///|
pub type MlPutTrainedModelAliasResponse = Json

///|
pub(all) struct MlPutTrainedModelAliasRequest {
  model_id : String
  model_alias : String
  query : MlPutTrainedModelAliasQuery
  body : MlPutTrainedModelAliasBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutTrainedModelAliasRequest::new(
  model_id : String,
  model_alias : String,
  query? : MlPutTrainedModelAliasQuery = MlPutTrainedModelAliasQuery::new(),
  body? : MlPutTrainedModelAliasBody,
) -> MlPutTrainedModelAliasRequest {
  { model_id, model_alias, query, body }
}

///|
pub async fn Client::ml_put_trained_model_alias(
  self : Client,
  request : MlPutTrainedModelAliasRequest,
) -> EsResponse[MlPutTrainedModelAliasResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  params["model_alias"] = request.model_alias
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/trained_models/{model_id}/model_aliases/{model_alias}",
        ["model_id", "model_alias"],
      ),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutTrainedModelDefinitionPartQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelDefinitionPartQuery with fn to_json(
  _self : MlPutTrainedModelDefinitionPartQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPutTrainedModelDefinitionPartQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlPutTrainedModelDefinitionPartQuery: expected object"),
    )
  }
  MlPutTrainedModelDefinitionPartQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPutTrainedModelDefinitionPartQuery::new() -> MlPutTrainedModelDefinitionPartQuery {
  MlPutTrainedModelDefinitionPartQuery::{  }
}

///|
pub fn MlPutTrainedModelDefinitionPartQuery::to_pairs(
  _self : MlPutTrainedModelDefinitionPartQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPutTrainedModelDefinitionPartBody {
  definition : String
  total_definition_length : Int
  total_parts : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelDefinitionPartBody with fn to_json(
  self : MlPutTrainedModelDefinitionPartBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["definition"] = self.definition.to_json()
  obj["total_definition_length"] = self.total_definition_length.to_json()
  obj["total_parts"] = self.total_parts.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlPutTrainedModelDefinitionPartBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPutTrainedModelDefinitionPartBody: expected object"),
    )
  }
  {
    definition: @json.from_json(
      obj.get("definition").unwrap_or(Json::null()),
      path=path.add_key("definition"),
    ),
    total_definition_length: @json.from_json(
      obj.get("total_definition_length").unwrap_or(Json::null()),
      path=path.add_key("total_definition_length"),
    ),
    total_parts: @json.from_json(
      obj.get("total_parts").unwrap_or(Json::null()),
      path=path.add_key("total_parts"),
    ),
  }
}

///|
pub fn MlPutTrainedModelDefinitionPartBody::new(
  definition : String,
  total_definition_length : Int,
  total_parts : Int,
) -> MlPutTrainedModelDefinitionPartBody {
  { definition, total_definition_length, total_parts }
}

///|
pub type MlPutTrainedModelDefinitionPartResponse = Json

///|
pub(all) struct MlPutTrainedModelDefinitionPartRequest {
  model_id : String
  part : String
  query : MlPutTrainedModelDefinitionPartQuery
  body : MlPutTrainedModelDefinitionPartBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutTrainedModelDefinitionPartRequest::new(
  model_id : String,
  part : String,
  body : MlPutTrainedModelDefinitionPartBody,
  query? : MlPutTrainedModelDefinitionPartQuery = MlPutTrainedModelDefinitionPartQuery::new(),
) -> MlPutTrainedModelDefinitionPartRequest {
  { model_id, part, query, body }
}

///|
pub async fn Client::ml_put_trained_model_definition_part(
  self : Client,
  request : MlPutTrainedModelDefinitionPartRequest,
) -> EsResponse[MlPutTrainedModelDefinitionPartResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  params["part"] = request.part
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}/definition/{part}", [
        "model_id", "part",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlPutTrainedModelVocabularyQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelVocabularyQuery with fn to_json(
  _self : MlPutTrainedModelVocabularyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlPutTrainedModelVocabularyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlPutTrainedModelVocabularyQuery: expected object"),
    )
  }
  MlPutTrainedModelVocabularyQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlPutTrainedModelVocabularyQuery::new() -> MlPutTrainedModelVocabularyQuery {
  MlPutTrainedModelVocabularyQuery::{  }
}

///|
pub fn MlPutTrainedModelVocabularyQuery::to_pairs(
  _self : MlPutTrainedModelVocabularyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlPutTrainedModelVocabularyBody {
  vocabulary : Array[String]
  merges : Array[String]?
  scores : Array[Double]?
} derive(Eq, Debug)

///|
pub impl ToJson for MlPutTrainedModelVocabularyBody with fn to_json(
  self : MlPutTrainedModelVocabularyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["vocabulary"] = self.vocabulary.to_json()
  match self.merges {
    Some(value) => obj["merges"] = value.to_json()
    None => ()
  }
  match self.scores {
    Some(value) => obj["scores"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlPutTrainedModelVocabularyBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlPutTrainedModelVocabularyBody: expected object"),
    )
  }
  {
    vocabulary: @json.from_json(
      obj.get("vocabulary").unwrap_or(Json::null()),
      path=path.add_key("vocabulary"),
    ),
    merges: match obj.get("merges") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("merges")))
    },
    scores: match obj.get("scores") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scores")))
    },
  }
}

///|
pub fn MlPutTrainedModelVocabularyBody::new(
  vocabulary : Array[String],
  merges? : Array[String],
  scores? : Array[Double],
) -> MlPutTrainedModelVocabularyBody {
  { vocabulary, merges, scores }
}

///|
pub type MlPutTrainedModelVocabularyResponse = Json

///|
pub(all) struct MlPutTrainedModelVocabularyRequest {
  model_id : String
  query : MlPutTrainedModelVocabularyQuery
  body : MlPutTrainedModelVocabularyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlPutTrainedModelVocabularyRequest::new(
  model_id : String,
  body : MlPutTrainedModelVocabularyBody,
  query? : MlPutTrainedModelVocabularyQuery = MlPutTrainedModelVocabularyQuery::new(),
) -> MlPutTrainedModelVocabularyRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_put_trained_model_vocabulary(
  self : Client,
  request : MlPutTrainedModelVocabularyRequest,
) -> EsResponse[MlPutTrainedModelVocabularyResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}/vocabulary", ["model_id"]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct MlResetJobQuery {
  wait_for_completion : Bool?
  delete_user_annotations : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlResetJobQuery with fn to_json(self : MlResetJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  match self.delete_user_annotations {
    Some(value) => obj["delete_user_annotations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlResetJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlResetJobQuery: expected object"))
  }
  {
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
    delete_user_annotations: match obj.get("delete_user_annotations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("delete_user_annotations")),
        )
    },
  }
}

///|
pub fn MlResetJobQuery::new(
  wait_for_completion? : Bool,
  delete_user_annotations? : Bool,
) -> MlResetJobQuery {
  { wait_for_completion, delete_user_annotations }
}

///|
pub fn MlResetJobQuery::to_pairs(
  self : MlResetJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  match self.delete_user_annotations {
    Some(value) =>
      push_query_json(pairs, "delete_user_annotations", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlResetJobResponse = Json

///|
pub(all) struct MlResetJobRequest {
  job_id : String
  query : MlResetJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlResetJobRequest::new(
  job_id : String,
  query? : MlResetJobQuery = MlResetJobQuery::new(),
) -> MlResetJobRequest {
  { job_id, query }
}

///|
pub async fn Client::ml_reset_job(
  self : Client,
  request : MlResetJobRequest,
) -> EsResponse[MlResetJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_reset", ["job_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct MlRevertModelSnapshotQuery {
  delete_intervening_results : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlRevertModelSnapshotQuery with fn to_json(
  self : MlRevertModelSnapshotQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.delete_intervening_results {
    Some(value) => obj["delete_intervening_results"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlRevertModelSnapshotQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlRevertModelSnapshotQuery: expected object"))
  }
  {
    delete_intervening_results: match obj.get("delete_intervening_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("delete_intervening_results"),
          ),
        )
    },
  }
}

///|
pub fn MlRevertModelSnapshotQuery::new(
  delete_intervening_results? : Bool,
) -> MlRevertModelSnapshotQuery {
  { delete_intervening_results, }
}

///|
pub fn MlRevertModelSnapshotQuery::to_pairs(
  self : MlRevertModelSnapshotQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.delete_intervening_results {
    Some(value) =>
      push_query_json(pairs, "delete_intervening_results", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlRevertModelSnapshotBody {
  delete_intervening_results : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlRevertModelSnapshotBody with fn to_json(
  self : MlRevertModelSnapshotBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.delete_intervening_results {
    Some(value) => obj["delete_intervening_results"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlRevertModelSnapshotBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlRevertModelSnapshotBody: expected object"))
  }
  {
    delete_intervening_results: match obj.get("delete_intervening_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("delete_intervening_results"),
          ),
        )
    },
  }
}

///|
pub fn MlRevertModelSnapshotBody::new(
  delete_intervening_results? : Bool,
) -> MlRevertModelSnapshotBody {
  { delete_intervening_results, }
}

///|
pub(all) struct MlRevertModelSnapshotResponse {
  model : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlRevertModelSnapshotResponse with fn to_json(
  self : MlRevertModelSnapshotResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["model"] = self.model.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlRevertModelSnapshotResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlRevertModelSnapshotResponse: expected object"),
    )
  }
  {
    model: @json.from_json(
      obj.get("model").unwrap_or(Json::null()),
      path=path.add_key("model"),
    ),
  }
}

///|
pub(all) struct MlRevertModelSnapshotRequest {
  job_id : String
  snapshot_id : String
  query : MlRevertModelSnapshotQuery
  body : MlRevertModelSnapshotBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlRevertModelSnapshotRequest::new(
  job_id : String,
  snapshot_id : String,
  query? : MlRevertModelSnapshotQuery = MlRevertModelSnapshotQuery::new(),
  body? : MlRevertModelSnapshotBody,
) -> MlRevertModelSnapshotRequest {
  { job_id, snapshot_id, query, body }
}

///|
pub async fn Client::ml_revert_model_snapshot(
  self : Client,
  request : MlRevertModelSnapshotRequest,
) -> EsResponse[MlRevertModelSnapshotResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  params["snapshot_id"] = request.snapshot_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_revert",
        ["job_id", "snapshot_id"],
      ),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlSetUpgradeModeQuery {
  enabled : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlSetUpgradeModeQuery with fn to_json(
  self : MlSetUpgradeModeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.enabled {
    Some(value) => obj["enabled"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlSetUpgradeModeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlSetUpgradeModeQuery: expected object"))
  }
  {
    enabled: match obj.get("enabled") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("enabled")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlSetUpgradeModeQuery::new(
  enabled? : Bool,
  timeout? : String,
) -> MlSetUpgradeModeQuery {
  { enabled, timeout }
}

///|
pub fn MlSetUpgradeModeQuery::to_pairs(
  self : MlSetUpgradeModeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.enabled {
    Some(value) => push_query_json(pairs, "enabled", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MlSetUpgradeModeResponse = Json

///|
pub(all) struct MlSetUpgradeModeRequest {
  query : MlSetUpgradeModeQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlSetUpgradeModeRequest::new(
  query? : MlSetUpgradeModeQuery = MlSetUpgradeModeQuery::new(),
) -> MlSetUpgradeModeRequest {
  { query, }
}

///|
pub async fn Client::ml_set_upgrade_mode(
  self : Client,
  request : MlSetUpgradeModeRequest,
) -> EsResponse[MlSetUpgradeModeResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/set_upgrade_mode", [])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct MlStartDataFrameAnalyticsQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartDataFrameAnalyticsQuery with fn to_json(
  self : MlStartDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStartDataFrameAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStartDataFrameAnalyticsQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlStartDataFrameAnalyticsQuery::new(
  timeout? : String,
) -> MlStartDataFrameAnalyticsQuery {
  { timeout, }
}

///|
pub fn MlStartDataFrameAnalyticsQuery::to_pairs(
  self : MlStartDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlStartDataFrameAnalyticsBody {
  id : Json?
  timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartDataFrameAnalyticsBody with fn to_json(
  self : MlStartDataFrameAnalyticsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStartDataFrameAnalyticsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStartDataFrameAnalyticsBody: expected object"),
    )
  }
  {
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlStartDataFrameAnalyticsBody::new(
  id? : Json,
  timeout? : Json,
) -> MlStartDataFrameAnalyticsBody {
  { id, timeout }
}

///|
pub(all) struct MlStartDataFrameAnalyticsResponse {
  acknowledged : Bool
  node : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartDataFrameAnalyticsResponse with fn to_json(
  self : MlStartDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["node"] = self.node.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlStartDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStartDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    node: @json.from_json(
      obj.get("node").unwrap_or(Json::null()),
      path=path.add_key("node"),
    ),
  }
}

///|
pub(all) struct MlStartDataFrameAnalyticsRequest {
  id : String
  query : MlStartDataFrameAnalyticsQuery
  body : MlStartDataFrameAnalyticsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlStartDataFrameAnalyticsRequest::new(
  id : String,
  query? : MlStartDataFrameAnalyticsQuery = MlStartDataFrameAnalyticsQuery::new(),
  body? : MlStartDataFrameAnalyticsBody,
) -> MlStartDataFrameAnalyticsRequest {
  { id, query, body }
}

///|
pub async fn Client::ml_start_data_frame_analytics(
  self : Client,
  request : MlStartDataFrameAnalyticsRequest,
) -> EsResponse[MlStartDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/data_frame/analytics/{id}/_start", ["id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlStartDatafeedQuery {
  end : String?
  start : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartDatafeedQuery with fn to_json(
  self : MlStartDatafeedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStartDatafeedQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlStartDatafeedQuery: expected object"))
  }
  {
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlStartDatafeedQuery::new(
  end? : String,
  start? : String,
  timeout? : String,
) -> MlStartDatafeedQuery {
  { end, start, timeout }
}

///|
pub fn MlStartDatafeedQuery::to_pairs(
  self : MlStartDatafeedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.end {
    Some(value) => push_query_json(pairs, "end", value.to_json())
    None => ()
  }
  match self.start {
    Some(value) => push_query_json(pairs, "start", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlStartDatafeedBody {
  end : Json?
  start : Json?
  timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartDatafeedBody with fn to_json(
  self : MlStartDatafeedBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.end {
    Some(value) => obj["end"] = value.to_json()
    None => ()
  }
  match self.start {
    Some(value) => obj["start"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStartDatafeedBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlStartDatafeedBody: expected object"))
  }
  {
    end: match obj.get("end") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("end")))
    },
    start: match obj.get("start") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("start")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlStartDatafeedBody::new(
  end? : Json,
  start? : Json,
  timeout? : Json,
) -> MlStartDatafeedBody {
  { end, start, timeout }
}

///|
pub(all) struct MlStartDatafeedResponse {
  node : Json
  started : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartDatafeedResponse with fn to_json(
  self : MlStartDatafeedResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["node"] = self.node.to_json()
  obj["started"] = self.started.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlStartDatafeedResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlStartDatafeedResponse: expected object"))
  }
  {
    node: @json.from_json(
      obj.get("node").unwrap_or(Json::null()),
      path=path.add_key("node"),
    ),
    started: @json.from_json(
      obj.get("started").unwrap_or(Json::null()),
      path=path.add_key("started"),
    ),
  }
}

///|
pub(all) struct MlStartDatafeedRequest {
  datafeed_id : String
  query : MlStartDatafeedQuery
  body : MlStartDatafeedBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlStartDatafeedRequest::new(
  datafeed_id : String,
  query? : MlStartDatafeedQuery = MlStartDatafeedQuery::new(),
  body? : MlStartDatafeedBody,
) -> MlStartDatafeedRequest {
  { datafeed_id, query, body }
}

///|
pub async fn Client::ml_start_datafeed(
  self : Client,
  request : MlStartDatafeedRequest,
) -> EsResponse[MlStartDatafeedResponse] {
  let params : Map[String, String] = Map([])
  params["datafeed_id"] = request.datafeed_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/datafeeds/{datafeed_id}/_start", ["datafeed_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlStartTrainedModelDeploymentQuery {
  cache_size : String?
  deployment_id : String?
  number_of_allocations : Int?
  priority : String?
  queue_capacity : Int?
  threads_per_allocation : Int?
  timeout : String?
  wait_for : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartTrainedModelDeploymentQuery with fn to_json(
  self : MlStartTrainedModelDeploymentQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.cache_size {
    Some(value) => obj["cache_size"] = value.to_json()
    None => ()
  }
  match self.deployment_id {
    Some(value) => obj["deployment_id"] = value.to_json()
    None => ()
  }
  match self.number_of_allocations {
    Some(value) => obj["number_of_allocations"] = value.to_json()
    None => ()
  }
  match self.priority {
    Some(value) => obj["priority"] = value.to_json()
    None => ()
  }
  match self.queue_capacity {
    Some(value) => obj["queue_capacity"] = value.to_json()
    None => ()
  }
  match self.threads_per_allocation {
    Some(value) => obj["threads_per_allocation"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for {
    Some(value) => obj["wait_for"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStartTrainedModelDeploymentQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStartTrainedModelDeploymentQuery: expected object"),
    )
  }
  {
    cache_size: match obj.get("cache_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("cache_size")))
    },
    deployment_id: match obj.get("deployment_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("deployment_id")))
    },
    number_of_allocations: match obj.get("number_of_allocations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("number_of_allocations")))
    },
    priority: match obj.get("priority") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("priority")))
    },
    queue_capacity: match obj.get("queue_capacity") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("queue_capacity")))
    },
    threads_per_allocation: match obj.get("threads_per_allocation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("threads_per_allocation")),
        )
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for: match obj.get("wait_for") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("wait_for")))
    },
  }
}

///|
pub fn MlStartTrainedModelDeploymentQuery::new(
  cache_size? : String,
  deployment_id? : String,
  number_of_allocations? : Int,
  priority? : String,
  queue_capacity? : Int,
  threads_per_allocation? : Int,
  timeout? : String,
  wait_for? : String,
) -> MlStartTrainedModelDeploymentQuery {
  {
    cache_size,
    deployment_id,
    number_of_allocations,
    priority,
    queue_capacity,
    threads_per_allocation,
    timeout,
    wait_for,
  }
}

///|
pub fn MlStartTrainedModelDeploymentQuery::to_pairs(
  self : MlStartTrainedModelDeploymentQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.cache_size {
    Some(value) => push_query_json(pairs, "cache_size", value.to_json())
    None => ()
  }
  match self.deployment_id {
    Some(value) => push_query_json(pairs, "deployment_id", value.to_json())
    None => ()
  }
  match self.number_of_allocations {
    Some(value) =>
      push_query_json(pairs, "number_of_allocations", value.to_json())
    None => ()
  }
  match self.priority {
    Some(value) => push_query_json(pairs, "priority", value.to_json())
    None => ()
  }
  match self.queue_capacity {
    Some(value) => push_query_json(pairs, "queue_capacity", value.to_json())
    None => ()
  }
  match self.threads_per_allocation {
    Some(value) =>
      push_query_json(pairs, "threads_per_allocation", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for {
    Some(value) => push_query_json(pairs, "wait_for", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlStartTrainedModelDeploymentBody {
  adaptive_allocations : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartTrainedModelDeploymentBody with fn to_json(
  self : MlStartTrainedModelDeploymentBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.adaptive_allocations {
    Some(value) => obj["adaptive_allocations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStartTrainedModelDeploymentBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStartTrainedModelDeploymentBody: expected object"),
    )
  }
  {
    adaptive_allocations: match obj.get("adaptive_allocations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("adaptive_allocations")))
    },
  }
}

///|
pub fn MlStartTrainedModelDeploymentBody::new(
  adaptive_allocations? : Json,
) -> MlStartTrainedModelDeploymentBody {
  { adaptive_allocations, }
}

///|
pub(all) struct MlStartTrainedModelDeploymentResponse {
  assignment : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlStartTrainedModelDeploymentResponse with fn to_json(
  self : MlStartTrainedModelDeploymentResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["assignment"] = self.assignment.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlStartTrainedModelDeploymentResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStartTrainedModelDeploymentResponse: expected object"),
    )
  }
  {
    assignment: @json.from_json(
      obj.get("assignment").unwrap_or(Json::null()),
      path=path.add_key("assignment"),
    ),
  }
}

///|
pub(all) struct MlStartTrainedModelDeploymentRequest {
  model_id : String
  query : MlStartTrainedModelDeploymentQuery
  body : MlStartTrainedModelDeploymentBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlStartTrainedModelDeploymentRequest::new(
  model_id : String,
  query? : MlStartTrainedModelDeploymentQuery = MlStartTrainedModelDeploymentQuery::new(),
  body? : MlStartTrainedModelDeploymentBody,
) -> MlStartTrainedModelDeploymentRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_start_trained_model_deployment(
  self : Client,
  request : MlStartTrainedModelDeploymentRequest,
) -> EsResponse[MlStartTrainedModelDeploymentResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}/deployment/_start", [
        "model_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlStopDataFrameAnalyticsQuery {
  allow_no_match : Bool?
  force : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopDataFrameAnalyticsQuery with fn to_json(
  self : MlStopDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStopDataFrameAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStopDataFrameAnalyticsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlStopDataFrameAnalyticsQuery::new(
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : String,
) -> MlStopDataFrameAnalyticsQuery {
  { allow_no_match, force, timeout }
}

///|
pub fn MlStopDataFrameAnalyticsQuery::to_pairs(
  self : MlStopDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlStopDataFrameAnalyticsBody {
  id : Json?
  allow_no_match : Bool?
  force : Bool?
  timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopDataFrameAnalyticsBody with fn to_json(
  self : MlStopDataFrameAnalyticsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStopDataFrameAnalyticsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStopDataFrameAnalyticsBody: expected object"),
    )
  }
  {
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlStopDataFrameAnalyticsBody::new(
  id? : Json,
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : Json,
) -> MlStopDataFrameAnalyticsBody {
  { id, allow_no_match, force, timeout }
}

///|
pub(all) struct MlStopDataFrameAnalyticsResponse {
  stopped : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopDataFrameAnalyticsResponse with fn to_json(
  self : MlStopDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["stopped"] = self.stopped.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlStopDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStopDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    stopped: @json.from_json(
      obj.get("stopped").unwrap_or(Json::null()),
      path=path.add_key("stopped"),
    ),
  }
}

///|
pub(all) struct MlStopDataFrameAnalyticsRequest {
  id : String
  query : MlStopDataFrameAnalyticsQuery
  body : MlStopDataFrameAnalyticsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlStopDataFrameAnalyticsRequest::new(
  id : String,
  query? : MlStopDataFrameAnalyticsQuery = MlStopDataFrameAnalyticsQuery::new(),
  body? : MlStopDataFrameAnalyticsBody,
) -> MlStopDataFrameAnalyticsRequest {
  { id, query, body }
}

///|
pub async fn Client::ml_stop_data_frame_analytics(
  self : Client,
  request : MlStopDataFrameAnalyticsRequest,
) -> EsResponse[MlStopDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/data_frame/analytics/{id}/_stop", ["id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlStopDatafeedQuery {
  allow_no_match : Bool?
  force : Bool?
  timeout : String?
  close_job : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopDatafeedQuery with fn to_json(
  self : MlStopDatafeedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.close_job {
    Some(value) => obj["close_job"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStopDatafeedQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlStopDatafeedQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    close_job: match obj.get("close_job") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("close_job")))
    },
  }
}

///|
pub fn MlStopDatafeedQuery::new(
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : String,
  close_job? : Bool,
) -> MlStopDatafeedQuery {
  { allow_no_match, force, timeout, close_job }
}

///|
pub fn MlStopDatafeedQuery::to_pairs(
  self : MlStopDatafeedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.close_job {
    Some(value) => push_query_json(pairs, "close_job", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlStopDatafeedBody {
  allow_no_match : Bool?
  force : Bool?
  timeout : Json?
  close_job : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopDatafeedBody with fn to_json(
  self : MlStopDatafeedBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.close_job {
    Some(value) => obj["close_job"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStopDatafeedBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlStopDatafeedBody: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    close_job: match obj.get("close_job") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("close_job")))
    },
  }
}

///|
pub fn MlStopDatafeedBody::new(
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : Json,
  close_job? : Bool,
) -> MlStopDatafeedBody {
  { allow_no_match, force, timeout, close_job }
}

///|
pub(all) struct MlStopDatafeedResponse {
  stopped : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopDatafeedResponse with fn to_json(
  self : MlStopDatafeedResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["stopped"] = self.stopped.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlStopDatafeedResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlStopDatafeedResponse: expected object"))
  }
  {
    stopped: @json.from_json(
      obj.get("stopped").unwrap_or(Json::null()),
      path=path.add_key("stopped"),
    ),
  }
}

///|
pub(all) struct MlStopDatafeedRequest {
  datafeed_id : String
  query : MlStopDatafeedQuery
  body : MlStopDatafeedBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlStopDatafeedRequest::new(
  datafeed_id : String,
  query? : MlStopDatafeedQuery = MlStopDatafeedQuery::new(),
  body? : MlStopDatafeedBody,
) -> MlStopDatafeedRequest {
  { datafeed_id, query, body }
}

///|
pub async fn Client::ml_stop_datafeed(
  self : Client,
  request : MlStopDatafeedRequest,
) -> EsResponse[MlStopDatafeedResponse] {
  let params : Map[String, String] = Map([])
  params["datafeed_id"] = request.datafeed_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/datafeeds/{datafeed_id}/_stop", ["datafeed_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlStopTrainedModelDeploymentQuery {
  allow_no_match : Bool?
  force : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopTrainedModelDeploymentQuery with fn to_json(
  self : MlStopTrainedModelDeploymentQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStopTrainedModelDeploymentQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStopTrainedModelDeploymentQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
  }
}

///|
pub fn MlStopTrainedModelDeploymentQuery::new(
  allow_no_match? : Bool,
  force? : Bool,
) -> MlStopTrainedModelDeploymentQuery {
  { allow_no_match, force }
}

///|
pub fn MlStopTrainedModelDeploymentQuery::to_pairs(
  self : MlStopTrainedModelDeploymentQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlStopTrainedModelDeploymentBody {
  id : Json?
  allow_no_match : Bool?
  force : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopTrainedModelDeploymentBody with fn to_json(
  self : MlStopTrainedModelDeploymentBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlStopTrainedModelDeploymentBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStopTrainedModelDeploymentBody: expected object"),
    )
  }
  {
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
  }
}

///|
pub fn MlStopTrainedModelDeploymentBody::new(
  id? : Json,
  allow_no_match? : Bool,
  force? : Bool,
) -> MlStopTrainedModelDeploymentBody {
  { id, allow_no_match, force }
}

///|
pub(all) struct MlStopTrainedModelDeploymentResponse {
  stopped : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlStopTrainedModelDeploymentResponse with fn to_json(
  self : MlStopTrainedModelDeploymentResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["stopped"] = self.stopped.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlStopTrainedModelDeploymentResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlStopTrainedModelDeploymentResponse: expected object"),
    )
  }
  {
    stopped: @json.from_json(
      obj.get("stopped").unwrap_or(Json::null()),
      path=path.add_key("stopped"),
    ),
  }
}

///|
pub(all) struct MlStopTrainedModelDeploymentRequest {
  model_id : String
  query : MlStopTrainedModelDeploymentQuery
  body : MlStopTrainedModelDeploymentBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlStopTrainedModelDeploymentRequest::new(
  model_id : String,
  query? : MlStopTrainedModelDeploymentQuery = MlStopTrainedModelDeploymentQuery::new(),
  body? : MlStopTrainedModelDeploymentBody,
) -> MlStopTrainedModelDeploymentRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_stop_trained_model_deployment(
  self : Client,
  request : MlStopTrainedModelDeploymentRequest,
) -> EsResponse[MlStopTrainedModelDeploymentResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}/deployment/_stop", [
        "model_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpdateDataFrameAnalyticsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateDataFrameAnalyticsQuery with fn to_json(
  _self : MlUpdateDataFrameAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlUpdateDataFrameAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "MlUpdateDataFrameAnalyticsQuery: expected object"),
    )
  }
  MlUpdateDataFrameAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlUpdateDataFrameAnalyticsQuery::new() -> MlUpdateDataFrameAnalyticsQuery {
  MlUpdateDataFrameAnalyticsQuery::{  }
}

///|
pub fn MlUpdateDataFrameAnalyticsQuery::to_pairs(
  _self : MlUpdateDataFrameAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlUpdateDataFrameAnalyticsBody {
  description : String?
  model_memory_limit : String?
  max_num_threads : Int?
  allow_lazy_start : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateDataFrameAnalyticsBody with fn to_json(
  self : MlUpdateDataFrameAnalyticsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.model_memory_limit {
    Some(value) => obj["model_memory_limit"] = value.to_json()
    None => ()
  }
  match self.max_num_threads {
    Some(value) => obj["max_num_threads"] = value.to_json()
    None => ()
  }
  match self.allow_lazy_start {
    Some(value) => obj["allow_lazy_start"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateDataFrameAnalyticsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpdateDataFrameAnalyticsBody: expected object"),
    )
  }
  {
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    model_memory_limit: match obj.get("model_memory_limit") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_memory_limit")))
    },
    max_num_threads: match obj.get("max_num_threads") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_num_threads")))
    },
    allow_lazy_start: match obj.get("allow_lazy_start") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_lazy_start")))
    },
  }
}

///|
pub fn MlUpdateDataFrameAnalyticsBody::new(
  description? : String,
  model_memory_limit? : String,
  max_num_threads? : Int,
  allow_lazy_start? : Bool,
) -> MlUpdateDataFrameAnalyticsBody {
  { description, model_memory_limit, max_num_threads, allow_lazy_start }
}

///|
pub(all) struct MlUpdateDataFrameAnalyticsResponse {
  authorization : Json?
  allow_lazy_start : Bool
  analysis : Json
  analyzed_fields : Json?
  create_time : Int
  description : String?
  dest : Json
  id : Json
  max_num_threads : Int
  model_memory_limit : String
  source : Json
  version : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateDataFrameAnalyticsResponse with fn to_json(
  self : MlUpdateDataFrameAnalyticsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.authorization {
    Some(value) => obj["authorization"] = value.to_json()
    None => ()
  }
  obj["allow_lazy_start"] = self.allow_lazy_start.to_json()
  obj["analysis"] = self.analysis.to_json()
  match self.analyzed_fields {
    Some(value) => obj["analyzed_fields"] = value.to_json()
    None => ()
  }
  obj["create_time"] = self.create_time.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  obj["dest"] = self.dest.to_json()
  obj["id"] = self.id.to_json()
  obj["max_num_threads"] = self.max_num_threads.to_json()
  obj["model_memory_limit"] = self.model_memory_limit.to_json()
  obj["source"] = self.source.to_json()
  obj["version"] = self.version.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateDataFrameAnalyticsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpdateDataFrameAnalyticsResponse: expected object"),
    )
  }
  {
    authorization: match obj.get("authorization") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("authorization")))
    },
    allow_lazy_start: @json.from_json(
      obj.get("allow_lazy_start").unwrap_or(Json::null()),
      path=path.add_key("allow_lazy_start"),
    ),
    analysis: @json.from_json(
      obj.get("analysis").unwrap_or(Json::null()),
      path=path.add_key("analysis"),
    ),
    analyzed_fields: match obj.get("analyzed_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyzed_fields")))
    },
    create_time: @json.from_json(
      obj.get("create_time").unwrap_or(Json::null()),
      path=path.add_key("create_time"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    dest: @json.from_json(
      obj.get("dest").unwrap_or(Json::null()),
      path=path.add_key("dest"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    max_num_threads: @json.from_json(
      obj.get("max_num_threads").unwrap_or(Json::null()),
      path=path.add_key("max_num_threads"),
    ),
    model_memory_limit: @json.from_json(
      obj.get("model_memory_limit").unwrap_or(Json::null()),
      path=path.add_key("model_memory_limit"),
    ),
    source: @json.from_json(
      obj.get("source").unwrap_or(Json::null()),
      path=path.add_key("source"),
    ),
    version: @json.from_json(
      obj.get("version").unwrap_or(Json::null()),
      path=path.add_key("version"),
    ),
  }
}

///|
pub(all) struct MlUpdateDataFrameAnalyticsRequest {
  id : String
  query : MlUpdateDataFrameAnalyticsQuery
  body : MlUpdateDataFrameAnalyticsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpdateDataFrameAnalyticsRequest::new(
  id : String,
  body : MlUpdateDataFrameAnalyticsBody,
  query? : MlUpdateDataFrameAnalyticsQuery = MlUpdateDataFrameAnalyticsQuery::new(),
) -> MlUpdateDataFrameAnalyticsRequest {
  { id, query, body }
}

///|
pub async fn Client::ml_update_data_frame_analytics(
  self : Client,
  request : MlUpdateDataFrameAnalyticsRequest,
) -> EsResponse[MlUpdateDataFrameAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/data_frame/analytics/{id}/_update", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpdateDatafeedQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateDatafeedQuery with fn to_json(
  self : MlUpdateDatafeedQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateDatafeedQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateDatafeedQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn MlUpdateDatafeedQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
) -> MlUpdateDatafeedQuery {
  { allow_no_indices, expand_wildcards, ignore_throttled, ignore_unavailable }
}

///|
pub fn MlUpdateDatafeedQuery::to_pairs(
  self : MlUpdateDatafeedQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlUpdateDatafeedBody {
  aggregations : Map[String, Json]?
  chunking_config : Json?
  delayed_data_check_config : Json?
  frequency : Json?
  indices : Array[String]?
  indices_options : Json?
  job_id : Json?
  max_empty_searches : Int?
  query : Json?
  query_delay : Json?
  runtime_mappings : Json?
  script_fields : Map[String, Json]?
  scroll_size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateDatafeedBody with fn to_json(
  self : MlUpdateDatafeedBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.chunking_config {
    Some(value) => obj["chunking_config"] = value.to_json()
    None => ()
  }
  match self.delayed_data_check_config {
    Some(value) => obj["delayed_data_check_config"] = value.to_json()
    None => ()
  }
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  match self.indices {
    Some(value) => obj["indices"] = value.to_json()
    None => ()
  }
  match self.indices_options {
    Some(value) => obj["indices_options"] = value.to_json()
    None => ()
  }
  match self.job_id {
    Some(value) => obj["job_id"] = value.to_json()
    None => ()
  }
  match self.max_empty_searches {
    Some(value) => obj["max_empty_searches"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.query_delay {
    Some(value) => obj["query_delay"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  match self.scroll_size {
    Some(value) => obj["scroll_size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateDatafeedBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateDatafeedBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    chunking_config: match obj.get("chunking_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("chunking_config")))
    },
    delayed_data_check_config: match obj.get("delayed_data_check_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("delayed_data_check_config")),
        )
    },
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    indices: match obj.get("indices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("indices")))
    },
    indices_options: match obj.get("indices_options") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_options")))
    },
    job_id: match obj.get("job_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_id")))
    },
    max_empty_searches: match obj.get("max_empty_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_empty_searches")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    query_delay: match obj.get("query_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("query_delay")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    scroll_size: match obj.get("scroll_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("scroll_size")))
    },
  }
}

///|
pub fn MlUpdateDatafeedBody::new(
  aggregations? : Map[String, Json],
  chunking_config? : Json,
  delayed_data_check_config? : Json,
  frequency? : Json,
  indices? : Array[String],
  indices_options? : Json,
  job_id? : Json,
  max_empty_searches? : Int,
  query? : Json,
  query_delay? : Json,
  runtime_mappings? : Json,
  script_fields? : Map[String, Json],
  scroll_size? : Int,
) -> MlUpdateDatafeedBody {
  {
    aggregations,
    chunking_config,
    delayed_data_check_config,
    frequency,
    indices,
    indices_options,
    job_id,
    max_empty_searches,
    query,
    query_delay,
    runtime_mappings,
    script_fields,
    scroll_size,
  }
}

///|
pub(all) struct MlUpdateDatafeedResponse {
  authorization : Json?
  aggregations : Map[String, Json]?
  chunking_config : Json
  delayed_data_check_config : Json?
  datafeed_id : Json
  frequency : Json?
  indices : Array[String]
  indices_options : Json?
  job_id : Json
  max_empty_searches : Int?
  query : Json
  query_delay : Json
  runtime_mappings : Json?
  script_fields : Map[String, Json]?
  scroll_size : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateDatafeedResponse with fn to_json(
  self : MlUpdateDatafeedResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.authorization {
    Some(value) => obj["authorization"] = value.to_json()
    None => ()
  }
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  obj["chunking_config"] = self.chunking_config.to_json()
  match self.delayed_data_check_config {
    Some(value) => obj["delayed_data_check_config"] = value.to_json()
    None => ()
  }
  obj["datafeed_id"] = self.datafeed_id.to_json()
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  obj["indices"] = self.indices.to_json()
  match self.indices_options {
    Some(value) => obj["indices_options"] = value.to_json()
    None => ()
  }
  obj["job_id"] = self.job_id.to_json()
  match self.max_empty_searches {
    Some(value) => obj["max_empty_searches"] = value.to_json()
    None => ()
  }
  obj["query"] = self.query.to_json()
  obj["query_delay"] = self.query_delay.to_json()
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  obj["scroll_size"] = self.scroll_size.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateDatafeedResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateDatafeedResponse: expected object"))
  }
  {
    authorization: match obj.get("authorization") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("authorization")))
    },
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    chunking_config: @json.from_json(
      obj.get("chunking_config").unwrap_or(Json::null()),
      path=path.add_key("chunking_config"),
    ),
    delayed_data_check_config: match obj.get("delayed_data_check_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("delayed_data_check_config")),
        )
    },
    datafeed_id: @json.from_json(
      obj.get("datafeed_id").unwrap_or(Json::null()),
      path=path.add_key("datafeed_id"),
    ),
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    indices_options: match obj.get("indices_options") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_options")))
    },
    job_id: @json.from_json(
      obj.get("job_id").unwrap_or(Json::null()),
      path=path.add_key("job_id"),
    ),
    max_empty_searches: match obj.get("max_empty_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_empty_searches")))
    },
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    query_delay: @json.from_json(
      obj.get("query_delay").unwrap_or(Json::null()),
      path=path.add_key("query_delay"),
    ),
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    scroll_size: @json.from_json(
      obj.get("scroll_size").unwrap_or(Json::null()),
      path=path.add_key("scroll_size"),
    ),
  }
}

///|
pub(all) struct MlUpdateDatafeedRequest {
  datafeed_id : String
  query : MlUpdateDatafeedQuery
  body : MlUpdateDatafeedBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpdateDatafeedRequest::new(
  datafeed_id : String,
  body : MlUpdateDatafeedBody,
  query? : MlUpdateDatafeedQuery = MlUpdateDatafeedQuery::new(),
) -> MlUpdateDatafeedRequest {
  { datafeed_id, query, body }
}

///|
pub async fn Client::ml_update_datafeed(
  self : Client,
  request : MlUpdateDatafeedRequest,
) -> EsResponse[MlUpdateDatafeedResponse] {
  let params : Map[String, String] = Map([])
  params["datafeed_id"] = request.datafeed_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/datafeeds/{datafeed_id}/_update", ["datafeed_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpdateFilterQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateFilterQuery with fn to_json(
  _self : MlUpdateFilterQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlUpdateFilterQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlUpdateFilterQuery: expected object"))
  }
  MlUpdateFilterQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlUpdateFilterQuery::new() -> MlUpdateFilterQuery {
  MlUpdateFilterQuery::{  }
}

///|
pub fn MlUpdateFilterQuery::to_pairs(
  _self : MlUpdateFilterQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlUpdateFilterBody {
  add_items : Array[String]?
  description : String?
  remove_items : Array[String]?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateFilterBody with fn to_json(
  self : MlUpdateFilterBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.add_items {
    Some(value) => obj["add_items"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.remove_items {
    Some(value) => obj["remove_items"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateFilterBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateFilterBody: expected object"))
  }
  {
    add_items: match obj.get("add_items") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("add_items")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    remove_items: match obj.get("remove_items") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("remove_items")))
    },
  }
}

///|
pub fn MlUpdateFilterBody::new(
  add_items? : Array[String],
  description? : String,
  remove_items? : Array[String],
) -> MlUpdateFilterBody {
  { add_items, description, remove_items }
}

///|
pub(all) struct MlUpdateFilterResponse {
  description : String
  filter_id : Json
  items : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateFilterResponse with fn to_json(
  self : MlUpdateFilterResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["description"] = self.description.to_json()
  obj["filter_id"] = self.filter_id.to_json()
  obj["items"] = self.items.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateFilterResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateFilterResponse: expected object"))
  }
  {
    description: @json.from_json(
      obj.get("description").unwrap_or(Json::null()),
      path=path.add_key("description"),
    ),
    filter_id: @json.from_json(
      obj.get("filter_id").unwrap_or(Json::null()),
      path=path.add_key("filter_id"),
    ),
    items: @json.from_json(
      obj.get("items").unwrap_or(Json::null()),
      path=path.add_key("items"),
    ),
  }
}

///|
pub(all) struct MlUpdateFilterRequest {
  filter_id : String
  query : MlUpdateFilterQuery
  body : MlUpdateFilterBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpdateFilterRequest::new(
  filter_id : String,
  body : MlUpdateFilterBody,
  query? : MlUpdateFilterQuery = MlUpdateFilterQuery::new(),
) -> MlUpdateFilterRequest {
  { filter_id, query, body }
}

///|
pub async fn Client::ml_update_filter(
  self : Client,
  request : MlUpdateFilterRequest,
) -> EsResponse[MlUpdateFilterResponse] {
  let params : Map[String, String] = Map([])
  params["filter_id"] = request.filter_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/filters/{filter_id}/_update", ["filter_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpdateJobQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateJobQuery with fn to_json(_self : MlUpdateJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlUpdateJobQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlUpdateJobQuery: expected object"))
  }
  MlUpdateJobQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlUpdateJobQuery::new() -> MlUpdateJobQuery {
  MlUpdateJobQuery::{  }
}

///|
pub fn MlUpdateJobQuery::to_pairs(
  _self : MlUpdateJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlUpdateJobBody {
  allow_lazy_open : Bool?
  analysis_limits : Json?
  background_persist_interval : Json?
  custom_settings : Map[String, Json]?
  categorization_filters : Array[String]?
  description : String?
  model_plot_config : Json?
  model_prune_window : Json?
  daily_model_snapshot_retention_after_days : Int?
  model_snapshot_retention_days : Int?
  renormalization_window_days : Int?
  results_retention_days : Int?
  groups : Array[String]?
  detectors : Array[Json]?
  per_partition_categorization : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateJobBody with fn to_json(self : MlUpdateJobBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_lazy_open {
    Some(value) => obj["allow_lazy_open"] = value.to_json()
    None => ()
  }
  match self.analysis_limits {
    Some(value) => obj["analysis_limits"] = value.to_json()
    None => ()
  }
  match self.background_persist_interval {
    Some(value) => obj["background_persist_interval"] = value.to_json()
    None => ()
  }
  match self.custom_settings {
    Some(value) => obj["custom_settings"] = value.to_json()
    None => ()
  }
  match self.categorization_filters {
    Some(value) => obj["categorization_filters"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.model_plot_config {
    Some(value) => obj["model_plot_config"] = value.to_json()
    None => ()
  }
  match self.model_prune_window {
    Some(value) => obj["model_prune_window"] = value.to_json()
    None => ()
  }
  match self.daily_model_snapshot_retention_after_days {
    Some(value) =>
      obj["daily_model_snapshot_retention_after_days"] = value.to_json()
    None => ()
  }
  match self.model_snapshot_retention_days {
    Some(value) => obj["model_snapshot_retention_days"] = value.to_json()
    None => ()
  }
  match self.renormalization_window_days {
    Some(value) => obj["renormalization_window_days"] = value.to_json()
    None => ()
  }
  match self.results_retention_days {
    Some(value) => obj["results_retention_days"] = value.to_json()
    None => ()
  }
  match self.groups {
    Some(value) => obj["groups"] = value.to_json()
    None => ()
  }
  match self.detectors {
    Some(value) => obj["detectors"] = value.to_json()
    None => ()
  }
  match self.per_partition_categorization {
    Some(value) => obj["per_partition_categorization"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateJobBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateJobBody: expected object"))
  }
  {
    allow_lazy_open: match obj.get("allow_lazy_open") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_lazy_open")))
    },
    analysis_limits: match obj.get("analysis_limits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analysis_limits")))
    },
    background_persist_interval: match obj.get("background_persist_interval") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("background_persist_interval"),
          ),
        )
    },
    custom_settings: match obj.get("custom_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("custom_settings")))
    },
    categorization_filters: match obj.get("categorization_filters") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("categorization_filters")),
        )
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    model_plot_config: match obj.get("model_plot_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_plot_config")))
    },
    model_prune_window: match obj.get("model_prune_window") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_prune_window")))
    },
    daily_model_snapshot_retention_after_days: match
      obj.get("daily_model_snapshot_retention_after_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("daily_model_snapshot_retention_after_days"),
          ),
        )
    },
    model_snapshot_retention_days: match
      obj.get("model_snapshot_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("model_snapshot_retention_days"),
          ),
        )
    },
    renormalization_window_days: match obj.get("renormalization_window_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("renormalization_window_days"),
          ),
        )
    },
    results_retention_days: match obj.get("results_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("results_retention_days")),
        )
    },
    groups: match obj.get("groups") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("groups")))
    },
    detectors: match obj.get("detectors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("detectors")))
    },
    per_partition_categorization: match
      obj.get("per_partition_categorization") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("per_partition_categorization"),
          ),
        )
    },
  }
}

///|
pub fn MlUpdateJobBody::new(
  allow_lazy_open? : Bool,
  analysis_limits? : Json,
  background_persist_interval? : Json,
  custom_settings? : Map[String, Json],
  categorization_filters? : Array[String],
  description? : String,
  model_plot_config? : Json,
  model_prune_window? : Json,
  daily_model_snapshot_retention_after_days? : Int,
  model_snapshot_retention_days? : Int,
  renormalization_window_days? : Int,
  results_retention_days? : Int,
  groups? : Array[String],
  detectors? : Array[Json],
  per_partition_categorization? : Json,
) -> MlUpdateJobBody {
  {
    allow_lazy_open,
    analysis_limits,
    background_persist_interval,
    custom_settings,
    categorization_filters,
    description,
    model_plot_config,
    model_prune_window,
    daily_model_snapshot_retention_after_days,
    model_snapshot_retention_days,
    renormalization_window_days,
    results_retention_days,
    groups,
    detectors,
    per_partition_categorization,
  }
}

///|
pub(all) struct MlUpdateJobResponse {
  allow_lazy_open : Bool
  analysis_config : Json
  analysis_limits : Json
  background_persist_interval : Json?
  create_time : Json
  finished_time : Json?
  custom_settings : Map[String, Json]?
  daily_model_snapshot_retention_after_days : Int
  data_description : Json
  datafeed_config : Json?
  description : String?
  groups : Array[String]?
  job_id : Json
  job_type : String
  job_version : Json
  model_plot_config : Json?
  model_snapshot_id : Json?
  model_snapshot_retention_days : Int
  renormalization_window_days : Int?
  results_index_name : Json
  results_retention_days : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateJobResponse with fn to_json(
  self : MlUpdateJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["allow_lazy_open"] = self.allow_lazy_open.to_json()
  obj["analysis_config"] = self.analysis_config.to_json()
  obj["analysis_limits"] = self.analysis_limits.to_json()
  match self.background_persist_interval {
    Some(value) => obj["background_persist_interval"] = value.to_json()
    None => ()
  }
  obj["create_time"] = self.create_time.to_json()
  match self.finished_time {
    Some(value) => obj["finished_time"] = value.to_json()
    None => ()
  }
  match self.custom_settings {
    Some(value) => obj["custom_settings"] = value.to_json()
    None => ()
  }
  obj["daily_model_snapshot_retention_after_days"] = self.daily_model_snapshot_retention_after_days.to_json()
  obj["data_description"] = self.data_description.to_json()
  match self.datafeed_config {
    Some(value) => obj["datafeed_config"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.groups {
    Some(value) => obj["groups"] = value.to_json()
    None => ()
  }
  obj["job_id"] = self.job_id.to_json()
  obj["job_type"] = self.job_type.to_json()
  obj["job_version"] = self.job_version.to_json()
  match self.model_plot_config {
    Some(value) => obj["model_plot_config"] = value.to_json()
    None => ()
  }
  match self.model_snapshot_id {
    Some(value) => obj["model_snapshot_id"] = value.to_json()
    None => ()
  }
  obj["model_snapshot_retention_days"] = self.model_snapshot_retention_days.to_json()
  match self.renormalization_window_days {
    Some(value) => obj["renormalization_window_days"] = value.to_json()
    None => ()
  }
  obj["results_index_name"] = self.results_index_name.to_json()
  match self.results_retention_days {
    Some(value) => obj["results_retention_days"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateJobResponse: expected object"))
  }
  {
    allow_lazy_open: @json.from_json(
      obj.get("allow_lazy_open").unwrap_or(Json::null()),
      path=path.add_key("allow_lazy_open"),
    ),
    analysis_config: @json.from_json(
      obj.get("analysis_config").unwrap_or(Json::null()),
      path=path.add_key("analysis_config"),
    ),
    analysis_limits: @json.from_json(
      obj.get("analysis_limits").unwrap_or(Json::null()),
      path=path.add_key("analysis_limits"),
    ),
    background_persist_interval: match obj.get("background_persist_interval") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("background_persist_interval"),
          ),
        )
    },
    create_time: @json.from_json(
      obj.get("create_time").unwrap_or(Json::null()),
      path=path.add_key("create_time"),
    ),
    finished_time: match obj.get("finished_time") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("finished_time")))
    },
    custom_settings: match obj.get("custom_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("custom_settings")))
    },
    daily_model_snapshot_retention_after_days: @json.from_json(
      obj
      .get("daily_model_snapshot_retention_after_days")
      .unwrap_or(Json::null()),
      path=path.add_key("daily_model_snapshot_retention_after_days"),
    ),
    data_description: @json.from_json(
      obj.get("data_description").unwrap_or(Json::null()),
      path=path.add_key("data_description"),
    ),
    datafeed_config: match obj.get("datafeed_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("datafeed_config")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    groups: match obj.get("groups") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("groups")))
    },
    job_id: @json.from_json(
      obj.get("job_id").unwrap_or(Json::null()),
      path=path.add_key("job_id"),
    ),
    job_type: @json.from_json(
      obj.get("job_type").unwrap_or(Json::null()),
      path=path.add_key("job_type"),
    ),
    job_version: @json.from_json(
      obj.get("job_version").unwrap_or(Json::null()),
      path=path.add_key("job_version"),
    ),
    model_plot_config: match obj.get("model_plot_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_plot_config")))
    },
    model_snapshot_id: match obj.get("model_snapshot_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_snapshot_id")))
    },
    model_snapshot_retention_days: @json.from_json(
      obj.get("model_snapshot_retention_days").unwrap_or(Json::null()),
      path=path.add_key("model_snapshot_retention_days"),
    ),
    renormalization_window_days: match obj.get("renormalization_window_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("renormalization_window_days"),
          ),
        )
    },
    results_index_name: @json.from_json(
      obj.get("results_index_name").unwrap_or(Json::null()),
      path=path.add_key("results_index_name"),
    ),
    results_retention_days: match obj.get("results_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("results_retention_days")),
        )
    },
  }
}

///|
pub(all) struct MlUpdateJobRequest {
  job_id : String
  query : MlUpdateJobQuery
  body : MlUpdateJobBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpdateJobRequest::new(
  job_id : String,
  body : MlUpdateJobBody,
  query? : MlUpdateJobQuery = MlUpdateJobQuery::new(),
) -> MlUpdateJobRequest {
  { job_id, query, body }
}

///|
pub async fn Client::ml_update_job(
  self : Client,
  request : MlUpdateJobRequest,
) -> EsResponse[MlUpdateJobResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/{job_id}/_update", ["job_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpdateModelSnapshotQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateModelSnapshotQuery with fn to_json(
  _self : MlUpdateModelSnapshotQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlUpdateModelSnapshotQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlUpdateModelSnapshotQuery: expected object"))
  }
  MlUpdateModelSnapshotQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlUpdateModelSnapshotQuery::new() -> MlUpdateModelSnapshotQuery {
  MlUpdateModelSnapshotQuery::{  }
}

///|
pub fn MlUpdateModelSnapshotQuery::to_pairs(
  _self : MlUpdateModelSnapshotQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlUpdateModelSnapshotBody {
  description : String?
  retain : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateModelSnapshotBody with fn to_json(
  self : MlUpdateModelSnapshotBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.retain {
    Some(value) => obj["retain"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateModelSnapshotBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpdateModelSnapshotBody: expected object"))
  }
  {
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    retain: match obj.get("retain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("retain")))
    },
  }
}

///|
pub fn MlUpdateModelSnapshotBody::new(
  description? : String,
  retain? : Bool,
) -> MlUpdateModelSnapshotBody {
  { description, retain }
}

///|
pub(all) struct MlUpdateModelSnapshotResponse {
  acknowledged : Bool
  model : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateModelSnapshotResponse with fn to_json(
  self : MlUpdateModelSnapshotResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  obj["model"] = self.model.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateModelSnapshotResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpdateModelSnapshotResponse: expected object"),
    )
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    model: @json.from_json(
      obj.get("model").unwrap_or(Json::null()),
      path=path.add_key("model"),
    ),
  }
}

///|
pub(all) struct MlUpdateModelSnapshotRequest {
  job_id : String
  snapshot_id : String
  query : MlUpdateModelSnapshotQuery
  body : MlUpdateModelSnapshotBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpdateModelSnapshotRequest::new(
  job_id : String,
  snapshot_id : String,
  body : MlUpdateModelSnapshotBody,
  query? : MlUpdateModelSnapshotQuery = MlUpdateModelSnapshotQuery::new(),
) -> MlUpdateModelSnapshotRequest {
  { job_id, snapshot_id, query, body }
}

///|
pub async fn Client::ml_update_model_snapshot(
  self : Client,
  request : MlUpdateModelSnapshotRequest,
) -> EsResponse[MlUpdateModelSnapshotResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  params["snapshot_id"] = request.snapshot_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_update",
        ["job_id", "snapshot_id"],
      ),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpdateTrainedModelDeploymentQuery {
  number_of_allocations : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateTrainedModelDeploymentQuery with fn to_json(
  self : MlUpdateTrainedModelDeploymentQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.number_of_allocations {
    Some(value) => obj["number_of_allocations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateTrainedModelDeploymentQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpdateTrainedModelDeploymentQuery: expected object"),
    )
  }
  {
    number_of_allocations: match obj.get("number_of_allocations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("number_of_allocations")))
    },
  }
}

///|
pub fn MlUpdateTrainedModelDeploymentQuery::new(
  number_of_allocations? : Int,
) -> MlUpdateTrainedModelDeploymentQuery {
  { number_of_allocations, }
}

///|
pub fn MlUpdateTrainedModelDeploymentQuery::to_pairs(
  self : MlUpdateTrainedModelDeploymentQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.number_of_allocations {
    Some(value) =>
      push_query_json(pairs, "number_of_allocations", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlUpdateTrainedModelDeploymentBody {
  number_of_allocations : Int?
  adaptive_allocations : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateTrainedModelDeploymentBody with fn to_json(
  self : MlUpdateTrainedModelDeploymentBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.number_of_allocations {
    Some(value) => obj["number_of_allocations"] = value.to_json()
    None => ()
  }
  match self.adaptive_allocations {
    Some(value) => obj["adaptive_allocations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateTrainedModelDeploymentBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpdateTrainedModelDeploymentBody: expected object"),
    )
  }
  {
    number_of_allocations: match obj.get("number_of_allocations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("number_of_allocations")))
    },
    adaptive_allocations: match obj.get("adaptive_allocations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("adaptive_allocations")))
    },
  }
}

///|
pub fn MlUpdateTrainedModelDeploymentBody::new(
  number_of_allocations? : Int,
  adaptive_allocations? : Json,
) -> MlUpdateTrainedModelDeploymentBody {
  { number_of_allocations, adaptive_allocations }
}

///|
pub(all) struct MlUpdateTrainedModelDeploymentResponse {
  assignment : Json
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpdateTrainedModelDeploymentResponse with fn to_json(
  self : MlUpdateTrainedModelDeploymentResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["assignment"] = self.assignment.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlUpdateTrainedModelDeploymentResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpdateTrainedModelDeploymentResponse: expected object"),
    )
  }
  {
    assignment: @json.from_json(
      obj.get("assignment").unwrap_or(Json::null()),
      path=path.add_key("assignment"),
    ),
  }
}

///|
pub(all) struct MlUpdateTrainedModelDeploymentRequest {
  model_id : String
  query : MlUpdateTrainedModelDeploymentQuery
  body : MlUpdateTrainedModelDeploymentBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpdateTrainedModelDeploymentRequest::new(
  model_id : String,
  query? : MlUpdateTrainedModelDeploymentQuery = MlUpdateTrainedModelDeploymentQuery::new(),
  body? : MlUpdateTrainedModelDeploymentBody,
) -> MlUpdateTrainedModelDeploymentRequest {
  { model_id, query, body }
}

///|
pub async fn Client::ml_update_trained_model_deployment(
  self : Client,
  request : MlUpdateTrainedModelDeploymentRequest,
) -> EsResponse[MlUpdateTrainedModelDeploymentResponse] {
  let params : Map[String, String] = Map([])
  params["model_id"] = request.model_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ml/trained_models/{model_id}/deployment/_update", [
        "model_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlUpgradeJobSnapshotQuery {
  wait_for_completion : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpgradeJobSnapshotQuery with fn to_json(
  self : MlUpgradeJobSnapshotQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlUpgradeJobSnapshotQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlUpgradeJobSnapshotQuery: expected object"))
  }
  {
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn MlUpgradeJobSnapshotQuery::new(
  wait_for_completion? : Bool,
  timeout? : String,
) -> MlUpgradeJobSnapshotQuery {
  { wait_for_completion, timeout }
}

///|
pub fn MlUpgradeJobSnapshotQuery::to_pairs(
  self : MlUpgradeJobSnapshotQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MlUpgradeJobSnapshotResponse {
  node : Json
  completed : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for MlUpgradeJobSnapshotResponse with fn to_json(
  self : MlUpgradeJobSnapshotResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["node"] = self.node.to_json()
  obj["completed"] = self.completed.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MlUpgradeJobSnapshotResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "MlUpgradeJobSnapshotResponse: expected object"),
    )
  }
  {
    node: @json.from_json(
      obj.get("node").unwrap_or(Json::null()),
      path=path.add_key("node"),
    ),
    completed: @json.from_json(
      obj.get("completed").unwrap_or(Json::null()),
      path=path.add_key("completed"),
    ),
  }
}

///|
pub(all) struct MlUpgradeJobSnapshotRequest {
  job_id : String
  snapshot_id : String
  query : MlUpgradeJobSnapshotQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlUpgradeJobSnapshotRequest::new(
  job_id : String,
  snapshot_id : String,
  query? : MlUpgradeJobSnapshotQuery = MlUpgradeJobSnapshotQuery::new(),
) -> MlUpgradeJobSnapshotRequest {
  { job_id, snapshot_id, query }
}

///|
pub async fn Client::ml_upgrade_job_snapshot(
  self : Client,
  request : MlUpgradeJobSnapshotRequest,
) -> EsResponse[MlUpgradeJobSnapshotResponse] {
  let params : Map[String, String] = Map([])
  params["job_id"] = request.job_id
  params["snapshot_id"] = request.snapshot_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_upgrade",
        ["job_id", "snapshot_id"],
      ),
    ],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct MlValidateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlValidateQuery with fn to_json(_self : MlValidateQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlValidateQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlValidateQuery: expected object"))
  }
  MlValidateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlValidateQuery::new() -> MlValidateQuery {
  MlValidateQuery::{  }
}

///|
pub fn MlValidateQuery::to_pairs(
  _self : MlValidateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct MlValidateBody {
  job_id : Json?
  analysis_config : Json?
  analysis_limits : Json?
  data_description : Json?
  description : String?
  model_plot : Json?
  model_snapshot_id : Json?
  model_snapshot_retention_days : Int?
  results_index_name : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for MlValidateBody with fn to_json(self : MlValidateBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.job_id {
    Some(value) => obj["job_id"] = value.to_json()
    None => ()
  }
  match self.analysis_config {
    Some(value) => obj["analysis_config"] = value.to_json()
    None => ()
  }
  match self.analysis_limits {
    Some(value) => obj["analysis_limits"] = value.to_json()
    None => ()
  }
  match self.data_description {
    Some(value) => obj["data_description"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.model_plot {
    Some(value) => obj["model_plot"] = value.to_json()
    None => ()
  }
  match self.model_snapshot_id {
    Some(value) => obj["model_snapshot_id"] = value.to_json()
    None => ()
  }
  match self.model_snapshot_retention_days {
    Some(value) => obj["model_snapshot_retention_days"] = value.to_json()
    None => ()
  }
  match self.results_index_name {
    Some(value) => obj["results_index_name"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MlValidateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MlValidateBody: expected object"))
  }
  {
    job_id: match obj.get("job_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("job_id")))
    },
    analysis_config: match obj.get("analysis_config") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analysis_config")))
    },
    analysis_limits: match obj.get("analysis_limits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analysis_limits")))
    },
    data_description: match obj.get("data_description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_description")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    model_plot: match obj.get("model_plot") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_plot")))
    },
    model_snapshot_id: match obj.get("model_snapshot_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("model_snapshot_id")))
    },
    model_snapshot_retention_days: match
      obj.get("model_snapshot_retention_days") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("model_snapshot_retention_days"),
          ),
        )
    },
    results_index_name: match obj.get("results_index_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("results_index_name")))
    },
  }
}

///|
pub fn MlValidateBody::new(
  job_id? : Json,
  analysis_config? : Json,
  analysis_limits? : Json,
  data_description? : Json,
  description? : String,
  model_plot? : Json,
  model_snapshot_id? : Json,
  model_snapshot_retention_days? : Int,
  results_index_name? : Json,
) -> MlValidateBody {
  {
    job_id,
    analysis_config,
    analysis_limits,
    data_description,
    description,
    model_plot,
    model_snapshot_id,
    model_snapshot_retention_days,
    results_index_name,
  }
}

///|
pub type MlValidateResponse = Json

///|
pub(all) struct MlValidateRequest {
  query : MlValidateQuery
  body : MlValidateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlValidateRequest::new(
  body : MlValidateBody,
  query? : MlValidateQuery = MlValidateQuery::new(),
) -> MlValidateRequest {
  { query, body }
}

///|
pub async fn Client::ml_validate(
  self : Client,
  request : MlValidateRequest,
) -> EsResponse[MlValidateResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/_validate", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MlValidateDetectorQuery {} derive(Eq, Debug)

///|
pub impl ToJson for MlValidateDetectorQuery with fn to_json(
  _self : MlValidateDetectorQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for MlValidateDetectorQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "MlValidateDetectorQuery: expected object"))
  }
  MlValidateDetectorQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn MlValidateDetectorQuery::new() -> MlValidateDetectorQuery {
  MlValidateDetectorQuery::{  }
}

///|
pub fn MlValidateDetectorQuery::to_pairs(
  _self : MlValidateDetectorQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type MlValidateDetectorBody = Json

///|
pub type MlValidateDetectorResponse = Json

///|
pub(all) struct MlValidateDetectorRequest {
  query : MlValidateDetectorQuery
  body : MlValidateDetectorBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MlValidateDetectorRequest::new(
  body : MlValidateDetectorBody,
  query? : MlValidateDetectorQuery = MlValidateDetectorQuery::new(),
) -> MlValidateDetectorRequest {
  { query, body }
}

///|
pub async fn Client::ml_validate_detector(
  self : Client,
  request : MlValidateDetectorRequest,
) -> EsResponse[MlValidateDetectorResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_ml/anomaly_detectors/_validate/detector", [])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MonitoringBulkQuery {
  system_id : String
  system_api_version : String
  interval : String
} derive(Eq, Debug)

///|
pub impl ToJson for MonitoringBulkQuery with fn to_json(
  self : MonitoringBulkQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["system_id"] = self.system_id.to_json()
  obj["system_api_version"] = self.system_api_version.to_json()
  obj["interval"] = self.interval.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MonitoringBulkQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MonitoringBulkQuery: expected object"))
  }
  {
    system_id: @json.from_json(
      obj.get("system_id").unwrap_or(Json::null()),
      path=path.add_key("system_id"),
    ),
    system_api_version: @json.from_json(
      obj.get("system_api_version").unwrap_or(Json::null()),
      path=path.add_key("system_api_version"),
    ),
    interval: @json.from_json(
      obj.get("interval").unwrap_or(Json::null()),
      path=path.add_key("interval"),
    ),
  }
}

///|
pub fn MonitoringBulkQuery::new(
  system_id : String,
  system_api_version : String,
  interval : String,
) -> MonitoringBulkQuery {
  { system_id, system_api_version, interval }
}

///|
pub fn MonitoringBulkQuery::to_pairs(
  self : MonitoringBulkQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  push_query_json(pairs, "system_id", self.system_id.to_json())
  push_query_json(
    pairs,
    "system_api_version",
    self.system_api_version.to_json(),
  )
  push_query_json(pairs, "interval", self.interval.to_json())
  pairs
}

///|
pub type MonitoringBulkBody = Array[Json]

///|
pub(all) struct MonitoringBulkResponse {
  error : Json?
  errors : Bool
  ignored : Bool
  took : Int
} derive(Eq, Debug)

///|
pub impl ToJson for MonitoringBulkResponse with fn to_json(
  self : MonitoringBulkResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.error {
    Some(value) => obj["error"] = value.to_json()
    None => ()
  }
  obj["errors"] = self.errors.to_json()
  obj["ignored"] = self.ignored.to_json()
  obj["took"] = self.took.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MonitoringBulkResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MonitoringBulkResponse: expected object"))
  }
  {
    error: match obj.get("error") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("error")))
    },
    errors: @json.from_json(
      obj.get("errors").unwrap_or(Json::null()),
      path=path.add_key("errors"),
    ),
    ignored: @json.from_json(
      obj.get("ignored").unwrap_or(Json::null()),
      path=path.add_key("ignored"),
    ),
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
  }
}

///|
pub(all) struct MonitoringBulkRequest {
  query : MonitoringBulkQuery
  body : MonitoringBulkBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MonitoringBulkRequest::new(
  body : MonitoringBulkBody,
  query : MonitoringBulkQuery,
) -> MonitoringBulkRequest {
  { query, body }
}

///|
pub async fn Client::monitoring_bulk(
  self : Client,
  request : MonitoringBulkRequest,
) -> EsResponse[MonitoringBulkResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_monitoring/bulk", [])], params)
  let body = Ndjson(request.body)
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MsearchQuery {
  allow_no_indices : Bool?
  ccs_minimize_roundtrips : Bool?
  expand_wildcards : String?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  include_named_queries_score : Bool?
  index : String?
  max_concurrent_searches : Int?
  max_concurrent_shard_requests : Int?
  pre_filter_shard_size : Int?
  project_routing : String?
  rest_total_hits_as_int : Bool?
  routing : String?
  search_type : String?
  typed_keys : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MsearchQuery with fn to_json(self : MsearchQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_named_queries_score {
    Some(value) => obj["include_named_queries_score"] = value.to_json()
    None => ()
  }
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_searches {
    Some(value) => obj["max_concurrent_searches"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) => obj["max_concurrent_shard_requests"] = value.to_json()
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) => obj["pre_filter_shard_size"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MsearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MsearchQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_named_queries_score: match obj.get("include_named_queries_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("include_named_queries_score"),
          ),
        )
    },
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
    max_concurrent_searches: match obj.get("max_concurrent_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_concurrent_searches")),
        )
    },
    max_concurrent_shard_requests: match
      obj.get("max_concurrent_shard_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_concurrent_shard_requests"),
          ),
        )
    },
    pre_filter_shard_size: match obj.get("pre_filter_shard_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("pre_filter_shard_size")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
  }
}

///|
pub fn MsearchQuery::new(
  allow_no_indices? : Bool,
  ccs_minimize_roundtrips? : Bool,
  expand_wildcards? : String,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  include_named_queries_score? : Bool,
  index? : String,
  max_concurrent_searches? : Int,
  max_concurrent_shard_requests? : Int,
  pre_filter_shard_size? : Int,
  project_routing? : String,
  rest_total_hits_as_int? : Bool,
  routing? : String,
  search_type? : String,
  typed_keys? : Bool,
) -> MsearchQuery {
  {
    allow_no_indices,
    ccs_minimize_roundtrips,
    expand_wildcards,
    ignore_throttled,
    ignore_unavailable,
    include_named_queries_score,
    index,
    max_concurrent_searches,
    max_concurrent_shard_requests,
    pre_filter_shard_size,
    project_routing,
    rest_total_hits_as_int,
    routing,
    search_type,
    typed_keys,
  }
}

///|
pub fn MsearchQuery::to_pairs(self : MsearchQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_named_queries_score {
    Some(value) =>
      push_query_json(pairs, "include_named_queries_score", value.to_json())
    None => ()
  }
  match self.index {
    Some(value) => push_query_json(pairs, "index", value.to_json())
    None => ()
  }
  match self.max_concurrent_searches {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_searches", value.to_json())
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_shard_requests", value.to_json())
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) =>
      push_query_json(pairs, "pre_filter_shard_size", value.to_json())
    None => ()
  }
  match self.project_routing {
    Some(value) => push_query_json(pairs, "project_routing", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MsearchBody = Array[Json]

///|
pub type MsearchResponse = Json

///|
pub(all) struct MsearchRequest {
  index : String?
  query : MsearchQuery
  body : MsearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MsearchRequest::new(
  body : MsearchBody,
  index? : String,
  query? : MsearchQuery = MsearchQuery::new(),
) -> MsearchRequest {
  { index, query, body }
}

///|
pub async fn Client::msearch(
  self : Client,
  request : MsearchRequest,
) -> EsResponse[MsearchResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_msearch", ["index"]),
      PathVariant::new("/_msearch", []),
    ],
    params,
  )
  let body = Ndjson(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MsearchTemplateQuery {
  ccs_minimize_roundtrips : Bool?
  max_concurrent_searches : Int?
  project_routing : String?
  search_type : String?
  rest_total_hits_as_int : Bool?
  typed_keys : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for MsearchTemplateQuery with fn to_json(
  self : MsearchTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_searches {
    Some(value) => obj["max_concurrent_searches"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MsearchTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MsearchTemplateQuery: expected object"))
  }
  {
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    max_concurrent_searches: match obj.get("max_concurrent_searches") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("max_concurrent_searches")),
        )
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
  }
}

///|
pub fn MsearchTemplateQuery::new(
  ccs_minimize_roundtrips? : Bool,
  max_concurrent_searches? : Int,
  project_routing? : String,
  search_type? : String,
  rest_total_hits_as_int? : Bool,
  typed_keys? : Bool,
) -> MsearchTemplateQuery {
  {
    ccs_minimize_roundtrips,
    max_concurrent_searches,
    project_routing,
    search_type,
    rest_total_hits_as_int,
    typed_keys,
  }
}

///|
pub fn MsearchTemplateQuery::to_pairs(
  self : MsearchTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.max_concurrent_searches {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_searches", value.to_json())
    None => ()
  }
  match self.project_routing {
    Some(value) => push_query_json(pairs, "project_routing", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type MsearchTemplateBody = Array[Json]

///|
pub type MsearchTemplateResponse = Json

///|
pub(all) struct MsearchTemplateRequest {
  index : String?
  query : MsearchTemplateQuery
  body : MsearchTemplateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MsearchTemplateRequest::new(
  body : MsearchTemplateBody,
  index? : String,
  query? : MsearchTemplateQuery = MsearchTemplateQuery::new(),
) -> MsearchTemplateRequest {
  { index, query, body }
}

///|
pub async fn Client::msearch_template(
  self : Client,
  request : MsearchTemplateRequest,
) -> EsResponse[MsearchTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_msearch/template", ["index"]),
      PathVariant::new("/_msearch/template", []),
    ],
    params,
  )
  let body = Ndjson(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct MtermvectorsQuery {
  ids : Array[String]?
  fields : String?
  field_statistics : Bool?
  offsets : Bool?
  payloads : Bool?
  positions : Bool?
  preference : String?
  realtime : Bool?
  routing : String?
  term_statistics : Bool?
  version : String?
  version_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for MtermvectorsQuery with fn to_json(self : MtermvectorsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ids {
    Some(value) => obj["ids"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.field_statistics {
    Some(value) => obj["field_statistics"] = value.to_json()
    None => ()
  }
  match self.offsets {
    Some(value) => obj["offsets"] = value.to_json()
    None => ()
  }
  match self.payloads {
    Some(value) => obj["payloads"] = value.to_json()
    None => ()
  }
  match self.positions {
    Some(value) => obj["positions"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.term_statistics {
    Some(value) => obj["term_statistics"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MtermvectorsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MtermvectorsQuery: expected object"))
  }
  {
    ids: match obj.get("ids") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ids")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    field_statistics: match obj.get("field_statistics") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("field_statistics")))
    },
    offsets: match obj.get("offsets") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("offsets")))
    },
    payloads: match obj.get("payloads") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("payloads")))
    },
    positions: match obj.get("positions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("positions")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    term_statistics: match obj.get("term_statistics") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("term_statistics")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn MtermvectorsQuery::new(
  ids? : Array[String],
  fields? : String,
  field_statistics? : Bool,
  offsets? : Bool,
  payloads? : Bool,
  positions? : Bool,
  preference? : String,
  realtime? : Bool,
  routing? : String,
  term_statistics? : Bool,
  version? : String,
  version_type? : String,
) -> MtermvectorsQuery {
  {
    ids,
    fields,
    field_statistics,
    offsets,
    payloads,
    positions,
    preference,
    realtime,
    routing,
    term_statistics,
    version,
    version_type,
  }
}

///|
pub fn MtermvectorsQuery::to_pairs(
  self : MtermvectorsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ids {
    Some(value) => push_query_json(pairs, "ids", value.to_json())
    None => ()
  }
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.field_statistics {
    Some(value) => push_query_json(pairs, "field_statistics", value.to_json())
    None => ()
  }
  match self.offsets {
    Some(value) => push_query_json(pairs, "offsets", value.to_json())
    None => ()
  }
  match self.payloads {
    Some(value) => push_query_json(pairs, "payloads", value.to_json())
    None => ()
  }
  match self.positions {
    Some(value) => push_query_json(pairs, "positions", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.term_statistics {
    Some(value) => push_query_json(pairs, "term_statistics", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct MtermvectorsBody {
  docs : Array[Json]?
  ids : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for MtermvectorsBody with fn to_json(self : MtermvectorsBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.docs {
    Some(value) => obj["docs"] = value.to_json()
    None => ()
  }
  match self.ids {
    Some(value) => obj["ids"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for MtermvectorsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MtermvectorsBody: expected object"))
  }
  {
    docs: match obj.get("docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("docs")))
    },
    ids: match obj.get("ids") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ids")))
    },
  }
}

///|
pub fn MtermvectorsBody::new(
  docs? : Array[Json],
  ids? : Array[Json],
) -> MtermvectorsBody {
  { docs, ids }
}

///|
pub(all) struct MtermvectorsResponse {
  docs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for MtermvectorsResponse with fn to_json(
  self : MtermvectorsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for MtermvectorsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "MtermvectorsResponse: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
  }
}

///|
pub(all) struct MtermvectorsRequest {
  index : String?
  query : MtermvectorsQuery
  body : MtermvectorsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn MtermvectorsRequest::new(
  index? : String,
  query? : MtermvectorsQuery = MtermvectorsQuery::new(),
  body? : MtermvectorsBody,
) -> MtermvectorsRequest {
  { index, query, body }
}

///|
pub async fn Client::mtermvectors(
  self : Client,
  request : MtermvectorsRequest,
) -> EsResponse[MtermvectorsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_mtermvectors", ["index"]),
      PathVariant::new("/_mtermvectors", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct NodesClearRepositoriesMeteringArchiveQuery {} derive(Eq, Debug)

///|
pub impl ToJson for NodesClearRepositoriesMeteringArchiveQuery with fn to_json(
  _self : NodesClearRepositoriesMeteringArchiveQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for NodesClearRepositoriesMeteringArchiveQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "NodesClearRepositoriesMeteringArchiveQuery: expected object"),
    )
  }
  NodesClearRepositoriesMeteringArchiveQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn NodesClearRepositoriesMeteringArchiveQuery::new() -> NodesClearRepositoriesMeteringArchiveQuery {
  NodesClearRepositoriesMeteringArchiveQuery::{  }
}

///|
pub fn NodesClearRepositoriesMeteringArchiveQuery::to_pairs(
  _self : NodesClearRepositoriesMeteringArchiveQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type NodesClearRepositoriesMeteringArchiveResponse = Json

///|
pub(all) struct NodesClearRepositoriesMeteringArchiveRequest {
  node_id : String
  max_archive_version : String
  query : NodesClearRepositoriesMeteringArchiveQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesClearRepositoriesMeteringArchiveRequest::new(
  node_id : String,
  max_archive_version : String,
  query? : NodesClearRepositoriesMeteringArchiveQuery = NodesClearRepositoriesMeteringArchiveQuery::new(),
) -> NodesClearRepositoriesMeteringArchiveRequest {
  { node_id, max_archive_version, query }
}

///|
pub async fn Client::nodes_clear_repositories_metering_archive(
  self : Client,
  request : NodesClearRepositoriesMeteringArchiveRequest,
) -> EsResponse[NodesClearRepositoriesMeteringArchiveResponse] {
  let params : Map[String, String] = Map([])
  params["node_id"] = request.node_id
  params["max_archive_version"] = request.max_archive_version
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_nodes/{node_id}/_repositories_metering/{max_archive_version}",
        ["node_id", "max_archive_version"],
      ),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct NodesGetRepositoriesMeteringInfoQuery {} derive(Eq, Debug)

///|
pub impl ToJson for NodesGetRepositoriesMeteringInfoQuery with fn to_json(
  _self : NodesGetRepositoriesMeteringInfoQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for NodesGetRepositoriesMeteringInfoQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "NodesGetRepositoriesMeteringInfoQuery: expected object"),
    )
  }
  NodesGetRepositoriesMeteringInfoQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn NodesGetRepositoriesMeteringInfoQuery::new() -> NodesGetRepositoriesMeteringInfoQuery {
  NodesGetRepositoriesMeteringInfoQuery::{  }
}

///|
pub fn NodesGetRepositoriesMeteringInfoQuery::to_pairs(
  _self : NodesGetRepositoriesMeteringInfoQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type NodesGetRepositoriesMeteringInfoResponse = Json

///|
pub(all) struct NodesGetRepositoriesMeteringInfoRequest {
  node_id : String
  query : NodesGetRepositoriesMeteringInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesGetRepositoriesMeteringInfoRequest::new(
  node_id : String,
  query? : NodesGetRepositoriesMeteringInfoQuery = NodesGetRepositoriesMeteringInfoQuery::new(),
) -> NodesGetRepositoriesMeteringInfoRequest {
  { node_id, query }
}

///|
pub async fn Client::nodes_get_repositories_metering_info(
  self : Client,
  request : NodesGetRepositoriesMeteringInfoRequest,
) -> EsResponse[NodesGetRepositoriesMeteringInfoResponse] {
  let params : Map[String, String] = Map([])
  params["node_id"] = request.node_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_nodes/{node_id}/_repositories_metering", ["node_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct NodesHotThreadsQuery {
  ignore_idle_threads : Bool?
  interval : String?
  snapshots : Int?
  threads : Int?
  timeout : String?
  type_ : String?
  sort : String?
} derive(Eq, Debug)

///|
pub impl ToJson for NodesHotThreadsQuery with fn to_json(
  self : NodesHotThreadsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ignore_idle_threads {
    Some(value) => obj["ignore_idle_threads"] = value.to_json()
    None => ()
  }
  match self.interval {
    Some(value) => obj["interval"] = value.to_json()
    None => ()
  }
  match self.snapshots {
    Some(value) => obj["snapshots"] = value.to_json()
    None => ()
  }
  match self.threads {
    Some(value) => obj["threads"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.type_ {
    Some(value) => obj["type"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for NodesHotThreadsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "NodesHotThreadsQuery: expected object"))
  }
  {
    ignore_idle_threads: match obj.get("ignore_idle_threads") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_idle_threads")))
    },
    interval: match obj.get("interval") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("interval")))
    },
    snapshots: match obj.get("snapshots") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("snapshots")))
    },
    threads: match obj.get("threads") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("threads")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    type_: match obj.get("type") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("type")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
  }
}

///|
pub fn NodesHotThreadsQuery::new(
  ignore_idle_threads? : Bool,
  interval? : String,
  snapshots? : Int,
  threads? : Int,
  timeout? : String,
  type_? : String,
  sort? : String,
) -> NodesHotThreadsQuery {
  { ignore_idle_threads, interval, snapshots, threads, timeout, type_, sort }
}

///|
pub fn NodesHotThreadsQuery::to_pairs(
  self : NodesHotThreadsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ignore_idle_threads {
    Some(value) =>
      push_query_json(pairs, "ignore_idle_threads", value.to_json())
    None => ()
  }
  match self.interval {
    Some(value) => push_query_json(pairs, "interval", value.to_json())
    None => ()
  }
  match self.snapshots {
    Some(value) => push_query_json(pairs, "snapshots", value.to_json())
    None => ()
  }
  match self.threads {
    Some(value) => push_query_json(pairs, "threads", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.type_ {
    Some(value) => push_query_json(pairs, "type", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type NodesHotThreadsResponse = Json

///|
pub(all) struct NodesHotThreadsRequest {
  node_id : String?
  query : NodesHotThreadsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesHotThreadsRequest::new(
  node_id? : String,
  query? : NodesHotThreadsQuery = NodesHotThreadsQuery::new(),
) -> NodesHotThreadsRequest {
  { node_id, query }
}

///|
pub async fn Client::nodes_hot_threads(
  self : Client,
  request : NodesHotThreadsRequest,
) -> EsResponse[NodesHotThreadsResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_nodes/{node_id}/hot_threads", ["node_id"]),
      PathVariant::new("/_nodes/hot_threads", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct NodesInfoQuery {
  flat_settings : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for NodesInfoQuery with fn to_json(self : NodesInfoQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.flat_settings {
    Some(value) => obj["flat_settings"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for NodesInfoQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "NodesInfoQuery: expected object"))
  }
  {
    flat_settings: match obj.get("flat_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flat_settings")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn NodesInfoQuery::new(
  flat_settings? : Bool,
  timeout? : String,
) -> NodesInfoQuery {
  { flat_settings, timeout }
}

///|
pub fn NodesInfoQuery::to_pairs(
  self : NodesInfoQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.flat_settings {
    Some(value) => push_query_json(pairs, "flat_settings", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type NodesInfoResponse = Json

///|
pub(all) struct NodesInfoRequest {
  node_id : String?
  metric : String?
  query : NodesInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesInfoRequest::new(
  node_id? : String,
  metric? : String,
  query? : NodesInfoQuery = NodesInfoQuery::new(),
) -> NodesInfoRequest {
  { node_id, metric, query }
}

///|
pub async fn Client::nodes_info(
  self : Client,
  request : NodesInfoRequest,
) -> EsResponse[NodesInfoResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  match request.metric {
    Some(value) => params["metric"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_nodes/{node_id}/{metric}", ["node_id", "metric"]),
      PathVariant::new("/_nodes/{node_id}", ["node_id"]),
      PathVariant::new("/_nodes/{metric}", ["metric"]),
      PathVariant::new("/_nodes", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct NodesReloadSecureSettingsQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for NodesReloadSecureSettingsQuery with fn to_json(
  self : NodesReloadSecureSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for NodesReloadSecureSettingsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "NodesReloadSecureSettingsQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn NodesReloadSecureSettingsQuery::new(
  timeout? : String,
) -> NodesReloadSecureSettingsQuery {
  { timeout, }
}

///|
pub fn NodesReloadSecureSettingsQuery::to_pairs(
  self : NodesReloadSecureSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct NodesReloadSecureSettingsBody {
  secure_settings_password : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for NodesReloadSecureSettingsBody with fn to_json(
  self : NodesReloadSecureSettingsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.secure_settings_password {
    Some(value) => obj["secure_settings_password"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for NodesReloadSecureSettingsBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "NodesReloadSecureSettingsBody: expected object"),
    )
  }
  {
    secure_settings_password: match obj.get("secure_settings_password") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("secure_settings_password")),
        )
    },
  }
}

///|
pub fn NodesReloadSecureSettingsBody::new(
  secure_settings_password? : Json,
) -> NodesReloadSecureSettingsBody {
  { secure_settings_password, }
}

///|
pub type NodesReloadSecureSettingsResponse = Json

///|
pub(all) struct NodesReloadSecureSettingsRequest {
  node_id : String?
  query : NodesReloadSecureSettingsQuery
  body : NodesReloadSecureSettingsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesReloadSecureSettingsRequest::new(
  node_id? : String,
  query? : NodesReloadSecureSettingsQuery = NodesReloadSecureSettingsQuery::new(),
  body? : NodesReloadSecureSettingsBody,
) -> NodesReloadSecureSettingsRequest {
  { node_id, query, body }
}

///|
pub async fn Client::nodes_reload_secure_settings(
  self : Client,
  request : NodesReloadSecureSettingsRequest,
) -> EsResponse[NodesReloadSecureSettingsResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_nodes/{node_id}/reload_secure_settings", ["node_id"]),
      PathVariant::new("/_nodes/reload_secure_settings", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct NodesStatsQuery {
  completion_fields : String?
  fielddata_fields : String?
  fields : String?
  groups : Bool?
  include_segment_file_sizes : Bool?
  level : String?
  timeout : String?
  types : Array[String]?
  include_unloaded_segments : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for NodesStatsQuery with fn to_json(self : NodesStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.completion_fields {
    Some(value) => obj["completion_fields"] = value.to_json()
    None => ()
  }
  match self.fielddata_fields {
    Some(value) => obj["fielddata_fields"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.groups {
    Some(value) => obj["groups"] = value.to_json()
    None => ()
  }
  match self.include_segment_file_sizes {
    Some(value) => obj["include_segment_file_sizes"] = value.to_json()
    None => ()
  }
  match self.level {
    Some(value) => obj["level"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.types {
    Some(value) => obj["types"] = value.to_json()
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) => obj["include_unloaded_segments"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for NodesStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "NodesStatsQuery: expected object"))
  }
  {
    completion_fields: match obj.get("completion_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("completion_fields")))
    },
    fielddata_fields: match obj.get("fielddata_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("fielddata_fields")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    groups: match obj.get("groups") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("groups")))
    },
    include_segment_file_sizes: match obj.get("include_segment_file_sizes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("include_segment_file_sizes"),
          ),
        )
    },
    level: match obj.get("level") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("level")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    types: match obj.get("types") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("types")))
    },
    include_unloaded_segments: match obj.get("include_unloaded_segments") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_unloaded_segments")),
        )
    },
  }
}

///|
pub fn NodesStatsQuery::new(
  completion_fields? : String,
  fielddata_fields? : String,
  fields? : String,
  groups? : Bool,
  include_segment_file_sizes? : Bool,
  level? : String,
  timeout? : String,
  types? : Array[String],
  include_unloaded_segments? : Bool,
) -> NodesStatsQuery {
  {
    completion_fields,
    fielddata_fields,
    fields,
    groups,
    include_segment_file_sizes,
    level,
    timeout,
    types,
    include_unloaded_segments,
  }
}

///|
pub fn NodesStatsQuery::to_pairs(
  self : NodesStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.completion_fields {
    Some(value) => push_query_json(pairs, "completion_fields", value.to_json())
    None => ()
  }
  match self.fielddata_fields {
    Some(value) => push_query_json(pairs, "fielddata_fields", value.to_json())
    None => ()
  }
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.groups {
    Some(value) => push_query_json(pairs, "groups", value.to_json())
    None => ()
  }
  match self.include_segment_file_sizes {
    Some(value) =>
      push_query_json(pairs, "include_segment_file_sizes", value.to_json())
    None => ()
  }
  match self.level {
    Some(value) => push_query_json(pairs, "level", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.types {
    Some(value) => push_query_json(pairs, "types", value.to_json())
    None => ()
  }
  match self.include_unloaded_segments {
    Some(value) =>
      push_query_json(pairs, "include_unloaded_segments", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type NodesStatsResponse = Json

///|
pub(all) struct NodesStatsRequest {
  node_id : String?
  metric : String?
  index_metric : String?
  query : NodesStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesStatsRequest::new(
  node_id? : String,
  metric? : String,
  index_metric? : String,
  query? : NodesStatsQuery = NodesStatsQuery::new(),
) -> NodesStatsRequest {
  { node_id, metric, index_metric, query }
}

///|
pub async fn Client::nodes_stats(
  self : Client,
  request : NodesStatsRequest,
) -> EsResponse[NodesStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  match request.metric {
    Some(value) => params["metric"] = value
    None => ()
  }
  match request.index_metric {
    Some(value) => params["index_metric"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_nodes/{node_id}/stats/{metric}/{index_metric}", [
        "node_id", "metric", "index_metric",
      ]),
      PathVariant::new("/_nodes/{node_id}/stats/{metric}", ["node_id", "metric"]),
      PathVariant::new("/_nodes/stats/{metric}/{index_metric}", [
        "metric", "index_metric",
      ]),
      PathVariant::new("/_nodes/{node_id}/stats", ["node_id"]),
      PathVariant::new("/_nodes/stats/{metric}", ["metric"]),
      PathVariant::new("/_nodes/stats", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct NodesUsageQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for NodesUsageQuery with fn to_json(self : NodesUsageQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for NodesUsageQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "NodesUsageQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn NodesUsageQuery::new(timeout? : String) -> NodesUsageQuery {
  { timeout, }
}

///|
pub fn NodesUsageQuery::to_pairs(
  self : NodesUsageQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type NodesUsageResponse = Json

///|
pub(all) struct NodesUsageRequest {
  node_id : String?
  metric : String?
  query : NodesUsageQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn NodesUsageRequest::new(
  node_id? : String,
  metric? : String,
  query? : NodesUsageQuery = NodesUsageQuery::new(),
) -> NodesUsageRequest {
  { node_id, metric, query }
}

///|
pub async fn Client::nodes_usage(
  self : Client,
  request : NodesUsageRequest,
) -> EsResponse[NodesUsageResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  match request.metric {
    Some(value) => params["metric"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_nodes/{node_id}/usage/{metric}", ["node_id", "metric"]),
      PathVariant::new("/_nodes/{node_id}/usage", ["node_id"]),
      PathVariant::new("/_nodes/usage/{metric}", ["metric"]),
      PathVariant::new("/_nodes/usage", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct OpenPointInTimeQuery {
  keep_alive : String
  ignore_unavailable : Bool?
  preference : String?
  routing : String?
  expand_wildcards : String?
  allow_partial_search_results : Bool?
  max_concurrent_shard_requests : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for OpenPointInTimeQuery with fn to_json(
  self : OpenPointInTimeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["keep_alive"] = self.keep_alive.to_json()
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) => obj["max_concurrent_shard_requests"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for OpenPointInTimeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "OpenPointInTimeQuery: expected object"))
  }
  {
    keep_alive: @json.from_json(
      obj.get("keep_alive").unwrap_or(Json::null()),
      path=path.add_key("keep_alive"),
    ),
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
    max_concurrent_shard_requests: match
      obj.get("max_concurrent_shard_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_concurrent_shard_requests"),
          ),
        )
    },
  }
}

///|
pub fn OpenPointInTimeQuery::new(
  keep_alive : String,
  ignore_unavailable? : Bool,
  preference? : String,
  routing? : String,
  expand_wildcards? : String,
  allow_partial_search_results? : Bool,
  max_concurrent_shard_requests? : Int,
) -> OpenPointInTimeQuery {
  {
    keep_alive,
    ignore_unavailable,
    preference,
    routing,
    expand_wildcards,
    allow_partial_search_results,
    max_concurrent_shard_requests,
  }
}

///|
pub fn OpenPointInTimeQuery::to_pairs(
  self : OpenPointInTimeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  push_query_json(pairs, "keep_alive", self.keep_alive.to_json())
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_search_results", value.to_json())
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_shard_requests", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct OpenPointInTimeBody {
  index_filter : Json?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for OpenPointInTimeBody with fn to_json(
  self : OpenPointInTimeBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index_filter {
    Some(value) => obj["index_filter"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for OpenPointInTimeBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "OpenPointInTimeBody: expected object"))
  }
  {
    index_filter: match obj.get("index_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_filter")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn OpenPointInTimeBody::new(
  index_filter? : Json,
  project_routing? : Json,
) -> OpenPointInTimeBody {
  { index_filter, project_routing }
}

///|
pub(all) struct OpenPointInTimeResponse {
  _shards : Json
  id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for OpenPointInTimeResponse with fn to_json(
  self : OpenPointInTimeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_shards"] = self._shards.to_json()
  obj["id"] = self.id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for OpenPointInTimeResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "OpenPointInTimeResponse: expected object"))
  }
  {
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
  }
}

///|
pub(all) struct OpenPointInTimeRequest {
  index : String
  query : OpenPointInTimeQuery
  body : OpenPointInTimeBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn OpenPointInTimeRequest::new(
  index : String,
  query : OpenPointInTimeQuery,
  body? : OpenPointInTimeBody,
) -> OpenPointInTimeRequest {
  { index, query, body }
}

///|
pub async fn Client::open_point_in_time(
  self : Client,
  request : OpenPointInTimeRequest,
) -> EsResponse[OpenPointInTimeResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/{index}/_pit", ["index"])], params)
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct PingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for PingQuery with fn to_json(_self : PingQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for PingQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "PingQuery: expected object"))
  }
  PingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn PingQuery::new() -> PingQuery {
  PingQuery::{  }
}

///|
pub fn PingQuery::to_pairs(_self : PingQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type PingResponse = Json

///|
pub(all) struct PingRequest {
  query : PingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn PingRequest::new(query? : PingQuery = PingQuery::new()) -> PingRequest {
  { query, }
}

///|
pub async fn Client::ping(
  self : Client,
  request : PingRequest,
) -> EsResponse[PingResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/", [])], params)
  self.perform_json(EsRequest::new(Head, path, query~))
}

///|
pub(all) struct ProfilingFlamegraphQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProfilingFlamegraphQuery with fn to_json(
  _self : ProfilingFlamegraphQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProfilingFlamegraphQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProfilingFlamegraphQuery: expected object"))
  }
  ProfilingFlamegraphQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProfilingFlamegraphQuery::new() -> ProfilingFlamegraphQuery {
  ProfilingFlamegraphQuery::{  }
}

///|
pub fn ProfilingFlamegraphQuery::to_pairs(
  _self : ProfilingFlamegraphQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProfilingFlamegraphBody = Json

///|
pub type ProfilingFlamegraphResponse = Json

///|
pub(all) struct ProfilingFlamegraphRequest {
  query : ProfilingFlamegraphQuery
  body : ProfilingFlamegraphBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProfilingFlamegraphRequest::new(
  body : ProfilingFlamegraphBody,
  query? : ProfilingFlamegraphQuery = ProfilingFlamegraphQuery::new(),
) -> ProfilingFlamegraphRequest {
  { query, body }
}

///|
pub async fn Client::profiling_flamegraph(
  self : Client,
  request : ProfilingFlamegraphRequest,
) -> EsResponse[ProfilingFlamegraphResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_profiling/flamegraph", [])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ProfilingStacktracesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProfilingStacktracesQuery with fn to_json(
  _self : ProfilingStacktracesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProfilingStacktracesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProfilingStacktracesQuery: expected object"))
  }
  ProfilingStacktracesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProfilingStacktracesQuery::new() -> ProfilingStacktracesQuery {
  ProfilingStacktracesQuery::{  }
}

///|
pub fn ProfilingStacktracesQuery::to_pairs(
  _self : ProfilingStacktracesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProfilingStacktracesBody = Json

///|
pub type ProfilingStacktracesResponse = Json

///|
pub(all) struct ProfilingStacktracesRequest {
  query : ProfilingStacktracesQuery
  body : ProfilingStacktracesBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProfilingStacktracesRequest::new(
  body : ProfilingStacktracesBody,
  query? : ProfilingStacktracesQuery = ProfilingStacktracesQuery::new(),
) -> ProfilingStacktracesRequest {
  { query, body }
}

///|
pub async fn Client::profiling_stacktraces(
  self : Client,
  request : ProfilingStacktracesRequest,
) -> EsResponse[ProfilingStacktracesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_profiling/stacktraces", [])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ProfilingStatusQuery {
  master_timeout : String?
  timeout : String?
  wait_for_resources_created : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ProfilingStatusQuery with fn to_json(
  self : ProfilingStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_resources_created {
    Some(value) => obj["wait_for_resources_created"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ProfilingStatusQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ProfilingStatusQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_resources_created: match obj.get("wait_for_resources_created") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_resources_created"),
          ),
        )
    },
  }
}

///|
pub fn ProfilingStatusQuery::new(
  master_timeout? : String,
  timeout? : String,
  wait_for_resources_created? : Bool,
) -> ProfilingStatusQuery {
  { master_timeout, timeout, wait_for_resources_created }
}

///|
pub fn ProfilingStatusQuery::to_pairs(
  self : ProfilingStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_resources_created {
    Some(value) =>
      push_query_json(pairs, "wait_for_resources_created", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ProfilingStatusResponse {
  operation_mode : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ProfilingStatusResponse with fn to_json(
  self : ProfilingStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["operation_mode"] = self.operation_mode.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ProfilingStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ProfilingStatusResponse: expected object"))
  }
  {
    operation_mode: @json.from_json(
      obj.get("operation_mode").unwrap_or(Json::null()),
      path=path.add_key("operation_mode"),
    ),
  }
}

///|
pub(all) struct ProfilingStatusRequest {
  query : ProfilingStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProfilingStatusRequest::new(
  query? : ProfilingStatusQuery = ProfilingStatusQuery::new(),
) -> ProfilingStatusRequest {
  { query, }
}

///|
pub async fn Client::profiling_status(
  self : Client,
  request : ProfilingStatusRequest,
) -> EsResponse[ProfilingStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_profiling/status", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ProfilingTopnFunctionsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProfilingTopnFunctionsQuery with fn to_json(
  _self : ProfilingTopnFunctionsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProfilingTopnFunctionsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ProfilingTopnFunctionsQuery: expected object"),
    )
  }
  ProfilingTopnFunctionsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProfilingTopnFunctionsQuery::new() -> ProfilingTopnFunctionsQuery {
  ProfilingTopnFunctionsQuery::{  }
}

///|
pub fn ProfilingTopnFunctionsQuery::to_pairs(
  _self : ProfilingTopnFunctionsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProfilingTopnFunctionsBody = Json

///|
pub type ProfilingTopnFunctionsResponse = Json

///|
pub(all) struct ProfilingTopnFunctionsRequest {
  query : ProfilingTopnFunctionsQuery
  body : ProfilingTopnFunctionsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProfilingTopnFunctionsRequest::new(
  body : ProfilingTopnFunctionsBody,
  query? : ProfilingTopnFunctionsQuery = ProfilingTopnFunctionsQuery::new(),
) -> ProfilingTopnFunctionsRequest {
  { query, body }
}

///|
pub async fn Client::profiling_topn_functions(
  self : Client,
  request : ProfilingTopnFunctionsRequest,
) -> EsResponse[ProfilingTopnFunctionsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_profiling/topn/functions", [])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ProjectCreateManyRoutingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProjectCreateManyRoutingQuery with fn to_json(
  _self : ProjectCreateManyRoutingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProjectCreateManyRoutingQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ProjectCreateManyRoutingQuery: expected object"),
    )
  }
  ProjectCreateManyRoutingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProjectCreateManyRoutingQuery::new() -> ProjectCreateManyRoutingQuery {
  ProjectCreateManyRoutingQuery::{  }
}

///|
pub fn ProjectCreateManyRoutingQuery::to_pairs(
  _self : ProjectCreateManyRoutingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProjectCreateManyRoutingBody = Json

///|
pub type ProjectCreateManyRoutingResponse = Json

///|
pub(all) struct ProjectCreateManyRoutingRequest {
  query : ProjectCreateManyRoutingQuery
  body : ProjectCreateManyRoutingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProjectCreateManyRoutingRequest::new(
  body : ProjectCreateManyRoutingBody,
  query? : ProjectCreateManyRoutingQuery = ProjectCreateManyRoutingQuery::new(),
) -> ProjectCreateManyRoutingRequest {
  { query, body }
}

///|
pub async fn Client::project_create_many_routing(
  self : Client,
  request : ProjectCreateManyRoutingRequest,
) -> EsResponse[ProjectCreateManyRoutingResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_project_routing", [])], params)
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ProjectCreateRoutingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProjectCreateRoutingQuery with fn to_json(
  _self : ProjectCreateRoutingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProjectCreateRoutingQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProjectCreateRoutingQuery: expected object"))
  }
  ProjectCreateRoutingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProjectCreateRoutingQuery::new() -> ProjectCreateRoutingQuery {
  ProjectCreateRoutingQuery::{  }
}

///|
pub fn ProjectCreateRoutingQuery::to_pairs(
  _self : ProjectCreateRoutingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProjectCreateRoutingBody = Json

///|
pub type ProjectCreateRoutingResponse = Json

///|
pub(all) struct ProjectCreateRoutingRequest {
  name : String
  query : ProjectCreateRoutingQuery
  body : ProjectCreateRoutingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProjectCreateRoutingRequest::new(
  name : String,
  body : ProjectCreateRoutingBody,
  query? : ProjectCreateRoutingQuery = ProjectCreateRoutingQuery::new(),
) -> ProjectCreateRoutingRequest {
  { name, query, body }
}

///|
pub async fn Client::project_create_routing(
  self : Client,
  request : ProjectCreateRoutingRequest,
) -> EsResponse[ProjectCreateRoutingResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_project_routing/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct ProjectDeleteRoutingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProjectDeleteRoutingQuery with fn to_json(
  _self : ProjectDeleteRoutingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProjectDeleteRoutingQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProjectDeleteRoutingQuery: expected object"))
  }
  ProjectDeleteRoutingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProjectDeleteRoutingQuery::new() -> ProjectDeleteRoutingQuery {
  ProjectDeleteRoutingQuery::{  }
}

///|
pub fn ProjectDeleteRoutingQuery::to_pairs(
  _self : ProjectDeleteRoutingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProjectDeleteRoutingResponse = Json

///|
pub(all) struct ProjectDeleteRoutingRequest {
  name : String
  query : ProjectDeleteRoutingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProjectDeleteRoutingRequest::new(
  name : String,
  query? : ProjectDeleteRoutingQuery = ProjectDeleteRoutingQuery::new(),
) -> ProjectDeleteRoutingRequest {
  { name, query }
}

///|
pub async fn Client::project_delete_routing(
  self : Client,
  request : ProjectDeleteRoutingRequest,
) -> EsResponse[ProjectDeleteRoutingResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_project_routing/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct ProjectGetManyRoutingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProjectGetManyRoutingQuery with fn to_json(
  _self : ProjectGetManyRoutingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProjectGetManyRoutingQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProjectGetManyRoutingQuery: expected object"))
  }
  ProjectGetManyRoutingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProjectGetManyRoutingQuery::new() -> ProjectGetManyRoutingQuery {
  ProjectGetManyRoutingQuery::{  }
}

///|
pub fn ProjectGetManyRoutingQuery::to_pairs(
  _self : ProjectGetManyRoutingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProjectGetManyRoutingResponse = Json

///|
pub(all) struct ProjectGetManyRoutingRequest {
  query : ProjectGetManyRoutingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProjectGetManyRoutingRequest::new(
  query? : ProjectGetManyRoutingQuery = ProjectGetManyRoutingQuery::new(),
) -> ProjectGetManyRoutingRequest {
  { query, }
}

///|
pub async fn Client::project_get_many_routing(
  self : Client,
  request : ProjectGetManyRoutingRequest,
) -> EsResponse[ProjectGetManyRoutingResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_project_routing", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ProjectGetRoutingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProjectGetRoutingQuery with fn to_json(
  _self : ProjectGetRoutingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProjectGetRoutingQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProjectGetRoutingQuery: expected object"))
  }
  ProjectGetRoutingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProjectGetRoutingQuery::new() -> ProjectGetRoutingQuery {
  ProjectGetRoutingQuery::{  }
}

///|
pub fn ProjectGetRoutingQuery::to_pairs(
  _self : ProjectGetRoutingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProjectGetRoutingResponse = Json

///|
pub(all) struct ProjectGetRoutingRequest {
  name : String
  query : ProjectGetRoutingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProjectGetRoutingRequest::new(
  name : String,
  query? : ProjectGetRoutingQuery = ProjectGetRoutingQuery::new(),
) -> ProjectGetRoutingRequest {
  { name, query }
}

///|
pub async fn Client::project_get_routing(
  self : Client,
  request : ProjectGetRoutingRequest,
) -> EsResponse[ProjectGetRoutingResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_project_routing/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct ProjectTagsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ProjectTagsQuery with fn to_json(_self : ProjectTagsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ProjectTagsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "ProjectTagsQuery: expected object"))
  }
  ProjectTagsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ProjectTagsQuery::new() -> ProjectTagsQuery {
  ProjectTagsQuery::{  }
}

///|
pub fn ProjectTagsQuery::to_pairs(
  _self : ProjectTagsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type ProjectTagsResponse = Json

///|
pub(all) struct ProjectTagsRequest {
  query : ProjectTagsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ProjectTagsRequest::new(
  query? : ProjectTagsQuery = ProjectTagsQuery::new(),
) -> ProjectTagsRequest {
  { query, }
}

///|
pub async fn Client::project_tags(
  self : Client,
  request : ProjectTagsRequest,
) -> EsResponse[ProjectTagsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_project/tags", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct PutScriptQuery {
  context : String?
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for PutScriptQuery with fn to_json(self : PutScriptQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.context {
    Some(value) => obj["context"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for PutScriptQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "PutScriptQuery: expected object"))
  }
  {
    context: match obj.get("context") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("context")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn PutScriptQuery::new(
  context? : String,
  master_timeout? : String,
  timeout? : String,
) -> PutScriptQuery {
  { context, master_timeout, timeout }
}

///|
pub fn PutScriptQuery::to_pairs(
  self : PutScriptQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.context {
    Some(value) => push_query_json(pairs, "context", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct PutScriptBody {
  script : Json
} derive(Eq, Debug)

///|
pub impl ToJson for PutScriptBody with fn to_json(self : PutScriptBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["script"] = self.script.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for PutScriptBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "PutScriptBody: expected object"))
  }
  {
    script: @json.from_json(
      obj.get("script").unwrap_or(Json::null()),
      path=path.add_key("script"),
    ),
  }
}

///|
pub fn PutScriptBody::new(script : Json) -> PutScriptBody {
  { script, }
}

///|
pub type PutScriptResponse = Json

///|
pub(all) struct PutScriptRequest {
  id : String
  context : String?
  query : PutScriptQuery
  body : PutScriptBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn PutScriptRequest::new(
  id : String,
  body : PutScriptBody,
  context? : String,
  query? : PutScriptQuery = PutScriptQuery::new(),
) -> PutScriptRequest {
  { id, context, query, body }
}

///|
pub async fn Client::put_script(
  self : Client,
  request : PutScriptRequest,
) -> EsResponse[PutScriptResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  match request.context {
    Some(value) => params["context"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_scripts/{id}/{context}", ["id", "context"]),
      PathVariant::new("/_scripts/{id}", ["id"]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct QueryRulesDeleteRuleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesDeleteRuleQuery with fn to_json(
  _self : QueryRulesDeleteRuleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesDeleteRuleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "QueryRulesDeleteRuleQuery: expected object"))
  }
  QueryRulesDeleteRuleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesDeleteRuleQuery::new() -> QueryRulesDeleteRuleQuery {
  QueryRulesDeleteRuleQuery::{  }
}

///|
pub fn QueryRulesDeleteRuleQuery::to_pairs(
  _self : QueryRulesDeleteRuleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type QueryRulesDeleteRuleResponse = Json

///|
pub(all) struct QueryRulesDeleteRuleRequest {
  ruleset_id : String
  rule_id : String
  query : QueryRulesDeleteRuleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesDeleteRuleRequest::new(
  ruleset_id : String,
  rule_id : String,
  query? : QueryRulesDeleteRuleQuery = QueryRulesDeleteRuleQuery::new(),
) -> QueryRulesDeleteRuleRequest {
  { ruleset_id, rule_id, query }
}

///|
pub async fn Client::query_rules_delete_rule(
  self : Client,
  request : QueryRulesDeleteRuleRequest,
) -> EsResponse[QueryRulesDeleteRuleResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  params["rule_id"] = request.rule_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_query_rules/{ruleset_id}/_rule/{rule_id}", [
        "ruleset_id", "rule_id",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct QueryRulesDeleteRulesetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesDeleteRulesetQuery with fn to_json(
  _self : QueryRulesDeleteRulesetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesDeleteRulesetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "QueryRulesDeleteRulesetQuery: expected object"),
    )
  }
  QueryRulesDeleteRulesetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesDeleteRulesetQuery::new() -> QueryRulesDeleteRulesetQuery {
  QueryRulesDeleteRulesetQuery::{  }
}

///|
pub fn QueryRulesDeleteRulesetQuery::to_pairs(
  _self : QueryRulesDeleteRulesetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type QueryRulesDeleteRulesetResponse = Json

///|
pub(all) struct QueryRulesDeleteRulesetRequest {
  ruleset_id : String
  query : QueryRulesDeleteRulesetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesDeleteRulesetRequest::new(
  ruleset_id : String,
  query? : QueryRulesDeleteRulesetQuery = QueryRulesDeleteRulesetQuery::new(),
) -> QueryRulesDeleteRulesetRequest {
  { ruleset_id, query }
}

///|
pub async fn Client::query_rules_delete_ruleset(
  self : Client,
  request : QueryRulesDeleteRulesetRequest,
) -> EsResponse[QueryRulesDeleteRulesetResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query_rules/{ruleset_id}", ["ruleset_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct QueryRulesGetRuleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesGetRuleQuery with fn to_json(
  _self : QueryRulesGetRuleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesGetRuleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "QueryRulesGetRuleQuery: expected object"))
  }
  QueryRulesGetRuleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesGetRuleQuery::new() -> QueryRulesGetRuleQuery {
  QueryRulesGetRuleQuery::{  }
}

///|
pub fn QueryRulesGetRuleQuery::to_pairs(
  _self : QueryRulesGetRuleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type QueryRulesGetRuleResponse = Json

///|
pub(all) struct QueryRulesGetRuleRequest {
  ruleset_id : String
  rule_id : String
  query : QueryRulesGetRuleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesGetRuleRequest::new(
  ruleset_id : String,
  rule_id : String,
  query? : QueryRulesGetRuleQuery = QueryRulesGetRuleQuery::new(),
) -> QueryRulesGetRuleRequest {
  { ruleset_id, rule_id, query }
}

///|
pub async fn Client::query_rules_get_rule(
  self : Client,
  request : QueryRulesGetRuleRequest,
) -> EsResponse[QueryRulesGetRuleResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  params["rule_id"] = request.rule_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_query_rules/{ruleset_id}/_rule/{rule_id}", [
        "ruleset_id", "rule_id",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct QueryRulesGetRulesetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesGetRulesetQuery with fn to_json(
  _self : QueryRulesGetRulesetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesGetRulesetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "QueryRulesGetRulesetQuery: expected object"))
  }
  QueryRulesGetRulesetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesGetRulesetQuery::new() -> QueryRulesGetRulesetQuery {
  QueryRulesGetRulesetQuery::{  }
}

///|
pub fn QueryRulesGetRulesetQuery::to_pairs(
  _self : QueryRulesGetRulesetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type QueryRulesGetRulesetResponse = Json

///|
pub(all) struct QueryRulesGetRulesetRequest {
  ruleset_id : String
  query : QueryRulesGetRulesetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesGetRulesetRequest::new(
  ruleset_id : String,
  query? : QueryRulesGetRulesetQuery = QueryRulesGetRulesetQuery::new(),
) -> QueryRulesGetRulesetRequest {
  { ruleset_id, query }
}

///|
pub async fn Client::query_rules_get_ruleset(
  self : Client,
  request : QueryRulesGetRulesetRequest,
) -> EsResponse[QueryRulesGetRulesetResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query_rules/{ruleset_id}", ["ruleset_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct QueryRulesListRulesetsQuery {
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesListRulesetsQuery with fn to_json(
  self : QueryRulesListRulesetsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesListRulesetsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "QueryRulesListRulesetsQuery: expected object"),
    )
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn QueryRulesListRulesetsQuery::new(
  from? : Int,
  size? : Int,
) -> QueryRulesListRulesetsQuery {
  { from, size }
}

///|
pub fn QueryRulesListRulesetsQuery::to_pairs(
  self : QueryRulesListRulesetsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct QueryRulesListRulesetsResponse {
  count : Int
  results : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesListRulesetsResponse with fn to_json(
  self : QueryRulesListRulesetsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["results"] = self.results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesListRulesetsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "QueryRulesListRulesetsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    results: @json.from_json(
      obj.get("results").unwrap_or(Json::null()),
      path=path.add_key("results"),
    ),
  }
}

///|
pub(all) struct QueryRulesListRulesetsRequest {
  query : QueryRulesListRulesetsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesListRulesetsRequest::new(
  query? : QueryRulesListRulesetsQuery = QueryRulesListRulesetsQuery::new(),
) -> QueryRulesListRulesetsRequest {
  { query, }
}

///|
pub async fn Client::query_rules_list_rulesets(
  self : Client,
  request : QueryRulesListRulesetsRequest,
) -> EsResponse[QueryRulesListRulesetsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_query_rules", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct QueryRulesPutRuleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesPutRuleQuery with fn to_json(
  _self : QueryRulesPutRuleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesPutRuleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "QueryRulesPutRuleQuery: expected object"))
  }
  QueryRulesPutRuleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesPutRuleQuery::new() -> QueryRulesPutRuleQuery {
  QueryRulesPutRuleQuery::{  }
}

///|
pub fn QueryRulesPutRuleQuery::to_pairs(
  _self : QueryRulesPutRuleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct QueryRulesPutRuleBody {
  type_ : Json
  criteria : Json
  actions : Json
  priority : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesPutRuleBody with fn to_json(
  self : QueryRulesPutRuleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["type"] = self.type_.to_json()
  obj["criteria"] = self.criteria.to_json()
  obj["actions"] = self.actions.to_json()
  match self.priority {
    Some(value) => obj["priority"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesPutRuleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "QueryRulesPutRuleBody: expected object"))
  }
  {
    type_: @json.from_json(
      obj.get("type").unwrap_or(Json::null()),
      path=path.add_key("type"),
    ),
    criteria: @json.from_json(
      obj.get("criteria").unwrap_or(Json::null()),
      path=path.add_key("criteria"),
    ),
    actions: @json.from_json(
      obj.get("actions").unwrap_or(Json::null()),
      path=path.add_key("actions"),
    ),
    priority: match obj.get("priority") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("priority")))
    },
  }
}

///|
pub fn QueryRulesPutRuleBody::new(
  type_ : Json,
  criteria : Json,
  actions : Json,
  priority? : Int,
) -> QueryRulesPutRuleBody {
  { type_, criteria, actions, priority }
}

///|
pub(all) struct QueryRulesPutRuleResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesPutRuleResponse with fn to_json(
  self : QueryRulesPutRuleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesPutRuleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "QueryRulesPutRuleResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct QueryRulesPutRuleRequest {
  ruleset_id : String
  rule_id : String
  query : QueryRulesPutRuleQuery
  body : QueryRulesPutRuleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesPutRuleRequest::new(
  ruleset_id : String,
  rule_id : String,
  body : QueryRulesPutRuleBody,
  query? : QueryRulesPutRuleQuery = QueryRulesPutRuleQuery::new(),
) -> QueryRulesPutRuleRequest {
  { ruleset_id, rule_id, query, body }
}

///|
pub async fn Client::query_rules_put_rule(
  self : Client,
  request : QueryRulesPutRuleRequest,
) -> EsResponse[QueryRulesPutRuleResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  params["rule_id"] = request.rule_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_query_rules/{ruleset_id}/_rule/{rule_id}", [
        "ruleset_id", "rule_id",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct QueryRulesPutRulesetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesPutRulesetQuery with fn to_json(
  _self : QueryRulesPutRulesetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesPutRulesetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "QueryRulesPutRulesetQuery: expected object"))
  }
  QueryRulesPutRulesetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesPutRulesetQuery::new() -> QueryRulesPutRulesetQuery {
  QueryRulesPutRulesetQuery::{  }
}

///|
pub fn QueryRulesPutRulesetQuery::to_pairs(
  _self : QueryRulesPutRulesetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct QueryRulesPutRulesetBody {
  rules : Json
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesPutRulesetBody with fn to_json(
  self : QueryRulesPutRulesetBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["rules"] = self.rules.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesPutRulesetBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "QueryRulesPutRulesetBody: expected object"))
  }
  {
    rules: @json.from_json(
      obj.get("rules").unwrap_or(Json::null()),
      path=path.add_key("rules"),
    ),
  }
}

///|
pub fn QueryRulesPutRulesetBody::new(rules : Json) -> QueryRulesPutRulesetBody {
  { rules, }
}

///|
pub(all) struct QueryRulesPutRulesetResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesPutRulesetResponse with fn to_json(
  self : QueryRulesPutRulesetResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesPutRulesetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "QueryRulesPutRulesetResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct QueryRulesPutRulesetRequest {
  ruleset_id : String
  query : QueryRulesPutRulesetQuery
  body : QueryRulesPutRulesetBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesPutRulesetRequest::new(
  ruleset_id : String,
  body : QueryRulesPutRulesetBody,
  query? : QueryRulesPutRulesetQuery = QueryRulesPutRulesetQuery::new(),
) -> QueryRulesPutRulesetRequest {
  { ruleset_id, query, body }
}

///|
pub async fn Client::query_rules_put_ruleset(
  self : Client,
  request : QueryRulesPutRulesetRequest,
) -> EsResponse[QueryRulesPutRulesetResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query_rules/{ruleset_id}", ["ruleset_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct QueryRulesTestQuery {} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesTestQuery with fn to_json(
  _self : QueryRulesTestQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for QueryRulesTestQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "QueryRulesTestQuery: expected object"))
  }
  QueryRulesTestQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn QueryRulesTestQuery::new() -> QueryRulesTestQuery {
  QueryRulesTestQuery::{  }
}

///|
pub fn QueryRulesTestQuery::to_pairs(
  _self : QueryRulesTestQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct QueryRulesTestBody {
  match_criteria : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesTestBody with fn to_json(
  self : QueryRulesTestBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["match_criteria"] = self.match_criteria.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesTestBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "QueryRulesTestBody: expected object"))
  }
  {
    match_criteria: @json.from_json(
      obj.get("match_criteria").unwrap_or(Json::null()),
      path=path.add_key("match_criteria"),
    ),
  }
}

///|
pub fn QueryRulesTestBody::new(
  match_criteria : Map[String, Json],
) -> QueryRulesTestBody {
  { match_criteria, }
}

///|
pub(all) struct QueryRulesTestResponse {
  total_matched_rules : Int
  matched_rules : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for QueryRulesTestResponse with fn to_json(
  self : QueryRulesTestResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["total_matched_rules"] = self.total_matched_rules.to_json()
  obj["matched_rules"] = self.matched_rules.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for QueryRulesTestResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "QueryRulesTestResponse: expected object"))
  }
  {
    total_matched_rules: @json.from_json(
      obj.get("total_matched_rules").unwrap_or(Json::null()),
      path=path.add_key("total_matched_rules"),
    ),
    matched_rules: @json.from_json(
      obj.get("matched_rules").unwrap_or(Json::null()),
      path=path.add_key("matched_rules"),
    ),
  }
}

///|
pub(all) struct QueryRulesTestRequest {
  ruleset_id : String
  query : QueryRulesTestQuery
  body : QueryRulesTestBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn QueryRulesTestRequest::new(
  ruleset_id : String,
  body : QueryRulesTestBody,
  query? : QueryRulesTestQuery = QueryRulesTestQuery::new(),
) -> QueryRulesTestRequest {
  { ruleset_id, query, body }
}

///|
pub async fn Client::query_rules_test(
  self : Client,
  request : QueryRulesTestRequest,
) -> EsResponse[QueryRulesTestResponse] {
  let params : Map[String, String] = Map([])
  params["ruleset_id"] = request.ruleset_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_query_rules/{ruleset_id}/_test", ["ruleset_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct RankEvalQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  search_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for RankEvalQuery with fn to_json(self : RankEvalQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RankEvalQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RankEvalQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
  }
}

///|
pub fn RankEvalQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  search_type? : String,
) -> RankEvalQuery {
  { allow_no_indices, expand_wildcards, ignore_unavailable, search_type }
}

///|
pub fn RankEvalQuery::to_pairs(self : RankEvalQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct RankEvalBody {
  requests : Array[Json]
  metric : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for RankEvalBody with fn to_json(self : RankEvalBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["requests"] = self.requests.to_json()
  match self.metric {
    Some(value) => obj["metric"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RankEvalBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RankEvalBody: expected object"))
  }
  {
    requests: @json.from_json(
      obj.get("requests").unwrap_or(Json::null()),
      path=path.add_key("requests"),
    ),
    metric: match obj.get("metric") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metric")))
    },
  }
}

///|
pub fn RankEvalBody::new(
  requests : Array[Json],
  metric? : Json,
) -> RankEvalBody {
  { requests, metric }
}

///|
pub(all) struct RankEvalResponse {
  metric_score : Double
  details : Map[String, Json]
  failures : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for RankEvalResponse with fn to_json(self : RankEvalResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["metric_score"] = self.metric_score.to_json()
  obj["details"] = self.details.to_json()
  obj["failures"] = self.failures.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for RankEvalResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RankEvalResponse: expected object"))
  }
  {
    metric_score: @json.from_json(
      obj.get("metric_score").unwrap_or(Json::null()),
      path=path.add_key("metric_score"),
    ),
    details: @json.from_json(
      obj.get("details").unwrap_or(Json::null()),
      path=path.add_key("details"),
    ),
    failures: @json.from_json(
      obj.get("failures").unwrap_or(Json::null()),
      path=path.add_key("failures"),
    ),
  }
}

///|
pub(all) struct RankEvalRequest {
  index : String?
  query : RankEvalQuery
  body : RankEvalBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RankEvalRequest::new(
  body : RankEvalBody,
  index? : String,
  query? : RankEvalQuery = RankEvalQuery::new(),
) -> RankEvalRequest {
  { index, query, body }
}

///|
pub async fn Client::rank_eval(
  self : Client,
  request : RankEvalRequest,
) -> EsResponse[RankEvalResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_rank_eval", ["index"]),
      PathVariant::new("/_rank_eval", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ReindexQuery {
  refresh : Bool?
  requests_per_second : Double?
  scroll : String?
  slices : String?
  max_docs : Int?
  timeout : String?
  wait_for_active_shards : String?
  wait_for_completion : Bool?
  require_alias : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ReindexQuery with fn to_json(self : ReindexQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.slices {
    Some(value) => obj["slices"] = value.to_json()
    None => ()
  }
  match self.max_docs {
    Some(value) => obj["max_docs"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  match self.require_alias {
    Some(value) => obj["require_alias"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ReindexQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ReindexQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    slices: match obj.get("slices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slices")))
    },
    max_docs: match obj.get("max_docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("max_docs")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
    require_alias: match obj.get("require_alias") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_alias")))
    },
  }
}

///|
pub fn ReindexQuery::new(
  refresh? : Bool,
  requests_per_second? : Double,
  scroll? : String,
  slices? : String,
  max_docs? : Int,
  timeout? : String,
  wait_for_active_shards? : String,
  wait_for_completion? : Bool,
  require_alias? : Bool,
) -> ReindexQuery {
  {
    refresh,
    requests_per_second,
    scroll,
    slices,
    max_docs,
    timeout,
    wait_for_active_shards,
    wait_for_completion,
    require_alias,
  }
}

///|
pub fn ReindexQuery::to_pairs(self : ReindexQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.requests_per_second {
    Some(value) =>
      push_query_json(pairs, "requests_per_second", value.to_json())
    None => ()
  }
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.slices {
    Some(value) => push_query_json(pairs, "slices", value.to_json())
    None => ()
  }
  match self.max_docs {
    Some(value) => push_query_json(pairs, "max_docs", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  match self.require_alias {
    Some(value) => push_query_json(pairs, "require_alias", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ReindexBody {
  conflicts : Json?
  dest : Json
  max_docs : Int?
  script : Json?
  source : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ReindexBody with fn to_json(self : ReindexBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.conflicts {
    Some(value) => obj["conflicts"] = value.to_json()
    None => ()
  }
  obj["dest"] = self.dest.to_json()
  match self.max_docs {
    Some(value) => obj["max_docs"] = value.to_json()
    None => ()
  }
  match self.script {
    Some(value) => obj["script"] = value.to_json()
    None => ()
  }
  obj["source"] = self.source.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ReindexBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ReindexBody: expected object"))
  }
  {
    conflicts: match obj.get("conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("conflicts")))
    },
    dest: @json.from_json(
      obj.get("dest").unwrap_or(Json::null()),
      path=path.add_key("dest"),
    ),
    max_docs: match obj.get("max_docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("max_docs")))
    },
    script: match obj.get("script") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("script")))
    },
    source: @json.from_json(
      obj.get("source").unwrap_or(Json::null()),
      path=path.add_key("source"),
    ),
  }
}

///|
pub fn ReindexBody::new(
  dest : Json,
  source : Json,
  conflicts? : Json,
  max_docs? : Int,
  script? : Json,
) -> ReindexBody {
  { conflicts, dest, max_docs, script, source }
}

///|
pub(all) struct ReindexResponse {
  batches : Int?
  created : Int?
  deleted : Int?
  failures : Array[Json]?
  noops : Int?
  retries : Json?
  requests_per_second : Double?
  slice_id : Int?
  slices : Array[Json]?
  task : Json?
  throttled_millis : Json?
  throttled_until_millis : Json?
  timed_out : Bool?
  took : Json?
  total : Int?
  updated : Int?
  version_conflicts : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for ReindexResponse with fn to_json(self : ReindexResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.batches {
    Some(value) => obj["batches"] = value.to_json()
    None => ()
  }
  match self.created {
    Some(value) => obj["created"] = value.to_json()
    None => ()
  }
  match self.deleted {
    Some(value) => obj["deleted"] = value.to_json()
    None => ()
  }
  match self.failures {
    Some(value) => obj["failures"] = value.to_json()
    None => ()
  }
  match self.noops {
    Some(value) => obj["noops"] = value.to_json()
    None => ()
  }
  match self.retries {
    Some(value) => obj["retries"] = value.to_json()
    None => ()
  }
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.slice_id {
    Some(value) => obj["slice_id"] = value.to_json()
    None => ()
  }
  match self.slices {
    Some(value) => obj["slices"] = value.to_json()
    None => ()
  }
  match self.task {
    Some(value) => obj["task"] = value.to_json()
    None => ()
  }
  match self.throttled_millis {
    Some(value) => obj["throttled_millis"] = value.to_json()
    None => ()
  }
  match self.throttled_until_millis {
    Some(value) => obj["throttled_until_millis"] = value.to_json()
    None => ()
  }
  match self.timed_out {
    Some(value) => obj["timed_out"] = value.to_json()
    None => ()
  }
  match self.took {
    Some(value) => obj["took"] = value.to_json()
    None => ()
  }
  match self.total {
    Some(value) => obj["total"] = value.to_json()
    None => ()
  }
  match self.updated {
    Some(value) => obj["updated"] = value.to_json()
    None => ()
  }
  match self.version_conflicts {
    Some(value) => obj["version_conflicts"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ReindexResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ReindexResponse: expected object"))
  }
  {
    batches: match obj.get("batches") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("batches")))
    },
    created: match obj.get("created") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("created")))
    },
    deleted: match obj.get("deleted") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("deleted")))
    },
    failures: match obj.get("failures") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("failures")))
    },
    noops: match obj.get("noops") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("noops")))
    },
    retries: match obj.get("retries") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("retries")))
    },
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    slice_id: match obj.get("slice_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice_id")))
    },
    slices: match obj.get("slices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slices")))
    },
    task: match obj.get("task") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("task")))
    },
    throttled_millis: match obj.get("throttled_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled_millis")))
    },
    throttled_until_millis: match obj.get("throttled_until_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("throttled_until_millis")),
        )
    },
    timed_out: match obj.get("timed_out") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timed_out")))
    },
    took: match obj.get("took") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("took")))
    },
    total: match obj.get("total") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("total")))
    },
    updated: match obj.get("updated") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("updated")))
    },
    version_conflicts: match obj.get("version_conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_conflicts")))
    },
  }
}

///|
pub(all) struct ReindexRequest {
  query : ReindexQuery
  body : ReindexBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ReindexRequest::new(
  body : ReindexBody,
  query? : ReindexQuery = ReindexQuery::new(),
) -> ReindexRequest {
  { query, body }
}

///|
pub async fn Client::reindex(
  self : Client,
  request : ReindexRequest,
) -> EsResponse[ReindexResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_reindex", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ReindexRethrottleQuery {
  requests_per_second : Double
  group_by : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ReindexRethrottleQuery with fn to_json(
  self : ReindexRethrottleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["requests_per_second"] = self.requests_per_second.to_json()
  match self.group_by {
    Some(value) => obj["group_by"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ReindexRethrottleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ReindexRethrottleQuery: expected object"))
  }
  {
    requests_per_second: @json.from_json(
      obj.get("requests_per_second").unwrap_or(Json::null()),
      path=path.add_key("requests_per_second"),
    ),
    group_by: match obj.get("group_by") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("group_by")))
    },
  }
}

///|
pub fn ReindexRethrottleQuery::new(
  requests_per_second : Double,
  group_by? : String,
) -> ReindexRethrottleQuery {
  { requests_per_second, group_by }
}

///|
pub fn ReindexRethrottleQuery::to_pairs(
  self : ReindexRethrottleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  push_query_json(
    pairs,
    "requests_per_second",
    self.requests_per_second.to_json(),
  )
  match self.group_by {
    Some(value) => push_query_json(pairs, "group_by", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ReindexRethrottleResponse {
  node_failures : Array[Json]?
  task_failures : Array[Json]?
  nodes : Map[String, Json]?
  tasks : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ReindexRethrottleResponse with fn to_json(
  self : ReindexRethrottleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.node_failures {
    Some(value) => obj["node_failures"] = value.to_json()
    None => ()
  }
  match self.task_failures {
    Some(value) => obj["task_failures"] = value.to_json()
    None => ()
  }
  match self.nodes {
    Some(value) => obj["nodes"] = value.to_json()
    None => ()
  }
  match self.tasks {
    Some(value) => obj["tasks"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ReindexRethrottleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ReindexRethrottleResponse: expected object"))
  }
  {
    node_failures: match obj.get("node_failures") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("node_failures")))
    },
    task_failures: match obj.get("task_failures") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_failures")))
    },
    nodes: match obj.get("nodes") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("nodes")))
    },
    tasks: match obj.get("tasks") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("tasks")))
    },
  }
}

///|
pub(all) struct ReindexRethrottleRequest {
  task_id : String
  query : ReindexRethrottleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ReindexRethrottleRequest::new(
  task_id : String,
  query : ReindexRethrottleQuery,
) -> ReindexRethrottleRequest {
  { task_id, query }
}

///|
pub async fn Client::reindex_rethrottle(
  self : Client,
  request : ReindexRethrottleRequest,
) -> EsResponse[ReindexRethrottleResponse] {
  let params : Map[String, String] = Map([])
  params["task_id"] = request.task_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_reindex/{task_id}/_rethrottle", ["task_id"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct RenderSearchTemplateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RenderSearchTemplateQuery with fn to_json(
  _self : RenderSearchTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RenderSearchTemplateQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "RenderSearchTemplateQuery: expected object"))
  }
  RenderSearchTemplateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RenderSearchTemplateQuery::new() -> RenderSearchTemplateQuery {
  RenderSearchTemplateQuery::{  }
}

///|
pub fn RenderSearchTemplateQuery::to_pairs(
  _self : RenderSearchTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct RenderSearchTemplateBody {
  id : Json?
  file : String?
  params : Map[String, Json]?
  source : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for RenderSearchTemplateBody with fn to_json(
  self : RenderSearchTemplateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.file {
    Some(value) => obj["file"] = value.to_json()
    None => ()
  }
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  match self.source {
    Some(value) => obj["source"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RenderSearchTemplateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RenderSearchTemplateBody: expected object"))
  }
  {
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    file: match obj.get("file") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("file")))
    },
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
    source: match obj.get("source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("source")))
    },
  }
}

///|
pub fn RenderSearchTemplateBody::new(
  id? : Json,
  file? : String,
  params? : Map[String, Json],
  source? : Json,
) -> RenderSearchTemplateBody {
  { id, file, params, source }
}

///|
pub(all) struct RenderSearchTemplateResponse {
  template_output : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for RenderSearchTemplateResponse with fn to_json(
  self : RenderSearchTemplateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["template_output"] = self.template_output.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for RenderSearchTemplateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "RenderSearchTemplateResponse: expected object"),
    )
  }
  {
    template_output: @json.from_json(
      obj.get("template_output").unwrap_or(Json::null()),
      path=path.add_key("template_output"),
    ),
  }
}

///|
pub(all) struct RenderSearchTemplateRequest {
  id : String?
  query : RenderSearchTemplateQuery
  body : RenderSearchTemplateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RenderSearchTemplateRequest::new(
  body : RenderSearchTemplateBody,
  id? : String,
  query? : RenderSearchTemplateQuery = RenderSearchTemplateQuery::new(),
) -> RenderSearchTemplateRequest {
  { id, query, body }
}

///|
pub async fn Client::render_search_template(
  self : Client,
  request : RenderSearchTemplateRequest,
) -> EsResponse[RenderSearchTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_render/template/{id}", ["id"]),
      PathVariant::new("/_render/template", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct RollupDeleteJobQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RollupDeleteJobQuery with fn to_json(
  _self : RollupDeleteJobQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RollupDeleteJobQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "RollupDeleteJobQuery: expected object"))
  }
  RollupDeleteJobQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RollupDeleteJobQuery::new() -> RollupDeleteJobQuery {
  RollupDeleteJobQuery::{  }
}

///|
pub fn RollupDeleteJobQuery::to_pairs(
  _self : RollupDeleteJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct RollupDeleteJobResponse {
  acknowledged : Bool
  task_failures : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for RollupDeleteJobResponse with fn to_json(
  self : RollupDeleteJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  match self.task_failures {
    Some(value) => obj["task_failures"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RollupDeleteJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupDeleteJobResponse: expected object"))
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
    task_failures: match obj.get("task_failures") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("task_failures")))
    },
  }
}

///|
pub(all) struct RollupDeleteJobRequest {
  id : String
  query : RollupDeleteJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupDeleteJobRequest::new(
  id : String,
  query? : RollupDeleteJobQuery = RollupDeleteJobQuery::new(),
) -> RollupDeleteJobRequest {
  { id, query }
}

///|
pub async fn Client::rollup_delete_job(
  self : Client,
  request : RollupDeleteJobRequest,
) -> EsResponse[RollupDeleteJobResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_rollup/job/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct RollupGetJobsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RollupGetJobsQuery with fn to_json(
  _self : RollupGetJobsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RollupGetJobsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "RollupGetJobsQuery: expected object"))
  }
  RollupGetJobsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RollupGetJobsQuery::new() -> RollupGetJobsQuery {
  RollupGetJobsQuery::{  }
}

///|
pub fn RollupGetJobsQuery::to_pairs(
  _self : RollupGetJobsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct RollupGetJobsResponse {
  jobs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for RollupGetJobsResponse with fn to_json(
  self : RollupGetJobsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["jobs"] = self.jobs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for RollupGetJobsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupGetJobsResponse: expected object"))
  }
  {
    jobs: @json.from_json(
      obj.get("jobs").unwrap_or(Json::null()),
      path=path.add_key("jobs"),
    ),
  }
}

///|
pub(all) struct RollupGetJobsRequest {
  id : String?
  query : RollupGetJobsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupGetJobsRequest::new(
  id? : String,
  query? : RollupGetJobsQuery = RollupGetJobsQuery::new(),
) -> RollupGetJobsRequest {
  { id, query }
}

///|
pub async fn Client::rollup_get_jobs(
  self : Client,
  request : RollupGetJobsRequest,
) -> EsResponse[RollupGetJobsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_rollup/job/{id}", ["id"]),
      PathVariant::new("/_rollup/job", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct RollupGetRollupCapsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RollupGetRollupCapsQuery with fn to_json(
  _self : RollupGetRollupCapsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RollupGetRollupCapsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "RollupGetRollupCapsQuery: expected object"))
  }
  RollupGetRollupCapsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RollupGetRollupCapsQuery::new() -> RollupGetRollupCapsQuery {
  RollupGetRollupCapsQuery::{  }
}

///|
pub fn RollupGetRollupCapsQuery::to_pairs(
  _self : RollupGetRollupCapsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type RollupGetRollupCapsResponse = Json

///|
pub(all) struct RollupGetRollupCapsRequest {
  id : String?
  query : RollupGetRollupCapsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupGetRollupCapsRequest::new(
  id? : String,
  query? : RollupGetRollupCapsQuery = RollupGetRollupCapsQuery::new(),
) -> RollupGetRollupCapsRequest {
  { id, query }
}

///|
pub async fn Client::rollup_get_rollup_caps(
  self : Client,
  request : RollupGetRollupCapsRequest,
) -> EsResponse[RollupGetRollupCapsResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_rollup/data/{id}", ["id"]),
      PathVariant::new("/_rollup/data", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct RollupGetRollupIndexCapsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RollupGetRollupIndexCapsQuery with fn to_json(
  _self : RollupGetRollupIndexCapsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RollupGetRollupIndexCapsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "RollupGetRollupIndexCapsQuery: expected object"),
    )
  }
  RollupGetRollupIndexCapsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RollupGetRollupIndexCapsQuery::new() -> RollupGetRollupIndexCapsQuery {
  RollupGetRollupIndexCapsQuery::{  }
}

///|
pub fn RollupGetRollupIndexCapsQuery::to_pairs(
  _self : RollupGetRollupIndexCapsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type RollupGetRollupIndexCapsResponse = Json

///|
pub(all) struct RollupGetRollupIndexCapsRequest {
  index : String
  query : RollupGetRollupIndexCapsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupGetRollupIndexCapsRequest::new(
  index : String,
  query? : RollupGetRollupIndexCapsQuery = RollupGetRollupIndexCapsQuery::new(),
) -> RollupGetRollupIndexCapsRequest {
  { index, query }
}

///|
pub async fn Client::rollup_get_rollup_index_caps(
  self : Client,
  request : RollupGetRollupIndexCapsRequest,
) -> EsResponse[RollupGetRollupIndexCapsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_rollup/data", ["index"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct RollupPutJobQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RollupPutJobQuery with fn to_json(_self : RollupPutJobQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RollupPutJobQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "RollupPutJobQuery: expected object"))
  }
  RollupPutJobQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RollupPutJobQuery::new() -> RollupPutJobQuery {
  RollupPutJobQuery::{  }
}

///|
pub fn RollupPutJobQuery::to_pairs(
  _self : RollupPutJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct RollupPutJobBody {
  cron : String
  groups : Json
  index_pattern : String
  metrics : Array[Json]?
  page_size : Int
  rollup_index : Json
  timeout : Json?
  headers : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for RollupPutJobBody with fn to_json(self : RollupPutJobBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cron"] = self.cron.to_json()
  obj["groups"] = self.groups.to_json()
  obj["index_pattern"] = self.index_pattern.to_json()
  match self.metrics {
    Some(value) => obj["metrics"] = value.to_json()
    None => ()
  }
  obj["page_size"] = self.page_size.to_json()
  obj["rollup_index"] = self.rollup_index.to_json()
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.headers {
    Some(value) => obj["headers"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RollupPutJobBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupPutJobBody: expected object"))
  }
  {
    cron: @json.from_json(
      obj.get("cron").unwrap_or(Json::null()),
      path=path.add_key("cron"),
    ),
    groups: @json.from_json(
      obj.get("groups").unwrap_or(Json::null()),
      path=path.add_key("groups"),
    ),
    index_pattern: @json.from_json(
      obj.get("index_pattern").unwrap_or(Json::null()),
      path=path.add_key("index_pattern"),
    ),
    metrics: match obj.get("metrics") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metrics")))
    },
    page_size: @json.from_json(
      obj.get("page_size").unwrap_or(Json::null()),
      path=path.add_key("page_size"),
    ),
    rollup_index: @json.from_json(
      obj.get("rollup_index").unwrap_or(Json::null()),
      path=path.add_key("rollup_index"),
    ),
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    headers: match obj.get("headers") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("headers")))
    },
  }
}

///|
pub fn RollupPutJobBody::new(
  cron : String,
  groups : Json,
  index_pattern : String,
  page_size : Int,
  rollup_index : Json,
  metrics? : Array[Json],
  timeout? : Json,
  headers? : Json,
) -> RollupPutJobBody {
  {
    cron,
    groups,
    index_pattern,
    metrics,
    page_size,
    rollup_index,
    timeout,
    headers,
  }
}

///|
pub type RollupPutJobResponse = Json

///|
pub(all) struct RollupPutJobRequest {
  id : String
  query : RollupPutJobQuery
  body : RollupPutJobBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupPutJobRequest::new(
  id : String,
  body : RollupPutJobBody,
  query? : RollupPutJobQuery = RollupPutJobQuery::new(),
) -> RollupPutJobRequest {
  { id, query, body }
}

///|
pub async fn Client::rollup_put_job(
  self : Client,
  request : RollupPutJobRequest,
) -> EsResponse[RollupPutJobResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_rollup/job/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct RollupRollupSearchQuery {
  rest_total_hits_as_int : Bool?
  typed_keys : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for RollupRollupSearchQuery with fn to_json(
  self : RollupRollupSearchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RollupRollupSearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupRollupSearchQuery: expected object"))
  }
  {
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
  }
}

///|
pub fn RollupRollupSearchQuery::new(
  rest_total_hits_as_int? : Bool,
  typed_keys? : Bool,
) -> RollupRollupSearchQuery {
  { rest_total_hits_as_int, typed_keys }
}

///|
pub fn RollupRollupSearchQuery::to_pairs(
  self : RollupRollupSearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct RollupRollupSearchBody {
  aggregations : Map[String, Json]?
  query : Json?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for RollupRollupSearchBody with fn to_json(
  self : RollupRollupSearchBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RollupRollupSearchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupRollupSearchBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn RollupRollupSearchBody::new(
  aggregations? : Map[String, Json],
  query? : Json,
  size? : Int,
) -> RollupRollupSearchBody {
  { aggregations, query, size }
}

///|
pub(all) struct RollupRollupSearchResponse {
  took : Int
  timed_out : Bool
  terminated_early : Bool?
  _shards : Json
  hits : Json
  aggregations : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for RollupRollupSearchResponse with fn to_json(
  self : RollupRollupSearchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["took"] = self.took.to_json()
  obj["timed_out"] = self.timed_out.to_json()
  match self.terminated_early {
    Some(value) => obj["terminated_early"] = value.to_json()
    None => ()
  }
  obj["_shards"] = self._shards.to_json()
  obj["hits"] = self.hits.to_json()
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RollupRollupSearchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupRollupSearchResponse: expected object"))
  }
  {
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    timed_out: @json.from_json(
      obj.get("timed_out").unwrap_or(Json::null()),
      path=path.add_key("timed_out"),
    ),
    terminated_early: match obj.get("terminated_early") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminated_early")))
    },
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    hits: @json.from_json(
      obj.get("hits").unwrap_or(Json::null()),
      path=path.add_key("hits"),
    ),
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
  }
}

///|
pub(all) struct RollupRollupSearchRequest {
  index : String
  query : RollupRollupSearchQuery
  body : RollupRollupSearchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupRollupSearchRequest::new(
  index : String,
  body : RollupRollupSearchBody,
  query? : RollupRollupSearchQuery = RollupRollupSearchQuery::new(),
) -> RollupRollupSearchRequest {
  { index, query, body }
}

///|
pub async fn Client::rollup_rollup_search(
  self : Client,
  request : RollupRollupSearchRequest,
) -> EsResponse[RollupRollupSearchResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_rollup_search", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct RollupStartJobQuery {} derive(Eq, Debug)

///|
pub impl ToJson for RollupStartJobQuery with fn to_json(
  _self : RollupStartJobQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for RollupStartJobQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "RollupStartJobQuery: expected object"))
  }
  RollupStartJobQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn RollupStartJobQuery::new() -> RollupStartJobQuery {
  RollupStartJobQuery::{  }
}

///|
pub fn RollupStartJobQuery::to_pairs(
  _self : RollupStartJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct RollupStartJobResponse {
  started : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for RollupStartJobResponse with fn to_json(
  self : RollupStartJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["started"] = self.started.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for RollupStartJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupStartJobResponse: expected object"))
  }
  {
    started: @json.from_json(
      obj.get("started").unwrap_or(Json::null()),
      path=path.add_key("started"),
    ),
  }
}

///|
pub(all) struct RollupStartJobRequest {
  id : String
  query : RollupStartJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupStartJobRequest::new(
  id : String,
  query? : RollupStartJobQuery = RollupStartJobQuery::new(),
) -> RollupStartJobRequest {
  { id, query }
}

///|
pub async fn Client::rollup_start_job(
  self : Client,
  request : RollupStartJobRequest,
) -> EsResponse[RollupStartJobResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_rollup/job/{id}/_start", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct RollupStopJobQuery {
  timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for RollupStopJobQuery with fn to_json(
  self : RollupStopJobQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for RollupStopJobQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupStopJobQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn RollupStopJobQuery::new(
  timeout? : String,
  wait_for_completion? : Bool,
) -> RollupStopJobQuery {
  { timeout, wait_for_completion }
}

///|
pub fn RollupStopJobQuery::to_pairs(
  self : RollupStopJobQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct RollupStopJobResponse {
  stopped : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for RollupStopJobResponse with fn to_json(
  self : RollupStopJobResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["stopped"] = self.stopped.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for RollupStopJobResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "RollupStopJobResponse: expected object"))
  }
  {
    stopped: @json.from_json(
      obj.get("stopped").unwrap_or(Json::null()),
      path=path.add_key("stopped"),
    ),
  }
}

///|
pub(all) struct RollupStopJobRequest {
  id : String
  query : RollupStopJobQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn RollupStopJobRequest::new(
  id : String,
  query? : RollupStopJobQuery = RollupStopJobQuery::new(),
) -> RollupStopJobRequest {
  { id, query }
}

///|
pub async fn Client::rollup_stop_job(
  self : Client,
  request : RollupStopJobRequest,
) -> EsResponse[RollupStopJobResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_rollup/job/{id}/_stop", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct ScriptsPainlessExecuteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for ScriptsPainlessExecuteQuery with fn to_json(
  _self : ScriptsPainlessExecuteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for ScriptsPainlessExecuteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "ScriptsPainlessExecuteQuery: expected object"),
    )
  }
  ScriptsPainlessExecuteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn ScriptsPainlessExecuteQuery::new() -> ScriptsPainlessExecuteQuery {
  ScriptsPainlessExecuteQuery::{  }
}

///|
pub fn ScriptsPainlessExecuteQuery::to_pairs(
  _self : ScriptsPainlessExecuteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct ScriptsPainlessExecuteBody {
  context : Json?
  context_setup : Json?
  script : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for ScriptsPainlessExecuteBody with fn to_json(
  self : ScriptsPainlessExecuteBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.context {
    Some(value) => obj["context"] = value.to_json()
    None => ()
  }
  match self.context_setup {
    Some(value) => obj["context_setup"] = value.to_json()
    None => ()
  }
  match self.script {
    Some(value) => obj["script"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ScriptsPainlessExecuteBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ScriptsPainlessExecuteBody: expected object"))
  }
  {
    context: match obj.get("context") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("context")))
    },
    context_setup: match obj.get("context_setup") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("context_setup")))
    },
    script: match obj.get("script") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("script")))
    },
  }
}

///|
pub fn ScriptsPainlessExecuteBody::new(
  context? : Json,
  context_setup? : Json,
  script? : Json,
) -> ScriptsPainlessExecuteBody {
  { context, context_setup, script }
}

///|
pub(all) struct ScriptsPainlessExecuteResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ScriptsPainlessExecuteResponse with fn to_json(
  self : ScriptsPainlessExecuteResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ScriptsPainlessExecuteResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "ScriptsPainlessExecuteResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct ScriptsPainlessExecuteRequest {
  query : ScriptsPainlessExecuteQuery
  body : ScriptsPainlessExecuteBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ScriptsPainlessExecuteRequest::new(
  body : ScriptsPainlessExecuteBody,
  query? : ScriptsPainlessExecuteQuery = ScriptsPainlessExecuteQuery::new(),
) -> ScriptsPainlessExecuteRequest {
  { query, body }
}

///|
pub async fn Client::scripts_painless_execute(
  self : Client,
  request : ScriptsPainlessExecuteRequest,
) -> EsResponse[ScriptsPainlessExecuteResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_scripts/painless/_execute", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ScrollQuery {
  scroll : String?
  scroll_id : String?
  rest_total_hits_as_int : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for ScrollQuery with fn to_json(self : ScrollQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.scroll_id {
    Some(value) => obj["scroll_id"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ScrollQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ScrollQuery: expected object"))
  }
  {
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    scroll_id: match obj.get("scroll_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("scroll_id")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
  }
}

///|
pub fn ScrollQuery::new(
  scroll? : String,
  scroll_id? : String,
  rest_total_hits_as_int? : Bool,
) -> ScrollQuery {
  { scroll, scroll_id, rest_total_hits_as_int }
}

///|
pub fn ScrollQuery::to_pairs(self : ScrollQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.scroll_id {
    Some(value) => push_query_json(pairs, "scroll_id", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ScrollBody {
  scroll : Json?
  scroll_id : Json
} derive(Eq, Debug)

///|
pub impl ToJson for ScrollBody with fn to_json(self : ScrollBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  obj["scroll_id"] = self.scroll_id.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ScrollBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ScrollBody: expected object"))
  }
  {
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    scroll_id: @json.from_json(
      obj.get("scroll_id").unwrap_or(Json::null()),
      path=path.add_key("scroll_id"),
    ),
  }
}

///|
pub fn ScrollBody::new(scroll_id : Json, scroll? : Json) -> ScrollBody {
  { scroll, scroll_id }
}

///|
pub type ScrollResponse = Json

///|
pub(all) struct ScrollRequest {
  scroll_id : String?
  query : ScrollQuery
  body : ScrollBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ScrollRequest::new(
  scroll_id? : String,
  query? : ScrollQuery = ScrollQuery::new(),
  body? : ScrollBody,
) -> ScrollRequest {
  { scroll_id, query, body }
}

///|
pub async fn Client::scroll(
  self : Client,
  request : ScrollRequest,
) -> EsResponse[ScrollResponse] {
  let params : Map[String, String] = Map([])
  match request.scroll_id {
    Some(value) => params["scroll_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_search/scroll/{scroll_id}", ["scroll_id"]),
      PathVariant::new("/_search/scroll", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchQuery {
  allow_no_indices : Bool?
  allow_partial_search_results : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  batched_reduce_size : Int?
  ccs_minimize_roundtrips : Bool?
  default_operator : String?
  df : String?
  docvalue_fields : String?
  expand_wildcards : String?
  explain : Bool?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  include_named_queries_score : Bool?
  lenient : Bool?
  max_concurrent_shard_requests : Int?
  preference : String?
  pre_filter_shard_size : Int?
  request_cache : Bool?
  routing : String?
  scroll : String?
  search_type : String?
  stats : Array[String]?
  stored_fields : String?
  suggest_field : String?
  suggest_mode : String?
  suggest_size : Int?
  suggest_text : String?
  terminate_after : Int?
  timeout : String?
  track_total_hits : String?
  track_scores : Bool?
  typed_keys : Bool?
  rest_total_hits_as_int : Bool?
  version : Bool?
  _source : String?
  _source_excludes : String?
  _source_exclude_vectors : Bool?
  _source_includes : String?
  seq_no_primary_term : Bool?
  q : String?
  size : Int?
  from : Int?
  sort : Json?
  force_synthetic_source : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchQuery with fn to_json(self : SearchQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.batched_reduce_size {
    Some(value) => obj["batched_reduce_size"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_named_queries_score {
    Some(value) => obj["include_named_queries_score"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) => obj["max_concurrent_shard_requests"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) => obj["pre_filter_shard_size"] = value.to_json()
    None => ()
  }
  match self.request_cache {
    Some(value) => obj["request_cache"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.suggest_field {
    Some(value) => obj["suggest_field"] = value.to_json()
    None => ()
  }
  match self.suggest_mode {
    Some(value) => obj["suggest_mode"] = value.to_json()
    None => ()
  }
  match self.suggest_size {
    Some(value) => obj["suggest_size"] = value.to_json()
    None => ()
  }
  match self.suggest_text {
    Some(value) => obj["suggest_text"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.track_scores {
    Some(value) => obj["track_scores"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_exclude_vectors {
    Some(value) => obj["_source_exclude_vectors"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) => obj["seq_no_primary_term"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.force_synthetic_source {
    Some(value) => obj["force_synthetic_source"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    batched_reduce_size: match obj.get("batched_reduce_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("batched_reduce_size")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_named_queries_score: match obj.get("include_named_queries_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("include_named_queries_score"),
          ),
        )
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    max_concurrent_shard_requests: match
      obj.get("max_concurrent_shard_requests") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_concurrent_shard_requests"),
          ),
        )
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    pre_filter_shard_size: match obj.get("pre_filter_shard_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("pre_filter_shard_size")))
    },
    request_cache: match obj.get("request_cache") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("request_cache")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    suggest_field: match obj.get("suggest_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_field")))
    },
    suggest_mode: match obj.get("suggest_mode") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_mode")))
    },
    suggest_size: match obj.get("suggest_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_size")))
    },
    suggest_text: match obj.get("suggest_text") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("suggest_text")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    track_scores: match obj.get("track_scores") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_scores")))
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_exclude_vectors: match obj.get("_source_exclude_vectors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("_source_exclude_vectors")),
        )
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
    seq_no_primary_term: match obj.get("seq_no_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("seq_no_primary_term")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    force_synthetic_source: match obj.get("force_synthetic_source") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("force_synthetic_source")),
        )
    },
  }
}

///|
pub fn SearchQuery::new(
  allow_no_indices? : Bool,
  allow_partial_search_results? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  batched_reduce_size? : Int,
  ccs_minimize_roundtrips? : Bool,
  default_operator? : String,
  df? : String,
  docvalue_fields? : String,
  expand_wildcards? : String,
  explain? : Bool,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  include_named_queries_score? : Bool,
  lenient? : Bool,
  max_concurrent_shard_requests? : Int,
  preference? : String,
  pre_filter_shard_size? : Int,
  request_cache? : Bool,
  routing? : String,
  scroll? : String,
  search_type? : String,
  stats? : Array[String],
  stored_fields? : String,
  suggest_field? : String,
  suggest_mode? : String,
  suggest_size? : Int,
  suggest_text? : String,
  terminate_after? : Int,
  timeout? : String,
  track_total_hits? : String,
  track_scores? : Bool,
  typed_keys? : Bool,
  rest_total_hits_as_int? : Bool,
  version? : Bool,
  _source? : String,
  _source_excludes? : String,
  _source_exclude_vectors? : Bool,
  _source_includes? : String,
  seq_no_primary_term? : Bool,
  q? : String,
  size? : Int,
  from? : Int,
  sort? : Json,
  force_synthetic_source? : Bool,
) -> SearchQuery {
  {
    allow_no_indices,
    allow_partial_search_results,
    analyzer,
    analyze_wildcard,
    batched_reduce_size,
    ccs_minimize_roundtrips,
    default_operator,
    df,
    docvalue_fields,
    expand_wildcards,
    explain,
    ignore_throttled,
    ignore_unavailable,
    include_named_queries_score,
    lenient,
    max_concurrent_shard_requests,
    preference,
    pre_filter_shard_size,
    request_cache,
    routing,
    scroll,
    search_type,
    stats,
    stored_fields,
    suggest_field,
    suggest_mode,
    suggest_size,
    suggest_text,
    terminate_after,
    timeout,
    track_total_hits,
    track_scores,
    typed_keys,
    rest_total_hits_as_int,
    version,
    _source,
    _source_excludes,
    _source_exclude_vectors,
    _source_includes,
    seq_no_primary_term,
    q,
    size,
    from,
    sort,
    force_synthetic_source,
  }
}

///|
pub fn SearchQuery::to_pairs(self : SearchQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.allow_partial_search_results {
    Some(value) =>
      push_query_json(pairs, "allow_partial_search_results", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.batched_reduce_size {
    Some(value) =>
      push_query_json(pairs, "batched_reduce_size", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => push_query_json(pairs, "docvalue_fields", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.include_named_queries_score {
    Some(value) =>
      push_query_json(pairs, "include_named_queries_score", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.max_concurrent_shard_requests {
    Some(value) =>
      push_query_json(pairs, "max_concurrent_shard_requests", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.pre_filter_shard_size {
    Some(value) =>
      push_query_json(pairs, "pre_filter_shard_size", value.to_json())
    None => ()
  }
  match self.request_cache {
    Some(value) => push_query_json(pairs, "request_cache", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.stats {
    Some(value) => push_query_json(pairs, "stats", value.to_json())
    None => ()
  }
  match self.stored_fields {
    Some(value) => push_query_json(pairs, "stored_fields", value.to_json())
    None => ()
  }
  match self.suggest_field {
    Some(value) => push_query_json(pairs, "suggest_field", value.to_json())
    None => ()
  }
  match self.suggest_mode {
    Some(value) => push_query_json(pairs, "suggest_mode", value.to_json())
    None => ()
  }
  match self.suggest_size {
    Some(value) => push_query_json(pairs, "suggest_size", value.to_json())
    None => ()
  }
  match self.suggest_text {
    Some(value) => push_query_json(pairs, "suggest_text", value.to_json())
    None => ()
  }
  match self.terminate_after {
    Some(value) => push_query_json(pairs, "terminate_after", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.track_total_hits {
    Some(value) => push_query_json(pairs, "track_total_hits", value.to_json())
    None => ()
  }
  match self.track_scores {
    Some(value) => push_query_json(pairs, "track_scores", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_exclude_vectors {
    Some(value) =>
      push_query_json(pairs, "_source_exclude_vectors", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) =>
      push_query_json(pairs, "seq_no_primary_term", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.force_synthetic_source {
    Some(value) =>
      push_query_json(pairs, "force_synthetic_source", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchBody {
  aggregations : Map[String, Json]?
  collapse : Json?
  explain : Bool?
  ext : Map[String, Json]?
  from : Int?
  highlight : Json?
  track_total_hits : Json?
  indices_boost : Array[Map[String, Json]]?
  docvalue_fields : Array[Json]?
  knn : Json?
  rank : Json?
  min_score : Double?
  post_filter : Json?
  profile : Bool?
  query : Json?
  rescore : Json?
  retriever : Json?
  script_fields : Map[String, Json]?
  search_after : Json?
  size : Int?
  slice : Json?
  sort : Json?
  _source : Json?
  fields : Array[Json]?
  suggest : Json?
  terminate_after : Int?
  timeout : String?
  track_scores : Bool?
  version : Bool?
  seq_no_primary_term : Bool?
  stored_fields : Json?
  pit : Json?
  runtime_mappings : Json?
  stats : Array[String]?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchBody with fn to_json(self : SearchBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.collapse {
    Some(value) => obj["collapse"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ext {
    Some(value) => obj["ext"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.highlight {
    Some(value) => obj["highlight"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.indices_boost {
    Some(value) => obj["indices_boost"] = value.to_json()
    None => ()
  }
  match self.docvalue_fields {
    Some(value) => obj["docvalue_fields"] = value.to_json()
    None => ()
  }
  match self.knn {
    Some(value) => obj["knn"] = value.to_json()
    None => ()
  }
  match self.rank {
    Some(value) => obj["rank"] = value.to_json()
    None => ()
  }
  match self.min_score {
    Some(value) => obj["min_score"] = value.to_json()
    None => ()
  }
  match self.post_filter {
    Some(value) => obj["post_filter"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.rescore {
    Some(value) => obj["rescore"] = value.to_json()
    None => ()
  }
  match self.retriever {
    Some(value) => obj["retriever"] = value.to_json()
    None => ()
  }
  match self.script_fields {
    Some(value) => obj["script_fields"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.slice {
    Some(value) => obj["slice"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.suggest {
    Some(value) => obj["suggest"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.track_scores {
    Some(value) => obj["track_scores"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.seq_no_primary_term {
    Some(value) => obj["seq_no_primary_term"] = value.to_json()
    None => ()
  }
  match self.stored_fields {
    Some(value) => obj["stored_fields"] = value.to_json()
    None => ()
  }
  match self.pit {
    Some(value) => obj["pit"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    collapse: match obj.get("collapse") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("collapse")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ext: match obj.get("ext") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ext")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    highlight: match obj.get("highlight") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("highlight")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    indices_boost: match obj.get("indices_boost") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("indices_boost")))
    },
    docvalue_fields: match obj.get("docvalue_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("docvalue_fields")))
    },
    knn: match obj.get("knn") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("knn")))
    },
    rank: match obj.get("rank") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rank")))
    },
    min_score: match obj.get("min_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("min_score")))
    },
    post_filter: match obj.get("post_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("post_filter")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    rescore: match obj.get("rescore") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rescore")))
    },
    retriever: match obj.get("retriever") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retriever")))
    },
    script_fields: match obj.get("script_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("script_fields")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    slice: match obj.get("slice") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    suggest: match obj.get("suggest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("suggest")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    track_scores: match obj.get("track_scores") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_scores")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    seq_no_primary_term: match obj.get("seq_no_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("seq_no_primary_term")))
    },
    stored_fields: match obj.get("stored_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("stored_fields")))
    },
    pit: match obj.get("pit") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pit")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn SearchBody::new(
  aggregations? : Map[String, Json],
  collapse? : Json,
  explain? : Bool,
  ext? : Map[String, Json],
  from? : Int,
  highlight? : Json,
  track_total_hits? : Json,
  indices_boost? : Array[Map[String, Json]],
  docvalue_fields? : Array[Json],
  knn? : Json,
  rank? : Json,
  min_score? : Double,
  post_filter? : Json,
  profile? : Bool,
  query? : Json,
  rescore? : Json,
  retriever? : Json,
  script_fields? : Map[String, Json],
  search_after? : Json,
  size? : Int,
  slice? : Json,
  sort? : Json,
  _source? : Json,
  fields? : Array[Json],
  suggest? : Json,
  terminate_after? : Int,
  timeout? : String,
  track_scores? : Bool,
  version? : Bool,
  seq_no_primary_term? : Bool,
  stored_fields? : Json,
  pit? : Json,
  runtime_mappings? : Json,
  stats? : Array[String],
  project_routing? : Json,
) -> SearchBody {
  {
    aggregations,
    collapse,
    explain,
    ext,
    from,
    highlight,
    track_total_hits,
    indices_boost,
    docvalue_fields,
    knn,
    rank,
    min_score,
    post_filter,
    profile,
    query,
    rescore,
    retriever,
    script_fields,
    search_after,
    size,
    slice,
    sort,
    _source,
    fields,
    suggest,
    terminate_after,
    timeout,
    track_scores,
    version,
    seq_no_primary_term,
    stored_fields,
    pit,
    runtime_mappings,
    stats,
    project_routing,
  }
}

///|
pub type SearchResponse = Json

///|
pub(all) struct SearchRequest {
  index : String?
  query : SearchQuery
  body : SearchBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchRequest::new(
  index? : String,
  query? : SearchQuery = SearchQuery::new(),
  body? : SearchBody,
) -> SearchRequest {
  { index, query, body }
}

///|
pub async fn Client::search(
  self : Client,
  request : SearchRequest,
) -> EsResponse[SearchResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_search", ["index"]),
      PathVariant::new("/_search", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchApplicationDeleteQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationDeleteQuery with fn to_json(
  _self : SearchApplicationDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchApplicationDeleteQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SearchApplicationDeleteQuery: expected object"),
    )
  }
  SearchApplicationDeleteQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchApplicationDeleteQuery::new() -> SearchApplicationDeleteQuery {
  SearchApplicationDeleteQuery::{  }
}

///|
pub fn SearchApplicationDeleteQuery::to_pairs(
  _self : SearchApplicationDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SearchApplicationDeleteResponse = Json

///|
pub(all) struct SearchApplicationDeleteRequest {
  name : String
  query : SearchApplicationDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationDeleteRequest::new(
  name : String,
  query? : SearchApplicationDeleteQuery = SearchApplicationDeleteQuery::new(),
) -> SearchApplicationDeleteRequest {
  { name, query }
}

///|
pub async fn Client::search_application_delete(
  self : Client,
  request : SearchApplicationDeleteRequest,
) -> EsResponse[SearchApplicationDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_application/search_application/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SearchApplicationDeleteBehavioralAnalyticsQuery {} derive (
  Eq,
  Debug,
)

///|
pub impl ToJson for SearchApplicationDeleteBehavioralAnalyticsQuery with fn to_json(
  _self : SearchApplicationDeleteBehavioralAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchApplicationDeleteBehavioralAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SearchApplicationDeleteBehavioralAnalyticsQuery: expected object"),
    )
  }
  SearchApplicationDeleteBehavioralAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchApplicationDeleteBehavioralAnalyticsQuery::new() -> SearchApplicationDeleteBehavioralAnalyticsQuery {
  SearchApplicationDeleteBehavioralAnalyticsQuery::{  }
}

///|
pub fn SearchApplicationDeleteBehavioralAnalyticsQuery::to_pairs(
  _self : SearchApplicationDeleteBehavioralAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SearchApplicationDeleteBehavioralAnalyticsResponse = Json

///|
pub(all) struct SearchApplicationDeleteBehavioralAnalyticsRequest {
  name : String
  query : SearchApplicationDeleteBehavioralAnalyticsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationDeleteBehavioralAnalyticsRequest::new(
  name : String,
  query? : SearchApplicationDeleteBehavioralAnalyticsQuery = SearchApplicationDeleteBehavioralAnalyticsQuery::new(),
) -> SearchApplicationDeleteBehavioralAnalyticsRequest {
  { name, query }
}

///|
pub async fn Client::search_application_delete_behavioral_analytics(
  self : Client,
  request : SearchApplicationDeleteBehavioralAnalyticsRequest,
) -> EsResponse[SearchApplicationDeleteBehavioralAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_application/analytics/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SearchApplicationGetQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationGetQuery with fn to_json(
  _self : SearchApplicationGetQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchApplicationGetQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SearchApplicationGetQuery: expected object"))
  }
  SearchApplicationGetQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchApplicationGetQuery::new() -> SearchApplicationGetQuery {
  SearchApplicationGetQuery::{  }
}

///|
pub fn SearchApplicationGetQuery::to_pairs(
  _self : SearchApplicationGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SearchApplicationGetResponse = Json

///|
pub(all) struct SearchApplicationGetRequest {
  name : String
  query : SearchApplicationGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationGetRequest::new(
  name : String,
  query? : SearchApplicationGetQuery = SearchApplicationGetQuery::new(),
) -> SearchApplicationGetRequest {
  { name, query }
}

///|
pub async fn Client::search_application_get(
  self : Client,
  request : SearchApplicationGetRequest,
) -> EsResponse[SearchApplicationGetResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_application/search_application/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SearchApplicationGetBehavioralAnalyticsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationGetBehavioralAnalyticsQuery with fn to_json(
  _self : SearchApplicationGetBehavioralAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchApplicationGetBehavioralAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SearchApplicationGetBehavioralAnalyticsQuery: expected object"),
    )
  }
  SearchApplicationGetBehavioralAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchApplicationGetBehavioralAnalyticsQuery::new() -> SearchApplicationGetBehavioralAnalyticsQuery {
  SearchApplicationGetBehavioralAnalyticsQuery::{  }
}

///|
pub fn SearchApplicationGetBehavioralAnalyticsQuery::to_pairs(
  _self : SearchApplicationGetBehavioralAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SearchApplicationGetBehavioralAnalyticsResponse = Json

///|
pub(all) struct SearchApplicationGetBehavioralAnalyticsRequest {
  name : String?
  query : SearchApplicationGetBehavioralAnalyticsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationGetBehavioralAnalyticsRequest::new(
  name? : String,
  query? : SearchApplicationGetBehavioralAnalyticsQuery = SearchApplicationGetBehavioralAnalyticsQuery::new(),
) -> SearchApplicationGetBehavioralAnalyticsRequest {
  { name, query }
}

///|
pub async fn Client::search_application_get_behavioral_analytics(
  self : Client,
  request : SearchApplicationGetBehavioralAnalyticsRequest,
) -> EsResponse[SearchApplicationGetBehavioralAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_application/analytics/{name}", ["name"]),
      PathVariant::new("/_application/analytics", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SearchApplicationListQuery {
  q : String?
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationListQuery with fn to_json(
  self : SearchApplicationListQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationListQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchApplicationListQuery: expected object"))
  }
  {
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn SearchApplicationListQuery::new(
  q? : String,
  from? : Int,
  size? : Int,
) -> SearchApplicationListQuery {
  { q, from, size }
}

///|
pub fn SearchApplicationListQuery::to_pairs(
  self : SearchApplicationListQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchApplicationListResponse {
  count : Int
  results : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationListResponse with fn to_json(
  self : SearchApplicationListResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["results"] = self.results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationListResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchApplicationListResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    results: @json.from_json(
      obj.get("results").unwrap_or(Json::null()),
      path=path.add_key("results"),
    ),
  }
}

///|
pub(all) struct SearchApplicationListRequest {
  query : SearchApplicationListQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationListRequest::new(
  query? : SearchApplicationListQuery = SearchApplicationListQuery::new(),
) -> SearchApplicationListRequest {
  { query, }
}

///|
pub async fn Client::search_application_list(
  self : Client,
  request : SearchApplicationListRequest,
) -> EsResponse[SearchApplicationListResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_application/search_application", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SearchApplicationPostBehavioralAnalyticsEventQuery {
  debug : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationPostBehavioralAnalyticsEventQuery with fn to_json(
  self : SearchApplicationPostBehavioralAnalyticsEventQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.debug {
    Some(value) => obj["debug"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationPostBehavioralAnalyticsEventQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (
        path, "SearchApplicationPostBehavioralAnalyticsEventQuery: expected object",
      ),
    )
  }
  {
    debug: match obj.get("debug") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("debug")))
    },
  }
}

///|
pub fn SearchApplicationPostBehavioralAnalyticsEventQuery::new(
  debug? : Bool,
) -> SearchApplicationPostBehavioralAnalyticsEventQuery {
  { debug, }
}

///|
pub fn SearchApplicationPostBehavioralAnalyticsEventQuery::to_pairs(
  self : SearchApplicationPostBehavioralAnalyticsEventQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.debug {
    Some(value) => push_query_json(pairs, "debug", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SearchApplicationPostBehavioralAnalyticsEventBody = Json

///|
pub(all) struct SearchApplicationPostBehavioralAnalyticsEventResponse {
  accepted : Bool
  event : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationPostBehavioralAnalyticsEventResponse with fn to_json(
  self : SearchApplicationPostBehavioralAnalyticsEventResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["accepted"] = self.accepted.to_json()
  match self.event {
    Some(value) => obj["event"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationPostBehavioralAnalyticsEventResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (
        path, "SearchApplicationPostBehavioralAnalyticsEventResponse: expected object",
      ),
    )
  }
  {
    accepted: @json.from_json(
      obj.get("accepted").unwrap_or(Json::null()),
      path=path.add_key("accepted"),
    ),
    event: match obj.get("event") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("event")))
    },
  }
}

///|
pub(all) struct SearchApplicationPostBehavioralAnalyticsEventRequest {
  collection_name : String
  event_type : String
  query : SearchApplicationPostBehavioralAnalyticsEventQuery
  body : SearchApplicationPostBehavioralAnalyticsEventBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationPostBehavioralAnalyticsEventRequest::new(
  collection_name : String,
  event_type : String,
  body : SearchApplicationPostBehavioralAnalyticsEventBody,
  query? : SearchApplicationPostBehavioralAnalyticsEventQuery = SearchApplicationPostBehavioralAnalyticsEventQuery::new(),
) -> SearchApplicationPostBehavioralAnalyticsEventRequest {
  { collection_name, event_type, query, body }
}

///|
pub async fn Client::search_application_post_behavioral_analytics_event(
  self : Client,
  request : SearchApplicationPostBehavioralAnalyticsEventRequest,
) -> EsResponse[SearchApplicationPostBehavioralAnalyticsEventResponse] {
  let params : Map[String, String] = Map([])
  params["collection_name"] = request.collection_name
  params["event_type"] = request.event_type
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_application/analytics/{collection_name}/event/{event_type}",
        ["collection_name", "event_type"],
      ),
    ],
    params,
  )
  let body = JsonBody(request.body)
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchApplicationPutQuery {
  create : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationPutQuery with fn to_json(
  self : SearchApplicationPutQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.create {
    Some(value) => obj["create"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationPutQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchApplicationPutQuery: expected object"))
  }
  {
    create: match obj.get("create") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("create")))
    },
  }
}

///|
pub fn SearchApplicationPutQuery::new(
  create? : Bool,
) -> SearchApplicationPutQuery {
  { create, }
}

///|
pub fn SearchApplicationPutQuery::to_pairs(
  self : SearchApplicationPutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.create {
    Some(value) => push_query_json(pairs, "create", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SearchApplicationPutBody = Json

///|
pub(all) struct SearchApplicationPutResponse {
  result : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationPutResponse with fn to_json(
  self : SearchApplicationPutResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationPutResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchApplicationPutResponse: expected object"),
    )
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
  }
}

///|
pub(all) struct SearchApplicationPutRequest {
  name : String
  query : SearchApplicationPutQuery
  body : SearchApplicationPutBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationPutRequest::new(
  name : String,
  body : SearchApplicationPutBody,
  query? : SearchApplicationPutQuery = SearchApplicationPutQuery::new(),
) -> SearchApplicationPutRequest {
  { name, query, body }
}

///|
pub async fn Client::search_application_put(
  self : Client,
  request : SearchApplicationPutRequest,
) -> EsResponse[SearchApplicationPutResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_application/search_application/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SearchApplicationPutBehavioralAnalyticsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationPutBehavioralAnalyticsQuery with fn to_json(
  _self : SearchApplicationPutBehavioralAnalyticsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchApplicationPutBehavioralAnalyticsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SearchApplicationPutBehavioralAnalyticsQuery: expected object"),
    )
  }
  SearchApplicationPutBehavioralAnalyticsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchApplicationPutBehavioralAnalyticsQuery::new() -> SearchApplicationPutBehavioralAnalyticsQuery {
  SearchApplicationPutBehavioralAnalyticsQuery::{  }
}

///|
pub fn SearchApplicationPutBehavioralAnalyticsQuery::to_pairs(
  _self : SearchApplicationPutBehavioralAnalyticsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SearchApplicationPutBehavioralAnalyticsResponse = Json

///|
pub(all) struct SearchApplicationPutBehavioralAnalyticsRequest {
  name : String
  query : SearchApplicationPutBehavioralAnalyticsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationPutBehavioralAnalyticsRequest::new(
  name : String,
  query? : SearchApplicationPutBehavioralAnalyticsQuery = SearchApplicationPutBehavioralAnalyticsQuery::new(),
) -> SearchApplicationPutBehavioralAnalyticsRequest {
  { name, query }
}

///|
pub async fn Client::search_application_put_behavioral_analytics(
  self : Client,
  request : SearchApplicationPutBehavioralAnalyticsRequest,
) -> EsResponse[SearchApplicationPutBehavioralAnalyticsResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_application/analytics/{name}", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SearchApplicationRenderQueryQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationRenderQueryQuery with fn to_json(
  _self : SearchApplicationRenderQueryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchApplicationRenderQueryQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SearchApplicationRenderQueryQuery: expected object"),
    )
  }
  SearchApplicationRenderQueryQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchApplicationRenderQueryQuery::new() -> SearchApplicationRenderQueryQuery {
  SearchApplicationRenderQueryQuery::{  }
}

///|
pub fn SearchApplicationRenderQueryQuery::to_pairs(
  _self : SearchApplicationRenderQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SearchApplicationRenderQueryBody {
  params : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationRenderQueryBody with fn to_json(
  self : SearchApplicationRenderQueryBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationRenderQueryBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchApplicationRenderQueryBody: expected object"),
    )
  }
  {
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
  }
}

///|
pub fn SearchApplicationRenderQueryBody::new(
  params? : Map[String, Json],
) -> SearchApplicationRenderQueryBody {
  { params, }
}

///|
pub type SearchApplicationRenderQueryResponse = Json

///|
pub(all) struct SearchApplicationRenderQueryRequest {
  name : String
  query : SearchApplicationRenderQueryQuery
  body : SearchApplicationRenderQueryBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationRenderQueryRequest::new(
  name : String,
  query? : SearchApplicationRenderQueryQuery = SearchApplicationRenderQueryQuery::new(),
  body? : SearchApplicationRenderQueryBody,
) -> SearchApplicationRenderQueryRequest {
  { name, query, body }
}

///|
pub async fn Client::search_application_render_query(
  self : Client,
  request : SearchApplicationRenderQueryRequest,
) -> EsResponse[SearchApplicationRenderQueryResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_application/search_application/{name}/_render_query",
        ["name"],
      ),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchApplicationSearchQuery {
  typed_keys : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationSearchQuery with fn to_json(
  self : SearchApplicationSearchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationSearchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchApplicationSearchQuery: expected object"),
    )
  }
  {
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
  }
}

///|
pub fn SearchApplicationSearchQuery::new(
  typed_keys? : Bool,
) -> SearchApplicationSearchQuery {
  { typed_keys, }
}

///|
pub fn SearchApplicationSearchQuery::to_pairs(
  self : SearchApplicationSearchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchApplicationSearchBody {
  params : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchApplicationSearchBody with fn to_json(
  self : SearchApplicationSearchBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchApplicationSearchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchApplicationSearchBody: expected object"),
    )
  }
  {
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
  }
}

///|
pub fn SearchApplicationSearchBody::new(
  params? : Map[String, Json],
) -> SearchApplicationSearchBody {
  { params, }
}

///|
pub type SearchApplicationSearchResponse = Json

///|
pub(all) struct SearchApplicationSearchRequest {
  name : String
  query : SearchApplicationSearchQuery
  body : SearchApplicationSearchBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchApplicationSearchRequest::new(
  name : String,
  query? : SearchApplicationSearchQuery = SearchApplicationSearchQuery::new(),
  body? : SearchApplicationSearchBody,
) -> SearchApplicationSearchRequest {
  { name, query, body }
}

///|
pub async fn Client::search_application_search(
  self : Client,
  request : SearchApplicationSearchRequest,
) -> EsResponse[SearchApplicationSearchResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_application/search_application/{name}/_search", [
        "name",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchMvtQuery {
  exact_bounds : Bool?
  extent : Int?
  grid_agg : String?
  grid_precision : Int?
  grid_type : String?
  size : Int?
  track_total_hits : String?
  with_labels : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchMvtQuery with fn to_json(self : SearchMvtQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.exact_bounds {
    Some(value) => obj["exact_bounds"] = value.to_json()
    None => ()
  }
  match self.extent {
    Some(value) => obj["extent"] = value.to_json()
    None => ()
  }
  match self.grid_agg {
    Some(value) => obj["grid_agg"] = value.to_json()
    None => ()
  }
  match self.grid_precision {
    Some(value) => obj["grid_precision"] = value.to_json()
    None => ()
  }
  match self.grid_type {
    Some(value) => obj["grid_type"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.with_labels {
    Some(value) => obj["with_labels"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchMvtQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchMvtQuery: expected object"))
  }
  {
    exact_bounds: match obj.get("exact_bounds") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exact_bounds")))
    },
    extent: match obj.get("extent") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("extent")))
    },
    grid_agg: match obj.get("grid_agg") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("grid_agg")))
    },
    grid_precision: match obj.get("grid_precision") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grid_precision")))
    },
    grid_type: match obj.get("grid_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grid_type")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    with_labels: match obj.get("with_labels") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_labels")))
    },
  }
}

///|
pub fn SearchMvtQuery::new(
  exact_bounds? : Bool,
  extent? : Int,
  grid_agg? : String,
  grid_precision? : Int,
  grid_type? : String,
  size? : Int,
  track_total_hits? : String,
  with_labels? : Bool,
) -> SearchMvtQuery {
  {
    exact_bounds,
    extent,
    grid_agg,
    grid_precision,
    grid_type,
    size,
    track_total_hits,
    with_labels,
  }
}

///|
pub fn SearchMvtQuery::to_pairs(
  self : SearchMvtQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.exact_bounds {
    Some(value) => push_query_json(pairs, "exact_bounds", value.to_json())
    None => ()
  }
  match self.extent {
    Some(value) => push_query_json(pairs, "extent", value.to_json())
    None => ()
  }
  match self.grid_agg {
    Some(value) => push_query_json(pairs, "grid_agg", value.to_json())
    None => ()
  }
  match self.grid_precision {
    Some(value) => push_query_json(pairs, "grid_precision", value.to_json())
    None => ()
  }
  match self.grid_type {
    Some(value) => push_query_json(pairs, "grid_type", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.track_total_hits {
    Some(value) => push_query_json(pairs, "track_total_hits", value.to_json())
    None => ()
  }
  match self.with_labels {
    Some(value) => push_query_json(pairs, "with_labels", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchMvtBody {
  aggs : Map[String, Json]?
  buffer : Int?
  exact_bounds : Bool?
  extent : Int?
  fields : Json?
  grid_agg : Json?
  grid_precision : Int?
  grid_type : Json?
  query : Json?
  runtime_mappings : Json?
  size : Int?
  sort : Json?
  track_total_hits : Json?
  with_labels : Bool?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchMvtBody with fn to_json(self : SearchMvtBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggs {
    Some(value) => obj["aggs"] = value.to_json()
    None => ()
  }
  match self.buffer {
    Some(value) => obj["buffer"] = value.to_json()
    None => ()
  }
  match self.exact_bounds {
    Some(value) => obj["exact_bounds"] = value.to_json()
    None => ()
  }
  match self.extent {
    Some(value) => obj["extent"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.grid_agg {
    Some(value) => obj["grid_agg"] = value.to_json()
    None => ()
  }
  match self.grid_precision {
    Some(value) => obj["grid_precision"] = value.to_json()
    None => ()
  }
  match self.grid_type {
    Some(value) => obj["grid_type"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  match self.with_labels {
    Some(value) => obj["with_labels"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchMvtBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchMvtBody: expected object"))
  }
  {
    aggs: match obj.get("aggs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("aggs")))
    },
    buffer: match obj.get("buffer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("buffer")))
    },
    exact_bounds: match obj.get("exact_bounds") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exact_bounds")))
    },
    extent: match obj.get("extent") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("extent")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    grid_agg: match obj.get("grid_agg") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("grid_agg")))
    },
    grid_precision: match obj.get("grid_precision") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grid_precision")))
    },
    grid_type: match obj.get("grid_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grid_type")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
    with_labels: match obj.get("with_labels") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_labels")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn SearchMvtBody::new(
  aggs? : Map[String, Json],
  buffer? : Int,
  exact_bounds? : Bool,
  extent? : Int,
  fields? : Json,
  grid_agg? : Json,
  grid_precision? : Int,
  grid_type? : Json,
  query? : Json,
  runtime_mappings? : Json,
  size? : Int,
  sort? : Json,
  track_total_hits? : Json,
  with_labels? : Bool,
  project_routing? : Json,
) -> SearchMvtBody {
  {
    aggs,
    buffer,
    exact_bounds,
    extent,
    fields,
    grid_agg,
    grid_precision,
    grid_type,
    query,
    runtime_mappings,
    size,
    sort,
    track_total_hits,
    with_labels,
    project_routing,
  }
}

///|
pub type SearchMvtResponse = Json

///|
pub(all) struct SearchMvtRequest {
  index : String
  field : String
  zoom : String
  x : String
  y : String
  query : SearchMvtQuery
  body : SearchMvtBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchMvtRequest::new(
  index : String,
  field : String,
  zoom : String,
  x : String,
  y : String,
  query? : SearchMvtQuery = SearchMvtQuery::new(),
  body? : SearchMvtBody,
) -> SearchMvtRequest {
  { index, field, zoom, x, y, query, body }
}

///|
pub async fn Client::search_mvt(
  self : Client,
  request : SearchMvtRequest,
) -> EsResponse[SearchMvtResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["field"] = request.field
  params["zoom"] = request.zoom
  params["x"] = request.x
  params["y"] = request.y
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_mvt/{field}/{zoom}/{x}/{y}", [
        "index", "field", "zoom", "x", "y",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchShardsQuery {
  allow_no_indices : Bool?
  expand_wildcards : String?
  ignore_unavailable : Bool?
  local_ : Bool?
  master_timeout : String?
  preference : String?
  routing : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchShardsQuery with fn to_json(self : SearchShardsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchShardsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchShardsQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
  }
}

///|
pub fn SearchShardsQuery::new(
  allow_no_indices? : Bool,
  expand_wildcards? : String,
  ignore_unavailable? : Bool,
  local_? : Bool,
  master_timeout? : String,
  preference? : String,
  routing? : String,
) -> SearchShardsQuery {
  {
    allow_no_indices,
    expand_wildcards,
    ignore_unavailable,
    local_,
    master_timeout,
    preference,
    routing,
  }
}

///|
pub fn SearchShardsQuery::to_pairs(
  self : SearchShardsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchShardsResponse {
  nodes : Map[String, Json]
  shards : Array[Array[Json]]
  indices : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SearchShardsResponse with fn to_json(
  self : SearchShardsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nodes"] = self.nodes.to_json()
  obj["shards"] = self.shards.to_json()
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SearchShardsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchShardsResponse: expected object"))
  }
  {
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
    shards: @json.from_json(
      obj.get("shards").unwrap_or(Json::null()),
      path=path.add_key("shards"),
    ),
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub(all) struct SearchShardsRequest {
  index : String?
  query : SearchShardsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchShardsRequest::new(
  index? : String,
  query? : SearchShardsQuery = SearchShardsQuery::new(),
) -> SearchShardsRequest {
  { index, query }
}

///|
pub async fn Client::search_shards(
  self : Client,
  request : SearchShardsRequest,
) -> EsResponse[SearchShardsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_search_shards", ["index"]),
      PathVariant::new("/_search_shards", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SearchTemplateQuery {
  allow_no_indices : Bool?
  ccs_minimize_roundtrips : Bool?
  expand_wildcards : String?
  explain : Bool?
  ignore_throttled : Bool?
  ignore_unavailable : Bool?
  preference : String?
  profile : Bool?
  routing : String?
  scroll : String?
  search_type : String?
  rest_total_hits_as_int : Bool?
  typed_keys : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchTemplateQuery with fn to_json(
  self : SearchTemplateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) => obj["ccs_minimize_roundtrips"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => obj["ignore_throttled"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) => obj["rest_total_hits_as_int"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchTemplateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchTemplateQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    ccs_minimize_roundtrips: match obj.get("ccs_minimize_roundtrips") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("ccs_minimize_roundtrips")),
        )
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    ignore_throttled: match obj.get("ignore_throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_throttled")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    rest_total_hits_as_int: match obj.get("rest_total_hits_as_int") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rest_total_hits_as_int")),
        )
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
  }
}

///|
pub fn SearchTemplateQuery::new(
  allow_no_indices? : Bool,
  ccs_minimize_roundtrips? : Bool,
  expand_wildcards? : String,
  explain? : Bool,
  ignore_throttled? : Bool,
  ignore_unavailable? : Bool,
  preference? : String,
  profile? : Bool,
  routing? : String,
  scroll? : String,
  search_type? : String,
  rest_total_hits_as_int? : Bool,
  typed_keys? : Bool,
) -> SearchTemplateQuery {
  {
    allow_no_indices,
    ccs_minimize_roundtrips,
    expand_wildcards,
    explain,
    ignore_throttled,
    ignore_unavailable,
    preference,
    profile,
    routing,
    scroll,
    search_type,
    rest_total_hits_as_int,
    typed_keys,
  }
}

///|
pub fn SearchTemplateQuery::to_pairs(
  self : SearchTemplateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.ccs_minimize_roundtrips {
    Some(value) =>
      push_query_json(pairs, "ccs_minimize_roundtrips", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.ignore_throttled {
    Some(value) => push_query_json(pairs, "ignore_throttled", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.profile {
    Some(value) => push_query_json(pairs, "profile", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.rest_total_hits_as_int {
    Some(value) =>
      push_query_json(pairs, "rest_total_hits_as_int", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchTemplateBody {
  explain : Bool?
  id : Json?
  params : Map[String, Json]?
  profile : Bool?
  source : Json?
  project_routing : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchTemplateBody with fn to_json(
  self : SearchTemplateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.source {
    Some(value) => obj["source"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchTemplateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchTemplateBody: expected object"))
  }
  {
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    source: match obj.get("source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("source")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
  }
}

///|
pub fn SearchTemplateBody::new(
  explain? : Bool,
  id? : Json,
  params? : Map[String, Json],
  profile? : Bool,
  source? : Json,
  project_routing? : Json,
) -> SearchTemplateBody {
  { explain, id, params, profile, source, project_routing }
}

///|
pub(all) struct SearchTemplateResponse {
  took : Int
  timed_out : Bool
  _shards : Json
  hits : Json
  aggregations : Map[String, Json]?
  _clusters : Json?
  fields : Map[String, Json]?
  max_score : Double?
  num_reduce_phases : Int?
  profile : Json?
  pit_id : Json?
  _scroll_id : Json?
  suggest : Map[String, Json]?
  terminated_early : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchTemplateResponse with fn to_json(
  self : SearchTemplateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["took"] = self.took.to_json()
  obj["timed_out"] = self.timed_out.to_json()
  obj["_shards"] = self._shards.to_json()
  obj["hits"] = self.hits.to_json()
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self._clusters {
    Some(value) => obj["_clusters"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.max_score {
    Some(value) => obj["max_score"] = value.to_json()
    None => ()
  }
  match self.num_reduce_phases {
    Some(value) => obj["num_reduce_phases"] = value.to_json()
    None => ()
  }
  match self.profile {
    Some(value) => obj["profile"] = value.to_json()
    None => ()
  }
  match self.pit_id {
    Some(value) => obj["pit_id"] = value.to_json()
    None => ()
  }
  match self._scroll_id {
    Some(value) => obj["_scroll_id"] = value.to_json()
    None => ()
  }
  match self.suggest {
    Some(value) => obj["suggest"] = value.to_json()
    None => ()
  }
  match self.terminated_early {
    Some(value) => obj["terminated_early"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchTemplateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SearchTemplateResponse: expected object"))
  }
  {
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    timed_out: @json.from_json(
      obj.get("timed_out").unwrap_or(Json::null()),
      path=path.add_key("timed_out"),
    ),
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    hits: @json.from_json(
      obj.get("hits").unwrap_or(Json::null()),
      path=path.add_key("hits"),
    ),
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    _clusters: match obj.get("_clusters") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_clusters")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    max_score: match obj.get("max_score") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_score")))
    },
    num_reduce_phases: match obj.get("num_reduce_phases") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("num_reduce_phases")))
    },
    profile: match obj.get("profile") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("profile")))
    },
    pit_id: match obj.get("pit_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pit_id")))
    },
    _scroll_id: match obj.get("_scroll_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_scroll_id")))
    },
    suggest: match obj.get("suggest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("suggest")))
    },
    terminated_early: match obj.get("terminated_early") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminated_early")))
    },
  }
}

///|
pub(all) struct SearchTemplateRequest {
  index : String?
  query : SearchTemplateQuery
  body : SearchTemplateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchTemplateRequest::new(
  body : SearchTemplateBody,
  index? : String,
  query? : SearchTemplateQuery = SearchTemplateQuery::new(),
) -> SearchTemplateRequest {
  { index, query, body }
}

///|
pub async fn Client::search_template(
  self : Client,
  request : SearchTemplateRequest,
) -> EsResponse[SearchTemplateResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_search/template", ["index"]),
      PathVariant::new("/_search/template", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchableSnapshotsCacheStatsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsCacheStatsQuery with fn to_json(
  _self : SearchableSnapshotsCacheStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SearchableSnapshotsCacheStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsCacheStatsQuery: expected object"),
    )
  }
  SearchableSnapshotsCacheStatsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SearchableSnapshotsCacheStatsQuery::new() -> SearchableSnapshotsCacheStatsQuery {
  SearchableSnapshotsCacheStatsQuery::{  }
}

///|
pub fn SearchableSnapshotsCacheStatsQuery::to_pairs(
  _self : SearchableSnapshotsCacheStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SearchableSnapshotsCacheStatsResponse {
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsCacheStatsResponse with fn to_json(
  self : SearchableSnapshotsCacheStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsCacheStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsCacheStatsResponse: expected object"),
    )
  }
  {
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SearchableSnapshotsCacheStatsRequest {
  node_id : String?
  query : SearchableSnapshotsCacheStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchableSnapshotsCacheStatsRequest::new(
  node_id? : String,
  query? : SearchableSnapshotsCacheStatsQuery = SearchableSnapshotsCacheStatsQuery::new(),
) -> SearchableSnapshotsCacheStatsRequest {
  { node_id, query }
}

///|
pub async fn Client::searchable_snapshots_cache_stats(
  self : Client,
  request : SearchableSnapshotsCacheStatsRequest,
) -> EsResponse[SearchableSnapshotsCacheStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_searchable_snapshots/{node_id}/cache/stats", [
        "node_id",
      ]),
      PathVariant::new("/_searchable_snapshots/cache/stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SearchableSnapshotsClearCacheQuery {
  expand_wildcards : String?
  allow_no_indices : Bool?
  ignore_unavailable : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsClearCacheQuery with fn to_json(
  self : SearchableSnapshotsClearCacheQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsClearCacheQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsClearCacheQuery: expected object"),
    )
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
  }
}

///|
pub fn SearchableSnapshotsClearCacheQuery::new(
  expand_wildcards? : String,
  allow_no_indices? : Bool,
  ignore_unavailable? : Bool,
) -> SearchableSnapshotsClearCacheQuery {
  { expand_wildcards, allow_no_indices, ignore_unavailable }
}

///|
pub fn SearchableSnapshotsClearCacheQuery::to_pairs(
  self : SearchableSnapshotsClearCacheQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SearchableSnapshotsClearCacheResponse = Json

///|
pub(all) struct SearchableSnapshotsClearCacheRequest {
  index : String?
  query : SearchableSnapshotsClearCacheQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchableSnapshotsClearCacheRequest::new(
  index? : String,
  query? : SearchableSnapshotsClearCacheQuery = SearchableSnapshotsClearCacheQuery::new(),
) -> SearchableSnapshotsClearCacheRequest {
  { index, query }
}

///|
pub async fn Client::searchable_snapshots_clear_cache(
  self : Client,
  request : SearchableSnapshotsClearCacheRequest,
) -> EsResponse[SearchableSnapshotsClearCacheResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_searchable_snapshots/cache/clear", ["index"]),
      PathVariant::new("/_searchable_snapshots/cache/clear", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SearchableSnapshotsMountQuery {
  master_timeout : String?
  wait_for_completion : Bool?
  storage : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsMountQuery with fn to_json(
  self : SearchableSnapshotsMountQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  match self.storage {
    Some(value) => obj["storage"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsMountQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsMountQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
    storage: match obj.get("storage") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("storage")))
    },
  }
}

///|
pub fn SearchableSnapshotsMountQuery::new(
  master_timeout? : String,
  wait_for_completion? : Bool,
  storage? : String,
) -> SearchableSnapshotsMountQuery {
  { master_timeout, wait_for_completion, storage }
}

///|
pub fn SearchableSnapshotsMountQuery::to_pairs(
  self : SearchableSnapshotsMountQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  match self.storage {
    Some(value) => push_query_json(pairs, "storage", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchableSnapshotsMountBody {
  index : Json
  renamed_index : Json?
  index_settings : Map[String, Json]?
  ignore_index_settings : Array[String]?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsMountBody with fn to_json(
  self : SearchableSnapshotsMountBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["index"] = self.index.to_json()
  match self.renamed_index {
    Some(value) => obj["renamed_index"] = value.to_json()
    None => ()
  }
  match self.index_settings {
    Some(value) => obj["index_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_index_settings {
    Some(value) => obj["ignore_index_settings"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsMountBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsMountBody: expected object"),
    )
  }
  {
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    renamed_index: match obj.get("renamed_index") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("renamed_index")))
    },
    index_settings: match obj.get("index_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_settings")))
    },
    ignore_index_settings: match obj.get("ignore_index_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_index_settings")))
    },
  }
}

///|
pub fn SearchableSnapshotsMountBody::new(
  index : Json,
  renamed_index? : Json,
  index_settings? : Map[String, Json],
  ignore_index_settings? : Array[String],
) -> SearchableSnapshotsMountBody {
  { index, renamed_index, index_settings, ignore_index_settings }
}

///|
pub(all) struct SearchableSnapshotsMountResponse {
  snapshot : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsMountResponse with fn to_json(
  self : SearchableSnapshotsMountResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["snapshot"] = self.snapshot.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsMountResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsMountResponse: expected object"),
    )
  }
  {
    snapshot: @json.from_json(
      obj.get("snapshot").unwrap_or(Json::null()),
      path=path.add_key("snapshot"),
    ),
  }
}

///|
pub(all) struct SearchableSnapshotsMountRequest {
  repository : String
  snapshot : String
  query : SearchableSnapshotsMountQuery
  body : SearchableSnapshotsMountBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchableSnapshotsMountRequest::new(
  repository : String,
  snapshot : String,
  body : SearchableSnapshotsMountBody,
  query? : SearchableSnapshotsMountQuery = SearchableSnapshotsMountQuery::new(),
) -> SearchableSnapshotsMountRequest {
  { repository, snapshot, query, body }
}

///|
pub async fn Client::searchable_snapshots_mount(
  self : Client,
  request : SearchableSnapshotsMountRequest,
) -> EsResponse[SearchableSnapshotsMountResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  params["snapshot"] = request.snapshot
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/{snapshot}/_mount", [
        "repository", "snapshot",
      ]),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SearchableSnapshotsStatsQuery {
  level : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsStatsQuery with fn to_json(
  self : SearchableSnapshotsStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.level {
    Some(value) => obj["level"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsStatsQuery: expected object"),
    )
  }
  {
    level: match obj.get("level") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("level")))
    },
  }
}

///|
pub fn SearchableSnapshotsStatsQuery::new(
  level? : String,
) -> SearchableSnapshotsStatsQuery {
  { level, }
}

///|
pub fn SearchableSnapshotsStatsQuery::to_pairs(
  self : SearchableSnapshotsStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.level {
    Some(value) => push_query_json(pairs, "level", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SearchableSnapshotsStatsResponse {
  stats : Json
  total : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SearchableSnapshotsStatsResponse with fn to_json(
  self : SearchableSnapshotsStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["stats"] = self.stats.to_json()
  obj["total"] = self.total.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SearchableSnapshotsStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SearchableSnapshotsStatsResponse: expected object"),
    )
  }
  {
    stats: @json.from_json(
      obj.get("stats").unwrap_or(Json::null()),
      path=path.add_key("stats"),
    ),
    total: @json.from_json(
      obj.get("total").unwrap_or(Json::null()),
      path=path.add_key("total"),
    ),
  }
}

///|
pub(all) struct SearchableSnapshotsStatsRequest {
  index : String?
  query : SearchableSnapshotsStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SearchableSnapshotsStatsRequest::new(
  index? : String,
  query? : SearchableSnapshotsStatsQuery = SearchableSnapshotsStatsQuery::new(),
) -> SearchableSnapshotsStatsRequest {
  { index, query }
}

///|
pub async fn Client::searchable_snapshots_stats(
  self : Client,
  request : SearchableSnapshotsStatsRequest,
) -> EsResponse[SearchableSnapshotsStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_searchable_snapshots/stats", ["index"]),
      PathVariant::new("/_searchable_snapshots/stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityActivateUserProfileQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityActivateUserProfileQuery with fn to_json(
  _self : SecurityActivateUserProfileQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityActivateUserProfileQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityActivateUserProfileQuery: expected object"),
    )
  }
  SecurityActivateUserProfileQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityActivateUserProfileQuery::new() -> SecurityActivateUserProfileQuery {
  SecurityActivateUserProfileQuery::{  }
}

///|
pub fn SecurityActivateUserProfileQuery::to_pairs(
  _self : SecurityActivateUserProfileQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityActivateUserProfileBody {
  access_token : String?
  grant_type : Json
  password : String?
  username : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityActivateUserProfileBody with fn to_json(
  self : SecurityActivateUserProfileBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.access_token {
    Some(value) => obj["access_token"] = value.to_json()
    None => ()
  }
  obj["grant_type"] = self.grant_type.to_json()
  match self.password {
    Some(value) => obj["password"] = value.to_json()
    None => ()
  }
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityActivateUserProfileBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityActivateUserProfileBody: expected object"),
    )
  }
  {
    access_token: match obj.get("access_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("access_token")))
    },
    grant_type: @json.from_json(
      obj.get("grant_type").unwrap_or(Json::null()),
      path=path.add_key("grant_type"),
    ),
    password: match obj.get("password") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("password")))
    },
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
  }
}

///|
pub fn SecurityActivateUserProfileBody::new(
  grant_type : Json,
  access_token? : String,
  password? : String,
  username? : String,
) -> SecurityActivateUserProfileBody {
  { access_token, grant_type, password, username }
}

///|
pub type SecurityActivateUserProfileResponse = Json

///|
pub(all) struct SecurityActivateUserProfileRequest {
  query : SecurityActivateUserProfileQuery
  body : SecurityActivateUserProfileBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityActivateUserProfileRequest::new(
  body : SecurityActivateUserProfileBody,
  query? : SecurityActivateUserProfileQuery = SecurityActivateUserProfileQuery::new(),
) -> SecurityActivateUserProfileRequest {
  { query, body }
}

///|
pub async fn Client::security_activate_user_profile(
  self : Client,
  request : SecurityActivateUserProfileRequest,
) -> EsResponse[SecurityActivateUserProfileResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/_activate", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityAuthenticateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityAuthenticateQuery with fn to_json(
  _self : SecurityAuthenticateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityAuthenticateQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityAuthenticateQuery: expected object"))
  }
  SecurityAuthenticateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityAuthenticateQuery::new() -> SecurityAuthenticateQuery {
  SecurityAuthenticateQuery::{  }
}

///|
pub fn SecurityAuthenticateQuery::to_pairs(
  _self : SecurityAuthenticateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityAuthenticateResponse {
  api_key : Json?
  authentication_realm : Json
  email : Json?
  full_name : Json?
  lookup_realm : Json
  metadata : Json
  roles : Array[String]
  username : Json
  enabled : Bool
  authentication_type : String
  token : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityAuthenticateResponse with fn to_json(
  self : SecurityAuthenticateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.api_key {
    Some(value) => obj["api_key"] = value.to_json()
    None => ()
  }
  obj["authentication_realm"] = self.authentication_realm.to_json()
  match self.email {
    Some(value) => obj["email"] = value.to_json()
    None => ()
  }
  match self.full_name {
    Some(value) => obj["full_name"] = value.to_json()
    None => ()
  }
  obj["lookup_realm"] = self.lookup_realm.to_json()
  obj["metadata"] = self.metadata.to_json()
  obj["roles"] = self.roles.to_json()
  obj["username"] = self.username.to_json()
  obj["enabled"] = self.enabled.to_json()
  obj["authentication_type"] = self.authentication_type.to_json()
  match self.token {
    Some(value) => obj["token"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityAuthenticateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityAuthenticateResponse: expected object"),
    )
  }
  {
    api_key: match obj.get("api_key") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("api_key")))
    },
    authentication_realm: @json.from_json(
      obj.get("authentication_realm").unwrap_or(Json::null()),
      path=path.add_key("authentication_realm"),
    ),
    email: match obj.get("email") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("email")))
    },
    full_name: match obj.get("full_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("full_name")))
    },
    lookup_realm: @json.from_json(
      obj.get("lookup_realm").unwrap_or(Json::null()),
      path=path.add_key("lookup_realm"),
    ),
    metadata: @json.from_json(
      obj.get("metadata").unwrap_or(Json::null()),
      path=path.add_key("metadata"),
    ),
    roles: @json.from_json(
      obj.get("roles").unwrap_or(Json::null()),
      path=path.add_key("roles"),
    ),
    username: @json.from_json(
      obj.get("username").unwrap_or(Json::null()),
      path=path.add_key("username"),
    ),
    enabled: @json.from_json(
      obj.get("enabled").unwrap_or(Json::null()),
      path=path.add_key("enabled"),
    ),
    authentication_type: @json.from_json(
      obj.get("authentication_type").unwrap_or(Json::null()),
      path=path.add_key("authentication_type"),
    ),
    token: match obj.get("token") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("token")))
    },
  }
}

///|
pub(all) struct SecurityAuthenticateRequest {
  query : SecurityAuthenticateQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityAuthenticateRequest::new(
  query? : SecurityAuthenticateQuery = SecurityAuthenticateQuery::new(),
) -> SecurityAuthenticateRequest {
  { query, }
}

///|
pub async fn Client::security_authenticate(
  self : Client,
  request : SecurityAuthenticateRequest,
) -> EsResponse[SecurityAuthenticateResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/_authenticate", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityBulkDeleteRoleQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkDeleteRoleQuery with fn to_json(
  self : SecurityBulkDeleteRoleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkDeleteRoleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityBulkDeleteRoleQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityBulkDeleteRoleQuery::new(
  refresh? : String,
) -> SecurityBulkDeleteRoleQuery {
  { refresh, }
}

///|
pub fn SecurityBulkDeleteRoleQuery::to_pairs(
  self : SecurityBulkDeleteRoleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityBulkDeleteRoleBody {
  names : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkDeleteRoleBody with fn to_json(
  self : SecurityBulkDeleteRoleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["names"] = self.names.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkDeleteRoleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityBulkDeleteRoleBody: expected object"))
  }
  {
    names: @json.from_json(
      obj.get("names").unwrap_or(Json::null()),
      path=path.add_key("names"),
    ),
  }
}

///|
pub fn SecurityBulkDeleteRoleBody::new(
  names : Array[String],
) -> SecurityBulkDeleteRoleBody {
  { names, }
}

///|
pub(all) struct SecurityBulkDeleteRoleResponse {
  deleted : Array[String]?
  not_found : Array[String]?
  errors : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkDeleteRoleResponse with fn to_json(
  self : SecurityBulkDeleteRoleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.deleted {
    Some(value) => obj["deleted"] = value.to_json()
    None => ()
  }
  match self.not_found {
    Some(value) => obj["not_found"] = value.to_json()
    None => ()
  }
  match self.errors {
    Some(value) => obj["errors"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkDeleteRoleResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityBulkDeleteRoleResponse: expected object"),
    )
  }
  {
    deleted: match obj.get("deleted") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("deleted")))
    },
    not_found: match obj.get("not_found") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("not_found")))
    },
    errors: match obj.get("errors") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("errors")))
    },
  }
}

///|
pub(all) struct SecurityBulkDeleteRoleRequest {
  query : SecurityBulkDeleteRoleQuery
  body : SecurityBulkDeleteRoleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityBulkDeleteRoleRequest::new(
  body : SecurityBulkDeleteRoleBody,
  query? : SecurityBulkDeleteRoleQuery = SecurityBulkDeleteRoleQuery::new(),
) -> SecurityBulkDeleteRoleRequest {
  { query, body }
}

///|
pub async fn Client::security_bulk_delete_role(
  self : Client,
  request : SecurityBulkDeleteRoleRequest,
) -> EsResponse[SecurityBulkDeleteRoleResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/role", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct SecurityBulkPutRoleQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkPutRoleQuery with fn to_json(
  self : SecurityBulkPutRoleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkPutRoleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityBulkPutRoleQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityBulkPutRoleQuery::new(
  refresh? : String,
) -> SecurityBulkPutRoleQuery {
  { refresh, }
}

///|
pub fn SecurityBulkPutRoleQuery::to_pairs(
  self : SecurityBulkPutRoleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityBulkPutRoleBody {
  roles : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkPutRoleBody with fn to_json(
  self : SecurityBulkPutRoleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["roles"] = self.roles.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkPutRoleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityBulkPutRoleBody: expected object"))
  }
  {
    roles: @json.from_json(
      obj.get("roles").unwrap_or(Json::null()),
      path=path.add_key("roles"),
    ),
  }
}

///|
pub fn SecurityBulkPutRoleBody::new(
  roles : Map[String, Json],
) -> SecurityBulkPutRoleBody {
  { roles, }
}

///|
pub(all) struct SecurityBulkPutRoleResponse {
  created : Array[String]?
  updated : Array[String]?
  noop : Array[String]?
  errors : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkPutRoleResponse with fn to_json(
  self : SecurityBulkPutRoleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.created {
    Some(value) => obj["created"] = value.to_json()
    None => ()
  }
  match self.updated {
    Some(value) => obj["updated"] = value.to_json()
    None => ()
  }
  match self.noop {
    Some(value) => obj["noop"] = value.to_json()
    None => ()
  }
  match self.errors {
    Some(value) => obj["errors"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkPutRoleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityBulkPutRoleResponse: expected object"),
    )
  }
  {
    created: match obj.get("created") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("created")))
    },
    updated: match obj.get("updated") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("updated")))
    },
    noop: match obj.get("noop") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("noop")))
    },
    errors: match obj.get("errors") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("errors")))
    },
  }
}

///|
pub(all) struct SecurityBulkPutRoleRequest {
  query : SecurityBulkPutRoleQuery
  body : SecurityBulkPutRoleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityBulkPutRoleRequest::new(
  body : SecurityBulkPutRoleBody,
  query? : SecurityBulkPutRoleQuery = SecurityBulkPutRoleQuery::new(),
) -> SecurityBulkPutRoleRequest {
  { query, body }
}

///|
pub async fn Client::security_bulk_put_role(
  self : Client,
  request : SecurityBulkPutRoleRequest,
) -> EsResponse[SecurityBulkPutRoleResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/role", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityBulkUpdateApiKeysQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkUpdateApiKeysQuery with fn to_json(
  _self : SecurityBulkUpdateApiKeysQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityBulkUpdateApiKeysQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityBulkUpdateApiKeysQuery: expected object"),
    )
  }
  SecurityBulkUpdateApiKeysQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityBulkUpdateApiKeysQuery::new() -> SecurityBulkUpdateApiKeysQuery {
  SecurityBulkUpdateApiKeysQuery::{  }
}

///|
pub fn SecurityBulkUpdateApiKeysQuery::to_pairs(
  _self : SecurityBulkUpdateApiKeysQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityBulkUpdateApiKeysBody {
  expiration : Json?
  ids : Json
  metadata : Json?
  role_descriptors : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkUpdateApiKeysBody with fn to_json(
  self : SecurityBulkUpdateApiKeysBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  obj["ids"] = self.ids.to_json()
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.role_descriptors {
    Some(value) => obj["role_descriptors"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkUpdateApiKeysBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityBulkUpdateApiKeysBody: expected object"),
    )
  }
  {
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    ids: @json.from_json(
      obj.get("ids").unwrap_or(Json::null()),
      path=path.add_key("ids"),
    ),
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    role_descriptors: match obj.get("role_descriptors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("role_descriptors")))
    },
  }
}

///|
pub fn SecurityBulkUpdateApiKeysBody::new(
  ids : Json,
  expiration? : Json,
  metadata? : Json,
  role_descriptors? : Map[String, Json],
) -> SecurityBulkUpdateApiKeysBody {
  { expiration, ids, metadata, role_descriptors }
}

///|
pub(all) struct SecurityBulkUpdateApiKeysResponse {
  errors : Json?
  noops : Array[String]
  updated : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityBulkUpdateApiKeysResponse with fn to_json(
  self : SecurityBulkUpdateApiKeysResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.errors {
    Some(value) => obj["errors"] = value.to_json()
    None => ()
  }
  obj["noops"] = self.noops.to_json()
  obj["updated"] = self.updated.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityBulkUpdateApiKeysResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityBulkUpdateApiKeysResponse: expected object"),
    )
  }
  {
    errors: match obj.get("errors") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("errors")))
    },
    noops: @json.from_json(
      obj.get("noops").unwrap_or(Json::null()),
      path=path.add_key("noops"),
    ),
    updated: @json.from_json(
      obj.get("updated").unwrap_or(Json::null()),
      path=path.add_key("updated"),
    ),
  }
}

///|
pub(all) struct SecurityBulkUpdateApiKeysRequest {
  query : SecurityBulkUpdateApiKeysQuery
  body : SecurityBulkUpdateApiKeysBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityBulkUpdateApiKeysRequest::new(
  body : SecurityBulkUpdateApiKeysBody,
  query? : SecurityBulkUpdateApiKeysQuery = SecurityBulkUpdateApiKeysQuery::new(),
) -> SecurityBulkUpdateApiKeysRequest {
  { query, body }
}

///|
pub async fn Client::security_bulk_update_api_keys(
  self : Client,
  request : SecurityBulkUpdateApiKeysRequest,
) -> EsResponse[SecurityBulkUpdateApiKeysResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/api_key/_bulk_update", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityChangePasswordQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityChangePasswordQuery with fn to_json(
  self : SecurityChangePasswordQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityChangePasswordQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityChangePasswordQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityChangePasswordQuery::new(
  refresh? : String,
) -> SecurityChangePasswordQuery {
  { refresh, }
}

///|
pub fn SecurityChangePasswordQuery::to_pairs(
  self : SecurityChangePasswordQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityChangePasswordBody {
  password : Json?
  password_hash : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityChangePasswordBody with fn to_json(
  self : SecurityChangePasswordBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.password {
    Some(value) => obj["password"] = value.to_json()
    None => ()
  }
  match self.password_hash {
    Some(value) => obj["password_hash"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityChangePasswordBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityChangePasswordBody: expected object"))
  }
  {
    password: match obj.get("password") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("password")))
    },
    password_hash: match obj.get("password_hash") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("password_hash")))
    },
  }
}

///|
pub fn SecurityChangePasswordBody::new(
  password? : Json,
  password_hash? : String,
) -> SecurityChangePasswordBody {
  { password, password_hash }
}

///|
pub type SecurityChangePasswordResponse = Json

///|
pub(all) struct SecurityChangePasswordRequest {
  username : String?
  query : SecurityChangePasswordQuery
  body : SecurityChangePasswordBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityChangePasswordRequest::new(
  body : SecurityChangePasswordBody,
  username? : String,
  query? : SecurityChangePasswordQuery = SecurityChangePasswordQuery::new(),
) -> SecurityChangePasswordRequest {
  { username, query, body }
}

///|
pub async fn Client::security_change_password(
  self : Client,
  request : SecurityChangePasswordRequest,
) -> EsResponse[SecurityChangePasswordResponse] {
  let params : Map[String, String] = Map([])
  match request.username {
    Some(value) => params["username"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/user/{username}/_password", ["username"]),
      PathVariant::new("/_security/user/_password", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityClearApiKeyCacheQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearApiKeyCacheQuery with fn to_json(
  _self : SecurityClearApiKeyCacheQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityClearApiKeyCacheQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityClearApiKeyCacheQuery: expected object"),
    )
  }
  SecurityClearApiKeyCacheQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityClearApiKeyCacheQuery::new() -> SecurityClearApiKeyCacheQuery {
  SecurityClearApiKeyCacheQuery::{  }
}

///|
pub fn SecurityClearApiKeyCacheQuery::to_pairs(
  _self : SecurityClearApiKeyCacheQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityClearApiKeyCacheResponse {
  _nodes : Json
  cluster_name : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearApiKeyCacheResponse with fn to_json(
  self : SecurityClearApiKeyCacheResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityClearApiKeyCacheResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityClearApiKeyCacheResponse: expected object"),
    )
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SecurityClearApiKeyCacheRequest {
  ids : String
  query : SecurityClearApiKeyCacheQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityClearApiKeyCacheRequest::new(
  ids : String,
  query? : SecurityClearApiKeyCacheQuery = SecurityClearApiKeyCacheQuery::new(),
) -> SecurityClearApiKeyCacheRequest {
  { ids, query }
}

///|
pub async fn Client::security_clear_api_key_cache(
  self : Client,
  request : SecurityClearApiKeyCacheRequest,
) -> EsResponse[SecurityClearApiKeyCacheResponse] {
  let params : Map[String, String] = Map([])
  params["ids"] = request.ids
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/api_key/{ids}/_clear_cache", ["ids"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SecurityClearCachedPrivilegesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedPrivilegesQuery with fn to_json(
  _self : SecurityClearCachedPrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityClearCachedPrivilegesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedPrivilegesQuery: expected object"),
    )
  }
  SecurityClearCachedPrivilegesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityClearCachedPrivilegesQuery::new() -> SecurityClearCachedPrivilegesQuery {
  SecurityClearCachedPrivilegesQuery::{  }
}

///|
pub fn SecurityClearCachedPrivilegesQuery::to_pairs(
  _self : SecurityClearCachedPrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityClearCachedPrivilegesResponse {
  _nodes : Json
  cluster_name : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedPrivilegesResponse with fn to_json(
  self : SecurityClearCachedPrivilegesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityClearCachedPrivilegesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedPrivilegesResponse: expected object"),
    )
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SecurityClearCachedPrivilegesRequest {
  application : String
  query : SecurityClearCachedPrivilegesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityClearCachedPrivilegesRequest::new(
  application : String,
  query? : SecurityClearCachedPrivilegesQuery = SecurityClearCachedPrivilegesQuery::new(),
) -> SecurityClearCachedPrivilegesRequest {
  { application, query }
}

///|
pub async fn Client::security_clear_cached_privileges(
  self : Client,
  request : SecurityClearCachedPrivilegesRequest,
) -> EsResponse[SecurityClearCachedPrivilegesResponse] {
  let params : Map[String, String] = Map([])
  params["application"] = request.application
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/privilege/{application}/_clear_cache", [
        "application",
      ]),
    ],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SecurityClearCachedRealmsQuery {
  usernames : Array[String]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedRealmsQuery with fn to_json(
  self : SecurityClearCachedRealmsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.usernames {
    Some(value) => obj["usernames"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityClearCachedRealmsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedRealmsQuery: expected object"),
    )
  }
  {
    usernames: match obj.get("usernames") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("usernames")))
    },
  }
}

///|
pub fn SecurityClearCachedRealmsQuery::new(
  usernames? : Array[String],
) -> SecurityClearCachedRealmsQuery {
  { usernames, }
}

///|
pub fn SecurityClearCachedRealmsQuery::to_pairs(
  self : SecurityClearCachedRealmsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.usernames {
    Some(value) => push_query_json(pairs, "usernames", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityClearCachedRealmsResponse {
  _nodes : Json
  cluster_name : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedRealmsResponse with fn to_json(
  self : SecurityClearCachedRealmsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityClearCachedRealmsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedRealmsResponse: expected object"),
    )
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SecurityClearCachedRealmsRequest {
  realms : String
  query : SecurityClearCachedRealmsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityClearCachedRealmsRequest::new(
  realms : String,
  query? : SecurityClearCachedRealmsQuery = SecurityClearCachedRealmsQuery::new(),
) -> SecurityClearCachedRealmsRequest {
  { realms, query }
}

///|
pub async fn Client::security_clear_cached_realms(
  self : Client,
  request : SecurityClearCachedRealmsRequest,
) -> EsResponse[SecurityClearCachedRealmsResponse] {
  let params : Map[String, String] = Map([])
  params["realms"] = request.realms
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/realm/{realms}/_clear_cache", ["realms"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SecurityClearCachedRolesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedRolesQuery with fn to_json(
  _self : SecurityClearCachedRolesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityClearCachedRolesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedRolesQuery: expected object"),
    )
  }
  SecurityClearCachedRolesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityClearCachedRolesQuery::new() -> SecurityClearCachedRolesQuery {
  SecurityClearCachedRolesQuery::{  }
}

///|
pub fn SecurityClearCachedRolesQuery::to_pairs(
  _self : SecurityClearCachedRolesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityClearCachedRolesResponse {
  _nodes : Json
  cluster_name : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedRolesResponse with fn to_json(
  self : SecurityClearCachedRolesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityClearCachedRolesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedRolesResponse: expected object"),
    )
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SecurityClearCachedRolesRequest {
  name : String
  query : SecurityClearCachedRolesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityClearCachedRolesRequest::new(
  name : String,
  query? : SecurityClearCachedRolesQuery = SecurityClearCachedRolesQuery::new(),
) -> SecurityClearCachedRolesRequest {
  { name, query }
}

///|
pub async fn Client::security_clear_cached_roles(
  self : Client,
  request : SecurityClearCachedRolesRequest,
) -> EsResponse[SecurityClearCachedRolesResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/role/{name}/_clear_cache", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SecurityClearCachedServiceTokensQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedServiceTokensQuery with fn to_json(
  _self : SecurityClearCachedServiceTokensQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityClearCachedServiceTokensQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedServiceTokensQuery: expected object"),
    )
  }
  SecurityClearCachedServiceTokensQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityClearCachedServiceTokensQuery::new() -> SecurityClearCachedServiceTokensQuery {
  SecurityClearCachedServiceTokensQuery::{  }
}

///|
pub fn SecurityClearCachedServiceTokensQuery::to_pairs(
  _self : SecurityClearCachedServiceTokensQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityClearCachedServiceTokensResponse {
  _nodes : Json
  cluster_name : Json
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityClearCachedServiceTokensResponse with fn to_json(
  self : SecurityClearCachedServiceTokensResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityClearCachedServiceTokensResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityClearCachedServiceTokensResponse: expected object"),
    )
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SecurityClearCachedServiceTokensRequest {
  namespace_ : String
  service : String
  name : String
  query : SecurityClearCachedServiceTokensQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityClearCachedServiceTokensRequest::new(
  namespace_ : String,
  service : String,
  name : String,
  query? : SecurityClearCachedServiceTokensQuery = SecurityClearCachedServiceTokensQuery::new(),
) -> SecurityClearCachedServiceTokensRequest {
  { namespace_, service, name, query }
}

///|
pub async fn Client::security_clear_cached_service_tokens(
  self : Client,
  request : SecurityClearCachedServiceTokensRequest,
) -> EsResponse[SecurityClearCachedServiceTokensResponse] {
  let params : Map[String, String] = Map([])
  params["namespace"] = request.namespace_
  params["service"] = request.service
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_security/service/{namespace}/{service}/credential/token/{name}/_clear_cache",
        ["namespace", "service", "name"],
      ),
    ],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SecurityCloneApiKeyQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCloneApiKeyQuery with fn to_json(
  self : SecurityCloneApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCloneApiKeyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityCloneApiKeyQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityCloneApiKeyQuery::new(
  refresh? : String,
) -> SecurityCloneApiKeyQuery {
  { refresh, }
}

///|
pub fn SecurityCloneApiKeyQuery::to_pairs(
  self : SecurityCloneApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityCloneApiKeyBody {
  api_key : String
  name : Json?
  expiration : Json?
  metadata : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCloneApiKeyBody with fn to_json(
  self : SecurityCloneApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_key"] = self.api_key.to_json()
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCloneApiKeyBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityCloneApiKeyBody: expected object"))
  }
  {
    api_key: @json.from_json(
      obj.get("api_key").unwrap_or(Json::null()),
      path=path.add_key("api_key"),
    ),
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
  }
}

///|
pub fn SecurityCloneApiKeyBody::new(
  api_key : String,
  name? : Json,
  expiration? : Json,
  metadata? : Json,
) -> SecurityCloneApiKeyBody {
  { api_key, name, expiration, metadata }
}

///|
pub(all) struct SecurityCloneApiKeyResponse {
  api_key : String
  expiration : Int?
  id : Json
  name : Json
  encoded : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCloneApiKeyResponse with fn to_json(
  self : SecurityCloneApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_key"] = self.api_key.to_json()
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  obj["id"] = self.id.to_json()
  obj["name"] = self.name.to_json()
  obj["encoded"] = self.encoded.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCloneApiKeyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityCloneApiKeyResponse: expected object"),
    )
  }
  {
    api_key: @json.from_json(
      obj.get("api_key").unwrap_or(Json::null()),
      path=path.add_key("api_key"),
    ),
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    encoded: @json.from_json(
      obj.get("encoded").unwrap_or(Json::null()),
      path=path.add_key("encoded"),
    ),
  }
}

///|
pub(all) struct SecurityCloneApiKeyRequest {
  query : SecurityCloneApiKeyQuery
  body : SecurityCloneApiKeyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityCloneApiKeyRequest::new(
  body : SecurityCloneApiKeyBody,
  query? : SecurityCloneApiKeyQuery = SecurityCloneApiKeyQuery::new(),
) -> SecurityCloneApiKeyRequest {
  { query, body }
}

///|
pub async fn Client::security_clone_api_key(
  self : Client,
  request : SecurityCloneApiKeyRequest,
) -> EsResponse[SecurityCloneApiKeyResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/api_key/clone", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityCreateApiKeyQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateApiKeyQuery with fn to_json(
  self : SecurityCreateApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateApiKeyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityCreateApiKeyQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityCreateApiKeyQuery::new(
  refresh? : String,
) -> SecurityCreateApiKeyQuery {
  { refresh, }
}

///|
pub fn SecurityCreateApiKeyQuery::to_pairs(
  self : SecurityCreateApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityCreateApiKeyBody {
  expiration : Json?
  name : Json?
  role_descriptors : Map[String, Json]?
  metadata : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateApiKeyBody with fn to_json(
  self : SecurityCreateApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.role_descriptors {
    Some(value) => obj["role_descriptors"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateApiKeyBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityCreateApiKeyBody: expected object"))
  }
  {
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    role_descriptors: match obj.get("role_descriptors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("role_descriptors")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
  }
}

///|
pub fn SecurityCreateApiKeyBody::new(
  expiration? : Json,
  name? : Json,
  role_descriptors? : Map[String, Json],
  metadata? : Json,
) -> SecurityCreateApiKeyBody {
  { expiration, name, role_descriptors, metadata }
}

///|
pub(all) struct SecurityCreateApiKeyResponse {
  api_key : String
  expiration : Int?
  id : Json
  name : Json
  encoded : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateApiKeyResponse with fn to_json(
  self : SecurityCreateApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_key"] = self.api_key.to_json()
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  obj["id"] = self.id.to_json()
  obj["name"] = self.name.to_json()
  obj["encoded"] = self.encoded.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateApiKeyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityCreateApiKeyResponse: expected object"),
    )
  }
  {
    api_key: @json.from_json(
      obj.get("api_key").unwrap_or(Json::null()),
      path=path.add_key("api_key"),
    ),
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    encoded: @json.from_json(
      obj.get("encoded").unwrap_or(Json::null()),
      path=path.add_key("encoded"),
    ),
  }
}

///|
pub(all) struct SecurityCreateApiKeyRequest {
  query : SecurityCreateApiKeyQuery
  body : SecurityCreateApiKeyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityCreateApiKeyRequest::new(
  body : SecurityCreateApiKeyBody,
  query? : SecurityCreateApiKeyQuery = SecurityCreateApiKeyQuery::new(),
) -> SecurityCreateApiKeyRequest {
  { query, body }
}

///|
pub async fn Client::security_create_api_key(
  self : Client,
  request : SecurityCreateApiKeyRequest,
) -> EsResponse[SecurityCreateApiKeyResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/api_key", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityCreateCrossClusterApiKeyQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateCrossClusterApiKeyQuery with fn to_json(
  _self : SecurityCreateCrossClusterApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityCreateCrossClusterApiKeyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityCreateCrossClusterApiKeyQuery: expected object"),
    )
  }
  SecurityCreateCrossClusterApiKeyQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityCreateCrossClusterApiKeyQuery::new() -> SecurityCreateCrossClusterApiKeyQuery {
  SecurityCreateCrossClusterApiKeyQuery::{  }
}

///|
pub fn SecurityCreateCrossClusterApiKeyQuery::to_pairs(
  _self : SecurityCreateCrossClusterApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityCreateCrossClusterApiKeyBody {
  access : Json
  expiration : Json?
  metadata : Json?
  name : Json
  certificate_identity : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateCrossClusterApiKeyBody with fn to_json(
  self : SecurityCreateCrossClusterApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["access"] = self.access.to_json()
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  obj["name"] = self.name.to_json()
  match self.certificate_identity {
    Some(value) => obj["certificate_identity"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateCrossClusterApiKeyBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityCreateCrossClusterApiKeyBody: expected object"),
    )
  }
  {
    access: @json.from_json(
      obj.get("access").unwrap_or(Json::null()),
      path=path.add_key("access"),
    ),
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    certificate_identity: match obj.get("certificate_identity") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("certificate_identity")))
    },
  }
}

///|
pub fn SecurityCreateCrossClusterApiKeyBody::new(
  access : Json,
  name : Json,
  expiration? : Json,
  metadata? : Json,
  certificate_identity? : String,
) -> SecurityCreateCrossClusterApiKeyBody {
  { access, expiration, metadata, name, certificate_identity }
}

///|
pub(all) struct SecurityCreateCrossClusterApiKeyResponse {
  api_key : String
  expiration : Json?
  id : Json
  name : Json
  encoded : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateCrossClusterApiKeyResponse with fn to_json(
  self : SecurityCreateCrossClusterApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_key"] = self.api_key.to_json()
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  obj["id"] = self.id.to_json()
  obj["name"] = self.name.to_json()
  obj["encoded"] = self.encoded.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateCrossClusterApiKeyResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityCreateCrossClusterApiKeyResponse: expected object"),
    )
  }
  {
    api_key: @json.from_json(
      obj.get("api_key").unwrap_or(Json::null()),
      path=path.add_key("api_key"),
    ),
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    encoded: @json.from_json(
      obj.get("encoded").unwrap_or(Json::null()),
      path=path.add_key("encoded"),
    ),
  }
}

///|
pub(all) struct SecurityCreateCrossClusterApiKeyRequest {
  query : SecurityCreateCrossClusterApiKeyQuery
  body : SecurityCreateCrossClusterApiKeyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityCreateCrossClusterApiKeyRequest::new(
  body : SecurityCreateCrossClusterApiKeyBody,
  query? : SecurityCreateCrossClusterApiKeyQuery = SecurityCreateCrossClusterApiKeyQuery::new(),
) -> SecurityCreateCrossClusterApiKeyRequest {
  { query, body }
}

///|
pub async fn Client::security_create_cross_cluster_api_key(
  self : Client,
  request : SecurityCreateCrossClusterApiKeyRequest,
) -> EsResponse[SecurityCreateCrossClusterApiKeyResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/cross_cluster/api_key", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityCreateServiceTokenQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateServiceTokenQuery with fn to_json(
  self : SecurityCreateServiceTokenQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateServiceTokenQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityCreateServiceTokenQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityCreateServiceTokenQuery::new(
  refresh? : String,
) -> SecurityCreateServiceTokenQuery {
  { refresh, }
}

///|
pub fn SecurityCreateServiceTokenQuery::to_pairs(
  self : SecurityCreateServiceTokenQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityCreateServiceTokenResponse {
  created : Bool
  token : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityCreateServiceTokenResponse with fn to_json(
  self : SecurityCreateServiceTokenResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["created"] = self.created.to_json()
  obj["token"] = self.token.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityCreateServiceTokenResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityCreateServiceTokenResponse: expected object"),
    )
  }
  {
    created: @json.from_json(
      obj.get("created").unwrap_or(Json::null()),
      path=path.add_key("created"),
    ),
    token: @json.from_json(
      obj.get("token").unwrap_or(Json::null()),
      path=path.add_key("token"),
    ),
  }
}

///|
pub(all) struct SecurityCreateServiceTokenRequest {
  namespace_ : String
  service : String
  name : String?
  query : SecurityCreateServiceTokenQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityCreateServiceTokenRequest::new(
  namespace_ : String,
  service : String,
  name? : String,
  query? : SecurityCreateServiceTokenQuery = SecurityCreateServiceTokenQuery::new(),
) -> SecurityCreateServiceTokenRequest {
  { namespace_, service, name, query }
}

///|
pub async fn Client::security_create_service_token(
  self : Client,
  request : SecurityCreateServiceTokenRequest,
) -> EsResponse[SecurityCreateServiceTokenResponse] {
  let params : Map[String, String] = Map([])
  params["namespace"] = request.namespace_
  params["service"] = request.service
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_security/service/{namespace}/{service}/credential/token/{name}",
        ["namespace", "service", "name"],
      ),
      PathVariant::new(
        "/_security/service/{namespace}/{service}/credential/token",
        ["namespace", "service"],
      ),
    ],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SecurityDelegatePkiQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDelegatePkiQuery with fn to_json(
  _self : SecurityDelegatePkiQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityDelegatePkiQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityDelegatePkiQuery: expected object"))
  }
  SecurityDelegatePkiQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityDelegatePkiQuery::new() -> SecurityDelegatePkiQuery {
  SecurityDelegatePkiQuery::{  }
}

///|
pub fn SecurityDelegatePkiQuery::to_pairs(
  _self : SecurityDelegatePkiQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityDelegatePkiResponse {
  access_token : String
  expires_in : Int
  type_ : String
  authentication : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDelegatePkiResponse with fn to_json(
  self : SecurityDelegatePkiResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["access_token"] = self.access_token.to_json()
  obj["expires_in"] = self.expires_in.to_json()
  obj["type"] = self.type_.to_json()
  match self.authentication {
    Some(value) => obj["authentication"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDelegatePkiResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDelegatePkiResponse: expected object"),
    )
  }
  {
    access_token: @json.from_json(
      obj.get("access_token").unwrap_or(Json::null()),
      path=path.add_key("access_token"),
    ),
    expires_in: @json.from_json(
      obj.get("expires_in").unwrap_or(Json::null()),
      path=path.add_key("expires_in"),
    ),
    type_: @json.from_json(
      obj.get("type").unwrap_or(Json::null()),
      path=path.add_key("type"),
    ),
    authentication: match obj.get("authentication") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("authentication")))
    },
  }
}

///|
pub(all) struct SecurityDelegatePkiRequest {
  query : SecurityDelegatePkiQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDelegatePkiRequest::new(
  query? : SecurityDelegatePkiQuery = SecurityDelegatePkiQuery::new(),
) -> SecurityDelegatePkiRequest {
  { query, }
}

///|
pub async fn Client::security_delegate_pki(
  self : Client,
  request : SecurityDelegatePkiRequest,
) -> EsResponse[SecurityDelegatePkiResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/delegate_pki", [])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SecurityDeletePrivilegesQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeletePrivilegesQuery with fn to_json(
  self : SecurityDeletePrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeletePrivilegesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDeletePrivilegesQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDeletePrivilegesQuery::new(
  refresh? : String,
) -> SecurityDeletePrivilegesQuery {
  { refresh, }
}

///|
pub fn SecurityDeletePrivilegesQuery::to_pairs(
  self : SecurityDeletePrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityDeletePrivilegesResponse = Json

///|
pub(all) struct SecurityDeletePrivilegesRequest {
  application : String
  name : String
  query : SecurityDeletePrivilegesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDeletePrivilegesRequest::new(
  application : String,
  name : String,
  query? : SecurityDeletePrivilegesQuery = SecurityDeletePrivilegesQuery::new(),
) -> SecurityDeletePrivilegesRequest {
  { application, name, query }
}

///|
pub async fn Client::security_delete_privileges(
  self : Client,
  request : SecurityDeletePrivilegesRequest,
) -> EsResponse[SecurityDeletePrivilegesResponse] {
  let params : Map[String, String] = Map([])
  params["application"] = request.application
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/privilege/{application}/{name}", [
        "application", "name",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SecurityDeleteRoleQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteRoleQuery with fn to_json(
  self : SecurityDeleteRoleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteRoleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityDeleteRoleQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDeleteRoleQuery::new(
  refresh? : String,
) -> SecurityDeleteRoleQuery {
  { refresh, }
}

///|
pub fn SecurityDeleteRoleQuery::to_pairs(
  self : SecurityDeleteRoleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityDeleteRoleResponse {
  found : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteRoleResponse with fn to_json(
  self : SecurityDeleteRoleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteRoleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityDeleteRoleResponse: expected object"))
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
  }
}

///|
pub(all) struct SecurityDeleteRoleRequest {
  name : String
  query : SecurityDeleteRoleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDeleteRoleRequest::new(
  name : String,
  query? : SecurityDeleteRoleQuery = SecurityDeleteRoleQuery::new(),
) -> SecurityDeleteRoleRequest {
  { name, query }
}

///|
pub async fn Client::security_delete_role(
  self : Client,
  request : SecurityDeleteRoleRequest,
) -> EsResponse[SecurityDeleteRoleResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/role/{name}", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SecurityDeleteRoleMappingQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteRoleMappingQuery with fn to_json(
  self : SecurityDeleteRoleMappingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteRoleMappingQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDeleteRoleMappingQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDeleteRoleMappingQuery::new(
  refresh? : String,
) -> SecurityDeleteRoleMappingQuery {
  { refresh, }
}

///|
pub fn SecurityDeleteRoleMappingQuery::to_pairs(
  self : SecurityDeleteRoleMappingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityDeleteRoleMappingResponse {
  found : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteRoleMappingResponse with fn to_json(
  self : SecurityDeleteRoleMappingResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteRoleMappingResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDeleteRoleMappingResponse: expected object"),
    )
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
  }
}

///|
pub(all) struct SecurityDeleteRoleMappingRequest {
  name : String
  query : SecurityDeleteRoleMappingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDeleteRoleMappingRequest::new(
  name : String,
  query? : SecurityDeleteRoleMappingQuery = SecurityDeleteRoleMappingQuery::new(),
) -> SecurityDeleteRoleMappingRequest {
  { name, query }
}

///|
pub async fn Client::security_delete_role_mapping(
  self : Client,
  request : SecurityDeleteRoleMappingRequest,
) -> EsResponse[SecurityDeleteRoleMappingResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/role_mapping/{name}", ["name"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SecurityDeleteServiceTokenQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteServiceTokenQuery with fn to_json(
  self : SecurityDeleteServiceTokenQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteServiceTokenQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDeleteServiceTokenQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDeleteServiceTokenQuery::new(
  refresh? : String,
) -> SecurityDeleteServiceTokenQuery {
  { refresh, }
}

///|
pub fn SecurityDeleteServiceTokenQuery::to_pairs(
  self : SecurityDeleteServiceTokenQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityDeleteServiceTokenResponse {
  found : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteServiceTokenResponse with fn to_json(
  self : SecurityDeleteServiceTokenResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteServiceTokenResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDeleteServiceTokenResponse: expected object"),
    )
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
  }
}

///|
pub(all) struct SecurityDeleteServiceTokenRequest {
  namespace_ : String
  service : String
  name : String
  query : SecurityDeleteServiceTokenQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDeleteServiceTokenRequest::new(
  namespace_ : String,
  service : String,
  name : String,
  query? : SecurityDeleteServiceTokenQuery = SecurityDeleteServiceTokenQuery::new(),
) -> SecurityDeleteServiceTokenRequest {
  { namespace_, service, name, query }
}

///|
pub async fn Client::security_delete_service_token(
  self : Client,
  request : SecurityDeleteServiceTokenRequest,
) -> EsResponse[SecurityDeleteServiceTokenResponse] {
  let params : Map[String, String] = Map([])
  params["namespace"] = request.namespace_
  params["service"] = request.service
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_security/service/{namespace}/{service}/credential/token/{name}",
        ["namespace", "service", "name"],
      ),
    ],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SecurityDeleteUserQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteUserQuery with fn to_json(
  self : SecurityDeleteUserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteUserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityDeleteUserQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDeleteUserQuery::new(
  refresh? : String,
) -> SecurityDeleteUserQuery {
  { refresh, }
}

///|
pub fn SecurityDeleteUserQuery::to_pairs(
  self : SecurityDeleteUserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityDeleteUserResponse {
  found : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDeleteUserResponse with fn to_json(
  self : SecurityDeleteUserResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDeleteUserResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityDeleteUserResponse: expected object"))
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
  }
}

///|
pub(all) struct SecurityDeleteUserRequest {
  username : String
  query : SecurityDeleteUserQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDeleteUserRequest::new(
  username : String,
  query? : SecurityDeleteUserQuery = SecurityDeleteUserQuery::new(),
) -> SecurityDeleteUserRequest {
  { username, query }
}

///|
pub async fn Client::security_delete_user(
  self : Client,
  request : SecurityDeleteUserRequest,
) -> EsResponse[SecurityDeleteUserResponse] {
  let params : Map[String, String] = Map([])
  params["username"] = request.username
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/user/{username}", ["username"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SecurityDisableUserQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDisableUserQuery with fn to_json(
  self : SecurityDisableUserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDisableUserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityDisableUserQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDisableUserQuery::new(
  refresh? : String,
) -> SecurityDisableUserQuery {
  { refresh, }
}

///|
pub fn SecurityDisableUserQuery::to_pairs(
  self : SecurityDisableUserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityDisableUserResponse = Json

///|
pub(all) struct SecurityDisableUserRequest {
  username : String
  query : SecurityDisableUserQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDisableUserRequest::new(
  username : String,
  query? : SecurityDisableUserQuery = SecurityDisableUserQuery::new(),
) -> SecurityDisableUserRequest {
  { username, query }
}

///|
pub async fn Client::security_disable_user(
  self : Client,
  request : SecurityDisableUserRequest,
) -> EsResponse[SecurityDisableUserResponse] {
  let params : Map[String, String] = Map([])
  params["username"] = request.username
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/user/{username}/_disable", ["username"])],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SecurityDisableUserProfileQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityDisableUserProfileQuery with fn to_json(
  self : SecurityDisableUserProfileQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityDisableUserProfileQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityDisableUserProfileQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityDisableUserProfileQuery::new(
  refresh? : String,
) -> SecurityDisableUserProfileQuery {
  { refresh, }
}

///|
pub fn SecurityDisableUserProfileQuery::to_pairs(
  self : SecurityDisableUserProfileQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityDisableUserProfileResponse = Json

///|
pub(all) struct SecurityDisableUserProfileRequest {
  uid : String
  query : SecurityDisableUserProfileQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityDisableUserProfileRequest::new(
  uid : String,
  query? : SecurityDisableUserProfileQuery = SecurityDisableUserProfileQuery::new(),
) -> SecurityDisableUserProfileRequest {
  { uid, query }
}

///|
pub async fn Client::security_disable_user_profile(
  self : Client,
  request : SecurityDisableUserProfileRequest,
) -> EsResponse[SecurityDisableUserProfileResponse] {
  let params : Map[String, String] = Map([])
  params["uid"] = request.uid
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/{uid}/_disable", ["uid"])],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SecurityEnableUserQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityEnableUserQuery with fn to_json(
  self : SecurityEnableUserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityEnableUserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityEnableUserQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityEnableUserQuery::new(
  refresh? : String,
) -> SecurityEnableUserQuery {
  { refresh, }
}

///|
pub fn SecurityEnableUserQuery::to_pairs(
  self : SecurityEnableUserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityEnableUserResponse = Json

///|
pub(all) struct SecurityEnableUserRequest {
  username : String
  query : SecurityEnableUserQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityEnableUserRequest::new(
  username : String,
  query? : SecurityEnableUserQuery = SecurityEnableUserQuery::new(),
) -> SecurityEnableUserRequest {
  { username, query }
}

///|
pub async fn Client::security_enable_user(
  self : Client,
  request : SecurityEnableUserRequest,
) -> EsResponse[SecurityEnableUserResponse] {
  let params : Map[String, String] = Map([])
  params["username"] = request.username
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/user/{username}/_enable", ["username"])],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SecurityEnableUserProfileQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityEnableUserProfileQuery with fn to_json(
  self : SecurityEnableUserProfileQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityEnableUserProfileQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityEnableUserProfileQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityEnableUserProfileQuery::new(
  refresh? : String,
) -> SecurityEnableUserProfileQuery {
  { refresh, }
}

///|
pub fn SecurityEnableUserProfileQuery::to_pairs(
  self : SecurityEnableUserProfileQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityEnableUserProfileResponse = Json

///|
pub(all) struct SecurityEnableUserProfileRequest {
  uid : String
  query : SecurityEnableUserProfileQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityEnableUserProfileRequest::new(
  uid : String,
  query? : SecurityEnableUserProfileQuery = SecurityEnableUserProfileQuery::new(),
) -> SecurityEnableUserProfileRequest {
  { uid, query }
}

///|
pub async fn Client::security_enable_user_profile(
  self : Client,
  request : SecurityEnableUserProfileRequest,
) -> EsResponse[SecurityEnableUserProfileResponse] {
  let params : Map[String, String] = Map([])
  params["uid"] = request.uid
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/{uid}/_enable", ["uid"])],
    params,
  )
  self.perform_json(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SecurityEnrollKibanaQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityEnrollKibanaQuery with fn to_json(
  _self : SecurityEnrollKibanaQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityEnrollKibanaQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityEnrollKibanaQuery: expected object"))
  }
  SecurityEnrollKibanaQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityEnrollKibanaQuery::new() -> SecurityEnrollKibanaQuery {
  SecurityEnrollKibanaQuery::{  }
}

///|
pub fn SecurityEnrollKibanaQuery::to_pairs(
  _self : SecurityEnrollKibanaQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityEnrollKibanaBody = Json

///|
pub(all) struct SecurityEnrollKibanaResponse {
  token : Json
  http_ca : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityEnrollKibanaResponse with fn to_json(
  self : SecurityEnrollKibanaResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["token"] = self.token.to_json()
  obj["http_ca"] = self.http_ca.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityEnrollKibanaResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityEnrollKibanaResponse: expected object"),
    )
  }
  {
    token: @json.from_json(
      obj.get("token").unwrap_or(Json::null()),
      path=path.add_key("token"),
    ),
    http_ca: @json.from_json(
      obj.get("http_ca").unwrap_or(Json::null()),
      path=path.add_key("http_ca"),
    ),
  }
}

///|
pub(all) struct SecurityEnrollKibanaRequest {
  query : SecurityEnrollKibanaQuery
  body : SecurityEnrollKibanaBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityEnrollKibanaRequest::new(
  query? : SecurityEnrollKibanaQuery = SecurityEnrollKibanaQuery::new(),
  body? : SecurityEnrollKibanaBody,
) -> SecurityEnrollKibanaRequest {
  { query, body }
}

///|
pub async fn Client::security_enroll_kibana(
  self : Client,
  request : SecurityEnrollKibanaRequest,
) -> EsResponse[SecurityEnrollKibanaResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/enroll/kibana", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct SecurityEnrollNodeQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityEnrollNodeQuery with fn to_json(
  _self : SecurityEnrollNodeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityEnrollNodeQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityEnrollNodeQuery: expected object"))
  }
  SecurityEnrollNodeQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityEnrollNodeQuery::new() -> SecurityEnrollNodeQuery {
  SecurityEnrollNodeQuery::{  }
}

///|
pub fn SecurityEnrollNodeQuery::to_pairs(
  _self : SecurityEnrollNodeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityEnrollNodeBody = Json

///|
pub(all) struct SecurityEnrollNodeResponse {
  http_ca_key : String
  http_ca_cert : String
  transport_ca_cert : String
  transport_key : String
  transport_cert : String
  nodes_addresses : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityEnrollNodeResponse with fn to_json(
  self : SecurityEnrollNodeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["http_ca_key"] = self.http_ca_key.to_json()
  obj["http_ca_cert"] = self.http_ca_cert.to_json()
  obj["transport_ca_cert"] = self.transport_ca_cert.to_json()
  obj["transport_key"] = self.transport_key.to_json()
  obj["transport_cert"] = self.transport_cert.to_json()
  obj["nodes_addresses"] = self.nodes_addresses.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityEnrollNodeResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityEnrollNodeResponse: expected object"))
  }
  {
    http_ca_key: @json.from_json(
      obj.get("http_ca_key").unwrap_or(Json::null()),
      path=path.add_key("http_ca_key"),
    ),
    http_ca_cert: @json.from_json(
      obj.get("http_ca_cert").unwrap_or(Json::null()),
      path=path.add_key("http_ca_cert"),
    ),
    transport_ca_cert: @json.from_json(
      obj.get("transport_ca_cert").unwrap_or(Json::null()),
      path=path.add_key("transport_ca_cert"),
    ),
    transport_key: @json.from_json(
      obj.get("transport_key").unwrap_or(Json::null()),
      path=path.add_key("transport_key"),
    ),
    transport_cert: @json.from_json(
      obj.get("transport_cert").unwrap_or(Json::null()),
      path=path.add_key("transport_cert"),
    ),
    nodes_addresses: @json.from_json(
      obj.get("nodes_addresses").unwrap_or(Json::null()),
      path=path.add_key("nodes_addresses"),
    ),
  }
}

///|
pub(all) struct SecurityEnrollNodeRequest {
  query : SecurityEnrollNodeQuery
  body : SecurityEnrollNodeBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityEnrollNodeRequest::new(
  query? : SecurityEnrollNodeQuery = SecurityEnrollNodeQuery::new(),
  body? : SecurityEnrollNodeBody,
) -> SecurityEnrollNodeRequest {
  { query, body }
}

///|
pub async fn Client::security_enroll_node(
  self : Client,
  request : SecurityEnrollNodeRequest,
) -> EsResponse[SecurityEnrollNodeResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/enroll/node", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct SecurityGetApiKeyQuery {
  id : String?
  name : String?
  owner : Bool?
  realm_name : String?
  username : String?
  with_limited_by : Bool?
  active_only : Bool?
  with_profile_uid : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetApiKeyQuery with fn to_json(
  self : SecurityGetApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.owner {
    Some(value) => obj["owner"] = value.to_json()
    None => ()
  }
  match self.realm_name {
    Some(value) => obj["realm_name"] = value.to_json()
    None => ()
  }
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  match self.with_limited_by {
    Some(value) => obj["with_limited_by"] = value.to_json()
    None => ()
  }
  match self.active_only {
    Some(value) => obj["active_only"] = value.to_json()
    None => ()
  }
  match self.with_profile_uid {
    Some(value) => obj["with_profile_uid"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetApiKeyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetApiKeyQuery: expected object"))
  }
  {
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    owner: match obj.get("owner") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("owner")))
    },
    realm_name: match obj.get("realm_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("realm_name")))
    },
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
    with_limited_by: match obj.get("with_limited_by") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_limited_by")))
    },
    active_only: match obj.get("active_only") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("active_only")))
    },
    with_profile_uid: match obj.get("with_profile_uid") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_profile_uid")))
    },
  }
}

///|
pub fn SecurityGetApiKeyQuery::new(
  id? : String,
  name? : String,
  owner? : Bool,
  realm_name? : String,
  username? : String,
  with_limited_by? : Bool,
  active_only? : Bool,
  with_profile_uid? : Bool,
) -> SecurityGetApiKeyQuery {
  {
    id,
    name,
    owner,
    realm_name,
    username,
    with_limited_by,
    active_only,
    with_profile_uid,
  }
}

///|
pub fn SecurityGetApiKeyQuery::to_pairs(
  self : SecurityGetApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.id {
    Some(value) => push_query_json(pairs, "id", value.to_json())
    None => ()
  }
  match self.name {
    Some(value) => push_query_json(pairs, "name", value.to_json())
    None => ()
  }
  match self.owner {
    Some(value) => push_query_json(pairs, "owner", value.to_json())
    None => ()
  }
  match self.realm_name {
    Some(value) => push_query_json(pairs, "realm_name", value.to_json())
    None => ()
  }
  match self.username {
    Some(value) => push_query_json(pairs, "username", value.to_json())
    None => ()
  }
  match self.with_limited_by {
    Some(value) => push_query_json(pairs, "with_limited_by", value.to_json())
    None => ()
  }
  match self.active_only {
    Some(value) => push_query_json(pairs, "active_only", value.to_json())
    None => ()
  }
  match self.with_profile_uid {
    Some(value) => push_query_json(pairs, "with_profile_uid", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityGetApiKeyResponse {
  api_keys : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetApiKeyResponse with fn to_json(
  self : SecurityGetApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_keys"] = self.api_keys.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetApiKeyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetApiKeyResponse: expected object"))
  }
  {
    api_keys: @json.from_json(
      obj.get("api_keys").unwrap_or(Json::null()),
      path=path.add_key("api_keys"),
    ),
  }
}

///|
pub(all) struct SecurityGetApiKeyRequest {
  query : SecurityGetApiKeyQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetApiKeyRequest::new(
  query? : SecurityGetApiKeyQuery = SecurityGetApiKeyQuery::new(),
) -> SecurityGetApiKeyRequest {
  { query, }
}

///|
pub async fn Client::security_get_api_key(
  self : Client,
  request : SecurityGetApiKeyRequest,
) -> EsResponse[SecurityGetApiKeyResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/api_key", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetBuiltinPrivilegesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetBuiltinPrivilegesQuery with fn to_json(
  _self : SecurityGetBuiltinPrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetBuiltinPrivilegesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityGetBuiltinPrivilegesQuery: expected object"),
    )
  }
  SecurityGetBuiltinPrivilegesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetBuiltinPrivilegesQuery::new() -> SecurityGetBuiltinPrivilegesQuery {
  SecurityGetBuiltinPrivilegesQuery::{  }
}

///|
pub fn SecurityGetBuiltinPrivilegesQuery::to_pairs(
  _self : SecurityGetBuiltinPrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityGetBuiltinPrivilegesResponse {
  cluster : Array[Json]
  index : Array[Json]
  remote_cluster : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetBuiltinPrivilegesResponse with fn to_json(
  self : SecurityGetBuiltinPrivilegesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cluster"] = self.cluster.to_json()
  obj["index"] = self.index.to_json()
  obj["remote_cluster"] = self.remote_cluster.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetBuiltinPrivilegesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGetBuiltinPrivilegesResponse: expected object"),
    )
  }
  {
    cluster: @json.from_json(
      obj.get("cluster").unwrap_or(Json::null()),
      path=path.add_key("cluster"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    remote_cluster: @json.from_json(
      obj.get("remote_cluster").unwrap_or(Json::null()),
      path=path.add_key("remote_cluster"),
    ),
  }
}

///|
pub(all) struct SecurityGetBuiltinPrivilegesRequest {
  query : SecurityGetBuiltinPrivilegesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetBuiltinPrivilegesRequest::new(
  query? : SecurityGetBuiltinPrivilegesQuery = SecurityGetBuiltinPrivilegesQuery::new(),
) -> SecurityGetBuiltinPrivilegesRequest {
  { query, }
}

///|
pub async fn Client::security_get_builtin_privileges(
  self : Client,
  request : SecurityGetBuiltinPrivilegesRequest,
) -> EsResponse[SecurityGetBuiltinPrivilegesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/privilege/_builtin", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetPrivilegesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetPrivilegesQuery with fn to_json(
  _self : SecurityGetPrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetPrivilegesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityGetPrivilegesQuery: expected object"))
  }
  SecurityGetPrivilegesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetPrivilegesQuery::new() -> SecurityGetPrivilegesQuery {
  SecurityGetPrivilegesQuery::{  }
}

///|
pub fn SecurityGetPrivilegesQuery::to_pairs(
  _self : SecurityGetPrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityGetPrivilegesResponse = Json

///|
pub(all) struct SecurityGetPrivilegesRequest {
  application : String?
  name : String?
  query : SecurityGetPrivilegesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetPrivilegesRequest::new(
  application? : String,
  name? : String,
  query? : SecurityGetPrivilegesQuery = SecurityGetPrivilegesQuery::new(),
) -> SecurityGetPrivilegesRequest {
  { application, name, query }
}

///|
pub async fn Client::security_get_privileges(
  self : Client,
  request : SecurityGetPrivilegesRequest,
) -> EsResponse[SecurityGetPrivilegesResponse] {
  let params : Map[String, String] = Map([])
  match request.application {
    Some(value) => params["application"] = value
    None => ()
  }
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/privilege/{application}/{name}", [
        "application", "name",
      ]),
      PathVariant::new("/_security/privilege/{application}", ["application"]),
      PathVariant::new("/_security/privilege", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetRoleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetRoleQuery with fn to_json(
  _self : SecurityGetRoleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetRoleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityGetRoleQuery: expected object"))
  }
  SecurityGetRoleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetRoleQuery::new() -> SecurityGetRoleQuery {
  SecurityGetRoleQuery::{  }
}

///|
pub fn SecurityGetRoleQuery::to_pairs(
  _self : SecurityGetRoleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityGetRoleResponse = Json

///|
pub(all) struct SecurityGetRoleRequest {
  name : String?
  query : SecurityGetRoleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetRoleRequest::new(
  name? : String,
  query? : SecurityGetRoleQuery = SecurityGetRoleQuery::new(),
) -> SecurityGetRoleRequest {
  { name, query }
}

///|
pub async fn Client::security_get_role(
  self : Client,
  request : SecurityGetRoleRequest,
) -> EsResponse[SecurityGetRoleResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/role/{name}", ["name"]),
      PathVariant::new("/_security/role", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetRoleMappingQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetRoleMappingQuery with fn to_json(
  _self : SecurityGetRoleMappingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetRoleMappingQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityGetRoleMappingQuery: expected object"),
    )
  }
  SecurityGetRoleMappingQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetRoleMappingQuery::new() -> SecurityGetRoleMappingQuery {
  SecurityGetRoleMappingQuery::{  }
}

///|
pub fn SecurityGetRoleMappingQuery::to_pairs(
  _self : SecurityGetRoleMappingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityGetRoleMappingResponse = Json

///|
pub(all) struct SecurityGetRoleMappingRequest {
  name : String?
  query : SecurityGetRoleMappingQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetRoleMappingRequest::new(
  name? : String,
  query? : SecurityGetRoleMappingQuery = SecurityGetRoleMappingQuery::new(),
) -> SecurityGetRoleMappingRequest {
  { name, query }
}

///|
pub async fn Client::security_get_role_mapping(
  self : Client,
  request : SecurityGetRoleMappingRequest,
) -> EsResponse[SecurityGetRoleMappingResponse] {
  let params : Map[String, String] = Map([])
  match request.name {
    Some(value) => params["name"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/role_mapping/{name}", ["name"]),
      PathVariant::new("/_security/role_mapping", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetServiceAccountsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetServiceAccountsQuery with fn to_json(
  _self : SecurityGetServiceAccountsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetServiceAccountsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityGetServiceAccountsQuery: expected object"),
    )
  }
  SecurityGetServiceAccountsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetServiceAccountsQuery::new() -> SecurityGetServiceAccountsQuery {
  SecurityGetServiceAccountsQuery::{  }
}

///|
pub fn SecurityGetServiceAccountsQuery::to_pairs(
  _self : SecurityGetServiceAccountsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityGetServiceAccountsResponse = Json

///|
pub(all) struct SecurityGetServiceAccountsRequest {
  namespace_ : String?
  service : String?
  query : SecurityGetServiceAccountsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetServiceAccountsRequest::new(
  namespace_? : String,
  service? : String,
  query? : SecurityGetServiceAccountsQuery = SecurityGetServiceAccountsQuery::new(),
) -> SecurityGetServiceAccountsRequest {
  { namespace_, service, query }
}

///|
pub async fn Client::security_get_service_accounts(
  self : Client,
  request : SecurityGetServiceAccountsRequest,
) -> EsResponse[SecurityGetServiceAccountsResponse] {
  let params : Map[String, String] = Map([])
  match request.namespace_ {
    Some(value) => params["namespace"] = value
    None => ()
  }
  match request.service {
    Some(value) => params["service"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/service/{namespace}/{service}", [
        "namespace", "service",
      ]),
      PathVariant::new("/_security/service/{namespace}", ["namespace"]),
      PathVariant::new("/_security/service", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetServiceCredentialsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetServiceCredentialsQuery with fn to_json(
  _self : SecurityGetServiceCredentialsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetServiceCredentialsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityGetServiceCredentialsQuery: expected object"),
    )
  }
  SecurityGetServiceCredentialsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetServiceCredentialsQuery::new() -> SecurityGetServiceCredentialsQuery {
  SecurityGetServiceCredentialsQuery::{  }
}

///|
pub fn SecurityGetServiceCredentialsQuery::to_pairs(
  _self : SecurityGetServiceCredentialsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityGetServiceCredentialsResponse {
  service_account : String
  count : Int
  tokens : Map[String, Json]
  nodes_credentials : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetServiceCredentialsResponse with fn to_json(
  self : SecurityGetServiceCredentialsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["service_account"] = self.service_account.to_json()
  obj["count"] = self.count.to_json()
  obj["tokens"] = self.tokens.to_json()
  obj["nodes_credentials"] = self.nodes_credentials.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetServiceCredentialsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGetServiceCredentialsResponse: expected object"),
    )
  }
  {
    service_account: @json.from_json(
      obj.get("service_account").unwrap_or(Json::null()),
      path=path.add_key("service_account"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    tokens: @json.from_json(
      obj.get("tokens").unwrap_or(Json::null()),
      path=path.add_key("tokens"),
    ),
    nodes_credentials: @json.from_json(
      obj.get("nodes_credentials").unwrap_or(Json::null()),
      path=path.add_key("nodes_credentials"),
    ),
  }
}

///|
pub(all) struct SecurityGetServiceCredentialsRequest {
  namespace_ : String
  service : String
  query : SecurityGetServiceCredentialsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetServiceCredentialsRequest::new(
  namespace_ : String,
  service : String,
  query? : SecurityGetServiceCredentialsQuery = SecurityGetServiceCredentialsQuery::new(),
) -> SecurityGetServiceCredentialsRequest {
  { namespace_, service, query }
}

///|
pub async fn Client::security_get_service_credentials(
  self : Client,
  request : SecurityGetServiceCredentialsRequest,
) -> EsResponse[SecurityGetServiceCredentialsResponse] {
  let params : Map[String, String] = Map([])
  params["namespace"] = request.namespace_
  params["service"] = request.service
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/service/{namespace}/{service}/credential", [
        "namespace", "service",
      ]),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetSettingsQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetSettingsQuery with fn to_json(
  self : SecurityGetSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetSettingsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn SecurityGetSettingsQuery::new(
  master_timeout? : String,
) -> SecurityGetSettingsQuery {
  { master_timeout, }
}

///|
pub fn SecurityGetSettingsQuery::to_pairs(
  self : SecurityGetSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityGetSettingsBody = Json

///|
pub(all) struct SecurityGetSettingsResponse {
  security : Json
  security_profile : Json
  security_tokens : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetSettingsResponse with fn to_json(
  self : SecurityGetSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["security"] = self.security.to_json()
  obj["security-profile"] = self.security_profile.to_json()
  obj["security-tokens"] = self.security_tokens.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetSettingsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGetSettingsResponse: expected object"),
    )
  }
  {
    security: @json.from_json(
      obj.get("security").unwrap_or(Json::null()),
      path=path.add_key("security"),
    ),
    security_profile: @json.from_json(
      obj.get("security-profile").unwrap_or(Json::null()),
      path=path.add_key("security-profile"),
    ),
    security_tokens: @json.from_json(
      obj.get("security-tokens").unwrap_or(Json::null()),
      path=path.add_key("security-tokens"),
    ),
  }
}

///|
pub(all) struct SecurityGetSettingsRequest {
  query : SecurityGetSettingsQuery
  body : SecurityGetSettingsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetSettingsRequest::new(
  query? : SecurityGetSettingsQuery = SecurityGetSettingsQuery::new(),
  body? : SecurityGetSettingsBody,
) -> SecurityGetSettingsRequest {
  { query, body }
}

///|
pub async fn Client::security_get_settings(
  self : Client,
  request : SecurityGetSettingsRequest,
) -> EsResponse[SecurityGetSettingsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/settings", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct SecurityGetStatsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetStatsQuery with fn to_json(
  _self : SecurityGetStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetStatsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityGetStatsQuery: expected object"))
  }
  SecurityGetStatsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetStatsQuery::new() -> SecurityGetStatsQuery {
  SecurityGetStatsQuery::{  }
}

///|
pub fn SecurityGetStatsQuery::to_pairs(
  _self : SecurityGetStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecurityGetStatsBody = Json

///|
pub(all) struct SecurityGetStatsResponse {
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetStatsResponse with fn to_json(
  self : SecurityGetStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetStatsResponse: expected object"))
  }
  {
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SecurityGetStatsRequest {
  query : SecurityGetStatsQuery
  body : SecurityGetStatsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetStatsRequest::new(
  query? : SecurityGetStatsQuery = SecurityGetStatsQuery::new(),
  body? : SecurityGetStatsBody,
) -> SecurityGetStatsRequest {
  { query, body }
}

///|
pub async fn Client::security_get_stats(
  self : Client,
  request : SecurityGetStatsRequest,
) -> EsResponse[SecurityGetStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/stats", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct SecurityGetTokenQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetTokenQuery with fn to_json(
  _self : SecurityGetTokenQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetTokenQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityGetTokenQuery: expected object"))
  }
  SecurityGetTokenQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetTokenQuery::new() -> SecurityGetTokenQuery {
  SecurityGetTokenQuery::{  }
}

///|
pub fn SecurityGetTokenQuery::to_pairs(
  _self : SecurityGetTokenQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityGetTokenBody {
  grant_type : Json?
  scope : String?
  password : Json?
  kerberos_ticket : String?
  refresh_token : String?
  username : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetTokenBody with fn to_json(
  self : SecurityGetTokenBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.grant_type {
    Some(value) => obj["grant_type"] = value.to_json()
    None => ()
  }
  match self.scope {
    Some(value) => obj["scope"] = value.to_json()
    None => ()
  }
  match self.password {
    Some(value) => obj["password"] = value.to_json()
    None => ()
  }
  match self.kerberos_ticket {
    Some(value) => obj["kerberos_ticket"] = value.to_json()
    None => ()
  }
  match self.refresh_token {
    Some(value) => obj["refresh_token"] = value.to_json()
    None => ()
  }
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetTokenBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetTokenBody: expected object"))
  }
  {
    grant_type: match obj.get("grant_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grant_type")))
    },
    scope: match obj.get("scope") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scope")))
    },
    password: match obj.get("password") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("password")))
    },
    kerberos_ticket: match obj.get("kerberos_ticket") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("kerberos_ticket")))
    },
    refresh_token: match obj.get("refresh_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("refresh_token")))
    },
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
  }
}

///|
pub fn SecurityGetTokenBody::new(
  grant_type? : Json,
  scope? : String,
  password? : Json,
  kerberos_ticket? : String,
  refresh_token? : String,
  username? : Json,
) -> SecurityGetTokenBody {
  { grant_type, scope, password, kerberos_ticket, refresh_token, username }
}

///|
pub(all) struct SecurityGetTokenResponse {
  access_token : String
  expires_in : Int
  scope : String?
  type_ : String
  refresh_token : String?
  kerberos_authentication_response_token : String?
  authentication : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetTokenResponse with fn to_json(
  self : SecurityGetTokenResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["access_token"] = self.access_token.to_json()
  obj["expires_in"] = self.expires_in.to_json()
  match self.scope {
    Some(value) => obj["scope"] = value.to_json()
    None => ()
  }
  obj["type"] = self.type_.to_json()
  match self.refresh_token {
    Some(value) => obj["refresh_token"] = value.to_json()
    None => ()
  }
  match self.kerberos_authentication_response_token {
    Some(value) =>
      obj["kerberos_authentication_response_token"] = value.to_json()
    None => ()
  }
  obj["authentication"] = self.authentication.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetTokenResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetTokenResponse: expected object"))
  }
  {
    access_token: @json.from_json(
      obj.get("access_token").unwrap_or(Json::null()),
      path=path.add_key("access_token"),
    ),
    expires_in: @json.from_json(
      obj.get("expires_in").unwrap_or(Json::null()),
      path=path.add_key("expires_in"),
    ),
    scope: match obj.get("scope") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scope")))
    },
    type_: @json.from_json(
      obj.get("type").unwrap_or(Json::null()),
      path=path.add_key("type"),
    ),
    refresh_token: match obj.get("refresh_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("refresh_token")))
    },
    kerberos_authentication_response_token: match
      obj.get("kerberos_authentication_response_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("kerberos_authentication_response_token"),
          ),
        )
    },
    authentication: @json.from_json(
      obj.get("authentication").unwrap_or(Json::null()),
      path=path.add_key("authentication"),
    ),
  }
}

///|
pub(all) struct SecurityGetTokenRequest {
  query : SecurityGetTokenQuery
  body : SecurityGetTokenBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetTokenRequest::new(
  body : SecurityGetTokenBody,
  query? : SecurityGetTokenQuery = SecurityGetTokenQuery::new(),
) -> SecurityGetTokenRequest {
  { query, body }
}

///|
pub async fn Client::security_get_token(
  self : Client,
  request : SecurityGetTokenRequest,
) -> EsResponse[SecurityGetTokenResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/oauth2/token", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityGetUserQuery {
  with_profile_uid : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetUserQuery with fn to_json(
  self : SecurityGetUserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.with_profile_uid {
    Some(value) => obj["with_profile_uid"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetUserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGetUserQuery: expected object"))
  }
  {
    with_profile_uid: match obj.get("with_profile_uid") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_profile_uid")))
    },
  }
}

///|
pub fn SecurityGetUserQuery::new(
  with_profile_uid? : Bool,
) -> SecurityGetUserQuery {
  { with_profile_uid, }
}

///|
pub fn SecurityGetUserQuery::to_pairs(
  self : SecurityGetUserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.with_profile_uid {
    Some(value) => push_query_json(pairs, "with_profile_uid", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityGetUserResponse = Json

///|
pub(all) struct SecurityGetUserRequest {
  username : String?
  query : SecurityGetUserQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetUserRequest::new(
  username? : String,
  query? : SecurityGetUserQuery = SecurityGetUserQuery::new(),
) -> SecurityGetUserRequest {
  { username, query }
}

///|
pub async fn Client::security_get_user(
  self : Client,
  request : SecurityGetUserRequest,
) -> EsResponse[SecurityGetUserResponse] {
  let params : Map[String, String] = Map([])
  match request.username {
    Some(value) => params["username"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/user/{username}", ["username"]),
      PathVariant::new("/_security/user", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetUserPrivilegesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetUserPrivilegesQuery with fn to_json(
  _self : SecurityGetUserPrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityGetUserPrivilegesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityGetUserPrivilegesQuery: expected object"),
    )
  }
  SecurityGetUserPrivilegesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityGetUserPrivilegesQuery::new() -> SecurityGetUserPrivilegesQuery {
  SecurityGetUserPrivilegesQuery::{  }
}

///|
pub fn SecurityGetUserPrivilegesQuery::to_pairs(
  _self : SecurityGetUserPrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityGetUserPrivilegesResponse {
  applications : Array[Json]
  cluster : Array[String]
  remote_cluster : Array[Json]?
  global : Array[Json]
  indices : Array[Json]
  remote_indices : Array[Json]?
  run_as : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetUserPrivilegesResponse with fn to_json(
  self : SecurityGetUserPrivilegesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["applications"] = self.applications.to_json()
  obj["cluster"] = self.cluster.to_json()
  match self.remote_cluster {
    Some(value) => obj["remote_cluster"] = value.to_json()
    None => ()
  }
  obj["global"] = self.global.to_json()
  obj["indices"] = self.indices.to_json()
  match self.remote_indices {
    Some(value) => obj["remote_indices"] = value.to_json()
    None => ()
  }
  obj["run_as"] = self.run_as.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetUserPrivilegesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGetUserPrivilegesResponse: expected object"),
    )
  }
  {
    applications: @json.from_json(
      obj.get("applications").unwrap_or(Json::null()),
      path=path.add_key("applications"),
    ),
    cluster: @json.from_json(
      obj.get("cluster").unwrap_or(Json::null()),
      path=path.add_key("cluster"),
    ),
    remote_cluster: match obj.get("remote_cluster") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("remote_cluster")))
    },
    global: @json.from_json(
      obj.get("global").unwrap_or(Json::null()),
      path=path.add_key("global"),
    ),
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
    remote_indices: match obj.get("remote_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("remote_indices")))
    },
    run_as: @json.from_json(
      obj.get("run_as").unwrap_or(Json::null()),
      path=path.add_key("run_as"),
    ),
  }
}

///|
pub(all) struct SecurityGetUserPrivilegesRequest {
  query : SecurityGetUserPrivilegesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetUserPrivilegesRequest::new(
  query? : SecurityGetUserPrivilegesQuery = SecurityGetUserPrivilegesQuery::new(),
) -> SecurityGetUserPrivilegesRequest {
  { query, }
}

///|
pub async fn Client::security_get_user_privileges(
  self : Client,
  request : SecurityGetUserPrivilegesRequest,
) -> EsResponse[SecurityGetUserPrivilegesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/user/_privileges", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGetUserProfileQuery {
  data : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetUserProfileQuery with fn to_json(
  self : SecurityGetUserProfileQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.data {
    Some(value) => obj["data"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetUserProfileQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGetUserProfileQuery: expected object"),
    )
  }
  {
    data: match obj.get("data") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("data")))
    },
  }
}

///|
pub fn SecurityGetUserProfileQuery::new(
  data? : Json,
) -> SecurityGetUserProfileQuery {
  { data, }
}

///|
pub fn SecurityGetUserProfileQuery::to_pairs(
  self : SecurityGetUserProfileQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.data {
    Some(value) => push_query_json(pairs, "data", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityGetUserProfileResponse {
  profiles : Array[Json]
  errors : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGetUserProfileResponse with fn to_json(
  self : SecurityGetUserProfileResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["profiles"] = self.profiles.to_json()
  match self.errors {
    Some(value) => obj["errors"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGetUserProfileResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGetUserProfileResponse: expected object"),
    )
  }
  {
    profiles: @json.from_json(
      obj.get("profiles").unwrap_or(Json::null()),
      path=path.add_key("profiles"),
    ),
    errors: match obj.get("errors") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("errors")))
    },
  }
}

///|
pub(all) struct SecurityGetUserProfileRequest {
  uid : String
  query : SecurityGetUserProfileQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGetUserProfileRequest::new(
  uid : String,
  query? : SecurityGetUserProfileQuery = SecurityGetUserProfileQuery::new(),
) -> SecurityGetUserProfileRequest {
  { uid, query }
}

///|
pub async fn Client::security_get_user_profile(
  self : Client,
  request : SecurityGetUserProfileRequest,
) -> EsResponse[SecurityGetUserProfileResponse] {
  let params : Map[String, String] = Map([])
  params["uid"] = request.uid
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/{uid}", ["uid"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SecurityGrantApiKeyQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGrantApiKeyQuery with fn to_json(
  self : SecurityGrantApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGrantApiKeyQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGrantApiKeyQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityGrantApiKeyQuery::new(
  refresh? : String,
) -> SecurityGrantApiKeyQuery {
  { refresh, }
}

///|
pub fn SecurityGrantApiKeyQuery::to_pairs(
  self : SecurityGrantApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityGrantApiKeyBody {
  api_key : Json
  grant_type : Json
  access_token : String?
  username : Json?
  password : Json?
  run_as : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGrantApiKeyBody with fn to_json(
  self : SecurityGrantApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_key"] = self.api_key.to_json()
  obj["grant_type"] = self.grant_type.to_json()
  match self.access_token {
    Some(value) => obj["access_token"] = value.to_json()
    None => ()
  }
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  match self.password {
    Some(value) => obj["password"] = value.to_json()
    None => ()
  }
  match self.run_as {
    Some(value) => obj["run_as"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGrantApiKeyBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityGrantApiKeyBody: expected object"))
  }
  {
    api_key: @json.from_json(
      obj.get("api_key").unwrap_or(Json::null()),
      path=path.add_key("api_key"),
    ),
    grant_type: @json.from_json(
      obj.get("grant_type").unwrap_or(Json::null()),
      path=path.add_key("grant_type"),
    ),
    access_token: match obj.get("access_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("access_token")))
    },
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
    password: match obj.get("password") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("password")))
    },
    run_as: match obj.get("run_as") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("run_as")))
    },
  }
}

///|
pub fn SecurityGrantApiKeyBody::new(
  api_key : Json,
  grant_type : Json,
  access_token? : String,
  username? : Json,
  password? : Json,
  run_as? : Json,
) -> SecurityGrantApiKeyBody {
  { api_key, grant_type, access_token, username, password, run_as }
}

///|
pub(all) struct SecurityGrantApiKeyResponse {
  api_key : String
  id : Json
  name : Json
  expiration : Json?
  encoded : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityGrantApiKeyResponse with fn to_json(
  self : SecurityGrantApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["api_key"] = self.api_key.to_json()
  obj["id"] = self.id.to_json()
  obj["name"] = self.name.to_json()
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  obj["encoded"] = self.encoded.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityGrantApiKeyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityGrantApiKeyResponse: expected object"),
    )
  }
  {
    api_key: @json.from_json(
      obj.get("api_key").unwrap_or(Json::null()),
      path=path.add_key("api_key"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    name: @json.from_json(
      obj.get("name").unwrap_or(Json::null()),
      path=path.add_key("name"),
    ),
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    encoded: @json.from_json(
      obj.get("encoded").unwrap_or(Json::null()),
      path=path.add_key("encoded"),
    ),
  }
}

///|
pub(all) struct SecurityGrantApiKeyRequest {
  query : SecurityGrantApiKeyQuery
  body : SecurityGrantApiKeyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityGrantApiKeyRequest::new(
  body : SecurityGrantApiKeyBody,
  query? : SecurityGrantApiKeyQuery = SecurityGrantApiKeyQuery::new(),
) -> SecurityGrantApiKeyRequest {
  { query, body }
}

///|
pub async fn Client::security_grant_api_key(
  self : Client,
  request : SecurityGrantApiKeyRequest,
) -> EsResponse[SecurityGrantApiKeyResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/api_key/grant", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityHasPrivilegesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityHasPrivilegesQuery with fn to_json(
  _self : SecurityHasPrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityHasPrivilegesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityHasPrivilegesQuery: expected object"))
  }
  SecurityHasPrivilegesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityHasPrivilegesQuery::new() -> SecurityHasPrivilegesQuery {
  SecurityHasPrivilegesQuery::{  }
}

///|
pub fn SecurityHasPrivilegesQuery::to_pairs(
  _self : SecurityHasPrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityHasPrivilegesBody {
  application : Array[Json]?
  cluster : Array[Json]?
  index : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityHasPrivilegesBody with fn to_json(
  self : SecurityHasPrivilegesBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.application {
    Some(value) => obj["application"] = value.to_json()
    None => ()
  }
  match self.cluster {
    Some(value) => obj["cluster"] = value.to_json()
    None => ()
  }
  match self.index {
    Some(value) => obj["index"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityHasPrivilegesBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityHasPrivilegesBody: expected object"))
  }
  {
    application: match obj.get("application") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("application")))
    },
    cluster: match obj.get("cluster") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cluster")))
    },
    index: match obj.get("index") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("index")))
    },
  }
}

///|
pub fn SecurityHasPrivilegesBody::new(
  application? : Array[Json],
  cluster? : Array[Json],
  index? : Array[Json],
) -> SecurityHasPrivilegesBody {
  { application, cluster, index }
}

///|
pub(all) struct SecurityHasPrivilegesResponse {
  application : Json
  cluster : Map[String, Json]
  has_all_requested : Bool
  index : Map[String, Json]
  username : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityHasPrivilegesResponse with fn to_json(
  self : SecurityHasPrivilegesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["application"] = self.application.to_json()
  obj["cluster"] = self.cluster.to_json()
  obj["has_all_requested"] = self.has_all_requested.to_json()
  obj["index"] = self.index.to_json()
  obj["username"] = self.username.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityHasPrivilegesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityHasPrivilegesResponse: expected object"),
    )
  }
  {
    application: @json.from_json(
      obj.get("application").unwrap_or(Json::null()),
      path=path.add_key("application"),
    ),
    cluster: @json.from_json(
      obj.get("cluster").unwrap_or(Json::null()),
      path=path.add_key("cluster"),
    ),
    has_all_requested: @json.from_json(
      obj.get("has_all_requested").unwrap_or(Json::null()),
      path=path.add_key("has_all_requested"),
    ),
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    username: @json.from_json(
      obj.get("username").unwrap_or(Json::null()),
      path=path.add_key("username"),
    ),
  }
}

///|
pub(all) struct SecurityHasPrivilegesRequest {
  user : String?
  query : SecurityHasPrivilegesQuery
  body : SecurityHasPrivilegesBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityHasPrivilegesRequest::new(
  body : SecurityHasPrivilegesBody,
  user? : String,
  query? : SecurityHasPrivilegesQuery = SecurityHasPrivilegesQuery::new(),
) -> SecurityHasPrivilegesRequest {
  { user, query, body }
}

///|
pub async fn Client::security_has_privileges(
  self : Client,
  request : SecurityHasPrivilegesRequest,
) -> EsResponse[SecurityHasPrivilegesResponse] {
  let params : Map[String, String] = Map([])
  match request.user {
    Some(value) => params["user"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_security/user/{user}/_has_privileges", ["user"]),
      PathVariant::new("/_security/user/_has_privileges", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityHasPrivilegesUserProfileQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityHasPrivilegesUserProfileQuery with fn to_json(
  _self : SecurityHasPrivilegesUserProfileQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityHasPrivilegesUserProfileQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityHasPrivilegesUserProfileQuery: expected object"),
    )
  }
  SecurityHasPrivilegesUserProfileQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityHasPrivilegesUserProfileQuery::new() -> SecurityHasPrivilegesUserProfileQuery {
  SecurityHasPrivilegesUserProfileQuery::{  }
}

///|
pub fn SecurityHasPrivilegesUserProfileQuery::to_pairs(
  _self : SecurityHasPrivilegesUserProfileQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityHasPrivilegesUserProfileBody {
  uids : Array[Json]
  privileges : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityHasPrivilegesUserProfileBody with fn to_json(
  self : SecurityHasPrivilegesUserProfileBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["uids"] = self.uids.to_json()
  obj["privileges"] = self.privileges.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityHasPrivilegesUserProfileBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityHasPrivilegesUserProfileBody: expected object"),
    )
  }
  {
    uids: @json.from_json(
      obj.get("uids").unwrap_or(Json::null()),
      path=path.add_key("uids"),
    ),
    privileges: @json.from_json(
      obj.get("privileges").unwrap_or(Json::null()),
      path=path.add_key("privileges"),
    ),
  }
}

///|
pub fn SecurityHasPrivilegesUserProfileBody::new(
  uids : Array[Json],
  privileges : Json,
) -> SecurityHasPrivilegesUserProfileBody {
  { uids, privileges }
}

///|
pub(all) struct SecurityHasPrivilegesUserProfileResponse {
  has_privilege_uids : Array[Json]
  errors : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityHasPrivilegesUserProfileResponse with fn to_json(
  self : SecurityHasPrivilegesUserProfileResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["has_privilege_uids"] = self.has_privilege_uids.to_json()
  match self.errors {
    Some(value) => obj["errors"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityHasPrivilegesUserProfileResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityHasPrivilegesUserProfileResponse: expected object"),
    )
  }
  {
    has_privilege_uids: @json.from_json(
      obj.get("has_privilege_uids").unwrap_or(Json::null()),
      path=path.add_key("has_privilege_uids"),
    ),
    errors: match obj.get("errors") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("errors")))
    },
  }
}

///|
pub(all) struct SecurityHasPrivilegesUserProfileRequest {
  query : SecurityHasPrivilegesUserProfileQuery
  body : SecurityHasPrivilegesUserProfileBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityHasPrivilegesUserProfileRequest::new(
  body : SecurityHasPrivilegesUserProfileBody,
  query? : SecurityHasPrivilegesUserProfileQuery = SecurityHasPrivilegesUserProfileQuery::new(),
) -> SecurityHasPrivilegesUserProfileRequest {
  { query, body }
}

///|
pub async fn Client::security_has_privileges_user_profile(
  self : Client,
  request : SecurityHasPrivilegesUserProfileRequest,
) -> EsResponse[SecurityHasPrivilegesUserProfileResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/_has_privileges", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityInvalidateApiKeyQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityInvalidateApiKeyQuery with fn to_json(
  _self : SecurityInvalidateApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityInvalidateApiKeyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityInvalidateApiKeyQuery: expected object"),
    )
  }
  SecurityInvalidateApiKeyQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityInvalidateApiKeyQuery::new() -> SecurityInvalidateApiKeyQuery {
  SecurityInvalidateApiKeyQuery::{  }
}

///|
pub fn SecurityInvalidateApiKeyQuery::to_pairs(
  _self : SecurityInvalidateApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityInvalidateApiKeyBody {
  id : Json?
  ids : Array[Json]?
  name : Json?
  owner : Bool?
  realm_name : String?
  username : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityInvalidateApiKeyBody with fn to_json(
  self : SecurityInvalidateApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.ids {
    Some(value) => obj["ids"] = value.to_json()
    None => ()
  }
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.owner {
    Some(value) => obj["owner"] = value.to_json()
    None => ()
  }
  match self.realm_name {
    Some(value) => obj["realm_name"] = value.to_json()
    None => ()
  }
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityInvalidateApiKeyBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityInvalidateApiKeyBody: expected object"),
    )
  }
  {
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    ids: match obj.get("ids") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("ids")))
    },
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    owner: match obj.get("owner") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("owner")))
    },
    realm_name: match obj.get("realm_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("realm_name")))
    },
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
  }
}

///|
pub fn SecurityInvalidateApiKeyBody::new(
  id? : Json,
  ids? : Array[Json],
  name? : Json,
  owner? : Bool,
  realm_name? : String,
  username? : Json,
) -> SecurityInvalidateApiKeyBody {
  { id, ids, name, owner, realm_name, username }
}

///|
pub(all) struct SecurityInvalidateApiKeyResponse {
  error_count : Int
  error_details : Array[Json]?
  invalidated_api_keys : Array[String]
  previously_invalidated_api_keys : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityInvalidateApiKeyResponse with fn to_json(
  self : SecurityInvalidateApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["error_count"] = self.error_count.to_json()
  match self.error_details {
    Some(value) => obj["error_details"] = value.to_json()
    None => ()
  }
  obj["invalidated_api_keys"] = self.invalidated_api_keys.to_json()
  obj["previously_invalidated_api_keys"] = self.previously_invalidated_api_keys.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityInvalidateApiKeyResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityInvalidateApiKeyResponse: expected object"),
    )
  }
  {
    error_count: @json.from_json(
      obj.get("error_count").unwrap_or(Json::null()),
      path=path.add_key("error_count"),
    ),
    error_details: match obj.get("error_details") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("error_details")))
    },
    invalidated_api_keys: @json.from_json(
      obj.get("invalidated_api_keys").unwrap_or(Json::null()),
      path=path.add_key("invalidated_api_keys"),
    ),
    previously_invalidated_api_keys: @json.from_json(
      obj.get("previously_invalidated_api_keys").unwrap_or(Json::null()),
      path=path.add_key("previously_invalidated_api_keys"),
    ),
  }
}

///|
pub(all) struct SecurityInvalidateApiKeyRequest {
  query : SecurityInvalidateApiKeyQuery
  body : SecurityInvalidateApiKeyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityInvalidateApiKeyRequest::new(
  body : SecurityInvalidateApiKeyBody,
  query? : SecurityInvalidateApiKeyQuery = SecurityInvalidateApiKeyQuery::new(),
) -> SecurityInvalidateApiKeyRequest {
  { query, body }
}

///|
pub async fn Client::security_invalidate_api_key(
  self : Client,
  request : SecurityInvalidateApiKeyRequest,
) -> EsResponse[SecurityInvalidateApiKeyResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/api_key", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct SecurityInvalidateTokenQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityInvalidateTokenQuery with fn to_json(
  _self : SecurityInvalidateTokenQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityInvalidateTokenQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityInvalidateTokenQuery: expected object"),
    )
  }
  SecurityInvalidateTokenQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityInvalidateTokenQuery::new() -> SecurityInvalidateTokenQuery {
  SecurityInvalidateTokenQuery::{  }
}

///|
pub fn SecurityInvalidateTokenQuery::to_pairs(
  _self : SecurityInvalidateTokenQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityInvalidateTokenBody {
  token : String?
  refresh_token : String?
  realm_name : Json?
  username : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityInvalidateTokenBody with fn to_json(
  self : SecurityInvalidateTokenBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.token {
    Some(value) => obj["token"] = value.to_json()
    None => ()
  }
  match self.refresh_token {
    Some(value) => obj["refresh_token"] = value.to_json()
    None => ()
  }
  match self.realm_name {
    Some(value) => obj["realm_name"] = value.to_json()
    None => ()
  }
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityInvalidateTokenBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityInvalidateTokenBody: expected object"),
    )
  }
  {
    token: match obj.get("token") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("token")))
    },
    refresh_token: match obj.get("refresh_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("refresh_token")))
    },
    realm_name: match obj.get("realm_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("realm_name")))
    },
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
  }
}

///|
pub fn SecurityInvalidateTokenBody::new(
  token? : String,
  refresh_token? : String,
  realm_name? : Json,
  username? : Json,
) -> SecurityInvalidateTokenBody {
  { token, refresh_token, realm_name, username }
}

///|
pub(all) struct SecurityInvalidateTokenResponse {
  error_count : Int
  error_details : Array[Json]?
  invalidated_tokens : Int
  previously_invalidated_tokens : Int
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityInvalidateTokenResponse with fn to_json(
  self : SecurityInvalidateTokenResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["error_count"] = self.error_count.to_json()
  match self.error_details {
    Some(value) => obj["error_details"] = value.to_json()
    None => ()
  }
  obj["invalidated_tokens"] = self.invalidated_tokens.to_json()
  obj["previously_invalidated_tokens"] = self.previously_invalidated_tokens.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityInvalidateTokenResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityInvalidateTokenResponse: expected object"),
    )
  }
  {
    error_count: @json.from_json(
      obj.get("error_count").unwrap_or(Json::null()),
      path=path.add_key("error_count"),
    ),
    error_details: match obj.get("error_details") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("error_details")))
    },
    invalidated_tokens: @json.from_json(
      obj.get("invalidated_tokens").unwrap_or(Json::null()),
      path=path.add_key("invalidated_tokens"),
    ),
    previously_invalidated_tokens: @json.from_json(
      obj.get("previously_invalidated_tokens").unwrap_or(Json::null()),
      path=path.add_key("previously_invalidated_tokens"),
    ),
  }
}

///|
pub(all) struct SecurityInvalidateTokenRequest {
  query : SecurityInvalidateTokenQuery
  body : SecurityInvalidateTokenBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityInvalidateTokenRequest::new(
  body : SecurityInvalidateTokenBody,
  query? : SecurityInvalidateTokenQuery = SecurityInvalidateTokenQuery::new(),
) -> SecurityInvalidateTokenRequest {
  { query, body }
}

///|
pub async fn Client::security_invalidate_token(
  self : Client,
  request : SecurityInvalidateTokenRequest,
) -> EsResponse[SecurityInvalidateTokenResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/oauth2/token", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct SecurityOidcAuthenticateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcAuthenticateQuery with fn to_json(
  _self : SecurityOidcAuthenticateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityOidcAuthenticateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityOidcAuthenticateQuery: expected object"),
    )
  }
  SecurityOidcAuthenticateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityOidcAuthenticateQuery::new() -> SecurityOidcAuthenticateQuery {
  SecurityOidcAuthenticateQuery::{  }
}

///|
pub fn SecurityOidcAuthenticateQuery::to_pairs(
  _self : SecurityOidcAuthenticateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityOidcAuthenticateBody {
  nonce : String
  realm : String?
  redirect_uri : String
  state : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcAuthenticateBody with fn to_json(
  self : SecurityOidcAuthenticateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nonce"] = self.nonce.to_json()
  match self.realm {
    Some(value) => obj["realm"] = value.to_json()
    None => ()
  }
  obj["redirect_uri"] = self.redirect_uri.to_json()
  obj["state"] = self.state.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityOidcAuthenticateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityOidcAuthenticateBody: expected object"),
    )
  }
  {
    nonce: @json.from_json(
      obj.get("nonce").unwrap_or(Json::null()),
      path=path.add_key("nonce"),
    ),
    realm: match obj.get("realm") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realm")))
    },
    redirect_uri: @json.from_json(
      obj.get("redirect_uri").unwrap_or(Json::null()),
      path=path.add_key("redirect_uri"),
    ),
    state: @json.from_json(
      obj.get("state").unwrap_or(Json::null()),
      path=path.add_key("state"),
    ),
  }
}

///|
pub fn SecurityOidcAuthenticateBody::new(
  nonce : String,
  redirect_uri : String,
  state : String,
  realm? : String,
) -> SecurityOidcAuthenticateBody {
  { nonce, realm, redirect_uri, state }
}

///|
pub(all) struct SecurityOidcAuthenticateResponse {
  access_token : String
  expires_in : Int
  refresh_token : String
  type_ : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcAuthenticateResponse with fn to_json(
  self : SecurityOidcAuthenticateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["access_token"] = self.access_token.to_json()
  obj["expires_in"] = self.expires_in.to_json()
  obj["refresh_token"] = self.refresh_token.to_json()
  obj["type"] = self.type_.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityOidcAuthenticateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityOidcAuthenticateResponse: expected object"),
    )
  }
  {
    access_token: @json.from_json(
      obj.get("access_token").unwrap_or(Json::null()),
      path=path.add_key("access_token"),
    ),
    expires_in: @json.from_json(
      obj.get("expires_in").unwrap_or(Json::null()),
      path=path.add_key("expires_in"),
    ),
    refresh_token: @json.from_json(
      obj.get("refresh_token").unwrap_or(Json::null()),
      path=path.add_key("refresh_token"),
    ),
    type_: @json.from_json(
      obj.get("type").unwrap_or(Json::null()),
      path=path.add_key("type"),
    ),
  }
}

///|
pub(all) struct SecurityOidcAuthenticateRequest {
  query : SecurityOidcAuthenticateQuery
  body : SecurityOidcAuthenticateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityOidcAuthenticateRequest::new(
  body : SecurityOidcAuthenticateBody,
  query? : SecurityOidcAuthenticateQuery = SecurityOidcAuthenticateQuery::new(),
) -> SecurityOidcAuthenticateRequest {
  { query, body }
}

///|
pub async fn Client::security_oidc_authenticate(
  self : Client,
  request : SecurityOidcAuthenticateRequest,
) -> EsResponse[SecurityOidcAuthenticateResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/oidc/authenticate", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityOidcLogoutQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcLogoutQuery with fn to_json(
  _self : SecurityOidcLogoutQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityOidcLogoutQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityOidcLogoutQuery: expected object"))
  }
  SecurityOidcLogoutQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityOidcLogoutQuery::new() -> SecurityOidcLogoutQuery {
  SecurityOidcLogoutQuery::{  }
}

///|
pub fn SecurityOidcLogoutQuery::to_pairs(
  _self : SecurityOidcLogoutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityOidcLogoutBody {
  token : String
  refresh_token : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcLogoutBody with fn to_json(
  self : SecurityOidcLogoutBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["token"] = self.token.to_json()
  match self.refresh_token {
    Some(value) => obj["refresh_token"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityOidcLogoutBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityOidcLogoutBody: expected object"))
  }
  {
    token: @json.from_json(
      obj.get("token").unwrap_or(Json::null()),
      path=path.add_key("token"),
    ),
    refresh_token: match obj.get("refresh_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("refresh_token")))
    },
  }
}

///|
pub fn SecurityOidcLogoutBody::new(
  token : String,
  refresh_token? : String,
) -> SecurityOidcLogoutBody {
  { token, refresh_token }
}

///|
pub(all) struct SecurityOidcLogoutResponse {
  redirect : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcLogoutResponse with fn to_json(
  self : SecurityOidcLogoutResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["redirect"] = self.redirect.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityOidcLogoutResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityOidcLogoutResponse: expected object"))
  }
  {
    redirect: @json.from_json(
      obj.get("redirect").unwrap_or(Json::null()),
      path=path.add_key("redirect"),
    ),
  }
}

///|
pub(all) struct SecurityOidcLogoutRequest {
  query : SecurityOidcLogoutQuery
  body : SecurityOidcLogoutBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityOidcLogoutRequest::new(
  body : SecurityOidcLogoutBody,
  query? : SecurityOidcLogoutQuery = SecurityOidcLogoutQuery::new(),
) -> SecurityOidcLogoutRequest {
  { query, body }
}

///|
pub async fn Client::security_oidc_logout(
  self : Client,
  request : SecurityOidcLogoutRequest,
) -> EsResponse[SecurityOidcLogoutResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/oidc/logout", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityOidcPrepareAuthenticationQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcPrepareAuthenticationQuery with fn to_json(
  _self : SecurityOidcPrepareAuthenticationQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityOidcPrepareAuthenticationQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityOidcPrepareAuthenticationQuery: expected object"),
    )
  }
  SecurityOidcPrepareAuthenticationQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityOidcPrepareAuthenticationQuery::new() -> SecurityOidcPrepareAuthenticationQuery {
  SecurityOidcPrepareAuthenticationQuery::{  }
}

///|
pub fn SecurityOidcPrepareAuthenticationQuery::to_pairs(
  _self : SecurityOidcPrepareAuthenticationQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityOidcPrepareAuthenticationBody {
  iss : String?
  login_hint : String?
  nonce : String?
  realm : String?
  state : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcPrepareAuthenticationBody with fn to_json(
  self : SecurityOidcPrepareAuthenticationBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.iss {
    Some(value) => obj["iss"] = value.to_json()
    None => ()
  }
  match self.login_hint {
    Some(value) => obj["login_hint"] = value.to_json()
    None => ()
  }
  match self.nonce {
    Some(value) => obj["nonce"] = value.to_json()
    None => ()
  }
  match self.realm {
    Some(value) => obj["realm"] = value.to_json()
    None => ()
  }
  match self.state {
    Some(value) => obj["state"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityOidcPrepareAuthenticationBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityOidcPrepareAuthenticationBody: expected object"),
    )
  }
  {
    iss: match obj.get("iss") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("iss")))
    },
    login_hint: match obj.get("login_hint") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("login_hint")))
    },
    nonce: match obj.get("nonce") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("nonce")))
    },
    realm: match obj.get("realm") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realm")))
    },
    state: match obj.get("state") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("state")))
    },
  }
}

///|
pub fn SecurityOidcPrepareAuthenticationBody::new(
  iss? : String,
  login_hint? : String,
  nonce? : String,
  realm? : String,
  state? : String,
) -> SecurityOidcPrepareAuthenticationBody {
  { iss, login_hint, nonce, realm, state }
}

///|
pub(all) struct SecurityOidcPrepareAuthenticationResponse {
  nonce : String
  realm : String
  redirect : String
  state : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityOidcPrepareAuthenticationResponse with fn to_json(
  self : SecurityOidcPrepareAuthenticationResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nonce"] = self.nonce.to_json()
  obj["realm"] = self.realm.to_json()
  obj["redirect"] = self.redirect.to_json()
  obj["state"] = self.state.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityOidcPrepareAuthenticationResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityOidcPrepareAuthenticationResponse: expected object"),
    )
  }
  {
    nonce: @json.from_json(
      obj.get("nonce").unwrap_or(Json::null()),
      path=path.add_key("nonce"),
    ),
    realm: @json.from_json(
      obj.get("realm").unwrap_or(Json::null()),
      path=path.add_key("realm"),
    ),
    redirect: @json.from_json(
      obj.get("redirect").unwrap_or(Json::null()),
      path=path.add_key("redirect"),
    ),
    state: @json.from_json(
      obj.get("state").unwrap_or(Json::null()),
      path=path.add_key("state"),
    ),
  }
}

///|
pub(all) struct SecurityOidcPrepareAuthenticationRequest {
  query : SecurityOidcPrepareAuthenticationQuery
  body : SecurityOidcPrepareAuthenticationBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityOidcPrepareAuthenticationRequest::new(
  body : SecurityOidcPrepareAuthenticationBody,
  query? : SecurityOidcPrepareAuthenticationQuery = SecurityOidcPrepareAuthenticationQuery::new(),
) -> SecurityOidcPrepareAuthenticationRequest {
  { query, body }
}

///|
pub async fn Client::security_oidc_prepare_authentication(
  self : Client,
  request : SecurityOidcPrepareAuthenticationRequest,
) -> EsResponse[SecurityOidcPrepareAuthenticationResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/oidc/prepare", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityPutPrivilegesQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutPrivilegesQuery with fn to_json(
  self : SecurityPutPrivilegesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutPrivilegesQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutPrivilegesQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityPutPrivilegesQuery::new(
  refresh? : String,
) -> SecurityPutPrivilegesQuery {
  { refresh, }
}

///|
pub fn SecurityPutPrivilegesQuery::to_pairs(
  self : SecurityPutPrivilegesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SecurityPutPrivilegesBody = Json

///|
pub type SecurityPutPrivilegesResponse = Json

///|
pub(all) struct SecurityPutPrivilegesRequest {
  query : SecurityPutPrivilegesQuery
  body : SecurityPutPrivilegesBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityPutPrivilegesRequest::new(
  body : SecurityPutPrivilegesBody,
  query? : SecurityPutPrivilegesQuery = SecurityPutPrivilegesQuery::new(),
) -> SecurityPutPrivilegesRequest {
  { query, body }
}

///|
pub async fn Client::security_put_privileges(
  self : Client,
  request : SecurityPutPrivilegesRequest,
) -> EsResponse[SecurityPutPrivilegesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/privilege", [])], params)
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityPutRoleQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutRoleQuery with fn to_json(
  self : SecurityPutRoleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutRoleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutRoleQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityPutRoleQuery::new(refresh? : String) -> SecurityPutRoleQuery {
  { refresh, }
}

///|
pub fn SecurityPutRoleQuery::to_pairs(
  self : SecurityPutRoleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityPutRoleBody {
  applications : Array[Json]?
  cluster : Array[Json]?
  global : Map[String, Json]?
  indices : Array[Json]?
  remote_indices : Array[Json]?
  remote_cluster : Array[Json]?
  metadata : Json?
  run_as : Array[String]?
  description : String?
  transient_metadata : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutRoleBody with fn to_json(
  self : SecurityPutRoleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.applications {
    Some(value) => obj["applications"] = value.to_json()
    None => ()
  }
  match self.cluster {
    Some(value) => obj["cluster"] = value.to_json()
    None => ()
  }
  match self.global {
    Some(value) => obj["global"] = value.to_json()
    None => ()
  }
  match self.indices {
    Some(value) => obj["indices"] = value.to_json()
    None => ()
  }
  match self.remote_indices {
    Some(value) => obj["remote_indices"] = value.to_json()
    None => ()
  }
  match self.remote_cluster {
    Some(value) => obj["remote_cluster"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.run_as {
    Some(value) => obj["run_as"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.transient_metadata {
    Some(value) => obj["transient_metadata"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutRoleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutRoleBody: expected object"))
  }
  {
    applications: match obj.get("applications") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("applications")))
    },
    cluster: match obj.get("cluster") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cluster")))
    },
    global: match obj.get("global") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("global")))
    },
    indices: match obj.get("indices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("indices")))
    },
    remote_indices: match obj.get("remote_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("remote_indices")))
    },
    remote_cluster: match obj.get("remote_cluster") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("remote_cluster")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    run_as: match obj.get("run_as") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("run_as")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    transient_metadata: match obj.get("transient_metadata") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("transient_metadata")))
    },
  }
}

///|
pub fn SecurityPutRoleBody::new(
  applications? : Array[Json],
  cluster? : Array[Json],
  global? : Map[String, Json],
  indices? : Array[Json],
  remote_indices? : Array[Json],
  remote_cluster? : Array[Json],
  metadata? : Json,
  run_as? : Array[String],
  description? : String,
  transient_metadata? : Map[String, Json],
) -> SecurityPutRoleBody {
  {
    applications,
    cluster,
    global,
    indices,
    remote_indices,
    remote_cluster,
    metadata,
    run_as,
    description,
    transient_metadata,
  }
}

///|
pub(all) struct SecurityPutRoleResponse {
  role : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutRoleResponse with fn to_json(
  self : SecurityPutRoleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["role"] = self.role.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutRoleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutRoleResponse: expected object"))
  }
  {
    role: @json.from_json(
      obj.get("role").unwrap_or(Json::null()),
      path=path.add_key("role"),
    ),
  }
}

///|
pub(all) struct SecurityPutRoleRequest {
  name : String
  query : SecurityPutRoleQuery
  body : SecurityPutRoleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityPutRoleRequest::new(
  name : String,
  body : SecurityPutRoleBody,
  query? : SecurityPutRoleQuery = SecurityPutRoleQuery::new(),
) -> SecurityPutRoleRequest {
  { name, query, body }
}

///|
pub async fn Client::security_put_role(
  self : Client,
  request : SecurityPutRoleRequest,
) -> EsResponse[SecurityPutRoleResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/role/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityPutRoleMappingQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutRoleMappingQuery with fn to_json(
  self : SecurityPutRoleMappingQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutRoleMappingQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityPutRoleMappingQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityPutRoleMappingQuery::new(
  refresh? : String,
) -> SecurityPutRoleMappingQuery {
  { refresh, }
}

///|
pub fn SecurityPutRoleMappingQuery::to_pairs(
  self : SecurityPutRoleMappingQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityPutRoleMappingBody {
  enabled : Bool?
  metadata : Json?
  roles : Array[String]?
  role_templates : Array[Json]?
  rules : Json?
  run_as : Array[String]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutRoleMappingBody with fn to_json(
  self : SecurityPutRoleMappingBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.enabled {
    Some(value) => obj["enabled"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.roles {
    Some(value) => obj["roles"] = value.to_json()
    None => ()
  }
  match self.role_templates {
    Some(value) => obj["role_templates"] = value.to_json()
    None => ()
  }
  match self.rules {
    Some(value) => obj["rules"] = value.to_json()
    None => ()
  }
  match self.run_as {
    Some(value) => obj["run_as"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutRoleMappingBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutRoleMappingBody: expected object"))
  }
  {
    enabled: match obj.get("enabled") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("enabled")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    roles: match obj.get("roles") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("roles")))
    },
    role_templates: match obj.get("role_templates") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("role_templates")))
    },
    rules: match obj.get("rules") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("rules")))
    },
    run_as: match obj.get("run_as") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("run_as")))
    },
  }
}

///|
pub fn SecurityPutRoleMappingBody::new(
  enabled? : Bool,
  metadata? : Json,
  roles? : Array[String],
  role_templates? : Array[Json],
  rules? : Json,
  run_as? : Array[String],
) -> SecurityPutRoleMappingBody {
  { enabled, metadata, roles, role_templates, rules, run_as }
}

///|
pub(all) struct SecurityPutRoleMappingResponse {
  created : Bool?
  role_mapping : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutRoleMappingResponse with fn to_json(
  self : SecurityPutRoleMappingResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.created {
    Some(value) => obj["created"] = value.to_json()
    None => ()
  }
  obj["role_mapping"] = self.role_mapping.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutRoleMappingResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityPutRoleMappingResponse: expected object"),
    )
  }
  {
    created: match obj.get("created") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("created")))
    },
    role_mapping: @json.from_json(
      obj.get("role_mapping").unwrap_or(Json::null()),
      path=path.add_key("role_mapping"),
    ),
  }
}

///|
pub(all) struct SecurityPutRoleMappingRequest {
  name : String
  query : SecurityPutRoleMappingQuery
  body : SecurityPutRoleMappingBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityPutRoleMappingRequest::new(
  name : String,
  body : SecurityPutRoleMappingBody,
  query? : SecurityPutRoleMappingQuery = SecurityPutRoleMappingQuery::new(),
) -> SecurityPutRoleMappingRequest {
  { name, query, body }
}

///|
pub async fn Client::security_put_role_mapping(
  self : Client,
  request : SecurityPutRoleMappingRequest,
) -> EsResponse[SecurityPutRoleMappingResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/role_mapping/{name}", ["name"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityPutUserQuery {
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutUserQuery with fn to_json(
  self : SecurityPutUserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutUserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutUserQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityPutUserQuery::new(refresh? : String) -> SecurityPutUserQuery {
  { refresh, }
}

///|
pub fn SecurityPutUserQuery::to_pairs(
  self : SecurityPutUserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityPutUserBody {
  username : Json?
  email : Json?
  full_name : Json?
  metadata : Json?
  password : Json?
  password_hash : String?
  roles : Array[String]?
  enabled : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutUserBody with fn to_json(
  self : SecurityPutUserBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.username {
    Some(value) => obj["username"] = value.to_json()
    None => ()
  }
  match self.email {
    Some(value) => obj["email"] = value.to_json()
    None => ()
  }
  match self.full_name {
    Some(value) => obj["full_name"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.password {
    Some(value) => obj["password"] = value.to_json()
    None => ()
  }
  match self.password_hash {
    Some(value) => obj["password_hash"] = value.to_json()
    None => ()
  }
  match self.roles {
    Some(value) => obj["roles"] = value.to_json()
    None => ()
  }
  match self.enabled {
    Some(value) => obj["enabled"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutUserBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutUserBody: expected object"))
  }
  {
    username: match obj.get("username") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("username")))
    },
    email: match obj.get("email") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("email")))
    },
    full_name: match obj.get("full_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("full_name")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    password: match obj.get("password") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("password")))
    },
    password_hash: match obj.get("password_hash") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("password_hash")))
    },
    roles: match obj.get("roles") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("roles")))
    },
    enabled: match obj.get("enabled") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("enabled")))
    },
  }
}

///|
pub fn SecurityPutUserBody::new(
  username? : Json,
  email? : Json,
  full_name? : Json,
  metadata? : Json,
  password? : Json,
  password_hash? : String,
  roles? : Array[String],
  enabled? : Bool,
) -> SecurityPutUserBody {
  {
    username,
    email,
    full_name,
    metadata,
    password,
    password_hash,
    roles,
    enabled,
  }
}

///|
pub(all) struct SecurityPutUserResponse {
  created : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityPutUserResponse with fn to_json(
  self : SecurityPutUserResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["created"] = self.created.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityPutUserResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityPutUserResponse: expected object"))
  }
  {
    created: @json.from_json(
      obj.get("created").unwrap_or(Json::null()),
      path=path.add_key("created"),
    ),
  }
}

///|
pub(all) struct SecurityPutUserRequest {
  username : String
  query : SecurityPutUserQuery
  body : SecurityPutUserBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityPutUserRequest::new(
  username : String,
  body : SecurityPutUserBody,
  query? : SecurityPutUserQuery = SecurityPutUserQuery::new(),
) -> SecurityPutUserRequest {
  { username, query, body }
}

///|
pub async fn Client::security_put_user(
  self : Client,
  request : SecurityPutUserRequest,
) -> EsResponse[SecurityPutUserResponse] {
  let params : Map[String, String] = Map([])
  params["username"] = request.username
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/user/{username}", ["username"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityQueryApiKeysQuery {
  with_limited_by : Bool?
  with_profile_uid : Bool?
  typed_keys : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryApiKeysQuery with fn to_json(
  self : SecurityQueryApiKeysQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.with_limited_by {
    Some(value) => obj["with_limited_by"] = value.to_json()
    None => ()
  }
  match self.with_profile_uid {
    Some(value) => obj["with_profile_uid"] = value.to_json()
    None => ()
  }
  match self.typed_keys {
    Some(value) => obj["typed_keys"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryApiKeysQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryApiKeysQuery: expected object"))
  }
  {
    with_limited_by: match obj.get("with_limited_by") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_limited_by")))
    },
    with_profile_uid: match obj.get("with_profile_uid") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_profile_uid")))
    },
    typed_keys: match obj.get("typed_keys") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("typed_keys")))
    },
  }
}

///|
pub fn SecurityQueryApiKeysQuery::new(
  with_limited_by? : Bool,
  with_profile_uid? : Bool,
  typed_keys? : Bool,
) -> SecurityQueryApiKeysQuery {
  { with_limited_by, with_profile_uid, typed_keys }
}

///|
pub fn SecurityQueryApiKeysQuery::to_pairs(
  self : SecurityQueryApiKeysQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.with_limited_by {
    Some(value) => push_query_json(pairs, "with_limited_by", value.to_json())
    None => ()
  }
  match self.with_profile_uid {
    Some(value) => push_query_json(pairs, "with_profile_uid", value.to_json())
    None => ()
  }
  match self.typed_keys {
    Some(value) => push_query_json(pairs, "typed_keys", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityQueryApiKeysBody {
  aggregations : Map[String, Json]?
  query : Json?
  from : Int?
  sort : Json?
  size : Int?
  search_after : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryApiKeysBody with fn to_json(
  self : SecurityQueryApiKeysBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryApiKeysBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryApiKeysBody: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
  }
}

///|
pub fn SecurityQueryApiKeysBody::new(
  aggregations? : Map[String, Json],
  query? : Json,
  from? : Int,
  sort? : Json,
  size? : Int,
  search_after? : Json,
) -> SecurityQueryApiKeysBody {
  { aggregations, query, from, sort, size, search_after }
}

///|
pub(all) struct SecurityQueryApiKeysResponse {
  total : Int
  count : Int
  api_keys : Array[Json]
  aggregations : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryApiKeysResponse with fn to_json(
  self : SecurityQueryApiKeysResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["total"] = self.total.to_json()
  obj["count"] = self.count.to_json()
  obj["api_keys"] = self.api_keys.to_json()
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryApiKeysResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityQueryApiKeysResponse: expected object"),
    )
  }
  {
    total: @json.from_json(
      obj.get("total").unwrap_or(Json::null()),
      path=path.add_key("total"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    api_keys: @json.from_json(
      obj.get("api_keys").unwrap_or(Json::null()),
      path=path.add_key("api_keys"),
    ),
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
  }
}

///|
pub(all) struct SecurityQueryApiKeysRequest {
  query : SecurityQueryApiKeysQuery
  body : SecurityQueryApiKeysBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityQueryApiKeysRequest::new(
  query? : SecurityQueryApiKeysQuery = SecurityQueryApiKeysQuery::new(),
  body? : SecurityQueryApiKeysBody,
) -> SecurityQueryApiKeysRequest {
  { query, body }
}

///|
pub async fn Client::security_query_api_keys(
  self : Client,
  request : SecurityQueryApiKeysRequest,
) -> EsResponse[SecurityQueryApiKeysResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/_query/api_key", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityQueryRoleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryRoleQuery with fn to_json(
  _self : SecurityQueryRoleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityQueryRoleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityQueryRoleQuery: expected object"))
  }
  SecurityQueryRoleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityQueryRoleQuery::new() -> SecurityQueryRoleQuery {
  SecurityQueryRoleQuery::{  }
}

///|
pub fn SecurityQueryRoleQuery::to_pairs(
  _self : SecurityQueryRoleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityQueryRoleBody {
  query : Json?
  from : Int?
  sort : Json?
  size : Int?
  search_after : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryRoleBody with fn to_json(
  self : SecurityQueryRoleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryRoleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryRoleBody: expected object"))
  }
  {
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
  }
}

///|
pub fn SecurityQueryRoleBody::new(
  query? : Json,
  from? : Int,
  sort? : Json,
  size? : Int,
  search_after? : Json,
) -> SecurityQueryRoleBody {
  { query, from, sort, size, search_after }
}

///|
pub(all) struct SecurityQueryRoleResponse {
  total : Int
  count : Int
  roles : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryRoleResponse with fn to_json(
  self : SecurityQueryRoleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["total"] = self.total.to_json()
  obj["count"] = self.count.to_json()
  obj["roles"] = self.roles.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryRoleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryRoleResponse: expected object"))
  }
  {
    total: @json.from_json(
      obj.get("total").unwrap_or(Json::null()),
      path=path.add_key("total"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    roles: @json.from_json(
      obj.get("roles").unwrap_or(Json::null()),
      path=path.add_key("roles"),
    ),
  }
}

///|
pub(all) struct SecurityQueryRoleRequest {
  query : SecurityQueryRoleQuery
  body : SecurityQueryRoleBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityQueryRoleRequest::new(
  query? : SecurityQueryRoleQuery = SecurityQueryRoleQuery::new(),
  body? : SecurityQueryRoleBody,
) -> SecurityQueryRoleRequest {
  { query, body }
}

///|
pub async fn Client::security_query_role(
  self : Client,
  request : SecurityQueryRoleRequest,
) -> EsResponse[SecurityQueryRoleResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/_query/role", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityQueryUserQuery {
  with_profile_uid : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryUserQuery with fn to_json(
  self : SecurityQueryUserQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.with_profile_uid {
    Some(value) => obj["with_profile_uid"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryUserQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryUserQuery: expected object"))
  }
  {
    with_profile_uid: match obj.get("with_profile_uid") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("with_profile_uid")))
    },
  }
}

///|
pub fn SecurityQueryUserQuery::new(
  with_profile_uid? : Bool,
) -> SecurityQueryUserQuery {
  { with_profile_uid, }
}

///|
pub fn SecurityQueryUserQuery::to_pairs(
  self : SecurityQueryUserQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.with_profile_uid {
    Some(value) => push_query_json(pairs, "with_profile_uid", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityQueryUserBody {
  query : Json?
  from : Int?
  sort : Json?
  size : Int?
  search_after : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryUserBody with fn to_json(
  self : SecurityQueryUserBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryUserBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryUserBody: expected object"))
  }
  {
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
  }
}

///|
pub fn SecurityQueryUserBody::new(
  query? : Json,
  from? : Int,
  sort? : Json,
  size? : Int,
  search_after? : Json,
) -> SecurityQueryUserBody {
  { query, from, sort, size, search_after }
}

///|
pub(all) struct SecurityQueryUserResponse {
  total : Int
  count : Int
  users : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityQueryUserResponse with fn to_json(
  self : SecurityQueryUserResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["total"] = self.total.to_json()
  obj["count"] = self.count.to_json()
  obj["users"] = self.users.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityQueryUserResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityQueryUserResponse: expected object"))
  }
  {
    total: @json.from_json(
      obj.get("total").unwrap_or(Json::null()),
      path=path.add_key("total"),
    ),
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    users: @json.from_json(
      obj.get("users").unwrap_or(Json::null()),
      path=path.add_key("users"),
    ),
  }
}

///|
pub(all) struct SecurityQueryUserRequest {
  query : SecurityQueryUserQuery
  body : SecurityQueryUserBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityQueryUserRequest::new(
  query? : SecurityQueryUserQuery = SecurityQueryUserQuery::new(),
  body? : SecurityQueryUserBody,
) -> SecurityQueryUserRequest {
  { query, body }
}

///|
pub async fn Client::security_query_user(
  self : Client,
  request : SecurityQueryUserRequest,
) -> EsResponse[SecurityQueryUserResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/_query/user", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecuritySamlAuthenticateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlAuthenticateQuery with fn to_json(
  _self : SecuritySamlAuthenticateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecuritySamlAuthenticateQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecuritySamlAuthenticateQuery: expected object"),
    )
  }
  SecuritySamlAuthenticateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecuritySamlAuthenticateQuery::new() -> SecuritySamlAuthenticateQuery {
  SecuritySamlAuthenticateQuery::{  }
}

///|
pub fn SecuritySamlAuthenticateQuery::to_pairs(
  _self : SecuritySamlAuthenticateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecuritySamlAuthenticateBody {
  content : String
  ids : Json
  realm : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlAuthenticateBody with fn to_json(
  self : SecuritySamlAuthenticateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["content"] = self.content.to_json()
  obj["ids"] = self.ids.to_json()
  match self.realm {
    Some(value) => obj["realm"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlAuthenticateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlAuthenticateBody: expected object"),
    )
  }
  {
    content: @json.from_json(
      obj.get("content").unwrap_or(Json::null()),
      path=path.add_key("content"),
    ),
    ids: @json.from_json(
      obj.get("ids").unwrap_or(Json::null()),
      path=path.add_key("ids"),
    ),
    realm: match obj.get("realm") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realm")))
    },
  }
}

///|
pub fn SecuritySamlAuthenticateBody::new(
  content : String,
  ids : Json,
  realm? : String,
) -> SecuritySamlAuthenticateBody {
  { content, ids, realm }
}

///|
pub(all) struct SecuritySamlAuthenticateResponse {
  access_token : String
  username : String
  expires_in : Int
  refresh_token : String
  realm : String
  in_response_to : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlAuthenticateResponse with fn to_json(
  self : SecuritySamlAuthenticateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["access_token"] = self.access_token.to_json()
  obj["username"] = self.username.to_json()
  obj["expires_in"] = self.expires_in.to_json()
  obj["refresh_token"] = self.refresh_token.to_json()
  obj["realm"] = self.realm.to_json()
  match self.in_response_to {
    Some(value) => obj["in_response_to"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlAuthenticateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlAuthenticateResponse: expected object"),
    )
  }
  {
    access_token: @json.from_json(
      obj.get("access_token").unwrap_or(Json::null()),
      path=path.add_key("access_token"),
    ),
    username: @json.from_json(
      obj.get("username").unwrap_or(Json::null()),
      path=path.add_key("username"),
    ),
    expires_in: @json.from_json(
      obj.get("expires_in").unwrap_or(Json::null()),
      path=path.add_key("expires_in"),
    ),
    refresh_token: @json.from_json(
      obj.get("refresh_token").unwrap_or(Json::null()),
      path=path.add_key("refresh_token"),
    ),
    realm: @json.from_json(
      obj.get("realm").unwrap_or(Json::null()),
      path=path.add_key("realm"),
    ),
    in_response_to: match obj.get("in_response_to") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("in_response_to")))
    },
  }
}

///|
pub(all) struct SecuritySamlAuthenticateRequest {
  query : SecuritySamlAuthenticateQuery
  body : SecuritySamlAuthenticateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySamlAuthenticateRequest::new(
  body : SecuritySamlAuthenticateBody,
  query? : SecuritySamlAuthenticateQuery = SecuritySamlAuthenticateQuery::new(),
) -> SecuritySamlAuthenticateRequest {
  { query, body }
}

///|
pub async fn Client::security_saml_authenticate(
  self : Client,
  request : SecuritySamlAuthenticateRequest,
) -> EsResponse[SecuritySamlAuthenticateResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/saml/authenticate", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecuritySamlCompleteLogoutQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlCompleteLogoutQuery with fn to_json(
  _self : SecuritySamlCompleteLogoutQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecuritySamlCompleteLogoutQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecuritySamlCompleteLogoutQuery: expected object"),
    )
  }
  SecuritySamlCompleteLogoutQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecuritySamlCompleteLogoutQuery::new() -> SecuritySamlCompleteLogoutQuery {
  SecuritySamlCompleteLogoutQuery::{  }
}

///|
pub fn SecuritySamlCompleteLogoutQuery::to_pairs(
  _self : SecuritySamlCompleteLogoutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecuritySamlCompleteLogoutBody {
  realm : String
  ids : Json
  query_string : String?
  content : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlCompleteLogoutBody with fn to_json(
  self : SecuritySamlCompleteLogoutBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["realm"] = self.realm.to_json()
  obj["ids"] = self.ids.to_json()
  match self.query_string {
    Some(value) => obj["query_string"] = value.to_json()
    None => ()
  }
  match self.content {
    Some(value) => obj["content"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlCompleteLogoutBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlCompleteLogoutBody: expected object"),
    )
  }
  {
    realm: @json.from_json(
      obj.get("realm").unwrap_or(Json::null()),
      path=path.add_key("realm"),
    ),
    ids: @json.from_json(
      obj.get("ids").unwrap_or(Json::null()),
      path=path.add_key("ids"),
    ),
    query_string: match obj.get("query_string") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("query_string")))
    },
    content: match obj.get("content") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("content")))
    },
  }
}

///|
pub fn SecuritySamlCompleteLogoutBody::new(
  realm : String,
  ids : Json,
  query_string? : String,
  content? : String,
) -> SecuritySamlCompleteLogoutBody {
  { realm, ids, query_string, content }
}

///|
pub type SecuritySamlCompleteLogoutResponse = Json

///|
pub(all) struct SecuritySamlCompleteLogoutRequest {
  query : SecuritySamlCompleteLogoutQuery
  body : SecuritySamlCompleteLogoutBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySamlCompleteLogoutRequest::new(
  body : SecuritySamlCompleteLogoutBody,
  query? : SecuritySamlCompleteLogoutQuery = SecuritySamlCompleteLogoutQuery::new(),
) -> SecuritySamlCompleteLogoutRequest {
  { query, body }
}

///|
pub async fn Client::security_saml_complete_logout(
  self : Client,
  request : SecuritySamlCompleteLogoutRequest,
) -> EsResponse[SecuritySamlCompleteLogoutResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/saml/complete_logout", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecuritySamlInvalidateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlInvalidateQuery with fn to_json(
  _self : SecuritySamlInvalidateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecuritySamlInvalidateQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecuritySamlInvalidateQuery: expected object"),
    )
  }
  SecuritySamlInvalidateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecuritySamlInvalidateQuery::new() -> SecuritySamlInvalidateQuery {
  SecuritySamlInvalidateQuery::{  }
}

///|
pub fn SecuritySamlInvalidateQuery::to_pairs(
  _self : SecuritySamlInvalidateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecuritySamlInvalidateBody {
  acs : String?
  query_string : String
  realm : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlInvalidateBody with fn to_json(
  self : SecuritySamlInvalidateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acs {
    Some(value) => obj["acs"] = value.to_json()
    None => ()
  }
  obj["query_string"] = self.query_string.to_json()
  match self.realm {
    Some(value) => obj["realm"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlInvalidateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecuritySamlInvalidateBody: expected object"))
  }
  {
    acs: match obj.get("acs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("acs")))
    },
    query_string: @json.from_json(
      obj.get("query_string").unwrap_or(Json::null()),
      path=path.add_key("query_string"),
    ),
    realm: match obj.get("realm") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realm")))
    },
  }
}

///|
pub fn SecuritySamlInvalidateBody::new(
  query_string : String,
  acs? : String,
  realm? : String,
) -> SecuritySamlInvalidateBody {
  { acs, query_string, realm }
}

///|
pub(all) struct SecuritySamlInvalidateResponse {
  invalidated : Int
  realm : String
  redirect : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlInvalidateResponse with fn to_json(
  self : SecuritySamlInvalidateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["invalidated"] = self.invalidated.to_json()
  obj["realm"] = self.realm.to_json()
  obj["redirect"] = self.redirect.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlInvalidateResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlInvalidateResponse: expected object"),
    )
  }
  {
    invalidated: @json.from_json(
      obj.get("invalidated").unwrap_or(Json::null()),
      path=path.add_key("invalidated"),
    ),
    realm: @json.from_json(
      obj.get("realm").unwrap_or(Json::null()),
      path=path.add_key("realm"),
    ),
    redirect: @json.from_json(
      obj.get("redirect").unwrap_or(Json::null()),
      path=path.add_key("redirect"),
    ),
  }
}

///|
pub(all) struct SecuritySamlInvalidateRequest {
  query : SecuritySamlInvalidateQuery
  body : SecuritySamlInvalidateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySamlInvalidateRequest::new(
  body : SecuritySamlInvalidateBody,
  query? : SecuritySamlInvalidateQuery = SecuritySamlInvalidateQuery::new(),
) -> SecuritySamlInvalidateRequest {
  { query, body }
}

///|
pub async fn Client::security_saml_invalidate(
  self : Client,
  request : SecuritySamlInvalidateRequest,
) -> EsResponse[SecuritySamlInvalidateResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/saml/invalidate", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecuritySamlLogoutQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlLogoutQuery with fn to_json(
  _self : SecuritySamlLogoutQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecuritySamlLogoutQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecuritySamlLogoutQuery: expected object"))
  }
  SecuritySamlLogoutQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecuritySamlLogoutQuery::new() -> SecuritySamlLogoutQuery {
  SecuritySamlLogoutQuery::{  }
}

///|
pub fn SecuritySamlLogoutQuery::to_pairs(
  _self : SecuritySamlLogoutQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecuritySamlLogoutBody {
  token : String
  refresh_token : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlLogoutBody with fn to_json(
  self : SecuritySamlLogoutBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["token"] = self.token.to_json()
  match self.refresh_token {
    Some(value) => obj["refresh_token"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlLogoutBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecuritySamlLogoutBody: expected object"))
  }
  {
    token: @json.from_json(
      obj.get("token").unwrap_or(Json::null()),
      path=path.add_key("token"),
    ),
    refresh_token: match obj.get("refresh_token") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("refresh_token")))
    },
  }
}

///|
pub fn SecuritySamlLogoutBody::new(
  token : String,
  refresh_token? : String,
) -> SecuritySamlLogoutBody {
  { token, refresh_token }
}

///|
pub(all) struct SecuritySamlLogoutResponse {
  redirect : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlLogoutResponse with fn to_json(
  self : SecuritySamlLogoutResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["redirect"] = self.redirect.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlLogoutResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecuritySamlLogoutResponse: expected object"))
  }
  {
    redirect: @json.from_json(
      obj.get("redirect").unwrap_or(Json::null()),
      path=path.add_key("redirect"),
    ),
  }
}

///|
pub(all) struct SecuritySamlLogoutRequest {
  query : SecuritySamlLogoutQuery
  body : SecuritySamlLogoutBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySamlLogoutRequest::new(
  body : SecuritySamlLogoutBody,
  query? : SecuritySamlLogoutQuery = SecuritySamlLogoutQuery::new(),
) -> SecuritySamlLogoutRequest {
  { query, body }
}

///|
pub async fn Client::security_saml_logout(
  self : Client,
  request : SecuritySamlLogoutRequest,
) -> EsResponse[SecuritySamlLogoutResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/saml/logout", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecuritySamlPrepareAuthenticationQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlPrepareAuthenticationQuery with fn to_json(
  _self : SecuritySamlPrepareAuthenticationQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecuritySamlPrepareAuthenticationQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecuritySamlPrepareAuthenticationQuery: expected object"),
    )
  }
  SecuritySamlPrepareAuthenticationQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecuritySamlPrepareAuthenticationQuery::new() -> SecuritySamlPrepareAuthenticationQuery {
  SecuritySamlPrepareAuthenticationQuery::{  }
}

///|
pub fn SecuritySamlPrepareAuthenticationQuery::to_pairs(
  _self : SecuritySamlPrepareAuthenticationQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecuritySamlPrepareAuthenticationBody {
  acs : String?
  realm : String?
  relay_state : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlPrepareAuthenticationBody with fn to_json(
  self : SecuritySamlPrepareAuthenticationBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.acs {
    Some(value) => obj["acs"] = value.to_json()
    None => ()
  }
  match self.realm {
    Some(value) => obj["realm"] = value.to_json()
    None => ()
  }
  match self.relay_state {
    Some(value) => obj["relay_state"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlPrepareAuthenticationBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlPrepareAuthenticationBody: expected object"),
    )
  }
  {
    acs: match obj.get("acs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("acs")))
    },
    realm: match obj.get("realm") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realm")))
    },
    relay_state: match obj.get("relay_state") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("relay_state")))
    },
  }
}

///|
pub fn SecuritySamlPrepareAuthenticationBody::new(
  acs? : String,
  realm? : String,
  relay_state? : String,
) -> SecuritySamlPrepareAuthenticationBody {
  { acs, realm, relay_state }
}

///|
pub(all) struct SecuritySamlPrepareAuthenticationResponse {
  id : Json
  realm : String
  redirect : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlPrepareAuthenticationResponse with fn to_json(
  self : SecuritySamlPrepareAuthenticationResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  obj["realm"] = self.realm.to_json()
  obj["redirect"] = self.redirect.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlPrepareAuthenticationResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlPrepareAuthenticationResponse: expected object"),
    )
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    realm: @json.from_json(
      obj.get("realm").unwrap_or(Json::null()),
      path=path.add_key("realm"),
    ),
    redirect: @json.from_json(
      obj.get("redirect").unwrap_or(Json::null()),
      path=path.add_key("redirect"),
    ),
  }
}

///|
pub(all) struct SecuritySamlPrepareAuthenticationRequest {
  query : SecuritySamlPrepareAuthenticationQuery
  body : SecuritySamlPrepareAuthenticationBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySamlPrepareAuthenticationRequest::new(
  body : SecuritySamlPrepareAuthenticationBody,
  query? : SecuritySamlPrepareAuthenticationQuery = SecuritySamlPrepareAuthenticationQuery::new(),
) -> SecuritySamlPrepareAuthenticationRequest {
  { query, body }
}

///|
pub async fn Client::security_saml_prepare_authentication(
  self : Client,
  request : SecuritySamlPrepareAuthenticationRequest,
) -> EsResponse[SecuritySamlPrepareAuthenticationResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/saml/prepare", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecuritySamlServiceProviderMetadataQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlServiceProviderMetadataQuery with fn to_json(
  _self : SecuritySamlServiceProviderMetadataQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecuritySamlServiceProviderMetadataQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecuritySamlServiceProviderMetadataQuery: expected object"),
    )
  }
  SecuritySamlServiceProviderMetadataQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecuritySamlServiceProviderMetadataQuery::new() -> SecuritySamlServiceProviderMetadataQuery {
  SecuritySamlServiceProviderMetadataQuery::{  }
}

///|
pub fn SecuritySamlServiceProviderMetadataQuery::to_pairs(
  _self : SecuritySamlServiceProviderMetadataQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SecuritySamlServiceProviderMetadataBody = Json

///|
pub(all) struct SecuritySamlServiceProviderMetadataResponse {
  metadata : String
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySamlServiceProviderMetadataResponse with fn to_json(
  self : SecuritySamlServiceProviderMetadataResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["metadata"] = self.metadata.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySamlServiceProviderMetadataResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySamlServiceProviderMetadataResponse: expected object"),
    )
  }
  {
    metadata: @json.from_json(
      obj.get("metadata").unwrap_or(Json::null()),
      path=path.add_key("metadata"),
    ),
  }
}

///|
pub(all) struct SecuritySamlServiceProviderMetadataRequest {
  realm_name : String
  query : SecuritySamlServiceProviderMetadataQuery
  body : SecuritySamlServiceProviderMetadataBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySamlServiceProviderMetadataRequest::new(
  realm_name : String,
  query? : SecuritySamlServiceProviderMetadataQuery = SecuritySamlServiceProviderMetadataQuery::new(),
  body? : SecuritySamlServiceProviderMetadataBody,
) -> SecuritySamlServiceProviderMetadataRequest {
  { realm_name, query, body }
}

///|
pub async fn Client::security_saml_service_provider_metadata(
  self : Client,
  request : SecuritySamlServiceProviderMetadataRequest,
) -> EsResponse[SecuritySamlServiceProviderMetadataResponse] {
  let params : Map[String, String] = Map([])
  params["realm_name"] = request.realm_name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/saml/metadata/{realm_name}", ["realm_name"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct SecuritySuggestUserProfilesQuery {
  data : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySuggestUserProfilesQuery with fn to_json(
  self : SecuritySuggestUserProfilesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.data {
    Some(value) => obj["data"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySuggestUserProfilesQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySuggestUserProfilesQuery: expected object"),
    )
  }
  {
    data: match obj.get("data") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("data")))
    },
  }
}

///|
pub fn SecuritySuggestUserProfilesQuery::new(
  data? : Json,
) -> SecuritySuggestUserProfilesQuery {
  { data, }
}

///|
pub fn SecuritySuggestUserProfilesQuery::to_pairs(
  self : SecuritySuggestUserProfilesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.data {
    Some(value) => push_query_json(pairs, "data", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecuritySuggestUserProfilesBody {
  name : String?
  size : Int?
  data : Json?
  hint : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySuggestUserProfilesBody with fn to_json(
  self : SecuritySuggestUserProfilesBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.data {
    Some(value) => obj["data"] = value.to_json()
    None => ()
  }
  match self.hint {
    Some(value) => obj["hint"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySuggestUserProfilesBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySuggestUserProfilesBody: expected object"),
    )
  }
  {
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    data: match obj.get("data") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("data")))
    },
    hint: match obj.get("hint") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("hint")))
    },
  }
}

///|
pub fn SecuritySuggestUserProfilesBody::new(
  name? : String,
  size? : Int,
  data? : Json,
  hint? : Json,
) -> SecuritySuggestUserProfilesBody {
  { name, size, data, hint }
}

///|
pub(all) struct SecuritySuggestUserProfilesResponse {
  total : Json
  took : Int
  profiles : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SecuritySuggestUserProfilesResponse with fn to_json(
  self : SecuritySuggestUserProfilesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["total"] = self.total.to_json()
  obj["took"] = self.took.to_json()
  obj["profiles"] = self.profiles.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecuritySuggestUserProfilesResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecuritySuggestUserProfilesResponse: expected object"),
    )
  }
  {
    total: @json.from_json(
      obj.get("total").unwrap_or(Json::null()),
      path=path.add_key("total"),
    ),
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    profiles: @json.from_json(
      obj.get("profiles").unwrap_or(Json::null()),
      path=path.add_key("profiles"),
    ),
  }
}

///|
pub(all) struct SecuritySuggestUserProfilesRequest {
  query : SecuritySuggestUserProfilesQuery
  body : SecuritySuggestUserProfilesBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecuritySuggestUserProfilesRequest::new(
  query? : SecuritySuggestUserProfilesQuery = SecuritySuggestUserProfilesQuery::new(),
  body? : SecuritySuggestUserProfilesBody,
) -> SecuritySuggestUserProfilesRequest {
  { query, body }
}

///|
pub async fn Client::security_suggest_user_profiles(
  self : Client,
  request : SecuritySuggestUserProfilesRequest,
) -> EsResponse[SecuritySuggestUserProfilesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/_suggest", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SecurityUpdateApiKeyQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateApiKeyQuery with fn to_json(
  _self : SecurityUpdateApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityUpdateApiKeyQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SecurityUpdateApiKeyQuery: expected object"))
  }
  SecurityUpdateApiKeyQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityUpdateApiKeyQuery::new() -> SecurityUpdateApiKeyQuery {
  SecurityUpdateApiKeyQuery::{  }
}

///|
pub fn SecurityUpdateApiKeyQuery::to_pairs(
  _self : SecurityUpdateApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityUpdateApiKeyBody {
  role_descriptors : Map[String, Json]?
  metadata : Json?
  expiration : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateApiKeyBody with fn to_json(
  self : SecurityUpdateApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.role_descriptors {
    Some(value) => obj["role_descriptors"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateApiKeyBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityUpdateApiKeyBody: expected object"))
  }
  {
    role_descriptors: match obj.get("role_descriptors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("role_descriptors")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
  }
}

///|
pub fn SecurityUpdateApiKeyBody::new(
  role_descriptors? : Map[String, Json],
  metadata? : Json,
  expiration? : Json,
) -> SecurityUpdateApiKeyBody {
  { role_descriptors, metadata, expiration }
}

///|
pub(all) struct SecurityUpdateApiKeyResponse {
  updated : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateApiKeyResponse with fn to_json(
  self : SecurityUpdateApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["updated"] = self.updated.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateApiKeyResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateApiKeyResponse: expected object"),
    )
  }
  {
    updated: @json.from_json(
      obj.get("updated").unwrap_or(Json::null()),
      path=path.add_key("updated"),
    ),
  }
}

///|
pub(all) struct SecurityUpdateApiKeyRequest {
  id : String
  query : SecurityUpdateApiKeyQuery
  body : SecurityUpdateApiKeyBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityUpdateApiKeyRequest::new(
  id : String,
  query? : SecurityUpdateApiKeyQuery = SecurityUpdateApiKeyQuery::new(),
  body? : SecurityUpdateApiKeyBody,
) -> SecurityUpdateApiKeyRequest {
  { id, query, body }
}

///|
pub async fn Client::security_update_api_key(
  self : Client,
  request : SecurityUpdateApiKeyRequest,
) -> EsResponse[SecurityUpdateApiKeyResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/api_key/{id}", ["id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SecurityUpdateCrossClusterApiKeyQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateCrossClusterApiKeyQuery with fn to_json(
  _self : SecurityUpdateCrossClusterApiKeyQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SecurityUpdateCrossClusterApiKeyQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SecurityUpdateCrossClusterApiKeyQuery: expected object"),
    )
  }
  SecurityUpdateCrossClusterApiKeyQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SecurityUpdateCrossClusterApiKeyQuery::new() -> SecurityUpdateCrossClusterApiKeyQuery {
  SecurityUpdateCrossClusterApiKeyQuery::{  }
}

///|
pub fn SecurityUpdateCrossClusterApiKeyQuery::to_pairs(
  _self : SecurityUpdateCrossClusterApiKeyQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SecurityUpdateCrossClusterApiKeyBody {
  access : Json
  expiration : Json?
  metadata : Json?
  certificate_identity : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateCrossClusterApiKeyBody with fn to_json(
  self : SecurityUpdateCrossClusterApiKeyBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["access"] = self.access.to_json()
  match self.expiration {
    Some(value) => obj["expiration"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.certificate_identity {
    Some(value) => obj["certificate_identity"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateCrossClusterApiKeyBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateCrossClusterApiKeyBody: expected object"),
    )
  }
  {
    access: @json.from_json(
      obj.get("access").unwrap_or(Json::null()),
      path=path.add_key("access"),
    ),
    expiration: match obj.get("expiration") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expiration")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    certificate_identity: match obj.get("certificate_identity") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("certificate_identity")))
    },
  }
}

///|
pub fn SecurityUpdateCrossClusterApiKeyBody::new(
  access : Json,
  expiration? : Json,
  metadata? : Json,
  certificate_identity? : String,
) -> SecurityUpdateCrossClusterApiKeyBody {
  { access, expiration, metadata, certificate_identity }
}

///|
pub(all) struct SecurityUpdateCrossClusterApiKeyResponse {
  updated : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateCrossClusterApiKeyResponse with fn to_json(
  self : SecurityUpdateCrossClusterApiKeyResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["updated"] = self.updated.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateCrossClusterApiKeyResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateCrossClusterApiKeyResponse: expected object"),
    )
  }
  {
    updated: @json.from_json(
      obj.get("updated").unwrap_or(Json::null()),
      path=path.add_key("updated"),
    ),
  }
}

///|
pub(all) struct SecurityUpdateCrossClusterApiKeyRequest {
  id : String
  query : SecurityUpdateCrossClusterApiKeyQuery
  body : SecurityUpdateCrossClusterApiKeyBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityUpdateCrossClusterApiKeyRequest::new(
  id : String,
  body : SecurityUpdateCrossClusterApiKeyBody,
  query? : SecurityUpdateCrossClusterApiKeyQuery = SecurityUpdateCrossClusterApiKeyQuery::new(),
) -> SecurityUpdateCrossClusterApiKeyRequest {
  { id, query, body }
}

///|
pub async fn Client::security_update_cross_cluster_api_key(
  self : Client,
  request : SecurityUpdateCrossClusterApiKeyRequest,
) -> EsResponse[SecurityUpdateCrossClusterApiKeyResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/cross_cluster/api_key/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SecurityUpdateSettingsQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateSettingsQuery with fn to_json(
  self : SecurityUpdateSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateSettingsQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SecurityUpdateSettingsQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SecurityUpdateSettingsQuery {
  { master_timeout, timeout }
}

///|
pub fn SecurityUpdateSettingsQuery::to_pairs(
  self : SecurityUpdateSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityUpdateSettingsBody {
  security : Json?
  security_profile : Json?
  security_tokens : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateSettingsBody with fn to_json(
  self : SecurityUpdateSettingsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.security {
    Some(value) => obj["security"] = value.to_json()
    None => ()
  }
  match self.security_profile {
    Some(value) => obj["security-profile"] = value.to_json()
    None => ()
  }
  match self.security_tokens {
    Some(value) => obj["security-tokens"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateSettingsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SecurityUpdateSettingsBody: expected object"))
  }
  {
    security: match obj.get("security") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("security")))
    },
    security_profile: match obj.get("security-profile") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("security-profile")))
    },
    security_tokens: match obj.get("security-tokens") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("security-tokens")))
    },
  }
}

///|
pub fn SecurityUpdateSettingsBody::new(
  security? : Json,
  security_profile? : Json,
  security_tokens? : Json,
) -> SecurityUpdateSettingsBody {
  { security, security_profile, security_tokens }
}

///|
pub(all) struct SecurityUpdateSettingsResponse {
  acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateSettingsResponse with fn to_json(
  self : SecurityUpdateSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateSettingsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateSettingsResponse: expected object"),
    )
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
  }
}

///|
pub(all) struct SecurityUpdateSettingsRequest {
  query : SecurityUpdateSettingsQuery
  body : SecurityUpdateSettingsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityUpdateSettingsRequest::new(
  body : SecurityUpdateSettingsBody,
  query? : SecurityUpdateSettingsQuery = SecurityUpdateSettingsQuery::new(),
) -> SecurityUpdateSettingsRequest {
  { query, body }
}

///|
pub async fn Client::security_update_settings(
  self : Client,
  request : SecurityUpdateSettingsRequest,
) -> EsResponse[SecurityUpdateSettingsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_security/settings", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SecurityUpdateUserProfileDataQuery {
  if_seq_no : String?
  if_primary_term : Int?
  refresh : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateUserProfileDataQuery with fn to_json(
  self : SecurityUpdateUserProfileDataQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.if_seq_no {
    Some(value) => obj["if_seq_no"] = value.to_json()
    None => ()
  }
  match self.if_primary_term {
    Some(value) => obj["if_primary_term"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateUserProfileDataQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateUserProfileDataQuery: expected object"),
    )
  }
  {
    if_seq_no: match obj.get("if_seq_no") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_seq_no")))
    },
    if_primary_term: match obj.get("if_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_primary_term")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SecurityUpdateUserProfileDataQuery::new(
  if_seq_no? : String,
  if_primary_term? : Int,
  refresh? : String,
) -> SecurityUpdateUserProfileDataQuery {
  { if_seq_no, if_primary_term, refresh }
}

///|
pub fn SecurityUpdateUserProfileDataQuery::to_pairs(
  self : SecurityUpdateUserProfileDataQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.if_seq_no {
    Some(value) => push_query_json(pairs, "if_seq_no", value.to_json())
    None => ()
  }
  match self.if_primary_term {
    Some(value) => push_query_json(pairs, "if_primary_term", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SecurityUpdateUserProfileDataBody {
  labels : Map[String, Json]?
  data : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SecurityUpdateUserProfileDataBody with fn to_json(
  self : SecurityUpdateUserProfileDataBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.labels {
    Some(value) => obj["labels"] = value.to_json()
    None => ()
  }
  match self.data {
    Some(value) => obj["data"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SecurityUpdateUserProfileDataBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SecurityUpdateUserProfileDataBody: expected object"),
    )
  }
  {
    labels: match obj.get("labels") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("labels")))
    },
    data: match obj.get("data") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("data")))
    },
  }
}

///|
pub fn SecurityUpdateUserProfileDataBody::new(
  labels? : Map[String, Json],
  data? : Map[String, Json],
) -> SecurityUpdateUserProfileDataBody {
  { labels, data }
}

///|
pub type SecurityUpdateUserProfileDataResponse = Json

///|
pub(all) struct SecurityUpdateUserProfileDataRequest {
  uid : String
  query : SecurityUpdateUserProfileDataQuery
  body : SecurityUpdateUserProfileDataBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SecurityUpdateUserProfileDataRequest::new(
  uid : String,
  body : SecurityUpdateUserProfileDataBody,
  query? : SecurityUpdateUserProfileDataQuery = SecurityUpdateUserProfileDataQuery::new(),
) -> SecurityUpdateUserProfileDataRequest {
  { uid, query, body }
}

///|
pub async fn Client::security_update_user_profile_data(
  self : Client,
  request : SecurityUpdateUserProfileDataRequest,
) -> EsResponse[SecurityUpdateUserProfileDataResponse] {
  let params : Map[String, String] = Map([])
  params["uid"] = request.uid
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_security/profile/{uid}/_data", ["uid"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct ShutdownDeleteNodeQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ShutdownDeleteNodeQuery with fn to_json(
  self : ShutdownDeleteNodeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ShutdownDeleteNodeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ShutdownDeleteNodeQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ShutdownDeleteNodeQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> ShutdownDeleteNodeQuery {
  { master_timeout, timeout }
}

///|
pub fn ShutdownDeleteNodeQuery::to_pairs(
  self : ShutdownDeleteNodeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ShutdownDeleteNodeBody = Json

///|
pub type ShutdownDeleteNodeResponse = Json

///|
pub(all) struct ShutdownDeleteNodeRequest {
  node_id : String
  query : ShutdownDeleteNodeQuery
  body : ShutdownDeleteNodeBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ShutdownDeleteNodeRequest::new(
  node_id : String,
  query? : ShutdownDeleteNodeQuery = ShutdownDeleteNodeQuery::new(),
  body? : ShutdownDeleteNodeBody,
) -> ShutdownDeleteNodeRequest {
  { node_id, query, body }
}

///|
pub async fn Client::shutdown_delete_node(
  self : Client,
  request : ShutdownDeleteNodeRequest,
) -> EsResponse[ShutdownDeleteNodeResponse] {
  let params : Map[String, String] = Map([])
  params["node_id"] = request.node_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_nodes/{node_id}/shutdown", ["node_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct ShutdownGetNodeQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ShutdownGetNodeQuery with fn to_json(
  self : ShutdownGetNodeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ShutdownGetNodeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ShutdownGetNodeQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn ShutdownGetNodeQuery::new(
  master_timeout? : String,
) -> ShutdownGetNodeQuery {
  { master_timeout, }
}

///|
pub fn ShutdownGetNodeQuery::to_pairs(
  self : ShutdownGetNodeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type ShutdownGetNodeBody = Json

///|
pub(all) struct ShutdownGetNodeResponse {
  nodes : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for ShutdownGetNodeResponse with fn to_json(
  self : ShutdownGetNodeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for ShutdownGetNodeResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ShutdownGetNodeResponse: expected object"))
  }
  {
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct ShutdownGetNodeRequest {
  node_id : String?
  query : ShutdownGetNodeQuery
  body : ShutdownGetNodeBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ShutdownGetNodeRequest::new(
  node_id? : String,
  query? : ShutdownGetNodeQuery = ShutdownGetNodeQuery::new(),
  body? : ShutdownGetNodeBody,
) -> ShutdownGetNodeRequest {
  { node_id, query, body }
}

///|
pub async fn Client::shutdown_get_node(
  self : Client,
  request : ShutdownGetNodeRequest,
) -> EsResponse[ShutdownGetNodeResponse] {
  let params : Map[String, String] = Map([])
  match request.node_id {
    Some(value) => params["node_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_nodes/{node_id}/shutdown", ["node_id"]),
      PathVariant::new("/_nodes/shutdown", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct ShutdownPutNodeQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ShutdownPutNodeQuery with fn to_json(
  self : ShutdownPutNodeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ShutdownPutNodeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ShutdownPutNodeQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn ShutdownPutNodeQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> ShutdownPutNodeQuery {
  { master_timeout, timeout }
}

///|
pub fn ShutdownPutNodeQuery::to_pairs(
  self : ShutdownPutNodeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct ShutdownPutNodeBody {
  type_ : Json
  reason : String
  allocation_delay : String?
  target_node_name : String?
} derive(Eq, Debug)

///|
pub impl ToJson for ShutdownPutNodeBody with fn to_json(
  self : ShutdownPutNodeBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["type"] = self.type_.to_json()
  obj["reason"] = self.reason.to_json()
  match self.allocation_delay {
    Some(value) => obj["allocation_delay"] = value.to_json()
    None => ()
  }
  match self.target_node_name {
    Some(value) => obj["target_node_name"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for ShutdownPutNodeBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "ShutdownPutNodeBody: expected object"))
  }
  {
    type_: @json.from_json(
      obj.get("type").unwrap_or(Json::null()),
      path=path.add_key("type"),
    ),
    reason: @json.from_json(
      obj.get("reason").unwrap_or(Json::null()),
      path=path.add_key("reason"),
    ),
    allocation_delay: match obj.get("allocation_delay") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allocation_delay")))
    },
    target_node_name: match obj.get("target_node_name") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("target_node_name")))
    },
  }
}

///|
pub fn ShutdownPutNodeBody::new(
  type_ : Json,
  reason : String,
  allocation_delay? : String,
  target_node_name? : String,
) -> ShutdownPutNodeBody {
  { type_, reason, allocation_delay, target_node_name }
}

///|
pub type ShutdownPutNodeResponse = Json

///|
pub(all) struct ShutdownPutNodeRequest {
  node_id : String
  query : ShutdownPutNodeQuery
  body : ShutdownPutNodeBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn ShutdownPutNodeRequest::new(
  node_id : String,
  body : ShutdownPutNodeBody,
  query? : ShutdownPutNodeQuery = ShutdownPutNodeQuery::new(),
) -> ShutdownPutNodeRequest {
  { node_id, query, body }
}

///|
pub async fn Client::shutdown_put_node(
  self : Client,
  request : ShutdownPutNodeRequest,
) -> EsResponse[ShutdownPutNodeResponse] {
  let params : Map[String, String] = Map([])
  params["node_id"] = request.node_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_nodes/{node_id}/shutdown", ["node_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SimulateIngestQuery {
  pipeline : String?
  merge_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SimulateIngestQuery with fn to_json(
  self : SimulateIngestQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.pipeline {
    Some(value) => obj["pipeline"] = value.to_json()
    None => ()
  }
  match self.merge_type {
    Some(value) => obj["merge_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SimulateIngestQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SimulateIngestQuery: expected object"))
  }
  {
    pipeline: match obj.get("pipeline") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pipeline")))
    },
    merge_type: match obj.get("merge_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("merge_type")))
    },
  }
}

///|
pub fn SimulateIngestQuery::new(
  pipeline? : String,
  merge_type? : String,
) -> SimulateIngestQuery {
  { pipeline, merge_type }
}

///|
pub fn SimulateIngestQuery::to_pairs(
  self : SimulateIngestQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.pipeline {
    Some(value) => push_query_json(pairs, "pipeline", value.to_json())
    None => ()
  }
  match self.merge_type {
    Some(value) => push_query_json(pairs, "merge_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SimulateIngestBody {
  docs : Array[Json]
  component_template_substitutions : Map[String, Json]?
  index_template_substitutions : Map[String, Json]?
  mapping_addition : Json?
  pipeline_substitutions : Map[String, Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SimulateIngestBody with fn to_json(
  self : SimulateIngestBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  match self.component_template_substitutions {
    Some(value) => obj["component_template_substitutions"] = value.to_json()
    None => ()
  }
  match self.index_template_substitutions {
    Some(value) => obj["index_template_substitutions"] = value.to_json()
    None => ()
  }
  match self.mapping_addition {
    Some(value) => obj["mapping_addition"] = value.to_json()
    None => ()
  }
  match self.pipeline_substitutions {
    Some(value) => obj["pipeline_substitutions"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SimulateIngestBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SimulateIngestBody: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
    component_template_substitutions: match
      obj.get("component_template_substitutions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("component_template_substitutions"),
          ),
        )
    },
    index_template_substitutions: match
      obj.get("index_template_substitutions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("index_template_substitutions"),
          ),
        )
    },
    mapping_addition: match obj.get("mapping_addition") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("mapping_addition")))
    },
    pipeline_substitutions: match obj.get("pipeline_substitutions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("pipeline_substitutions")),
        )
    },
  }
}

///|
pub fn SimulateIngestBody::new(
  docs : Array[Json],
  component_template_substitutions? : Map[String, Json],
  index_template_substitutions? : Map[String, Json],
  mapping_addition? : Json,
  pipeline_substitutions? : Map[String, Json],
) -> SimulateIngestBody {
  {
    docs,
    component_template_substitutions,
    index_template_substitutions,
    mapping_addition,
    pipeline_substitutions,
  }
}

///|
pub(all) struct SimulateIngestResponse {
  docs : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SimulateIngestResponse with fn to_json(
  self : SimulateIngestResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["docs"] = self.docs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SimulateIngestResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SimulateIngestResponse: expected object"))
  }
  {
    docs: @json.from_json(
      obj.get("docs").unwrap_or(Json::null()),
      path=path.add_key("docs"),
    ),
  }
}

///|
pub(all) struct SimulateIngestRequest {
  index : String?
  query : SimulateIngestQuery
  body : SimulateIngestBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SimulateIngestRequest::new(
  body : SimulateIngestBody,
  index? : String,
  query? : SimulateIngestQuery = SimulateIngestQuery::new(),
) -> SimulateIngestRequest {
  { index, query, body }
}

///|
pub async fn Client::simulate_ingest(
  self : Client,
  request : SimulateIngestRequest,
) -> EsResponse[SimulateIngestResponse] {
  let params : Map[String, String] = Map([])
  match request.index {
    Some(value) => params["index"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_ingest/{index}/_simulate", ["index"]),
      PathVariant::new("/_ingest/_simulate", []),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SlmDeleteLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmDeleteLifecycleQuery with fn to_json(
  self : SlmDeleteLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmDeleteLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmDeleteLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmDeleteLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmDeleteLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmDeleteLifecycleQuery::to_pairs(
  self : SlmDeleteLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SlmDeleteLifecycleResponse = Json

///|
pub(all) struct SlmDeleteLifecycleRequest {
  policy_id : String
  query : SlmDeleteLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmDeleteLifecycleRequest::new(
  policy_id : String,
  query? : SlmDeleteLifecycleQuery = SlmDeleteLifecycleQuery::new(),
) -> SlmDeleteLifecycleRequest {
  { policy_id, query }
}

///|
pub async fn Client::slm_delete_lifecycle(
  self : Client,
  request : SlmDeleteLifecycleRequest,
) -> EsResponse[SlmDeleteLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["policy_id"] = request.policy_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_slm/policy/{policy_id}", ["policy_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SlmExecuteLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmExecuteLifecycleQuery with fn to_json(
  self : SlmExecuteLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmExecuteLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmExecuteLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmExecuteLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmExecuteLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmExecuteLifecycleQuery::to_pairs(
  self : SlmExecuteLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SlmExecuteLifecycleResponse {
  snapshot_name : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SlmExecuteLifecycleResponse with fn to_json(
  self : SlmExecuteLifecycleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["snapshot_name"] = self.snapshot_name.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SlmExecuteLifecycleResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SlmExecuteLifecycleResponse: expected object"),
    )
  }
  {
    snapshot_name: @json.from_json(
      obj.get("snapshot_name").unwrap_or(Json::null()),
      path=path.add_key("snapshot_name"),
    ),
  }
}

///|
pub(all) struct SlmExecuteLifecycleRequest {
  policy_id : String
  query : SlmExecuteLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmExecuteLifecycleRequest::new(
  policy_id : String,
  query? : SlmExecuteLifecycleQuery = SlmExecuteLifecycleQuery::new(),
) -> SlmExecuteLifecycleRequest {
  { policy_id, query }
}

///|
pub async fn Client::slm_execute_lifecycle(
  self : Client,
  request : SlmExecuteLifecycleRequest,
) -> EsResponse[SlmExecuteLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["policy_id"] = request.policy_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_slm/policy/{policy_id}/_execute", ["policy_id"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct SlmExecuteRetentionQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmExecuteRetentionQuery with fn to_json(
  self : SlmExecuteRetentionQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmExecuteRetentionQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmExecuteRetentionQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmExecuteRetentionQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmExecuteRetentionQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmExecuteRetentionQuery::to_pairs(
  self : SlmExecuteRetentionQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SlmExecuteRetentionResponse = Json

///|
pub(all) struct SlmExecuteRetentionRequest {
  query : SlmExecuteRetentionQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmExecuteRetentionRequest::new(
  query? : SlmExecuteRetentionQuery = SlmExecuteRetentionQuery::new(),
) -> SlmExecuteRetentionRequest {
  { query, }
}

///|
pub async fn Client::slm_execute_retention(
  self : Client,
  request : SlmExecuteRetentionRequest,
) -> EsResponse[SlmExecuteRetentionResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_slm/_execute_retention", [])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SlmGetLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmGetLifecycleQuery with fn to_json(
  self : SlmGetLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmGetLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmGetLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmGetLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmGetLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmGetLifecycleQuery::to_pairs(
  self : SlmGetLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SlmGetLifecycleResponse = Json

///|
pub(all) struct SlmGetLifecycleRequest {
  policy_id : String?
  query : SlmGetLifecycleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmGetLifecycleRequest::new(
  policy_id? : String,
  query? : SlmGetLifecycleQuery = SlmGetLifecycleQuery::new(),
) -> SlmGetLifecycleRequest {
  { policy_id, query }
}

///|
pub async fn Client::slm_get_lifecycle(
  self : Client,
  request : SlmGetLifecycleRequest,
) -> EsResponse[SlmGetLifecycleResponse] {
  let params : Map[String, String] = Map([])
  match request.policy_id {
    Some(value) => params["policy_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_slm/policy/{policy_id}", ["policy_id"]),
      PathVariant::new("/_slm/policy", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SlmGetStatsQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmGetStatsQuery with fn to_json(self : SlmGetStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmGetStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmGetStatsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmGetStatsQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmGetStatsQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmGetStatsQuery::to_pairs(
  self : SlmGetStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SlmGetStatsResponse {
  retention_deletion_time : Json
  retention_deletion_time_millis : Json
  retention_failed : Int
  retention_runs : Int
  retention_timed_out : Int
  total_snapshots_deleted : Int
  total_snapshot_deletion_failures : Int
  total_snapshots_failed : Int
  total_snapshots_taken : Int
  policy_stats : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SlmGetStatsResponse with fn to_json(
  self : SlmGetStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["retention_deletion_time"] = self.retention_deletion_time.to_json()
  obj["retention_deletion_time_millis"] = self.retention_deletion_time_millis.to_json()
  obj["retention_failed"] = self.retention_failed.to_json()
  obj["retention_runs"] = self.retention_runs.to_json()
  obj["retention_timed_out"] = self.retention_timed_out.to_json()
  obj["total_snapshots_deleted"] = self.total_snapshots_deleted.to_json()
  obj["total_snapshot_deletion_failures"] = self.total_snapshot_deletion_failures.to_json()
  obj["total_snapshots_failed"] = self.total_snapshots_failed.to_json()
  obj["total_snapshots_taken"] = self.total_snapshots_taken.to_json()
  obj["policy_stats"] = self.policy_stats.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SlmGetStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmGetStatsResponse: expected object"))
  }
  {
    retention_deletion_time: @json.from_json(
      obj.get("retention_deletion_time").unwrap_or(Json::null()),
      path=path.add_key("retention_deletion_time"),
    ),
    retention_deletion_time_millis: @json.from_json(
      obj.get("retention_deletion_time_millis").unwrap_or(Json::null()),
      path=path.add_key("retention_deletion_time_millis"),
    ),
    retention_failed: @json.from_json(
      obj.get("retention_failed").unwrap_or(Json::null()),
      path=path.add_key("retention_failed"),
    ),
    retention_runs: @json.from_json(
      obj.get("retention_runs").unwrap_or(Json::null()),
      path=path.add_key("retention_runs"),
    ),
    retention_timed_out: @json.from_json(
      obj.get("retention_timed_out").unwrap_or(Json::null()),
      path=path.add_key("retention_timed_out"),
    ),
    total_snapshots_deleted: @json.from_json(
      obj.get("total_snapshots_deleted").unwrap_or(Json::null()),
      path=path.add_key("total_snapshots_deleted"),
    ),
    total_snapshot_deletion_failures: @json.from_json(
      obj.get("total_snapshot_deletion_failures").unwrap_or(Json::null()),
      path=path.add_key("total_snapshot_deletion_failures"),
    ),
    total_snapshots_failed: @json.from_json(
      obj.get("total_snapshots_failed").unwrap_or(Json::null()),
      path=path.add_key("total_snapshots_failed"),
    ),
    total_snapshots_taken: @json.from_json(
      obj.get("total_snapshots_taken").unwrap_or(Json::null()),
      path=path.add_key("total_snapshots_taken"),
    ),
    policy_stats: @json.from_json(
      obj.get("policy_stats").unwrap_or(Json::null()),
      path=path.add_key("policy_stats"),
    ),
  }
}

///|
pub(all) struct SlmGetStatsRequest {
  query : SlmGetStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmGetStatsRequest::new(
  query? : SlmGetStatsQuery = SlmGetStatsQuery::new(),
) -> SlmGetStatsRequest {
  { query, }
}

///|
pub async fn Client::slm_get_stats(
  self : Client,
  request : SlmGetStatsRequest,
) -> EsResponse[SlmGetStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_slm/stats", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SlmGetStatusQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmGetStatusQuery with fn to_json(self : SlmGetStatusQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmGetStatusQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmGetStatusQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmGetStatusQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmGetStatusQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmGetStatusQuery::to_pairs(
  self : SlmGetStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SlmGetStatusResponse {
  operation_mode : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SlmGetStatusResponse with fn to_json(
  self : SlmGetStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["operation_mode"] = self.operation_mode.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SlmGetStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmGetStatusResponse: expected object"))
  }
  {
    operation_mode: @json.from_json(
      obj.get("operation_mode").unwrap_or(Json::null()),
      path=path.add_key("operation_mode"),
    ),
  }
}

///|
pub(all) struct SlmGetStatusRequest {
  query : SlmGetStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmGetStatusRequest::new(
  query? : SlmGetStatusQuery = SlmGetStatusQuery::new(),
) -> SlmGetStatusRequest {
  { query, }
}

///|
pub async fn Client::slm_get_status(
  self : Client,
  request : SlmGetStatusRequest,
) -> EsResponse[SlmGetStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_slm/status", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SlmPutLifecycleQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmPutLifecycleQuery with fn to_json(
  self : SlmPutLifecycleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmPutLifecycleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmPutLifecycleQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmPutLifecycleQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmPutLifecycleQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmPutLifecycleQuery::to_pairs(
  self : SlmPutLifecycleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SlmPutLifecycleBody {
  config : Json?
  name : Json?
  repository : String?
  retention : Json?
  schedule : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmPutLifecycleBody with fn to_json(
  self : SlmPutLifecycleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.config {
    Some(value) => obj["config"] = value.to_json()
    None => ()
  }
  match self.name {
    Some(value) => obj["name"] = value.to_json()
    None => ()
  }
  match self.repository {
    Some(value) => obj["repository"] = value.to_json()
    None => ()
  }
  match self.retention {
    Some(value) => obj["retention"] = value.to_json()
    None => ()
  }
  match self.schedule {
    Some(value) => obj["schedule"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmPutLifecycleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmPutLifecycleBody: expected object"))
  }
  {
    config: match obj.get("config") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("config")))
    },
    name: match obj.get("name") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("name")))
    },
    repository: match obj.get("repository") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("repository")))
    },
    retention: match obj.get("retention") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retention")))
    },
    schedule: match obj.get("schedule") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("schedule")))
    },
  }
}

///|
pub fn SlmPutLifecycleBody::new(
  config? : Json,
  name? : Json,
  repository? : String,
  retention? : Json,
  schedule? : Json,
) -> SlmPutLifecycleBody {
  { config, name, repository, retention, schedule }
}

///|
pub type SlmPutLifecycleResponse = Json

///|
pub(all) struct SlmPutLifecycleRequest {
  policy_id : String
  query : SlmPutLifecycleQuery
  body : SlmPutLifecycleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmPutLifecycleRequest::new(
  policy_id : String,
  body : SlmPutLifecycleBody,
  query? : SlmPutLifecycleQuery = SlmPutLifecycleQuery::new(),
) -> SlmPutLifecycleRequest {
  { policy_id, query, body }
}

///|
pub async fn Client::slm_put_lifecycle(
  self : Client,
  request : SlmPutLifecycleRequest,
) -> EsResponse[SlmPutLifecycleResponse] {
  let params : Map[String, String] = Map([])
  params["policy_id"] = request.policy_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_slm/policy/{policy_id}", ["policy_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SlmStartQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmStartQuery with fn to_json(self : SlmStartQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmStartQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmStartQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmStartQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmStartQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmStartQuery::to_pairs(self : SlmStartQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SlmStartResponse = Json

///|
pub(all) struct SlmStartRequest {
  query : SlmStartQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmStartRequest::new(
  query? : SlmStartQuery = SlmStartQuery::new(),
) -> SlmStartRequest {
  { query, }
}

///|
pub async fn Client::slm_start(
  self : Client,
  request : SlmStartRequest,
) -> EsResponse[SlmStartResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_slm/start", [])], params)
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SlmStopQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SlmStopQuery with fn to_json(self : SlmStopQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SlmStopQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SlmStopQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SlmStopQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SlmStopQuery {
  { master_timeout, timeout }
}

///|
pub fn SlmStopQuery::to_pairs(self : SlmStopQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SlmStopResponse = Json

///|
pub(all) struct SlmStopRequest {
  query : SlmStopQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SlmStopRequest::new(
  query? : SlmStopQuery = SlmStopQuery::new(),
) -> SlmStopRequest {
  { query, }
}

///|
pub async fn Client::slm_stop(
  self : Client,
  request : SlmStopRequest,
) -> EsResponse[SlmStopResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_slm/stop", [])], params)
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SnapshotCleanupRepositoryQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCleanupRepositoryQuery with fn to_json(
  self : SnapshotCleanupRepositoryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCleanupRepositoryQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotCleanupRepositoryQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SnapshotCleanupRepositoryQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SnapshotCleanupRepositoryQuery {
  { master_timeout, timeout }
}

///|
pub fn SnapshotCleanupRepositoryQuery::to_pairs(
  self : SnapshotCleanupRepositoryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotCleanupRepositoryResponse {
  results : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCleanupRepositoryResponse with fn to_json(
  self : SnapshotCleanupRepositoryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["results"] = self.results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCleanupRepositoryResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotCleanupRepositoryResponse: expected object"),
    )
  }
  {
    results: @json.from_json(
      obj.get("results").unwrap_or(Json::null()),
      path=path.add_key("results"),
    ),
  }
}

///|
pub(all) struct SnapshotCleanupRepositoryRequest {
  repository : String
  query : SnapshotCleanupRepositoryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotCleanupRepositoryRequest::new(
  repository : String,
  query? : SnapshotCleanupRepositoryQuery = SnapshotCleanupRepositoryQuery::new(),
) -> SnapshotCleanupRepositoryRequest {
  { repository, query }
}

///|
pub async fn Client::snapshot_cleanup_repository(
  self : Client,
  request : SnapshotCleanupRepositoryRequest,
) -> EsResponse[SnapshotCleanupRepositoryResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_snapshot/{repository}/_cleanup", ["repository"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SnapshotCloneQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCloneQuery with fn to_json(
  self : SnapshotCloneQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCloneQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotCloneQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn SnapshotCloneQuery::new(master_timeout? : String) -> SnapshotCloneQuery {
  { master_timeout, }
}

///|
pub fn SnapshotCloneQuery::to_pairs(
  self : SnapshotCloneQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotCloneBody {
  indices : String
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCloneBody with fn to_json(self : SnapshotCloneBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["indices"] = self.indices.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCloneBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotCloneBody: expected object"))
  }
  {
    indices: @json.from_json(
      obj.get("indices").unwrap_or(Json::null()),
      path=path.add_key("indices"),
    ),
  }
}

///|
pub fn SnapshotCloneBody::new(indices : String) -> SnapshotCloneBody {
  { indices, }
}

///|
pub type SnapshotCloneResponse = Json

///|
pub(all) struct SnapshotCloneRequest {
  repository : String
  snapshot : String
  target_snapshot : String
  query : SnapshotCloneQuery
  body : SnapshotCloneBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotCloneRequest::new(
  repository : String,
  snapshot : String,
  target_snapshot : String,
  body : SnapshotCloneBody,
  query? : SnapshotCloneQuery = SnapshotCloneQuery::new(),
) -> SnapshotCloneRequest {
  { repository, snapshot, target_snapshot, query, body }
}

///|
pub async fn Client::snapshot_clone(
  self : Client,
  request : SnapshotCloneRequest,
) -> EsResponse[SnapshotCloneResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  params["snapshot"] = request.snapshot
  params["target_snapshot"] = request.target_snapshot
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new(
        "/_snapshot/{repository}/{snapshot}/_clone/{target_snapshot}",
        ["repository", "snapshot", "target_snapshot"],
      ),
    ],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SnapshotCreateQuery {
  master_timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCreateQuery with fn to_json(
  self : SnapshotCreateQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCreateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotCreateQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn SnapshotCreateQuery::new(
  master_timeout? : String,
  wait_for_completion? : Bool,
) -> SnapshotCreateQuery {
  { master_timeout, wait_for_completion }
}

///|
pub fn SnapshotCreateQuery::to_pairs(
  self : SnapshotCreateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotCreateBody {
  expand_wildcards : Json?
  feature_states : Array[String]?
  ignore_unavailable : Bool?
  include_global_state : Bool?
  indices : Json?
  metadata : Json?
  partial : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCreateBody with fn to_json(
  self : SnapshotCreateBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.feature_states {
    Some(value) => obj["feature_states"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_global_state {
    Some(value) => obj["include_global_state"] = value.to_json()
    None => ()
  }
  match self.indices {
    Some(value) => obj["indices"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.partial {
    Some(value) => obj["partial"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCreateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotCreateBody: expected object"))
  }
  {
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    feature_states: match obj.get("feature_states") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("feature_states")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_global_state: match obj.get("include_global_state") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_global_state")))
    },
    indices: match obj.get("indices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("indices")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    partial: match obj.get("partial") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("partial")))
    },
  }
}

///|
pub fn SnapshotCreateBody::new(
  expand_wildcards? : Json,
  feature_states? : Array[String],
  ignore_unavailable? : Bool,
  include_global_state? : Bool,
  indices? : Json,
  metadata? : Json,
  partial? : Bool,
) -> SnapshotCreateBody {
  {
    expand_wildcards,
    feature_states,
    ignore_unavailable,
    include_global_state,
    indices,
    metadata,
    partial,
  }
}

///|
pub(all) struct SnapshotCreateResponse {
  accepted : Bool?
  snapshot : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCreateResponse with fn to_json(
  self : SnapshotCreateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.accepted {
    Some(value) => obj["accepted"] = value.to_json()
    None => ()
  }
  match self.snapshot {
    Some(value) => obj["snapshot"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCreateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotCreateResponse: expected object"))
  }
  {
    accepted: match obj.get("accepted") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("accepted")))
    },
    snapshot: match obj.get("snapshot") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("snapshot")))
    },
  }
}

///|
pub(all) struct SnapshotCreateRequest {
  repository : String
  snapshot : String
  query : SnapshotCreateQuery
  body : SnapshotCreateBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotCreateRequest::new(
  repository : String,
  snapshot : String,
  query? : SnapshotCreateQuery = SnapshotCreateQuery::new(),
  body? : SnapshotCreateBody,
) -> SnapshotCreateRequest {
  { repository, snapshot, query, body }
}

///|
pub async fn Client::snapshot_create(
  self : Client,
  request : SnapshotCreateRequest,
) -> EsResponse[SnapshotCreateResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  params["snapshot"] = request.snapshot
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/{snapshot}", [
        "repository", "snapshot",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SnapshotCreateRepositoryQuery {
  master_timeout : String?
  timeout : String?
  verify : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotCreateRepositoryQuery with fn to_json(
  self : SnapshotCreateRepositoryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.verify {
    Some(value) => obj["verify"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotCreateRepositoryQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotCreateRepositoryQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    verify: match obj.get("verify") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("verify")))
    },
  }
}

///|
pub fn SnapshotCreateRepositoryQuery::new(
  master_timeout? : String,
  timeout? : String,
  verify? : Bool,
) -> SnapshotCreateRepositoryQuery {
  { master_timeout, timeout, verify }
}

///|
pub fn SnapshotCreateRepositoryQuery::to_pairs(
  self : SnapshotCreateRepositoryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.verify {
    Some(value) => push_query_json(pairs, "verify", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SnapshotCreateRepositoryBody = Json

///|
pub type SnapshotCreateRepositoryResponse = Json

///|
pub(all) struct SnapshotCreateRepositoryRequest {
  repository : String
  query : SnapshotCreateRepositoryQuery
  body : SnapshotCreateRepositoryBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotCreateRepositoryRequest::new(
  repository : String,
  body : SnapshotCreateRepositoryBody,
  query? : SnapshotCreateRepositoryQuery = SnapshotCreateRepositoryQuery::new(),
) -> SnapshotCreateRepositoryRequest {
  { repository, query, body }
}

///|
pub async fn Client::snapshot_create_repository(
  self : Client,
  request : SnapshotCreateRepositoryRequest,
) -> EsResponse[SnapshotCreateRepositoryResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_snapshot/{repository}", ["repository"])],
    params,
  )
  let body = JsonBody(request.body)
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SnapshotDeleteQuery {
  master_timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotDeleteQuery with fn to_json(
  self : SnapshotDeleteQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotDeleteQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotDeleteQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn SnapshotDeleteQuery::new(
  master_timeout? : String,
  wait_for_completion? : Bool,
) -> SnapshotDeleteQuery {
  { master_timeout, wait_for_completion }
}

///|
pub fn SnapshotDeleteQuery::to_pairs(
  self : SnapshotDeleteQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SnapshotDeleteResponse = Json

///|
pub(all) struct SnapshotDeleteRequest {
  repository : String
  snapshot : String
  query : SnapshotDeleteQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotDeleteRequest::new(
  repository : String,
  snapshot : String,
  query? : SnapshotDeleteQuery = SnapshotDeleteQuery::new(),
) -> SnapshotDeleteRequest {
  { repository, snapshot, query }
}

///|
pub async fn Client::snapshot_delete(
  self : Client,
  request : SnapshotDeleteRequest,
) -> EsResponse[SnapshotDeleteResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  params["snapshot"] = request.snapshot
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/{snapshot}", [
        "repository", "snapshot",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SnapshotDeleteRepositoryQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotDeleteRepositoryQuery with fn to_json(
  self : SnapshotDeleteRepositoryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotDeleteRepositoryQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotDeleteRepositoryQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SnapshotDeleteRepositoryQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SnapshotDeleteRepositoryQuery {
  { master_timeout, timeout }
}

///|
pub fn SnapshotDeleteRepositoryQuery::to_pairs(
  self : SnapshotDeleteRepositoryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SnapshotDeleteRepositoryResponse = Json

///|
pub(all) struct SnapshotDeleteRepositoryRequest {
  repository : String
  query : SnapshotDeleteRepositoryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotDeleteRepositoryRequest::new(
  repository : String,
  query? : SnapshotDeleteRepositoryQuery = SnapshotDeleteRepositoryQuery::new(),
) -> SnapshotDeleteRepositoryRequest {
  { repository, query }
}

///|
pub async fn Client::snapshot_delete_repository(
  self : Client,
  request : SnapshotDeleteRepositoryRequest,
) -> EsResponse[SnapshotDeleteRepositoryResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_snapshot/{repository}", ["repository"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SnapshotGetQuery {
  after : String?
  from_sort_value : String?
  ignore_unavailable : Bool?
  index_details : Bool?
  index_names : Bool?
  include_repository : Bool?
  master_timeout : String?
  order : String?
  offset : Int?
  size : Int?
  slm_policy_filter : String?
  sort : String?
  state : Json?
  verbose : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotGetQuery with fn to_json(self : SnapshotGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.after {
    Some(value) => obj["after"] = value.to_json()
    None => ()
  }
  match self.from_sort_value {
    Some(value) => obj["from_sort_value"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.index_details {
    Some(value) => obj["index_details"] = value.to_json()
    None => ()
  }
  match self.index_names {
    Some(value) => obj["index_names"] = value.to_json()
    None => ()
  }
  match self.include_repository {
    Some(value) => obj["include_repository"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.order {
    Some(value) => obj["order"] = value.to_json()
    None => ()
  }
  match self.offset {
    Some(value) => obj["offset"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.slm_policy_filter {
    Some(value) => obj["slm_policy_filter"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.state {
    Some(value) => obj["state"] = value.to_json()
    None => ()
  }
  match self.verbose {
    Some(value) => obj["verbose"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotGetQuery: expected object"))
  }
  {
    after: match obj.get("after") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("after")))
    },
    from_sort_value: match obj.get("from_sort_value") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("from_sort_value")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    index_details: match obj.get("index_details") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_details")))
    },
    index_names: match obj.get("index_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_names")))
    },
    include_repository: match obj.get("include_repository") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_repository")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    order: match obj.get("order") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("order")))
    },
    offset: match obj.get("offset") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("offset")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    slm_policy_filter: match obj.get("slm_policy_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("slm_policy_filter")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    state: match obj.get("state") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("state")))
    },
    verbose: match obj.get("verbose") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("verbose")))
    },
  }
}

///|
pub fn SnapshotGetQuery::new(
  after? : String,
  from_sort_value? : String,
  ignore_unavailable? : Bool,
  index_details? : Bool,
  index_names? : Bool,
  include_repository? : Bool,
  master_timeout? : String,
  order? : String,
  offset? : Int,
  size? : Int,
  slm_policy_filter? : String,
  sort? : String,
  state? : Json,
  verbose? : Bool,
) -> SnapshotGetQuery {
  {
    after,
    from_sort_value,
    ignore_unavailable,
    index_details,
    index_names,
    include_repository,
    master_timeout,
    order,
    offset,
    size,
    slm_policy_filter,
    sort,
    state,
    verbose,
  }
}

///|
pub fn SnapshotGetQuery::to_pairs(
  self : SnapshotGetQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.after {
    Some(value) => push_query_json(pairs, "after", value.to_json())
    None => ()
  }
  match self.from_sort_value {
    Some(value) => push_query_json(pairs, "from_sort_value", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.index_details {
    Some(value) => push_query_json(pairs, "index_details", value.to_json())
    None => ()
  }
  match self.index_names {
    Some(value) => push_query_json(pairs, "index_names", value.to_json())
    None => ()
  }
  match self.include_repository {
    Some(value) => push_query_json(pairs, "include_repository", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.order {
    Some(value) => push_query_json(pairs, "order", value.to_json())
    None => ()
  }
  match self.offset {
    Some(value) => push_query_json(pairs, "offset", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.slm_policy_filter {
    Some(value) => push_query_json(pairs, "slm_policy_filter", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.state {
    Some(value) => push_query_json(pairs, "state", value.to_json())
    None => ()
  }
  match self.verbose {
    Some(value) => push_query_json(pairs, "verbose", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotGetResponse {
  remaining : Int
  total : Int
  next : String?
  responses : Array[Json]?
  snapshots : Array[Json]?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotGetResponse with fn to_json(
  self : SnapshotGetResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["remaining"] = self.remaining.to_json()
  obj["total"] = self.total.to_json()
  match self.next {
    Some(value) => obj["next"] = value.to_json()
    None => ()
  }
  match self.responses {
    Some(value) => obj["responses"] = value.to_json()
    None => ()
  }
  match self.snapshots {
    Some(value) => obj["snapshots"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotGetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotGetResponse: expected object"))
  }
  {
    remaining: @json.from_json(
      obj.get("remaining").unwrap_or(Json::null()),
      path=path.add_key("remaining"),
    ),
    total: @json.from_json(
      obj.get("total").unwrap_or(Json::null()),
      path=path.add_key("total"),
    ),
    next: match obj.get("next") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("next")))
    },
    responses: match obj.get("responses") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("responses")))
    },
    snapshots: match obj.get("snapshots") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("snapshots")))
    },
  }
}

///|
pub(all) struct SnapshotGetRequest {
  repository : String
  snapshot : String
  query : SnapshotGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotGetRequest::new(
  repository : String,
  snapshot : String,
  query? : SnapshotGetQuery = SnapshotGetQuery::new(),
) -> SnapshotGetRequest {
  { repository, snapshot, query }
}

///|
pub async fn Client::snapshot_get(
  self : Client,
  request : SnapshotGetRequest,
) -> EsResponse[SnapshotGetResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  params["snapshot"] = request.snapshot
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/{snapshot}", [
        "repository", "snapshot",
      ]),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SnapshotGetRepositoryQuery {
  local_ : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotGetRepositoryQuery with fn to_json(
  self : SnapshotGetRepositoryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.local_ {
    Some(value) => obj["local"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotGetRepositoryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotGetRepositoryQuery: expected object"))
  }
  {
    local_: match obj.get("local") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("local")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn SnapshotGetRepositoryQuery::new(
  local_? : Bool,
  master_timeout? : String,
) -> SnapshotGetRepositoryQuery {
  { local_, master_timeout }
}

///|
pub fn SnapshotGetRepositoryQuery::to_pairs(
  self : SnapshotGetRepositoryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.local_ {
    Some(value) => push_query_json(pairs, "local", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SnapshotGetRepositoryResponse = Json

///|
pub(all) struct SnapshotGetRepositoryRequest {
  repository : String?
  query : SnapshotGetRepositoryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotGetRepositoryRequest::new(
  repository? : String,
  query? : SnapshotGetRepositoryQuery = SnapshotGetRepositoryQuery::new(),
) -> SnapshotGetRepositoryRequest {
  { repository, query }
}

///|
pub async fn Client::snapshot_get_repository(
  self : Client,
  request : SnapshotGetRepositoryRequest,
) -> EsResponse[SnapshotGetRepositoryResponse] {
  let params : Map[String, String] = Map([])
  match request.repository {
    Some(value) => params["repository"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}", ["repository"]),
      PathVariant::new("/_snapshot", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SnapshotRepositoryAnalyzeQuery {
  blob_count : Int?
  check_overwrite_protection : Bool?
  concurrency : Int?
  detailed : Bool?
  early_read_node_count : Int?
  max_blob_size : String?
  max_total_data_size : String?
  rare_action_probability : Double?
  rarely_abort_writes : Bool?
  read_node_count : Int?
  register_operation_count : Int?
  seed : Int?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotRepositoryAnalyzeQuery with fn to_json(
  self : SnapshotRepositoryAnalyzeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.blob_count {
    Some(value) => obj["blob_count"] = value.to_json()
    None => ()
  }
  match self.check_overwrite_protection {
    Some(value) => obj["check_overwrite_protection"] = value.to_json()
    None => ()
  }
  match self.concurrency {
    Some(value) => obj["concurrency"] = value.to_json()
    None => ()
  }
  match self.detailed {
    Some(value) => obj["detailed"] = value.to_json()
    None => ()
  }
  match self.early_read_node_count {
    Some(value) => obj["early_read_node_count"] = value.to_json()
    None => ()
  }
  match self.max_blob_size {
    Some(value) => obj["max_blob_size"] = value.to_json()
    None => ()
  }
  match self.max_total_data_size {
    Some(value) => obj["max_total_data_size"] = value.to_json()
    None => ()
  }
  match self.rare_action_probability {
    Some(value) => obj["rare_action_probability"] = value.to_json()
    None => ()
  }
  match self.rarely_abort_writes {
    Some(value) => obj["rarely_abort_writes"] = value.to_json()
    None => ()
  }
  match self.read_node_count {
    Some(value) => obj["read_node_count"] = value.to_json()
    None => ()
  }
  match self.register_operation_count {
    Some(value) => obj["register_operation_count"] = value.to_json()
    None => ()
  }
  match self.seed {
    Some(value) => obj["seed"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotRepositoryAnalyzeQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotRepositoryAnalyzeQuery: expected object"),
    )
  }
  {
    blob_count: match obj.get("blob_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("blob_count")))
    },
    check_overwrite_protection: match obj.get("check_overwrite_protection") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("check_overwrite_protection"),
          ),
        )
    },
    concurrency: match obj.get("concurrency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("concurrency")))
    },
    detailed: match obj.get("detailed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detailed")))
    },
    early_read_node_count: match obj.get("early_read_node_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("early_read_node_count")))
    },
    max_blob_size: match obj.get("max_blob_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_blob_size")))
    },
    max_total_data_size: match obj.get("max_total_data_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_total_data_size")))
    },
    rare_action_probability: match obj.get("rare_action_probability") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("rare_action_probability")),
        )
    },
    rarely_abort_writes: match obj.get("rarely_abort_writes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("rarely_abort_writes")))
    },
    read_node_count: match obj.get("read_node_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("read_node_count")))
    },
    register_operation_count: match obj.get("register_operation_count") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("register_operation_count")),
        )
    },
    seed: match obj.get("seed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("seed")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SnapshotRepositoryAnalyzeQuery::new(
  blob_count? : Int,
  check_overwrite_protection? : Bool,
  concurrency? : Int,
  detailed? : Bool,
  early_read_node_count? : Int,
  max_blob_size? : String,
  max_total_data_size? : String,
  rare_action_probability? : Double,
  rarely_abort_writes? : Bool,
  read_node_count? : Int,
  register_operation_count? : Int,
  seed? : Int,
  timeout? : String,
) -> SnapshotRepositoryAnalyzeQuery {
  {
    blob_count,
    check_overwrite_protection,
    concurrency,
    detailed,
    early_read_node_count,
    max_blob_size,
    max_total_data_size,
    rare_action_probability,
    rarely_abort_writes,
    read_node_count,
    register_operation_count,
    seed,
    timeout,
  }
}

///|
pub fn SnapshotRepositoryAnalyzeQuery::to_pairs(
  self : SnapshotRepositoryAnalyzeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.blob_count {
    Some(value) => push_query_json(pairs, "blob_count", value.to_json())
    None => ()
  }
  match self.check_overwrite_protection {
    Some(value) =>
      push_query_json(pairs, "check_overwrite_protection", value.to_json())
    None => ()
  }
  match self.concurrency {
    Some(value) => push_query_json(pairs, "concurrency", value.to_json())
    None => ()
  }
  match self.detailed {
    Some(value) => push_query_json(pairs, "detailed", value.to_json())
    None => ()
  }
  match self.early_read_node_count {
    Some(value) =>
      push_query_json(pairs, "early_read_node_count", value.to_json())
    None => ()
  }
  match self.max_blob_size {
    Some(value) => push_query_json(pairs, "max_blob_size", value.to_json())
    None => ()
  }
  match self.max_total_data_size {
    Some(value) =>
      push_query_json(pairs, "max_total_data_size", value.to_json())
    None => ()
  }
  match self.rare_action_probability {
    Some(value) =>
      push_query_json(pairs, "rare_action_probability", value.to_json())
    None => ()
  }
  match self.rarely_abort_writes {
    Some(value) =>
      push_query_json(pairs, "rarely_abort_writes", value.to_json())
    None => ()
  }
  match self.read_node_count {
    Some(value) => push_query_json(pairs, "read_node_count", value.to_json())
    None => ()
  }
  match self.register_operation_count {
    Some(value) =>
      push_query_json(pairs, "register_operation_count", value.to_json())
    None => ()
  }
  match self.seed {
    Some(value) => push_query_json(pairs, "seed", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotRepositoryAnalyzeResponse {
  blob_count : Int
  blob_path : String
  concurrency : Int
  coordinating_node : Json
  delete_elapsed : Json
  delete_elapsed_nanos : Json
  details : Json
  early_read_node_count : Int
  issues_detected : Array[String]
  listing_elapsed : Json
  listing_elapsed_nanos : Json
  max_blob_size : Json
  max_blob_size_bytes : Int
  max_total_data_size : Json
  max_total_data_size_bytes : Int
  rare_action_probability : Double
  read_node_count : Int
  repository : String
  seed : Int
  summary : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotRepositoryAnalyzeResponse with fn to_json(
  self : SnapshotRepositoryAnalyzeResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["blob_count"] = self.blob_count.to_json()
  obj["blob_path"] = self.blob_path.to_json()
  obj["concurrency"] = self.concurrency.to_json()
  obj["coordinating_node"] = self.coordinating_node.to_json()
  obj["delete_elapsed"] = self.delete_elapsed.to_json()
  obj["delete_elapsed_nanos"] = self.delete_elapsed_nanos.to_json()
  obj["details"] = self.details.to_json()
  obj["early_read_node_count"] = self.early_read_node_count.to_json()
  obj["issues_detected"] = self.issues_detected.to_json()
  obj["listing_elapsed"] = self.listing_elapsed.to_json()
  obj["listing_elapsed_nanos"] = self.listing_elapsed_nanos.to_json()
  obj["max_blob_size"] = self.max_blob_size.to_json()
  obj["max_blob_size_bytes"] = self.max_blob_size_bytes.to_json()
  obj["max_total_data_size"] = self.max_total_data_size.to_json()
  obj["max_total_data_size_bytes"] = self.max_total_data_size_bytes.to_json()
  obj["rare_action_probability"] = self.rare_action_probability.to_json()
  obj["read_node_count"] = self.read_node_count.to_json()
  obj["repository"] = self.repository.to_json()
  obj["seed"] = self.seed.to_json()
  obj["summary"] = self.summary.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotRepositoryAnalyzeResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotRepositoryAnalyzeResponse: expected object"),
    )
  }
  {
    blob_count: @json.from_json(
      obj.get("blob_count").unwrap_or(Json::null()),
      path=path.add_key("blob_count"),
    ),
    blob_path: @json.from_json(
      obj.get("blob_path").unwrap_or(Json::null()),
      path=path.add_key("blob_path"),
    ),
    concurrency: @json.from_json(
      obj.get("concurrency").unwrap_or(Json::null()),
      path=path.add_key("concurrency"),
    ),
    coordinating_node: @json.from_json(
      obj.get("coordinating_node").unwrap_or(Json::null()),
      path=path.add_key("coordinating_node"),
    ),
    delete_elapsed: @json.from_json(
      obj.get("delete_elapsed").unwrap_or(Json::null()),
      path=path.add_key("delete_elapsed"),
    ),
    delete_elapsed_nanos: @json.from_json(
      obj.get("delete_elapsed_nanos").unwrap_or(Json::null()),
      path=path.add_key("delete_elapsed_nanos"),
    ),
    details: @json.from_json(
      obj.get("details").unwrap_or(Json::null()),
      path=path.add_key("details"),
    ),
    early_read_node_count: @json.from_json(
      obj.get("early_read_node_count").unwrap_or(Json::null()),
      path=path.add_key("early_read_node_count"),
    ),
    issues_detected: @json.from_json(
      obj.get("issues_detected").unwrap_or(Json::null()),
      path=path.add_key("issues_detected"),
    ),
    listing_elapsed: @json.from_json(
      obj.get("listing_elapsed").unwrap_or(Json::null()),
      path=path.add_key("listing_elapsed"),
    ),
    listing_elapsed_nanos: @json.from_json(
      obj.get("listing_elapsed_nanos").unwrap_or(Json::null()),
      path=path.add_key("listing_elapsed_nanos"),
    ),
    max_blob_size: @json.from_json(
      obj.get("max_blob_size").unwrap_or(Json::null()),
      path=path.add_key("max_blob_size"),
    ),
    max_blob_size_bytes: @json.from_json(
      obj.get("max_blob_size_bytes").unwrap_or(Json::null()),
      path=path.add_key("max_blob_size_bytes"),
    ),
    max_total_data_size: @json.from_json(
      obj.get("max_total_data_size").unwrap_or(Json::null()),
      path=path.add_key("max_total_data_size"),
    ),
    max_total_data_size_bytes: @json.from_json(
      obj.get("max_total_data_size_bytes").unwrap_or(Json::null()),
      path=path.add_key("max_total_data_size_bytes"),
    ),
    rare_action_probability: @json.from_json(
      obj.get("rare_action_probability").unwrap_or(Json::null()),
      path=path.add_key("rare_action_probability"),
    ),
    read_node_count: @json.from_json(
      obj.get("read_node_count").unwrap_or(Json::null()),
      path=path.add_key("read_node_count"),
    ),
    repository: @json.from_json(
      obj.get("repository").unwrap_or(Json::null()),
      path=path.add_key("repository"),
    ),
    seed: @json.from_json(
      obj.get("seed").unwrap_or(Json::null()),
      path=path.add_key("seed"),
    ),
    summary: @json.from_json(
      obj.get("summary").unwrap_or(Json::null()),
      path=path.add_key("summary"),
    ),
  }
}

///|
pub(all) struct SnapshotRepositoryAnalyzeRequest {
  repository : String
  query : SnapshotRepositoryAnalyzeQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotRepositoryAnalyzeRequest::new(
  repository : String,
  query? : SnapshotRepositoryAnalyzeQuery = SnapshotRepositoryAnalyzeQuery::new(),
) -> SnapshotRepositoryAnalyzeRequest {
  { repository, query }
}

///|
pub async fn Client::snapshot_repository_analyze(
  self : Client,
  request : SnapshotRepositoryAnalyzeRequest,
) -> EsResponse[SnapshotRepositoryAnalyzeResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_snapshot/{repository}/_analyze", ["repository"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SnapshotRepositoryVerifyIntegrityQuery {
  blob_thread_pool_concurrency : Int?
  index_snapshot_verification_concurrency : Int?
  index_verification_concurrency : Int?
  max_bytes_per_sec : String?
  max_failed_shard_snapshots : Int?
  meta_thread_pool_concurrency : Int?
  snapshot_verification_concurrency : Int?
  verify_blob_contents : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotRepositoryVerifyIntegrityQuery with fn to_json(
  self : SnapshotRepositoryVerifyIntegrityQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.blob_thread_pool_concurrency {
    Some(value) => obj["blob_thread_pool_concurrency"] = value.to_json()
    None => ()
  }
  match self.index_snapshot_verification_concurrency {
    Some(value) =>
      obj["index_snapshot_verification_concurrency"] = value.to_json()
    None => ()
  }
  match self.index_verification_concurrency {
    Some(value) => obj["index_verification_concurrency"] = value.to_json()
    None => ()
  }
  match self.max_bytes_per_sec {
    Some(value) => obj["max_bytes_per_sec"] = value.to_json()
    None => ()
  }
  match self.max_failed_shard_snapshots {
    Some(value) => obj["max_failed_shard_snapshots"] = value.to_json()
    None => ()
  }
  match self.meta_thread_pool_concurrency {
    Some(value) => obj["meta_thread_pool_concurrency"] = value.to_json()
    None => ()
  }
  match self.snapshot_verification_concurrency {
    Some(value) => obj["snapshot_verification_concurrency"] = value.to_json()
    None => ()
  }
  match self.verify_blob_contents {
    Some(value) => obj["verify_blob_contents"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotRepositoryVerifyIntegrityQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotRepositoryVerifyIntegrityQuery: expected object"),
    )
  }
  {
    blob_thread_pool_concurrency: match
      obj.get("blob_thread_pool_concurrency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("blob_thread_pool_concurrency"),
          ),
        )
    },
    index_snapshot_verification_concurrency: match
      obj.get("index_snapshot_verification_concurrency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("index_snapshot_verification_concurrency"),
          ),
        )
    },
    index_verification_concurrency: match
      obj.get("index_verification_concurrency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("index_verification_concurrency"),
          ),
        )
    },
    max_bytes_per_sec: match obj.get("max_bytes_per_sec") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("max_bytes_per_sec")))
    },
    max_failed_shard_snapshots: match obj.get("max_failed_shard_snapshots") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("max_failed_shard_snapshots"),
          ),
        )
    },
    meta_thread_pool_concurrency: match
      obj.get("meta_thread_pool_concurrency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("meta_thread_pool_concurrency"),
          ),
        )
    },
    snapshot_verification_concurrency: match
      obj.get("snapshot_verification_concurrency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("snapshot_verification_concurrency"),
          ),
        )
    },
    verify_blob_contents: match obj.get("verify_blob_contents") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("verify_blob_contents")))
    },
  }
}

///|
pub fn SnapshotRepositoryVerifyIntegrityQuery::new(
  blob_thread_pool_concurrency? : Int,
  index_snapshot_verification_concurrency? : Int,
  index_verification_concurrency? : Int,
  max_bytes_per_sec? : String,
  max_failed_shard_snapshots? : Int,
  meta_thread_pool_concurrency? : Int,
  snapshot_verification_concurrency? : Int,
  verify_blob_contents? : Bool,
) -> SnapshotRepositoryVerifyIntegrityQuery {
  {
    blob_thread_pool_concurrency,
    index_snapshot_verification_concurrency,
    index_verification_concurrency,
    max_bytes_per_sec,
    max_failed_shard_snapshots,
    meta_thread_pool_concurrency,
    snapshot_verification_concurrency,
    verify_blob_contents,
  }
}

///|
pub fn SnapshotRepositoryVerifyIntegrityQuery::to_pairs(
  self : SnapshotRepositoryVerifyIntegrityQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.blob_thread_pool_concurrency {
    Some(value) =>
      push_query_json(pairs, "blob_thread_pool_concurrency", value.to_json())
    None => ()
  }
  match self.index_snapshot_verification_concurrency {
    Some(value) =>
      push_query_json(
        pairs,
        "index_snapshot_verification_concurrency",
        value.to_json(),
      )
    None => ()
  }
  match self.index_verification_concurrency {
    Some(value) =>
      push_query_json(pairs, "index_verification_concurrency", value.to_json())
    None => ()
  }
  match self.max_bytes_per_sec {
    Some(value) => push_query_json(pairs, "max_bytes_per_sec", value.to_json())
    None => ()
  }
  match self.max_failed_shard_snapshots {
    Some(value) =>
      push_query_json(pairs, "max_failed_shard_snapshots", value.to_json())
    None => ()
  }
  match self.meta_thread_pool_concurrency {
    Some(value) =>
      push_query_json(pairs, "meta_thread_pool_concurrency", value.to_json())
    None => ()
  }
  match self.snapshot_verification_concurrency {
    Some(value) =>
      push_query_json(
        pairs,
        "snapshot_verification_concurrency",
        value.to_json(),
      )
    None => ()
  }
  match self.verify_blob_contents {
    Some(value) =>
      push_query_json(pairs, "verify_blob_contents", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SnapshotRepositoryVerifyIntegrityResponse = Json

///|
pub(all) struct SnapshotRepositoryVerifyIntegrityRequest {
  repository : String
  query : SnapshotRepositoryVerifyIntegrityQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotRepositoryVerifyIntegrityRequest::new(
  repository : String,
  query? : SnapshotRepositoryVerifyIntegrityQuery = SnapshotRepositoryVerifyIntegrityQuery::new(),
) -> SnapshotRepositoryVerifyIntegrityRequest {
  { repository, query }
}

///|
pub async fn Client::snapshot_repository_verify_integrity(
  self : Client,
  request : SnapshotRepositoryVerifyIntegrityRequest,
) -> EsResponse[SnapshotRepositoryVerifyIntegrityResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/_verify_integrity", [
        "repository",
      ]),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SnapshotRestoreQuery {
  master_timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotRestoreQuery with fn to_json(
  self : SnapshotRestoreQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotRestoreQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotRestoreQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn SnapshotRestoreQuery::new(
  master_timeout? : String,
  wait_for_completion? : Bool,
) -> SnapshotRestoreQuery {
  { master_timeout, wait_for_completion }
}

///|
pub fn SnapshotRestoreQuery::to_pairs(
  self : SnapshotRestoreQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotRestoreBody {
  feature_states : Array[String]?
  ignore_index_settings : Array[String]?
  ignore_unavailable : Bool?
  include_aliases : Bool?
  include_global_state : Bool?
  index_settings : Json?
  indices : Json?
  partial : Bool?
  rename_pattern : String?
  rename_replacement : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotRestoreBody with fn to_json(
  self : SnapshotRestoreBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.feature_states {
    Some(value) => obj["feature_states"] = value.to_json()
    None => ()
  }
  match self.ignore_index_settings {
    Some(value) => obj["ignore_index_settings"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.include_aliases {
    Some(value) => obj["include_aliases"] = value.to_json()
    None => ()
  }
  match self.include_global_state {
    Some(value) => obj["include_global_state"] = value.to_json()
    None => ()
  }
  match self.index_settings {
    Some(value) => obj["index_settings"] = value.to_json()
    None => ()
  }
  match self.indices {
    Some(value) => obj["indices"] = value.to_json()
    None => ()
  }
  match self.partial {
    Some(value) => obj["partial"] = value.to_json()
    None => ()
  }
  match self.rename_pattern {
    Some(value) => obj["rename_pattern"] = value.to_json()
    None => ()
  }
  match self.rename_replacement {
    Some(value) => obj["rename_replacement"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotRestoreBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotRestoreBody: expected object"))
  }
  {
    feature_states: match obj.get("feature_states") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("feature_states")))
    },
    ignore_index_settings: match obj.get("ignore_index_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_index_settings")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    include_aliases: match obj.get("include_aliases") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_aliases")))
    },
    include_global_state: match obj.get("include_global_state") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("include_global_state")))
    },
    index_settings: match obj.get("index_settings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_settings")))
    },
    indices: match obj.get("indices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("indices")))
    },
    partial: match obj.get("partial") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("partial")))
    },
    rename_pattern: match obj.get("rename_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("rename_pattern")))
    },
    rename_replacement: match obj.get("rename_replacement") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("rename_replacement")))
    },
  }
}

///|
pub fn SnapshotRestoreBody::new(
  feature_states? : Array[String],
  ignore_index_settings? : Array[String],
  ignore_unavailable? : Bool,
  include_aliases? : Bool,
  include_global_state? : Bool,
  index_settings? : Json,
  indices? : Json,
  partial? : Bool,
  rename_pattern? : String,
  rename_replacement? : String,
) -> SnapshotRestoreBody {
  {
    feature_states,
    ignore_index_settings,
    ignore_unavailable,
    include_aliases,
    include_global_state,
    index_settings,
    indices,
    partial,
    rename_pattern,
    rename_replacement,
  }
}

///|
pub(all) struct SnapshotRestoreResponse {
  accepted : Bool?
  snapshot : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotRestoreResponse with fn to_json(
  self : SnapshotRestoreResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.accepted {
    Some(value) => obj["accepted"] = value.to_json()
    None => ()
  }
  match self.snapshot {
    Some(value) => obj["snapshot"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotRestoreResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotRestoreResponse: expected object"))
  }
  {
    accepted: match obj.get("accepted") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("accepted")))
    },
    snapshot: match obj.get("snapshot") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("snapshot")))
    },
  }
}

///|
pub(all) struct SnapshotRestoreRequest {
  repository : String
  snapshot : String
  query : SnapshotRestoreQuery
  body : SnapshotRestoreBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotRestoreRequest::new(
  repository : String,
  snapshot : String,
  query? : SnapshotRestoreQuery = SnapshotRestoreQuery::new(),
  body? : SnapshotRestoreBody,
) -> SnapshotRestoreRequest {
  { repository, snapshot, query, body }
}

///|
pub async fn Client::snapshot_restore(
  self : Client,
  request : SnapshotRestoreRequest,
) -> EsResponse[SnapshotRestoreResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  params["snapshot"] = request.snapshot
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/{snapshot}/_restore", [
        "repository", "snapshot",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SnapshotStatusQuery {
  ignore_unavailable : Bool?
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotStatusQuery with fn to_json(
  self : SnapshotStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotStatusQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotStatusQuery: expected object"))
  }
  {
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn SnapshotStatusQuery::new(
  ignore_unavailable? : Bool,
  master_timeout? : String,
) -> SnapshotStatusQuery {
  { ignore_unavailable, master_timeout }
}

///|
pub fn SnapshotStatusQuery::to_pairs(
  self : SnapshotStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotStatusResponse {
  snapshots : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotStatusResponse with fn to_json(
  self : SnapshotStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["snapshots"] = self.snapshots.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SnapshotStatusResponse: expected object"))
  }
  {
    snapshots: @json.from_json(
      obj.get("snapshots").unwrap_or(Json::null()),
      path=path.add_key("snapshots"),
    ),
  }
}

///|
pub(all) struct SnapshotStatusRequest {
  repository : String?
  snapshot : String?
  query : SnapshotStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotStatusRequest::new(
  repository? : String,
  snapshot? : String,
  query? : SnapshotStatusQuery = SnapshotStatusQuery::new(),
) -> SnapshotStatusRequest {
  { repository, snapshot, query }
}

///|
pub async fn Client::snapshot_status(
  self : Client,
  request : SnapshotStatusRequest,
) -> EsResponse[SnapshotStatusResponse] {
  let params : Map[String, String] = Map([])
  match request.repository {
    Some(value) => params["repository"] = value
    None => ()
  }
  match request.snapshot {
    Some(value) => params["snapshot"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_snapshot/{repository}/{snapshot}/_status", [
        "repository", "snapshot",
      ]),
      PathVariant::new("/_snapshot/{repository}/_status", ["repository"]),
      PathVariant::new("/_snapshot/_status", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SnapshotVerifyRepositoryQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotVerifyRepositoryQuery with fn to_json(
  self : SnapshotVerifyRepositoryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotVerifyRepositoryQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotVerifyRepositoryQuery: expected object"),
    )
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn SnapshotVerifyRepositoryQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> SnapshotVerifyRepositoryQuery {
  { master_timeout, timeout }
}

///|
pub fn SnapshotVerifyRepositoryQuery::to_pairs(
  self : SnapshotVerifyRepositoryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SnapshotVerifyRepositoryResponse {
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SnapshotVerifyRepositoryResponse with fn to_json(
  self : SnapshotVerifyRepositoryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SnapshotVerifyRepositoryResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SnapshotVerifyRepositoryResponse: expected object"),
    )
  }
  {
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct SnapshotVerifyRepositoryRequest {
  repository : String
  query : SnapshotVerifyRepositoryQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SnapshotVerifyRepositoryRequest::new(
  repository : String,
  query? : SnapshotVerifyRepositoryQuery = SnapshotVerifyRepositoryQuery::new(),
) -> SnapshotVerifyRepositoryRequest {
  { repository, query }
}

///|
pub async fn Client::snapshot_verify_repository(
  self : Client,
  request : SnapshotVerifyRepositoryRequest,
) -> EsResponse[SnapshotVerifyRepositoryResponse] {
  let params : Map[String, String] = Map([])
  params["repository"] = request.repository
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_snapshot/{repository}/_verify", ["repository"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct SqlClearCursorQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SqlClearCursorQuery with fn to_json(
  _self : SqlClearCursorQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SqlClearCursorQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SqlClearCursorQuery: expected object"))
  }
  SqlClearCursorQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SqlClearCursorQuery::new() -> SqlClearCursorQuery {
  SqlClearCursorQuery::{  }
}

///|
pub fn SqlClearCursorQuery::to_pairs(
  _self : SqlClearCursorQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SqlClearCursorBody {
  cursor : String
} derive(Eq, Debug)

///|
pub impl ToJson for SqlClearCursorBody with fn to_json(
  self : SqlClearCursorBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["cursor"] = self.cursor.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SqlClearCursorBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlClearCursorBody: expected object"))
  }
  {
    cursor: @json.from_json(
      obj.get("cursor").unwrap_or(Json::null()),
      path=path.add_key("cursor"),
    ),
  }
}

///|
pub fn SqlClearCursorBody::new(cursor : String) -> SqlClearCursorBody {
  { cursor, }
}

///|
pub(all) struct SqlClearCursorResponse {
  succeeded : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for SqlClearCursorResponse with fn to_json(
  self : SqlClearCursorResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["succeeded"] = self.succeeded.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SqlClearCursorResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlClearCursorResponse: expected object"))
  }
  {
    succeeded: @json.from_json(
      obj.get("succeeded").unwrap_or(Json::null()),
      path=path.add_key("succeeded"),
    ),
  }
}

///|
pub(all) struct SqlClearCursorRequest {
  query : SqlClearCursorQuery
  body : SqlClearCursorBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SqlClearCursorRequest::new(
  body : SqlClearCursorBody,
  query? : SqlClearCursorQuery = SqlClearCursorQuery::new(),
) -> SqlClearCursorRequest {
  { query, body }
}

///|
pub async fn Client::sql_clear_cursor(
  self : Client,
  request : SqlClearCursorRequest,
) -> EsResponse[SqlClearCursorResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_sql/close", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SqlDeleteAsyncQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SqlDeleteAsyncQuery with fn to_json(
  _self : SqlDeleteAsyncQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SqlDeleteAsyncQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SqlDeleteAsyncQuery: expected object"))
  }
  SqlDeleteAsyncQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SqlDeleteAsyncQuery::new() -> SqlDeleteAsyncQuery {
  SqlDeleteAsyncQuery::{  }
}

///|
pub fn SqlDeleteAsyncQuery::to_pairs(
  _self : SqlDeleteAsyncQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SqlDeleteAsyncResponse = Json

///|
pub(all) struct SqlDeleteAsyncRequest {
  id : String
  query : SqlDeleteAsyncQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SqlDeleteAsyncRequest::new(
  id : String,
  query? : SqlDeleteAsyncQuery = SqlDeleteAsyncQuery::new(),
) -> SqlDeleteAsyncRequest {
  { id, query }
}

///|
pub async fn Client::sql_delete_async(
  self : Client,
  request : SqlDeleteAsyncRequest,
) -> EsResponse[SqlDeleteAsyncResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_sql/async/delete/{id}", ["id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SqlGetAsyncQuery {
  delimiter : String?
  format : String?
  keep_alive : String?
  wait_for_completion_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SqlGetAsyncQuery with fn to_json(self : SqlGetAsyncQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SqlGetAsyncQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlGetAsyncQuery: expected object"))
  }
  {
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
  }
}

///|
pub fn SqlGetAsyncQuery::new(
  delimiter? : String,
  format? : String,
  keep_alive? : String,
  wait_for_completion_timeout? : String,
) -> SqlGetAsyncQuery {
  { delimiter, format, keep_alive, wait_for_completion_timeout }
}

///|
pub fn SqlGetAsyncQuery::to_pairs(
  self : SqlGetAsyncQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.delimiter {
    Some(value) => push_query_json(pairs, "delimiter", value.to_json())
    None => ()
  }
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  match self.keep_alive {
    Some(value) => push_query_json(pairs, "keep_alive", value.to_json())
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SqlGetAsyncResponse {
  id : Json
  is_running : Bool
  is_partial : Bool
  columns : Array[Json]?
  cursor : String?
  rows : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SqlGetAsyncResponse with fn to_json(
  self : SqlGetAsyncResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["id"] = self.id.to_json()
  obj["is_running"] = self.is_running.to_json()
  obj["is_partial"] = self.is_partial.to_json()
  match self.columns {
    Some(value) => obj["columns"] = value.to_json()
    None => ()
  }
  match self.cursor {
    Some(value) => obj["cursor"] = value.to_json()
    None => ()
  }
  obj["rows"] = self.rows.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SqlGetAsyncResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlGetAsyncResponse: expected object"))
  }
  {
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    is_running: @json.from_json(
      obj.get("is_running").unwrap_or(Json::null()),
      path=path.add_key("is_running"),
    ),
    is_partial: @json.from_json(
      obj.get("is_partial").unwrap_or(Json::null()),
      path=path.add_key("is_partial"),
    ),
    columns: match obj.get("columns") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("columns")))
    },
    cursor: match obj.get("cursor") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cursor")))
    },
    rows: @json.from_json(
      obj.get("rows").unwrap_or(Json::null()),
      path=path.add_key("rows"),
    ),
  }
}

///|
pub(all) struct SqlGetAsyncRequest {
  id : String
  query : SqlGetAsyncQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SqlGetAsyncRequest::new(
  id : String,
  query? : SqlGetAsyncQuery = SqlGetAsyncQuery::new(),
) -> SqlGetAsyncRequest {
  { id, query }
}

///|
pub async fn Client::sql_get_async(
  self : Client,
  request : SqlGetAsyncRequest,
) -> EsResponse[SqlGetAsyncResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_sql/async/{id}", ["id"])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SqlGetAsyncStatusQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SqlGetAsyncStatusQuery with fn to_json(
  _self : SqlGetAsyncStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SqlGetAsyncStatusQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SqlGetAsyncStatusQuery: expected object"))
  }
  SqlGetAsyncStatusQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SqlGetAsyncStatusQuery::new() -> SqlGetAsyncStatusQuery {
  SqlGetAsyncStatusQuery::{  }
}

///|
pub fn SqlGetAsyncStatusQuery::to_pairs(
  _self : SqlGetAsyncStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SqlGetAsyncStatusResponse {
  expiration_time_in_millis : Json
  id : String
  is_running : Bool
  is_partial : Bool
  start_time_in_millis : Json
  completion_status : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SqlGetAsyncStatusResponse with fn to_json(
  self : SqlGetAsyncStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["expiration_time_in_millis"] = self.expiration_time_in_millis.to_json()
  obj["id"] = self.id.to_json()
  obj["is_running"] = self.is_running.to_json()
  obj["is_partial"] = self.is_partial.to_json()
  obj["start_time_in_millis"] = self.start_time_in_millis.to_json()
  match self.completion_status {
    Some(value) => obj["completion_status"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SqlGetAsyncStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlGetAsyncStatusResponse: expected object"))
  }
  {
    expiration_time_in_millis: @json.from_json(
      obj.get("expiration_time_in_millis").unwrap_or(Json::null()),
      path=path.add_key("expiration_time_in_millis"),
    ),
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    is_running: @json.from_json(
      obj.get("is_running").unwrap_or(Json::null()),
      path=path.add_key("is_running"),
    ),
    is_partial: @json.from_json(
      obj.get("is_partial").unwrap_or(Json::null()),
      path=path.add_key("is_partial"),
    ),
    start_time_in_millis: @json.from_json(
      obj.get("start_time_in_millis").unwrap_or(Json::null()),
      path=path.add_key("start_time_in_millis"),
    ),
    completion_status: match obj.get("completion_status") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("completion_status")))
    },
  }
}

///|
pub(all) struct SqlGetAsyncStatusRequest {
  id : String
  query : SqlGetAsyncStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SqlGetAsyncStatusRequest::new(
  id : String,
  query? : SqlGetAsyncStatusQuery = SqlGetAsyncStatusQuery::new(),
) -> SqlGetAsyncStatusRequest {
  { id, query }
}

///|
pub async fn Client::sql_get_async_status(
  self : Client,
  request : SqlGetAsyncStatusRequest,
) -> EsResponse[SqlGetAsyncStatusResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_sql/async/status/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SqlQueryQuery {
  format : String?
} derive(Eq, Debug)

///|
pub impl ToJson for SqlQueryQuery with fn to_json(self : SqlQueryQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SqlQueryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlQueryQuery: expected object"))
  }
  {
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
  }
}

///|
pub fn SqlQueryQuery::new(format? : String) -> SqlQueryQuery {
  { format, }
}

///|
pub fn SqlQueryQuery::to_pairs(self : SqlQueryQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SqlQueryBody {
  allow_partial_search_results : Bool?
  catalog : String?
  columnar : Bool?
  cursor : String?
  fetch_size : Int?
  field_multi_value_leniency : Bool?
  filter : Json?
  index_using_frozen : Bool?
  keep_alive : Json?
  keep_on_completion : Bool?
  page_timeout : Json?
  params : Array[Json]?
  query : String?
  project_routing : Json?
  request_timeout : Json?
  runtime_mappings : Json?
  time_zone : Json?
  wait_for_completion_timeout : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SqlQueryBody with fn to_json(self : SqlQueryBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_partial_search_results {
    Some(value) => obj["allow_partial_search_results"] = value.to_json()
    None => ()
  }
  match self.catalog {
    Some(value) => obj["catalog"] = value.to_json()
    None => ()
  }
  match self.columnar {
    Some(value) => obj["columnar"] = value.to_json()
    None => ()
  }
  match self.cursor {
    Some(value) => obj["cursor"] = value.to_json()
    None => ()
  }
  match self.fetch_size {
    Some(value) => obj["fetch_size"] = value.to_json()
    None => ()
  }
  match self.field_multi_value_leniency {
    Some(value) => obj["field_multi_value_leniency"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.index_using_frozen {
    Some(value) => obj["index_using_frozen"] = value.to_json()
    None => ()
  }
  match self.keep_alive {
    Some(value) => obj["keep_alive"] = value.to_json()
    None => ()
  }
  match self.keep_on_completion {
    Some(value) => obj["keep_on_completion"] = value.to_json()
    None => ()
  }
  match self.page_timeout {
    Some(value) => obj["page_timeout"] = value.to_json()
    None => ()
  }
  match self.params {
    Some(value) => obj["params"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.project_routing {
    Some(value) => obj["project_routing"] = value.to_json()
    None => ()
  }
  match self.request_timeout {
    Some(value) => obj["request_timeout"] = value.to_json()
    None => ()
  }
  match self.runtime_mappings {
    Some(value) => obj["runtime_mappings"] = value.to_json()
    None => ()
  }
  match self.time_zone {
    Some(value) => obj["time_zone"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion_timeout {
    Some(value) => obj["wait_for_completion_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SqlQueryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlQueryBody: expected object"))
  }
  {
    allow_partial_search_results: match
      obj.get("allow_partial_search_results") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("allow_partial_search_results"),
          ),
        )
    },
    catalog: match obj.get("catalog") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("catalog")))
    },
    columnar: match obj.get("columnar") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("columnar")))
    },
    cursor: match obj.get("cursor") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cursor")))
    },
    fetch_size: match obj.get("fetch_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("fetch_size")))
    },
    field_multi_value_leniency: match obj.get("field_multi_value_leniency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("field_multi_value_leniency"),
          ),
        )
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    index_using_frozen: match obj.get("index_using_frozen") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_using_frozen")))
    },
    keep_alive: match obj.get("keep_alive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_alive")))
    },
    keep_on_completion: match obj.get("keep_on_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("keep_on_completion")))
    },
    page_timeout: match obj.get("page_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("page_timeout")))
    },
    params: match obj.get("params") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("params")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    project_routing: match obj.get("project_routing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("project_routing")))
    },
    request_timeout: match obj.get("request_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("request_timeout")))
    },
    runtime_mappings: match obj.get("runtime_mappings") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_mappings")))
    },
    time_zone: match obj.get("time_zone") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("time_zone")))
    },
    wait_for_completion_timeout: match obj.get("wait_for_completion_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("wait_for_completion_timeout"),
          ),
        )
    },
  }
}

///|
pub fn SqlQueryBody::new(
  allow_partial_search_results? : Bool,
  catalog? : String,
  columnar? : Bool,
  cursor? : String,
  fetch_size? : Int,
  field_multi_value_leniency? : Bool,
  filter? : Json,
  index_using_frozen? : Bool,
  keep_alive? : Json,
  keep_on_completion? : Bool,
  page_timeout? : Json,
  params? : Array[Json],
  query? : String,
  project_routing? : Json,
  request_timeout? : Json,
  runtime_mappings? : Json,
  time_zone? : Json,
  wait_for_completion_timeout? : Json,
) -> SqlQueryBody {
  {
    allow_partial_search_results,
    catalog,
    columnar,
    cursor,
    fetch_size,
    field_multi_value_leniency,
    filter,
    index_using_frozen,
    keep_alive,
    keep_on_completion,
    page_timeout,
    params,
    query,
    project_routing,
    request_timeout,
    runtime_mappings,
    time_zone,
    wait_for_completion_timeout,
  }
}

///|
pub(all) struct SqlQueryResponse {
  columns : Array[Json]?
  cursor : String?
  id : Json?
  is_running : Bool?
  is_partial : Bool?
  rows : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SqlQueryResponse with fn to_json(self : SqlQueryResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.columns {
    Some(value) => obj["columns"] = value.to_json()
    None => ()
  }
  match self.cursor {
    Some(value) => obj["cursor"] = value.to_json()
    None => ()
  }
  match self.id {
    Some(value) => obj["id"] = value.to_json()
    None => ()
  }
  match self.is_running {
    Some(value) => obj["is_running"] = value.to_json()
    None => ()
  }
  match self.is_partial {
    Some(value) => obj["is_partial"] = value.to_json()
    None => ()
  }
  obj["rows"] = self.rows.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SqlQueryResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlQueryResponse: expected object"))
  }
  {
    columns: match obj.get("columns") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("columns")))
    },
    cursor: match obj.get("cursor") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("cursor")))
    },
    id: match obj.get("id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("id")))
    },
    is_running: match obj.get("is_running") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("is_running")))
    },
    is_partial: match obj.get("is_partial") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("is_partial")))
    },
    rows: @json.from_json(
      obj.get("rows").unwrap_or(Json::null()),
      path=path.add_key("rows"),
    ),
  }
}

///|
pub(all) struct SqlQueryRequest {
  query : SqlQueryQuery
  body : SqlQueryBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SqlQueryRequest::new(
  body : SqlQueryBody,
  query? : SqlQueryQuery = SqlQueryQuery::new(),
) -> SqlQueryRequest {
  { query, body }
}

///|
pub async fn Client::sql_query(
  self : Client,
  request : SqlQueryRequest,
) -> EsResponse[SqlQueryResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_sql", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SqlTranslateQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SqlTranslateQuery with fn to_json(_self : SqlTranslateQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SqlTranslateQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SqlTranslateQuery: expected object"))
  }
  SqlTranslateQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SqlTranslateQuery::new() -> SqlTranslateQuery {
  SqlTranslateQuery::{  }
}

///|
pub fn SqlTranslateQuery::to_pairs(
  _self : SqlTranslateQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct SqlTranslateBody {
  fetch_size : Int?
  filter : Json?
  query : String
  time_zone : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SqlTranslateBody with fn to_json(self : SqlTranslateBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.fetch_size {
    Some(value) => obj["fetch_size"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  obj["query"] = self.query.to_json()
  match self.time_zone {
    Some(value) => obj["time_zone"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SqlTranslateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlTranslateBody: expected object"))
  }
  {
    fetch_size: match obj.get("fetch_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("fetch_size")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    query: @json.from_json(
      obj.get("query").unwrap_or(Json::null()),
      path=path.add_key("query"),
    ),
    time_zone: match obj.get("time_zone") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("time_zone")))
    },
  }
}

///|
pub fn SqlTranslateBody::new(
  query : String,
  fetch_size? : Int,
  filter? : Json,
  time_zone? : Json,
) -> SqlTranslateBody {
  { fetch_size, filter, query, time_zone }
}

///|
pub(all) struct SqlTranslateResponse {
  aggregations : Map[String, Json]?
  size : Int?
  _source : Json?
  fields : Array[Json]?
  query : Json?
  sort : Json?
  track_total_hits : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SqlTranslateResponse with fn to_json(
  self : SqlTranslateResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.aggregations {
    Some(value) => obj["aggregations"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.track_total_hits {
    Some(value) => obj["track_total_hits"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SqlTranslateResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SqlTranslateResponse: expected object"))
  }
  {
    aggregations: match obj.get("aggregations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("aggregations")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    track_total_hits: match obj.get("track_total_hits") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("track_total_hits")))
    },
  }
}

///|
pub(all) struct SqlTranslateRequest {
  query : SqlTranslateQuery
  body : SqlTranslateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SqlTranslateRequest::new(
  body : SqlTranslateBody,
  query? : SqlTranslateQuery = SqlTranslateQuery::new(),
) -> SqlTranslateRequest {
  { query, body }
}

///|
pub async fn Client::sql_translate(
  self : Client,
  request : SqlTranslateRequest,
) -> EsResponse[SqlTranslateResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_sql/translate", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct SslCertificatesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SslCertificatesQuery with fn to_json(
  _self : SslCertificatesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SslCertificatesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SslCertificatesQuery: expected object"))
  }
  SslCertificatesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SslCertificatesQuery::new() -> SslCertificatesQuery {
  SslCertificatesQuery::{  }
}

///|
pub fn SslCertificatesQuery::to_pairs(
  _self : SslCertificatesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SslCertificatesResponse = Json

///|
pub(all) struct SslCertificatesRequest {
  query : SslCertificatesQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SslCertificatesRequest::new(
  query? : SslCertificatesQuery = SslCertificatesQuery::new(),
) -> SslCertificatesRequest {
  { query, }
}

///|
pub async fn Client::ssl_certificates(
  self : Client,
  request : SslCertificatesRequest,
) -> EsResponse[SslCertificatesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_ssl/certificates", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct StreamsLogsDisableQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for StreamsLogsDisableQuery with fn to_json(
  self : StreamsLogsDisableQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for StreamsLogsDisableQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "StreamsLogsDisableQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn StreamsLogsDisableQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> StreamsLogsDisableQuery {
  { master_timeout, timeout }
}

///|
pub fn StreamsLogsDisableQuery::to_pairs(
  self : StreamsLogsDisableQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type StreamsLogsDisableResponse = Json

///|
pub(all) struct StreamsLogsDisableRequest {
  name : String
  query : StreamsLogsDisableQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn StreamsLogsDisableRequest::new(
  name : String,
  query? : StreamsLogsDisableQuery = StreamsLogsDisableQuery::new(),
) -> StreamsLogsDisableRequest {
  { name, query }
}

///|
pub async fn Client::streams_logs_disable(
  self : Client,
  request : StreamsLogsDisableRequest,
) -> EsResponse[StreamsLogsDisableResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_streams/{name}/_disable", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct StreamsLogsEnableQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for StreamsLogsEnableQuery with fn to_json(
  self : StreamsLogsEnableQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for StreamsLogsEnableQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "StreamsLogsEnableQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn StreamsLogsEnableQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> StreamsLogsEnableQuery {
  { master_timeout, timeout }
}

///|
pub fn StreamsLogsEnableQuery::to_pairs(
  self : StreamsLogsEnableQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type StreamsLogsEnableResponse = Json

///|
pub(all) struct StreamsLogsEnableRequest {
  name : String
  query : StreamsLogsEnableQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn StreamsLogsEnableRequest::new(
  name : String,
  query? : StreamsLogsEnableQuery = StreamsLogsEnableQuery::new(),
) -> StreamsLogsEnableRequest {
  { name, query }
}

///|
pub async fn Client::streams_logs_enable(
  self : Client,
  request : StreamsLogsEnableRequest,
) -> EsResponse[StreamsLogsEnableResponse] {
  let params : Map[String, String] = Map([])
  params["name"] = request.name
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_streams/{name}/_enable", ["name"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct StreamsStatusQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for StreamsStatusQuery with fn to_json(
  self : StreamsStatusQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for StreamsStatusQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "StreamsStatusQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn StreamsStatusQuery::new(master_timeout? : String) -> StreamsStatusQuery {
  { master_timeout, }
}

///|
pub fn StreamsStatusQuery::to_pairs(
  self : StreamsStatusQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct StreamsStatusResponse {
  logs : Json
  logs_otel : Json
  logs_ecs : Json
} derive(Eq, Debug)

///|
pub impl ToJson for StreamsStatusResponse with fn to_json(
  self : StreamsStatusResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["logs"] = self.logs.to_json()
  obj["logs.otel"] = self.logs_otel.to_json()
  obj["logs.ecs"] = self.logs_ecs.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for StreamsStatusResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "StreamsStatusResponse: expected object"))
  }
  {
    logs: @json.from_json(
      obj.get("logs").unwrap_or(Json::null()),
      path=path.add_key("logs"),
    ),
    logs_otel: @json.from_json(
      obj.get("logs.otel").unwrap_or(Json::null()),
      path=path.add_key("logs.otel"),
    ),
    logs_ecs: @json.from_json(
      obj.get("logs.ecs").unwrap_or(Json::null()),
      path=path.add_key("logs.ecs"),
    ),
  }
}

///|
pub(all) struct StreamsStatusRequest {
  query : StreamsStatusQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn StreamsStatusRequest::new(
  query? : StreamsStatusQuery = StreamsStatusQuery::new(),
) -> StreamsStatusRequest {
  { query, }
}

///|
pub async fn Client::streams_status(
  self : Client,
  request : StreamsStatusRequest,
) -> EsResponse[StreamsStatusResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_streams/status", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SynonymsDeleteSynonymQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsDeleteSynonymQuery with fn to_json(
  _self : SynonymsDeleteSynonymQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SynonymsDeleteSynonymQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "SynonymsDeleteSynonymQuery: expected object"))
  }
  SynonymsDeleteSynonymQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SynonymsDeleteSynonymQuery::new() -> SynonymsDeleteSynonymQuery {
  SynonymsDeleteSynonymQuery::{  }
}

///|
pub fn SynonymsDeleteSynonymQuery::to_pairs(
  _self : SynonymsDeleteSynonymQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SynonymsDeleteSynonymResponse = Json

///|
pub(all) struct SynonymsDeleteSynonymRequest {
  id : String
  query : SynonymsDeleteSynonymQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsDeleteSynonymRequest::new(
  id : String,
  query? : SynonymsDeleteSynonymQuery = SynonymsDeleteSynonymQuery::new(),
) -> SynonymsDeleteSynonymRequest {
  { id, query }
}

///|
pub async fn Client::synonyms_delete_synonym(
  self : Client,
  request : SynonymsDeleteSynonymRequest,
) -> EsResponse[SynonymsDeleteSynonymResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_synonyms/{id}", ["id"])], params)
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct SynonymsDeleteSynonymRuleQuery {
  refresh : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsDeleteSynonymRuleQuery with fn to_json(
  self : SynonymsDeleteSynonymRuleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsDeleteSynonymRuleQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SynonymsDeleteSynonymRuleQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SynonymsDeleteSynonymRuleQuery::new(
  refresh? : Bool,
) -> SynonymsDeleteSynonymRuleQuery {
  { refresh, }
}

///|
pub fn SynonymsDeleteSynonymRuleQuery::to_pairs(
  self : SynonymsDeleteSynonymRuleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type SynonymsDeleteSynonymRuleBody = Json

///|
pub type SynonymsDeleteSynonymRuleResponse = Json

///|
pub(all) struct SynonymsDeleteSynonymRuleRequest {
  set_id : String
  rule_id : String
  query : SynonymsDeleteSynonymRuleQuery
  body : SynonymsDeleteSynonymRuleBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsDeleteSynonymRuleRequest::new(
  set_id : String,
  rule_id : String,
  query? : SynonymsDeleteSynonymRuleQuery = SynonymsDeleteSynonymRuleQuery::new(),
  body? : SynonymsDeleteSynonymRuleBody,
) -> SynonymsDeleteSynonymRuleRequest {
  { set_id, rule_id, query, body }
}

///|
pub async fn Client::synonyms_delete_synonym_rule(
  self : Client,
  request : SynonymsDeleteSynonymRuleRequest,
) -> EsResponse[SynonymsDeleteSynonymRuleResponse] {
  let params : Map[String, String] = Map([])
  params["set_id"] = request.set_id
  params["rule_id"] = request.rule_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_synonyms/{set_id}/{rule_id}", ["set_id", "rule_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Delete, path, query~, body~))
}

///|
pub(all) struct SynonymsGetSynonymQuery {
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsGetSynonymQuery with fn to_json(
  self : SynonymsGetSynonymQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsGetSynonymQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SynonymsGetSynonymQuery: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn SynonymsGetSynonymQuery::new(
  from? : Int,
  size? : Int,
) -> SynonymsGetSynonymQuery {
  { from, size }
}

///|
pub fn SynonymsGetSynonymQuery::to_pairs(
  self : SynonymsGetSynonymQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SynonymsGetSynonymResponse {
  count : Int
  synonyms_set : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsGetSynonymResponse with fn to_json(
  self : SynonymsGetSynonymResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["synonyms_set"] = self.synonyms_set.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsGetSynonymResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SynonymsGetSynonymResponse: expected object"))
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    synonyms_set: @json.from_json(
      obj.get("synonyms_set").unwrap_or(Json::null()),
      path=path.add_key("synonyms_set"),
    ),
  }
}

///|
pub(all) struct SynonymsGetSynonymRequest {
  id : String
  query : SynonymsGetSynonymQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsGetSynonymRequest::new(
  id : String,
  query? : SynonymsGetSynonymQuery = SynonymsGetSynonymQuery::new(),
) -> SynonymsGetSynonymRequest {
  { id, query }
}

///|
pub async fn Client::synonyms_get_synonym(
  self : Client,
  request : SynonymsGetSynonymRequest,
) -> EsResponse[SynonymsGetSynonymResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_synonyms/{id}", ["id"])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SynonymsGetSynonymRuleQuery {} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsGetSynonymRuleQuery with fn to_json(
  _self : SynonymsGetSynonymRuleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for SynonymsGetSynonymRuleQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "SynonymsGetSynonymRuleQuery: expected object"),
    )
  }
  SynonymsGetSynonymRuleQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn SynonymsGetSynonymRuleQuery::new() -> SynonymsGetSynonymRuleQuery {
  SynonymsGetSynonymRuleQuery::{  }
}

///|
pub fn SynonymsGetSynonymRuleQuery::to_pairs(
  _self : SynonymsGetSynonymRuleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type SynonymsGetSynonymRuleBody = Json

///|
pub type SynonymsGetSynonymRuleResponse = Json

///|
pub(all) struct SynonymsGetSynonymRuleRequest {
  set_id : String
  rule_id : String
  query : SynonymsGetSynonymRuleQuery
  body : SynonymsGetSynonymRuleBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsGetSynonymRuleRequest::new(
  set_id : String,
  rule_id : String,
  query? : SynonymsGetSynonymRuleQuery = SynonymsGetSynonymRuleQuery::new(),
  body? : SynonymsGetSynonymRuleBody,
) -> SynonymsGetSynonymRuleRequest {
  { set_id, rule_id, query, body }
}

///|
pub async fn Client::synonyms_get_synonym_rule(
  self : Client,
  request : SynonymsGetSynonymRuleRequest,
) -> EsResponse[SynonymsGetSynonymRuleResponse] {
  let params : Map[String, String] = Map([])
  params["set_id"] = request.set_id
  params["rule_id"] = request.rule_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_synonyms/{set_id}/{rule_id}", ["set_id", "rule_id"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct SynonymsGetSynonymsSetsQuery {
  from : Int?
  size : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsGetSynonymsSetsQuery with fn to_json(
  self : SynonymsGetSynonymsSetsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsGetSynonymsSetsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SynonymsGetSynonymsSetsQuery: expected object"),
    )
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
  }
}

///|
pub fn SynonymsGetSynonymsSetsQuery::new(
  from? : Int,
  size? : Int,
) -> SynonymsGetSynonymsSetsQuery {
  { from, size }
}

///|
pub fn SynonymsGetSynonymsSetsQuery::to_pairs(
  self : SynonymsGetSynonymsSetsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SynonymsGetSynonymsSetsResponse {
  count : Int
  results : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsGetSynonymsSetsResponse with fn to_json(
  self : SynonymsGetSynonymsSetsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["results"] = self.results.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsGetSynonymsSetsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SynonymsGetSynonymsSetsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    results: @json.from_json(
      obj.get("results").unwrap_or(Json::null()),
      path=path.add_key("results"),
    ),
  }
}

///|
pub(all) struct SynonymsGetSynonymsSetsRequest {
  query : SynonymsGetSynonymsSetsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsGetSynonymsSetsRequest::new(
  query? : SynonymsGetSynonymsSetsQuery = SynonymsGetSynonymsSetsQuery::new(),
) -> SynonymsGetSynonymsSetsRequest {
  { query, }
}

///|
pub async fn Client::synonyms_get_synonyms_sets(
  self : Client,
  request : SynonymsGetSynonymsSetsRequest,
) -> EsResponse[SynonymsGetSynonymsSetsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_synonyms", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct SynonymsPutSynonymQuery {
  refresh : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsPutSynonymQuery with fn to_json(
  self : SynonymsPutSynonymQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsPutSynonymQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SynonymsPutSynonymQuery: expected object"))
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SynonymsPutSynonymQuery::new(refresh? : Bool) -> SynonymsPutSynonymQuery {
  { refresh, }
}

///|
pub fn SynonymsPutSynonymQuery::to_pairs(
  self : SynonymsPutSynonymQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SynonymsPutSynonymBody {
  synonyms_set : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsPutSynonymBody with fn to_json(
  self : SynonymsPutSynonymBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["synonyms_set"] = self.synonyms_set.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsPutSynonymBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SynonymsPutSynonymBody: expected object"))
  }
  {
    synonyms_set: @json.from_json(
      obj.get("synonyms_set").unwrap_or(Json::null()),
      path=path.add_key("synonyms_set"),
    ),
  }
}

///|
pub fn SynonymsPutSynonymBody::new(
  synonyms_set : Json,
) -> SynonymsPutSynonymBody {
  { synonyms_set, }
}

///|
pub(all) struct SynonymsPutSynonymResponse {
  result : Json
  reload_analyzers_details : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsPutSynonymResponse with fn to_json(
  self : SynonymsPutSynonymResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["result"] = self.result.to_json()
  match self.reload_analyzers_details {
    Some(value) => obj["reload_analyzers_details"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsPutSynonymResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SynonymsPutSynonymResponse: expected object"))
  }
  {
    result: @json.from_json(
      obj.get("result").unwrap_or(Json::null()),
      path=path.add_key("result"),
    ),
    reload_analyzers_details: match obj.get("reload_analyzers_details") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("reload_analyzers_details")),
        )
    },
  }
}

///|
pub(all) struct SynonymsPutSynonymRequest {
  id : String
  query : SynonymsPutSynonymQuery
  body : SynonymsPutSynonymBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsPutSynonymRequest::new(
  id : String,
  body : SynonymsPutSynonymBody,
  query? : SynonymsPutSynonymQuery = SynonymsPutSynonymQuery::new(),
) -> SynonymsPutSynonymRequest {
  { id, query, body }
}

///|
pub async fn Client::synonyms_put_synonym(
  self : Client,
  request : SynonymsPutSynonymRequest,
) -> EsResponse[SynonymsPutSynonymResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_synonyms/{id}", ["id"])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct SynonymsPutSynonymRuleQuery {
  refresh : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsPutSynonymRuleQuery with fn to_json(
  self : SynonymsPutSynonymRuleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsPutSynonymRuleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "SynonymsPutSynonymRuleQuery: expected object"),
    )
  }
  {
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
  }
}

///|
pub fn SynonymsPutSynonymRuleQuery::new(
  refresh? : Bool,
) -> SynonymsPutSynonymRuleQuery {
  { refresh, }
}

///|
pub fn SynonymsPutSynonymRuleQuery::to_pairs(
  self : SynonymsPutSynonymRuleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct SynonymsPutSynonymRuleBody {
  synonyms : Json
} derive(Eq, Debug)

///|
pub impl ToJson for SynonymsPutSynonymRuleBody with fn to_json(
  self : SynonymsPutSynonymRuleBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["synonyms"] = self.synonyms.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for SynonymsPutSynonymRuleBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "SynonymsPutSynonymRuleBody: expected object"))
  }
  {
    synonyms: @json.from_json(
      obj.get("synonyms").unwrap_or(Json::null()),
      path=path.add_key("synonyms"),
    ),
  }
}

///|
pub fn SynonymsPutSynonymRuleBody::new(
  synonyms : Json,
) -> SynonymsPutSynonymRuleBody {
  { synonyms, }
}

///|
pub type SynonymsPutSynonymRuleResponse = Json

///|
pub(all) struct SynonymsPutSynonymRuleRequest {
  set_id : String
  rule_id : String
  query : SynonymsPutSynonymRuleQuery
  body : SynonymsPutSynonymRuleBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn SynonymsPutSynonymRuleRequest::new(
  set_id : String,
  rule_id : String,
  body : SynonymsPutSynonymRuleBody,
  query? : SynonymsPutSynonymRuleQuery = SynonymsPutSynonymRuleQuery::new(),
) -> SynonymsPutSynonymRuleRequest {
  { set_id, rule_id, query, body }
}

///|
pub async fn Client::synonyms_put_synonym_rule(
  self : Client,
  request : SynonymsPutSynonymRuleRequest,
) -> EsResponse[SynonymsPutSynonymRuleResponse] {
  let params : Map[String, String] = Map([])
  params["set_id"] = request.set_id
  params["rule_id"] = request.rule_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_synonyms/{set_id}/{rule_id}", ["set_id", "rule_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct TasksCancelQuery {
  actions : Json?
  nodes : Array[String]?
  parent_task_id : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for TasksCancelQuery with fn to_json(self : TasksCancelQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.actions {
    Some(value) => obj["actions"] = value.to_json()
    None => ()
  }
  match self.nodes {
    Some(value) => obj["nodes"] = value.to_json()
    None => ()
  }
  match self.parent_task_id {
    Some(value) => obj["parent_task_id"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TasksCancelQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TasksCancelQuery: expected object"))
  }
  {
    actions: match obj.get("actions") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("actions")))
    },
    nodes: match obj.get("nodes") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("nodes")))
    },
    parent_task_id: match obj.get("parent_task_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("parent_task_id")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn TasksCancelQuery::new(
  actions? : Json,
  nodes? : Array[String],
  parent_task_id? : String,
  wait_for_completion? : Bool,
) -> TasksCancelQuery {
  { actions, nodes, parent_task_id, wait_for_completion }
}

///|
pub fn TasksCancelQuery::to_pairs(
  self : TasksCancelQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.actions {
    Some(value) => push_query_json(pairs, "actions", value.to_json())
    None => ()
  }
  match self.nodes {
    Some(value) => push_query_json(pairs, "nodes", value.to_json())
    None => ()
  }
  match self.parent_task_id {
    Some(value) => push_query_json(pairs, "parent_task_id", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TasksCancelResponse = Json

///|
pub(all) struct TasksCancelRequest {
  task_id : String?
  query : TasksCancelQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TasksCancelRequest::new(
  task_id? : String,
  query? : TasksCancelQuery = TasksCancelQuery::new(),
) -> TasksCancelRequest {
  { task_id, query }
}

///|
pub async fn Client::tasks_cancel(
  self : Client,
  request : TasksCancelRequest,
) -> EsResponse[TasksCancelResponse] {
  let params : Map[String, String] = Map([])
  match request.task_id {
    Some(value) => params["task_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_tasks/{task_id}/_cancel", ["task_id"]),
      PathVariant::new("/_tasks/_cancel", []),
    ],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct TasksGetQuery {
  timeout : String?
  wait_for_completion : Bool?
  follow_relocations : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for TasksGetQuery with fn to_json(self : TasksGetQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  match self.follow_relocations {
    Some(value) => obj["follow_relocations"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TasksGetQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TasksGetQuery: expected object"))
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
    follow_relocations: match obj.get("follow_relocations") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("follow_relocations")))
    },
  }
}

///|
pub fn TasksGetQuery::new(
  timeout? : String,
  wait_for_completion? : Bool,
  follow_relocations? : Bool,
) -> TasksGetQuery {
  { timeout, wait_for_completion, follow_relocations }
}

///|
pub fn TasksGetQuery::to_pairs(self : TasksGetQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  match self.follow_relocations {
    Some(value) => push_query_json(pairs, "follow_relocations", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TasksGetResponse {
  completed : Bool
  task : Json
  response : Json?
  error : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TasksGetResponse with fn to_json(self : TasksGetResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["completed"] = self.completed.to_json()
  obj["task"] = self.task.to_json()
  match self.response {
    Some(value) => obj["response"] = value.to_json()
    None => ()
  }
  match self.error {
    Some(value) => obj["error"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TasksGetResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TasksGetResponse: expected object"))
  }
  {
    completed: @json.from_json(
      obj.get("completed").unwrap_or(Json::null()),
      path=path.add_key("completed"),
    ),
    task: @json.from_json(
      obj.get("task").unwrap_or(Json::null()),
      path=path.add_key("task"),
    ),
    response: match obj.get("response") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("response")))
    },
    error: match obj.get("error") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("error")))
    },
  }
}

///|
pub(all) struct TasksGetRequest {
  task_id : String
  query : TasksGetQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TasksGetRequest::new(
  task_id : String,
  query? : TasksGetQuery = TasksGetQuery::new(),
) -> TasksGetRequest {
  { task_id, query }
}

///|
pub async fn Client::tasks_get(
  self : Client,
  request : TasksGetRequest,
) -> EsResponse[TasksGetResponse] {
  let params : Map[String, String] = Map([])
  params["task_id"] = request.task_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_tasks/{task_id}", ["task_id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct TasksListQuery {
  actions : Json?
  detailed : Bool?
  group_by : String?
  nodes : String?
  parent_task_id : String?
  timeout : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for TasksListQuery with fn to_json(self : TasksListQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.actions {
    Some(value) => obj["actions"] = value.to_json()
    None => ()
  }
  match self.detailed {
    Some(value) => obj["detailed"] = value.to_json()
    None => ()
  }
  match self.group_by {
    Some(value) => obj["group_by"] = value.to_json()
    None => ()
  }
  match self.nodes {
    Some(value) => obj["nodes"] = value.to_json()
    None => ()
  }
  match self.parent_task_id {
    Some(value) => obj["parent_task_id"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TasksListQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TasksListQuery: expected object"))
  }
  {
    actions: match obj.get("actions") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("actions")))
    },
    detailed: match obj.get("detailed") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("detailed")))
    },
    group_by: match obj.get("group_by") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("group_by")))
    },
    nodes: match obj.get("nodes") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("nodes")))
    },
    parent_task_id: match obj.get("parent_task_id") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("parent_task_id")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn TasksListQuery::new(
  actions? : Json,
  detailed? : Bool,
  group_by? : String,
  nodes? : String,
  parent_task_id? : String,
  timeout? : String,
  wait_for_completion? : Bool,
) -> TasksListQuery {
  {
    actions,
    detailed,
    group_by,
    nodes,
    parent_task_id,
    timeout,
    wait_for_completion,
  }
}

///|
pub fn TasksListQuery::to_pairs(
  self : TasksListQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.actions {
    Some(value) => push_query_json(pairs, "actions", value.to_json())
    None => ()
  }
  match self.detailed {
    Some(value) => push_query_json(pairs, "detailed", value.to_json())
    None => ()
  }
  match self.group_by {
    Some(value) => push_query_json(pairs, "group_by", value.to_json())
    None => ()
  }
  match self.nodes {
    Some(value) => push_query_json(pairs, "nodes", value.to_json())
    None => ()
  }
  match self.parent_task_id {
    Some(value) => push_query_json(pairs, "parent_task_id", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TasksListResponse = Json

///|
pub(all) struct TasksListRequest {
  query : TasksListQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TasksListRequest::new(
  query? : TasksListQuery = TasksListQuery::new(),
) -> TasksListRequest {
  { query, }
}

///|
pub async fn Client::tasks_list(
  self : Client,
  request : TasksListRequest,
) -> EsResponse[TasksListResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_tasks", [])], params)
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct TermsEnumQuery {} derive(Eq, Debug)

///|
pub impl ToJson for TermsEnumQuery with fn to_json(_self : TermsEnumQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for TermsEnumQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "TermsEnumQuery: expected object"))
  }
  TermsEnumQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn TermsEnumQuery::new() -> TermsEnumQuery {
  TermsEnumQuery::{  }
}

///|
pub fn TermsEnumQuery::to_pairs(
  _self : TermsEnumQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct TermsEnumBody {
  field : Json
  size : Int?
  timeout : Json?
  case_insensitive : Bool?
  index_filter : Json?
  string : String?
  search_after : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TermsEnumBody with fn to_json(self : TermsEnumBody) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["field"] = self.field.to_json()
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.case_insensitive {
    Some(value) => obj["case_insensitive"] = value.to_json()
    None => ()
  }
  match self.index_filter {
    Some(value) => obj["index_filter"] = value.to_json()
    None => ()
  }
  match self.string {
    Some(value) => obj["string"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TermsEnumBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TermsEnumBody: expected object"))
  }
  {
    field: @json.from_json(
      obj.get("field").unwrap_or(Json::null()),
      path=path.add_key("field"),
    ),
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    case_insensitive: match obj.get("case_insensitive") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("case_insensitive")))
    },
    index_filter: match obj.get("index_filter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("index_filter")))
    },
    string: match obj.get("string") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("string")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
  }
}

///|
pub fn TermsEnumBody::new(
  field : Json,
  size? : Int,
  timeout? : Json,
  case_insensitive? : Bool,
  index_filter? : Json,
  string? : String,
  search_after? : String,
) -> TermsEnumBody {
  { field, size, timeout, case_insensitive, index_filter, string, search_after }
}

///|
pub(all) struct TermsEnumResponse {
  _shards : Json
  terms : Array[String]
  complete : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for TermsEnumResponse with fn to_json(self : TermsEnumResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_shards"] = self._shards.to_json()
  obj["terms"] = self.terms.to_json()
  obj["complete"] = self.complete.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TermsEnumResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TermsEnumResponse: expected object"))
  }
  {
    _shards: @json.from_json(
      obj.get("_shards").unwrap_or(Json::null()),
      path=path.add_key("_shards"),
    ),
    terms: @json.from_json(
      obj.get("terms").unwrap_or(Json::null()),
      path=path.add_key("terms"),
    ),
    complete: @json.from_json(
      obj.get("complete").unwrap_or(Json::null()),
      path=path.add_key("complete"),
    ),
  }
}

///|
pub(all) struct TermsEnumRequest {
  index : String
  query : TermsEnumQuery
  body : TermsEnumBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TermsEnumRequest::new(
  index : String,
  body : TermsEnumBody,
  query? : TermsEnumQuery = TermsEnumQuery::new(),
) -> TermsEnumRequest {
  { index, query, body }
}

///|
pub async fn Client::terms_enum(
  self : Client,
  request : TermsEnumRequest,
) -> EsResponse[TermsEnumResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_terms_enum", ["index"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TermvectorsQuery {
  fields : String?
  field_statistics : Bool?
  offsets : Bool?
  payloads : Bool?
  positions : Bool?
  preference : String?
  realtime : Bool?
  routing : String?
  term_statistics : Bool?
  version : String?
  version_type : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TermvectorsQuery with fn to_json(self : TermvectorsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.field_statistics {
    Some(value) => obj["field_statistics"] = value.to_json()
    None => ()
  }
  match self.offsets {
    Some(value) => obj["offsets"] = value.to_json()
    None => ()
  }
  match self.payloads {
    Some(value) => obj["payloads"] = value.to_json()
    None => ()
  }
  match self.positions {
    Some(value) => obj["positions"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.realtime {
    Some(value) => obj["realtime"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.term_statistics {
    Some(value) => obj["term_statistics"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TermvectorsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TermvectorsQuery: expected object"))
  }
  {
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    field_statistics: match obj.get("field_statistics") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("field_statistics")))
    },
    offsets: match obj.get("offsets") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("offsets")))
    },
    payloads: match obj.get("payloads") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("payloads")))
    },
    positions: match obj.get("positions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("positions")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    realtime: match obj.get("realtime") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("realtime")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    term_statistics: match obj.get("term_statistics") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("term_statistics")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn TermvectorsQuery::new(
  fields? : String,
  field_statistics? : Bool,
  offsets? : Bool,
  payloads? : Bool,
  positions? : Bool,
  preference? : String,
  realtime? : Bool,
  routing? : String,
  term_statistics? : Bool,
  version? : String,
  version_type? : String,
) -> TermvectorsQuery {
  {
    fields,
    field_statistics,
    offsets,
    payloads,
    positions,
    preference,
    realtime,
    routing,
    term_statistics,
    version,
    version_type,
  }
}

///|
pub fn TermvectorsQuery::to_pairs(
  self : TermvectorsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.fields {
    Some(value) => push_query_json(pairs, "fields", value.to_json())
    None => ()
  }
  match self.field_statistics {
    Some(value) => push_query_json(pairs, "field_statistics", value.to_json())
    None => ()
  }
  match self.offsets {
    Some(value) => push_query_json(pairs, "offsets", value.to_json())
    None => ()
  }
  match self.payloads {
    Some(value) => push_query_json(pairs, "payloads", value.to_json())
    None => ()
  }
  match self.positions {
    Some(value) => push_query_json(pairs, "positions", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.realtime {
    Some(value) => push_query_json(pairs, "realtime", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.term_statistics {
    Some(value) => push_query_json(pairs, "term_statistics", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TermvectorsBody {
  doc : Json?
  filter : Json?
  per_field_analyzer : Map[String, Json]?
  fields : Array[Json]?
  field_statistics : Bool?
  offsets : Bool?
  payloads : Bool?
  positions : Bool?
  term_statistics : Bool?
  routing : Json?
  version : Json?
  version_type : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TermvectorsBody with fn to_json(self : TermvectorsBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.doc {
    Some(value) => obj["doc"] = value.to_json()
    None => ()
  }
  match self.filter {
    Some(value) => obj["filter"] = value.to_json()
    None => ()
  }
  match self.per_field_analyzer {
    Some(value) => obj["per_field_analyzer"] = value.to_json()
    None => ()
  }
  match self.fields {
    Some(value) => obj["fields"] = value.to_json()
    None => ()
  }
  match self.field_statistics {
    Some(value) => obj["field_statistics"] = value.to_json()
    None => ()
  }
  match self.offsets {
    Some(value) => obj["offsets"] = value.to_json()
    None => ()
  }
  match self.payloads {
    Some(value) => obj["payloads"] = value.to_json()
    None => ()
  }
  match self.positions {
    Some(value) => obj["positions"] = value.to_json()
    None => ()
  }
  match self.term_statistics {
    Some(value) => obj["term_statistics"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TermvectorsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TermvectorsBody: expected object"))
  }
  {
    doc: match obj.get("doc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("doc")))
    },
    filter: match obj.get("filter") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("filter")))
    },
    per_field_analyzer: match obj.get("per_field_analyzer") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("per_field_analyzer")))
    },
    fields: match obj.get("fields") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("fields")))
    },
    field_statistics: match obj.get("field_statistics") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("field_statistics")))
    },
    offsets: match obj.get("offsets") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("offsets")))
    },
    payloads: match obj.get("payloads") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("payloads")))
    },
    positions: match obj.get("positions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("positions")))
    },
    term_statistics: match obj.get("term_statistics") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("term_statistics")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
  }
}

///|
pub fn TermvectorsBody::new(
  doc? : Json,
  filter? : Json,
  per_field_analyzer? : Map[String, Json],
  fields? : Array[Json],
  field_statistics? : Bool,
  offsets? : Bool,
  payloads? : Bool,
  positions? : Bool,
  term_statistics? : Bool,
  routing? : Json,
  version? : Json,
  version_type? : Json,
) -> TermvectorsBody {
  {
    doc,
    filter,
    per_field_analyzer,
    fields,
    field_statistics,
    offsets,
    payloads,
    positions,
    term_statistics,
    routing,
    version,
    version_type,
  }
}

///|
pub(all) struct TermvectorsResponse {
  found : Bool
  _id : Json?
  _index : Json
  term_vectors : Map[String, Json]?
  took : Int
  _version : Json
} derive(Eq, Debug)

///|
pub impl ToJson for TermvectorsResponse with fn to_json(
  self : TermvectorsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  match self._id {
    Some(value) => obj["_id"] = value.to_json()
    None => ()
  }
  obj["_index"] = self._index.to_json()
  match self.term_vectors {
    Some(value) => obj["term_vectors"] = value.to_json()
    None => ()
  }
  obj["took"] = self.took.to_json()
  obj["_version"] = self._version.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TermvectorsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TermvectorsResponse: expected object"))
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
    _id: match obj.get("_id") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_id")))
    },
    _index: @json.from_json(
      obj.get("_index").unwrap_or(Json::null()),
      path=path.add_key("_index"),
    ),
    term_vectors: match obj.get("term_vectors") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("term_vectors")))
    },
    took: @json.from_json(
      obj.get("took").unwrap_or(Json::null()),
      path=path.add_key("took"),
    ),
    _version: @json.from_json(
      obj.get("_version").unwrap_or(Json::null()),
      path=path.add_key("_version"),
    ),
  }
}

///|
pub(all) struct TermvectorsRequest {
  index : String
  id : String?
  query : TermvectorsQuery
  body : TermvectorsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TermvectorsRequest::new(
  index : String,
  id? : String,
  query? : TermvectorsQuery = TermvectorsQuery::new(),
  body? : TermvectorsBody,
) -> TermvectorsRequest {
  { index, id, query, body }
}

///|
pub async fn Client::termvectors(
  self : Client,
  request : TermvectorsRequest,
) -> EsResponse[TermvectorsResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/{index}/_termvectors/{id}", ["index", "id"]),
      PathVariant::new("/{index}/_termvectors", ["index"]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TextStructureFindFieldStructureQuery {
  column_names : Json?
  delimiter : String?
  documents_to_sample : String?
  ecs_compatibility : String?
  explain : Bool?
  field : String
  format : String?
  grok_pattern : String?
  index : String
  quote : String?
  should_trim_fields : Bool?
  should_parse_recursively : Bool?
  timeout : String?
  timestamp_field : String?
  timestamp_format : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindFieldStructureQuery with fn to_json(
  self : TextStructureFindFieldStructureQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.column_names {
    Some(value) => obj["column_names"] = value.to_json()
    None => ()
  }
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  match self.documents_to_sample {
    Some(value) => obj["documents_to_sample"] = value.to_json()
    None => ()
  }
  match self.ecs_compatibility {
    Some(value) => obj["ecs_compatibility"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  obj["field"] = self.field.to_json()
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  match self.grok_pattern {
    Some(value) => obj["grok_pattern"] = value.to_json()
    None => ()
  }
  obj["index"] = self.index.to_json()
  match self.quote {
    Some(value) => obj["quote"] = value.to_json()
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => obj["should_trim_fields"] = value.to_json()
    None => ()
  }
  match self.should_parse_recursively {
    Some(value) => obj["should_parse_recursively"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  match self.timestamp_format {
    Some(value) => obj["timestamp_format"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindFieldStructureQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindFieldStructureQuery: expected object"),
    )
  }
  {
    column_names: match obj.get("column_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("column_names")))
    },
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    documents_to_sample: match obj.get("documents_to_sample") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("documents_to_sample")))
    },
    ecs_compatibility: match obj.get("ecs_compatibility") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ecs_compatibility")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    field: @json.from_json(
      obj.get("field").unwrap_or(Json::null()),
      path=path.add_key("field"),
    ),
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
    grok_pattern: match obj.get("grok_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grok_pattern")))
    },
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
    quote: match obj.get("quote") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("quote")))
    },
    should_trim_fields: match obj.get("should_trim_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("should_trim_fields")))
    },
    should_parse_recursively: match obj.get("should_parse_recursively") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("should_parse_recursively")),
        )
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
    timestamp_format: match obj.get("timestamp_format") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_format")))
    },
  }
}

///|
pub fn TextStructureFindFieldStructureQuery::new(
  field : String,
  index : String,
  column_names? : Json,
  delimiter? : String,
  documents_to_sample? : String,
  ecs_compatibility? : String,
  explain? : Bool,
  format? : String,
  grok_pattern? : String,
  quote? : String,
  should_trim_fields? : Bool,
  should_parse_recursively? : Bool,
  timeout? : String,
  timestamp_field? : String,
  timestamp_format? : String,
) -> TextStructureFindFieldStructureQuery {
  {
    column_names,
    delimiter,
    documents_to_sample,
    ecs_compatibility,
    explain,
    field,
    format,
    grok_pattern,
    index,
    quote,
    should_trim_fields,
    should_parse_recursively,
    timeout,
    timestamp_field,
    timestamp_format,
  }
}

///|
pub fn TextStructureFindFieldStructureQuery::to_pairs(
  self : TextStructureFindFieldStructureQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.column_names {
    Some(value) => push_query_json(pairs, "column_names", value.to_json())
    None => ()
  }
  match self.delimiter {
    Some(value) => push_query_json(pairs, "delimiter", value.to_json())
    None => ()
  }
  match self.documents_to_sample {
    Some(value) =>
      push_query_json(pairs, "documents_to_sample", value.to_json())
    None => ()
  }
  match self.ecs_compatibility {
    Some(value) => push_query_json(pairs, "ecs_compatibility", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  push_query_json(pairs, "field", self.field.to_json())
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  match self.grok_pattern {
    Some(value) => push_query_json(pairs, "grok_pattern", value.to_json())
    None => ()
  }
  push_query_json(pairs, "index", self.index.to_json())
  match self.quote {
    Some(value) => push_query_json(pairs, "quote", value.to_json())
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => push_query_json(pairs, "should_trim_fields", value.to_json())
    None => ()
  }
  match self.should_parse_recursively {
    Some(value) =>
      push_query_json(pairs, "should_parse_recursively", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.timestamp_field {
    Some(value) => push_query_json(pairs, "timestamp_field", value.to_json())
    None => ()
  }
  match self.timestamp_format {
    Some(value) => push_query_json(pairs, "timestamp_format", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TextStructureFindFieldStructureResponse {
  charset : String
  ecs_compatibility : Json?
  field_stats : Map[String, Json]
  format : Json
  grok_pattern : Json?
  java_timestamp_formats : Array[String]?
  joda_timestamp_formats : Array[String]?
  ingest_pipeline : Json
  mappings : Json
  multiline_start_pattern : String?
  need_client_timezone : Bool
  num_lines_analyzed : Int
  num_messages_analyzed : Int
  sample_start : String
  timestamp_field : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindFieldStructureResponse with fn to_json(
  self : TextStructureFindFieldStructureResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["charset"] = self.charset.to_json()
  match self.ecs_compatibility {
    Some(value) => obj["ecs_compatibility"] = value.to_json()
    None => ()
  }
  obj["field_stats"] = self.field_stats.to_json()
  obj["format"] = self.format.to_json()
  match self.grok_pattern {
    Some(value) => obj["grok_pattern"] = value.to_json()
    None => ()
  }
  match self.java_timestamp_formats {
    Some(value) => obj["java_timestamp_formats"] = value.to_json()
    None => ()
  }
  match self.joda_timestamp_formats {
    Some(value) => obj["joda_timestamp_formats"] = value.to_json()
    None => ()
  }
  obj["ingest_pipeline"] = self.ingest_pipeline.to_json()
  obj["mappings"] = self.mappings.to_json()
  match self.multiline_start_pattern {
    Some(value) => obj["multiline_start_pattern"] = value.to_json()
    None => ()
  }
  obj["need_client_timezone"] = self.need_client_timezone.to_json()
  obj["num_lines_analyzed"] = self.num_lines_analyzed.to_json()
  obj["num_messages_analyzed"] = self.num_messages_analyzed.to_json()
  obj["sample_start"] = self.sample_start.to_json()
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindFieldStructureResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindFieldStructureResponse: expected object"),
    )
  }
  {
    charset: @json.from_json(
      obj.get("charset").unwrap_or(Json::null()),
      path=path.add_key("charset"),
    ),
    ecs_compatibility: match obj.get("ecs_compatibility") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ecs_compatibility")))
    },
    field_stats: @json.from_json(
      obj.get("field_stats").unwrap_or(Json::null()),
      path=path.add_key("field_stats"),
    ),
    format: @json.from_json(
      obj.get("format").unwrap_or(Json::null()),
      path=path.add_key("format"),
    ),
    grok_pattern: match obj.get("grok_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grok_pattern")))
    },
    java_timestamp_formats: match obj.get("java_timestamp_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("java_timestamp_formats")),
        )
    },
    joda_timestamp_formats: match obj.get("joda_timestamp_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("joda_timestamp_formats")),
        )
    },
    ingest_pipeline: @json.from_json(
      obj.get("ingest_pipeline").unwrap_or(Json::null()),
      path=path.add_key("ingest_pipeline"),
    ),
    mappings: @json.from_json(
      obj.get("mappings").unwrap_or(Json::null()),
      path=path.add_key("mappings"),
    ),
    multiline_start_pattern: match obj.get("multiline_start_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("multiline_start_pattern")),
        )
    },
    need_client_timezone: @json.from_json(
      obj.get("need_client_timezone").unwrap_or(Json::null()),
      path=path.add_key("need_client_timezone"),
    ),
    num_lines_analyzed: @json.from_json(
      obj.get("num_lines_analyzed").unwrap_or(Json::null()),
      path=path.add_key("num_lines_analyzed"),
    ),
    num_messages_analyzed: @json.from_json(
      obj.get("num_messages_analyzed").unwrap_or(Json::null()),
      path=path.add_key("num_messages_analyzed"),
    ),
    sample_start: @json.from_json(
      obj.get("sample_start").unwrap_or(Json::null()),
      path=path.add_key("sample_start"),
    ),
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
  }
}

///|
pub(all) struct TextStructureFindFieldStructureRequest {
  query : TextStructureFindFieldStructureQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TextStructureFindFieldStructureRequest::new(
  query : TextStructureFindFieldStructureQuery,
) -> TextStructureFindFieldStructureRequest {
  { query, }
}

///|
pub async fn Client::text_structure_find_field_structure(
  self : Client,
  request : TextStructureFindFieldStructureRequest,
) -> EsResponse[TextStructureFindFieldStructureResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_text_structure/find_field_structure", [])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct TextStructureFindMessageStructureQuery {
  column_names : Json?
  delimiter : String?
  ecs_compatibility : String?
  explain : Bool?
  format : String?
  grok_pattern : String?
  quote : String?
  should_trim_fields : Bool?
  should_parse_recursively : Bool?
  timeout : String?
  timestamp_field : String?
  timestamp_format : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindMessageStructureQuery with fn to_json(
  self : TextStructureFindMessageStructureQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.column_names {
    Some(value) => obj["column_names"] = value.to_json()
    None => ()
  }
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  match self.ecs_compatibility {
    Some(value) => obj["ecs_compatibility"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  match self.grok_pattern {
    Some(value) => obj["grok_pattern"] = value.to_json()
    None => ()
  }
  match self.quote {
    Some(value) => obj["quote"] = value.to_json()
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => obj["should_trim_fields"] = value.to_json()
    None => ()
  }
  match self.should_parse_recursively {
    Some(value) => obj["should_parse_recursively"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  match self.timestamp_format {
    Some(value) => obj["timestamp_format"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindMessageStructureQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindMessageStructureQuery: expected object"),
    )
  }
  {
    column_names: match obj.get("column_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("column_names")))
    },
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    ecs_compatibility: match obj.get("ecs_compatibility") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ecs_compatibility")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
    grok_pattern: match obj.get("grok_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grok_pattern")))
    },
    quote: match obj.get("quote") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("quote")))
    },
    should_trim_fields: match obj.get("should_trim_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("should_trim_fields")))
    },
    should_parse_recursively: match obj.get("should_parse_recursively") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("should_parse_recursively")),
        )
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
    timestamp_format: match obj.get("timestamp_format") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_format")))
    },
  }
}

///|
pub fn TextStructureFindMessageStructureQuery::new(
  column_names? : Json,
  delimiter? : String,
  ecs_compatibility? : String,
  explain? : Bool,
  format? : String,
  grok_pattern? : String,
  quote? : String,
  should_trim_fields? : Bool,
  should_parse_recursively? : Bool,
  timeout? : String,
  timestamp_field? : String,
  timestamp_format? : String,
) -> TextStructureFindMessageStructureQuery {
  {
    column_names,
    delimiter,
    ecs_compatibility,
    explain,
    format,
    grok_pattern,
    quote,
    should_trim_fields,
    should_parse_recursively,
    timeout,
    timestamp_field,
    timestamp_format,
  }
}

///|
pub fn TextStructureFindMessageStructureQuery::to_pairs(
  self : TextStructureFindMessageStructureQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.column_names {
    Some(value) => push_query_json(pairs, "column_names", value.to_json())
    None => ()
  }
  match self.delimiter {
    Some(value) => push_query_json(pairs, "delimiter", value.to_json())
    None => ()
  }
  match self.ecs_compatibility {
    Some(value) => push_query_json(pairs, "ecs_compatibility", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  match self.grok_pattern {
    Some(value) => push_query_json(pairs, "grok_pattern", value.to_json())
    None => ()
  }
  match self.quote {
    Some(value) => push_query_json(pairs, "quote", value.to_json())
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => push_query_json(pairs, "should_trim_fields", value.to_json())
    None => ()
  }
  match self.should_parse_recursively {
    Some(value) =>
      push_query_json(pairs, "should_parse_recursively", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.timestamp_field {
    Some(value) => push_query_json(pairs, "timestamp_field", value.to_json())
    None => ()
  }
  match self.timestamp_format {
    Some(value) => push_query_json(pairs, "timestamp_format", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TextStructureFindMessageStructureBody {
  messages : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindMessageStructureBody with fn to_json(
  self : TextStructureFindMessageStructureBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["messages"] = self.messages.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindMessageStructureBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindMessageStructureBody: expected object"),
    )
  }
  {
    messages: @json.from_json(
      obj.get("messages").unwrap_or(Json::null()),
      path=path.add_key("messages"),
    ),
  }
}

///|
pub fn TextStructureFindMessageStructureBody::new(
  messages : Array[String],
) -> TextStructureFindMessageStructureBody {
  { messages, }
}

///|
pub(all) struct TextStructureFindMessageStructureResponse {
  charset : String
  ecs_compatibility : Json?
  field_stats : Map[String, Json]
  format : Json
  grok_pattern : Json?
  java_timestamp_formats : Array[String]?
  joda_timestamp_formats : Array[String]?
  ingest_pipeline : Json
  mappings : Json
  multiline_start_pattern : String?
  need_client_timezone : Bool
  num_lines_analyzed : Int
  num_messages_analyzed : Int
  sample_start : String
  timestamp_field : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindMessageStructureResponse with fn to_json(
  self : TextStructureFindMessageStructureResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["charset"] = self.charset.to_json()
  match self.ecs_compatibility {
    Some(value) => obj["ecs_compatibility"] = value.to_json()
    None => ()
  }
  obj["field_stats"] = self.field_stats.to_json()
  obj["format"] = self.format.to_json()
  match self.grok_pattern {
    Some(value) => obj["grok_pattern"] = value.to_json()
    None => ()
  }
  match self.java_timestamp_formats {
    Some(value) => obj["java_timestamp_formats"] = value.to_json()
    None => ()
  }
  match self.joda_timestamp_formats {
    Some(value) => obj["joda_timestamp_formats"] = value.to_json()
    None => ()
  }
  obj["ingest_pipeline"] = self.ingest_pipeline.to_json()
  obj["mappings"] = self.mappings.to_json()
  match self.multiline_start_pattern {
    Some(value) => obj["multiline_start_pattern"] = value.to_json()
    None => ()
  }
  obj["need_client_timezone"] = self.need_client_timezone.to_json()
  obj["num_lines_analyzed"] = self.num_lines_analyzed.to_json()
  obj["num_messages_analyzed"] = self.num_messages_analyzed.to_json()
  obj["sample_start"] = self.sample_start.to_json()
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindMessageStructureResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindMessageStructureResponse: expected object"),
    )
  }
  {
    charset: @json.from_json(
      obj.get("charset").unwrap_or(Json::null()),
      path=path.add_key("charset"),
    ),
    ecs_compatibility: match obj.get("ecs_compatibility") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ecs_compatibility")))
    },
    field_stats: @json.from_json(
      obj.get("field_stats").unwrap_or(Json::null()),
      path=path.add_key("field_stats"),
    ),
    format: @json.from_json(
      obj.get("format").unwrap_or(Json::null()),
      path=path.add_key("format"),
    ),
    grok_pattern: match obj.get("grok_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grok_pattern")))
    },
    java_timestamp_formats: match obj.get("java_timestamp_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("java_timestamp_formats")),
        )
    },
    joda_timestamp_formats: match obj.get("joda_timestamp_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("joda_timestamp_formats")),
        )
    },
    ingest_pipeline: @json.from_json(
      obj.get("ingest_pipeline").unwrap_or(Json::null()),
      path=path.add_key("ingest_pipeline"),
    ),
    mappings: @json.from_json(
      obj.get("mappings").unwrap_or(Json::null()),
      path=path.add_key("mappings"),
    ),
    multiline_start_pattern: match obj.get("multiline_start_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("multiline_start_pattern")),
        )
    },
    need_client_timezone: @json.from_json(
      obj.get("need_client_timezone").unwrap_or(Json::null()),
      path=path.add_key("need_client_timezone"),
    ),
    num_lines_analyzed: @json.from_json(
      obj.get("num_lines_analyzed").unwrap_or(Json::null()),
      path=path.add_key("num_lines_analyzed"),
    ),
    num_messages_analyzed: @json.from_json(
      obj.get("num_messages_analyzed").unwrap_or(Json::null()),
      path=path.add_key("num_messages_analyzed"),
    ),
    sample_start: @json.from_json(
      obj.get("sample_start").unwrap_or(Json::null()),
      path=path.add_key("sample_start"),
    ),
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
  }
}

///|
pub(all) struct TextStructureFindMessageStructureRequest {
  query : TextStructureFindMessageStructureQuery
  body : TextStructureFindMessageStructureBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TextStructureFindMessageStructureRequest::new(
  body : TextStructureFindMessageStructureBody,
  query? : TextStructureFindMessageStructureQuery = TextStructureFindMessageStructureQuery::new(),
) -> TextStructureFindMessageStructureRequest {
  { query, body }
}

///|
pub async fn Client::text_structure_find_message_structure(
  self : Client,
  request : TextStructureFindMessageStructureRequest,
) -> EsResponse[TextStructureFindMessageStructureResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_text_structure/find_message_structure", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TextStructureFindStructureQuery {
  charset : String?
  column_names : Json?
  delimiter : String?
  ecs_compatibility : String?
  explain : Bool?
  format : String?
  grok_pattern : String?
  has_header_row : Bool?
  line_merge_size_limit : String?
  lines_to_sample : String?
  quote : String?
  should_trim_fields : Bool?
  should_parse_recursively : Bool?
  timeout : String?
  timestamp_field : String?
  timestamp_format : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindStructureQuery with fn to_json(
  self : TextStructureFindStructureQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.charset {
    Some(value) => obj["charset"] = value.to_json()
    None => ()
  }
  match self.column_names {
    Some(value) => obj["column_names"] = value.to_json()
    None => ()
  }
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  match self.ecs_compatibility {
    Some(value) => obj["ecs_compatibility"] = value.to_json()
    None => ()
  }
  match self.explain {
    Some(value) => obj["explain"] = value.to_json()
    None => ()
  }
  match self.format {
    Some(value) => obj["format"] = value.to_json()
    None => ()
  }
  match self.grok_pattern {
    Some(value) => obj["grok_pattern"] = value.to_json()
    None => ()
  }
  match self.has_header_row {
    Some(value) => obj["has_header_row"] = value.to_json()
    None => ()
  }
  match self.line_merge_size_limit {
    Some(value) => obj["line_merge_size_limit"] = value.to_json()
    None => ()
  }
  match self.lines_to_sample {
    Some(value) => obj["lines_to_sample"] = value.to_json()
    None => ()
  }
  match self.quote {
    Some(value) => obj["quote"] = value.to_json()
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => obj["should_trim_fields"] = value.to_json()
    None => ()
  }
  match self.should_parse_recursively {
    Some(value) => obj["should_parse_recursively"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  match self.timestamp_format {
    Some(value) => obj["timestamp_format"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindStructureQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindStructureQuery: expected object"),
    )
  }
  {
    charset: match obj.get("charset") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("charset")))
    },
    column_names: match obj.get("column_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("column_names")))
    },
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    ecs_compatibility: match obj.get("ecs_compatibility") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ecs_compatibility")))
    },
    explain: match obj.get("explain") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("explain")))
    },
    format: match obj.get("format") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("format")))
    },
    grok_pattern: match obj.get("grok_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grok_pattern")))
    },
    has_header_row: match obj.get("has_header_row") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("has_header_row")))
    },
    line_merge_size_limit: match obj.get("line_merge_size_limit") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("line_merge_size_limit")))
    },
    lines_to_sample: match obj.get("lines_to_sample") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("lines_to_sample")))
    },
    quote: match obj.get("quote") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("quote")))
    },
    should_trim_fields: match obj.get("should_trim_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("should_trim_fields")))
    },
    should_parse_recursively: match obj.get("should_parse_recursively") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("should_parse_recursively")),
        )
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
    timestamp_format: match obj.get("timestamp_format") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_format")))
    },
  }
}

///|
pub fn TextStructureFindStructureQuery::new(
  charset? : String,
  column_names? : Json,
  delimiter? : String,
  ecs_compatibility? : String,
  explain? : Bool,
  format? : String,
  grok_pattern? : String,
  has_header_row? : Bool,
  line_merge_size_limit? : String,
  lines_to_sample? : String,
  quote? : String,
  should_trim_fields? : Bool,
  should_parse_recursively? : Bool,
  timeout? : String,
  timestamp_field? : String,
  timestamp_format? : String,
) -> TextStructureFindStructureQuery {
  {
    charset,
    column_names,
    delimiter,
    ecs_compatibility,
    explain,
    format,
    grok_pattern,
    has_header_row,
    line_merge_size_limit,
    lines_to_sample,
    quote,
    should_trim_fields,
    should_parse_recursively,
    timeout,
    timestamp_field,
    timestamp_format,
  }
}

///|
pub fn TextStructureFindStructureQuery::to_pairs(
  self : TextStructureFindStructureQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.charset {
    Some(value) => push_query_json(pairs, "charset", value.to_json())
    None => ()
  }
  match self.column_names {
    Some(value) => push_query_json(pairs, "column_names", value.to_json())
    None => ()
  }
  match self.delimiter {
    Some(value) => push_query_json(pairs, "delimiter", value.to_json())
    None => ()
  }
  match self.ecs_compatibility {
    Some(value) => push_query_json(pairs, "ecs_compatibility", value.to_json())
    None => ()
  }
  match self.explain {
    Some(value) => push_query_json(pairs, "explain", value.to_json())
    None => ()
  }
  match self.format {
    Some(value) => push_query_json(pairs, "format", value.to_json())
    None => ()
  }
  match self.grok_pattern {
    Some(value) => push_query_json(pairs, "grok_pattern", value.to_json())
    None => ()
  }
  match self.has_header_row {
    Some(value) => push_query_json(pairs, "has_header_row", value.to_json())
    None => ()
  }
  match self.line_merge_size_limit {
    Some(value) =>
      push_query_json(pairs, "line_merge_size_limit", value.to_json())
    None => ()
  }
  match self.lines_to_sample {
    Some(value) => push_query_json(pairs, "lines_to_sample", value.to_json())
    None => ()
  }
  match self.quote {
    Some(value) => push_query_json(pairs, "quote", value.to_json())
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => push_query_json(pairs, "should_trim_fields", value.to_json())
    None => ()
  }
  match self.should_parse_recursively {
    Some(value) =>
      push_query_json(pairs, "should_parse_recursively", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.timestamp_field {
    Some(value) => push_query_json(pairs, "timestamp_field", value.to_json())
    None => ()
  }
  match self.timestamp_format {
    Some(value) => push_query_json(pairs, "timestamp_format", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TextStructureFindStructureBody = Array[Json]

///|
pub(all) struct TextStructureFindStructureResponse {
  charset : String
  has_header_row : Bool?
  has_byte_order_marker : Bool
  format : String
  field_stats : Map[String, Json]
  sample_start : String
  num_messages_analyzed : Int
  mappings : Json
  quote : String?
  delimiter : String?
  need_client_timezone : Bool
  num_lines_analyzed : Int
  column_names : Array[String]?
  explanation : Array[String]?
  grok_pattern : Json?
  multiline_start_pattern : String?
  exclude_lines_pattern : String?
  java_timestamp_formats : Array[String]?
  joda_timestamp_formats : Array[String]?
  timestamp_field : Json?
  should_trim_fields : Bool?
  ingest_pipeline : Json
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureFindStructureResponse with fn to_json(
  self : TextStructureFindStructureResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["charset"] = self.charset.to_json()
  match self.has_header_row {
    Some(value) => obj["has_header_row"] = value.to_json()
    None => ()
  }
  obj["has_byte_order_marker"] = self.has_byte_order_marker.to_json()
  obj["format"] = self.format.to_json()
  obj["field_stats"] = self.field_stats.to_json()
  obj["sample_start"] = self.sample_start.to_json()
  obj["num_messages_analyzed"] = self.num_messages_analyzed.to_json()
  obj["mappings"] = self.mappings.to_json()
  match self.quote {
    Some(value) => obj["quote"] = value.to_json()
    None => ()
  }
  match self.delimiter {
    Some(value) => obj["delimiter"] = value.to_json()
    None => ()
  }
  obj["need_client_timezone"] = self.need_client_timezone.to_json()
  obj["num_lines_analyzed"] = self.num_lines_analyzed.to_json()
  match self.column_names {
    Some(value) => obj["column_names"] = value.to_json()
    None => ()
  }
  match self.explanation {
    Some(value) => obj["explanation"] = value.to_json()
    None => ()
  }
  match self.grok_pattern {
    Some(value) => obj["grok_pattern"] = value.to_json()
    None => ()
  }
  match self.multiline_start_pattern {
    Some(value) => obj["multiline_start_pattern"] = value.to_json()
    None => ()
  }
  match self.exclude_lines_pattern {
    Some(value) => obj["exclude_lines_pattern"] = value.to_json()
    None => ()
  }
  match self.java_timestamp_formats {
    Some(value) => obj["java_timestamp_formats"] = value.to_json()
    None => ()
  }
  match self.joda_timestamp_formats {
    Some(value) => obj["joda_timestamp_formats"] = value.to_json()
    None => ()
  }
  match self.timestamp_field {
    Some(value) => obj["timestamp_field"] = value.to_json()
    None => ()
  }
  match self.should_trim_fields {
    Some(value) => obj["should_trim_fields"] = value.to_json()
    None => ()
  }
  obj["ingest_pipeline"] = self.ingest_pipeline.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureFindStructureResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureFindStructureResponse: expected object"),
    )
  }
  {
    charset: @json.from_json(
      obj.get("charset").unwrap_or(Json::null()),
      path=path.add_key("charset"),
    ),
    has_header_row: match obj.get("has_header_row") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("has_header_row")))
    },
    has_byte_order_marker: @json.from_json(
      obj.get("has_byte_order_marker").unwrap_or(Json::null()),
      path=path.add_key("has_byte_order_marker"),
    ),
    format: @json.from_json(
      obj.get("format").unwrap_or(Json::null()),
      path=path.add_key("format"),
    ),
    field_stats: @json.from_json(
      obj.get("field_stats").unwrap_or(Json::null()),
      path=path.add_key("field_stats"),
    ),
    sample_start: @json.from_json(
      obj.get("sample_start").unwrap_or(Json::null()),
      path=path.add_key("sample_start"),
    ),
    num_messages_analyzed: @json.from_json(
      obj.get("num_messages_analyzed").unwrap_or(Json::null()),
      path=path.add_key("num_messages_analyzed"),
    ),
    mappings: @json.from_json(
      obj.get("mappings").unwrap_or(Json::null()),
      path=path.add_key("mappings"),
    ),
    quote: match obj.get("quote") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("quote")))
    },
    delimiter: match obj.get("delimiter") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delimiter")))
    },
    need_client_timezone: @json.from_json(
      obj.get("need_client_timezone").unwrap_or(Json::null()),
      path=path.add_key("need_client_timezone"),
    ),
    num_lines_analyzed: @json.from_json(
      obj.get("num_lines_analyzed").unwrap_or(Json::null()),
      path=path.add_key("num_lines_analyzed"),
    ),
    column_names: match obj.get("column_names") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("column_names")))
    },
    explanation: match obj.get("explanation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("explanation")))
    },
    grok_pattern: match obj.get("grok_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("grok_pattern")))
    },
    multiline_start_pattern: match obj.get("multiline_start_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("multiline_start_pattern")),
        )
    },
    exclude_lines_pattern: match obj.get("exclude_lines_pattern") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_lines_pattern")))
    },
    java_timestamp_formats: match obj.get("java_timestamp_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("java_timestamp_formats")),
        )
    },
    joda_timestamp_formats: match obj.get("joda_timestamp_formats") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("joda_timestamp_formats")),
        )
    },
    timestamp_field: match obj.get("timestamp_field") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timestamp_field")))
    },
    should_trim_fields: match obj.get("should_trim_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("should_trim_fields")))
    },
    ingest_pipeline: @json.from_json(
      obj.get("ingest_pipeline").unwrap_or(Json::null()),
      path=path.add_key("ingest_pipeline"),
    ),
  }
}

///|
pub(all) struct TextStructureFindStructureRequest {
  query : TextStructureFindStructureQuery
  body : TextStructureFindStructureBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TextStructureFindStructureRequest::new(
  body : TextStructureFindStructureBody,
  query? : TextStructureFindStructureQuery = TextStructureFindStructureQuery::new(),
) -> TextStructureFindStructureRequest {
  { query, body }
}

///|
pub async fn Client::text_structure_find_structure(
  self : Client,
  request : TextStructureFindStructureRequest,
) -> EsResponse[TextStructureFindStructureResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_text_structure/find_structure", [])],
    params,
  )
  let body = Ndjson(request.body)
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TextStructureTestGrokPatternQuery {
  ecs_compatibility : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureTestGrokPatternQuery with fn to_json(
  self : TextStructureTestGrokPatternQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.ecs_compatibility {
    Some(value) => obj["ecs_compatibility"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureTestGrokPatternQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureTestGrokPatternQuery: expected object"),
    )
  }
  {
    ecs_compatibility: match obj.get("ecs_compatibility") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ecs_compatibility")))
    },
  }
}

///|
pub fn TextStructureTestGrokPatternQuery::new(
  ecs_compatibility? : String,
) -> TextStructureTestGrokPatternQuery {
  { ecs_compatibility, }
}

///|
pub fn TextStructureTestGrokPatternQuery::to_pairs(
  self : TextStructureTestGrokPatternQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.ecs_compatibility {
    Some(value) => push_query_json(pairs, "ecs_compatibility", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TextStructureTestGrokPatternBody {
  grok_pattern : Json
  text : Array[String]
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureTestGrokPatternBody with fn to_json(
  self : TextStructureTestGrokPatternBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["grok_pattern"] = self.grok_pattern.to_json()
  obj["text"] = self.text.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureTestGrokPatternBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureTestGrokPatternBody: expected object"),
    )
  }
  {
    grok_pattern: @json.from_json(
      obj.get("grok_pattern").unwrap_or(Json::null()),
      path=path.add_key("grok_pattern"),
    ),
    text: @json.from_json(
      obj.get("text").unwrap_or(Json::null()),
      path=path.add_key("text"),
    ),
  }
}

///|
pub fn TextStructureTestGrokPatternBody::new(
  grok_pattern : Json,
  text : Array[String],
) -> TextStructureTestGrokPatternBody {
  { grok_pattern, text }
}

///|
pub(all) struct TextStructureTestGrokPatternResponse {
  matches : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for TextStructureTestGrokPatternResponse with fn to_json(
  self : TextStructureTestGrokPatternResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["matches"] = self.matches.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TextStructureTestGrokPatternResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TextStructureTestGrokPatternResponse: expected object"),
    )
  }
  {
    matches: @json.from_json(
      obj.get("matches").unwrap_or(Json::null()),
      path=path.add_key("matches"),
    ),
  }
}

///|
pub(all) struct TextStructureTestGrokPatternRequest {
  query : TextStructureTestGrokPatternQuery
  body : TextStructureTestGrokPatternBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TextStructureTestGrokPatternRequest::new(
  body : TextStructureTestGrokPatternBody,
  query? : TextStructureTestGrokPatternQuery = TextStructureTestGrokPatternQuery::new(),
) -> TextStructureTestGrokPatternRequest {
  { query, body }
}

///|
pub async fn Client::text_structure_test_grok_pattern(
  self : Client,
  request : TextStructureTestGrokPatternRequest,
) -> EsResponse[TextStructureTestGrokPatternResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_text_structure/test_grok_pattern", [])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TransformDeleteTransformQuery {
  force : Bool?
  delete_dest_index : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformDeleteTransformQuery with fn to_json(
  self : TransformDeleteTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.delete_dest_index {
    Some(value) => obj["delete_dest_index"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformDeleteTransformQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformDeleteTransformQuery: expected object"),
    )
  }
  {
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    delete_dest_index: match obj.get("delete_dest_index") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("delete_dest_index")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformDeleteTransformQuery::new(
  force? : Bool,
  delete_dest_index? : Bool,
  timeout? : String,
) -> TransformDeleteTransformQuery {
  { force, delete_dest_index, timeout }
}

///|
pub fn TransformDeleteTransformQuery::to_pairs(
  self : TransformDeleteTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.delete_dest_index {
    Some(value) => push_query_json(pairs, "delete_dest_index", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformDeleteTransformResponse = Json

///|
pub(all) struct TransformDeleteTransformRequest {
  transform_id : String
  query : TransformDeleteTransformQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformDeleteTransformRequest::new(
  transform_id : String,
  query? : TransformDeleteTransformQuery = TransformDeleteTransformQuery::new(),
) -> TransformDeleteTransformRequest {
  { transform_id, query }
}

///|
pub async fn Client::transform_delete_transform(
  self : Client,
  request : TransformDeleteTransformRequest,
) -> EsResponse[TransformDeleteTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}", ["transform_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct TransformGetNodeStatsQuery {} derive(Eq, Debug)

///|
pub impl ToJson for TransformGetNodeStatsQuery with fn to_json(
  _self : TransformGetNodeStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for TransformGetNodeStatsQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "TransformGetNodeStatsQuery: expected object"))
  }
  TransformGetNodeStatsQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn TransformGetNodeStatsQuery::new() -> TransformGetNodeStatsQuery {
  TransformGetNodeStatsQuery::{  }
}

///|
pub fn TransformGetNodeStatsQuery::to_pairs(
  _self : TransformGetNodeStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub type TransformGetNodeStatsResponse = Json

///|
pub(all) struct TransformGetNodeStatsRequest {
  query : TransformGetNodeStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformGetNodeStatsRequest::new(
  query? : TransformGetNodeStatsQuery = TransformGetNodeStatsQuery::new(),
) -> TransformGetNodeStatsRequest {
  { query, }
}

///|
pub async fn Client::transform_get_node_stats(
  self : Client,
  request : TransformGetNodeStatsRequest,
) -> EsResponse[TransformGetNodeStatsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/_node_stats", [])],
    params,
  )
  self.perform_json(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct TransformGetTransformQuery {
  allow_no_match : Bool?
  from : Int?
  size : Int?
  exclude_generated : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformGetTransformQuery with fn to_json(
  self : TransformGetTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.exclude_generated {
    Some(value) => obj["exclude_generated"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformGetTransformQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TransformGetTransformQuery: expected object"))
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    exclude_generated: match obj.get("exclude_generated") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("exclude_generated")))
    },
  }
}

///|
pub fn TransformGetTransformQuery::new(
  allow_no_match? : Bool,
  from? : Int,
  size? : Int,
  exclude_generated? : Bool,
) -> TransformGetTransformQuery {
  { allow_no_match, from, size, exclude_generated }
}

///|
pub fn TransformGetTransformQuery::to_pairs(
  self : TransformGetTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.exclude_generated {
    Some(value) => push_query_json(pairs, "exclude_generated", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TransformGetTransformResponse {
  count : Int
  transforms : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for TransformGetTransformResponse with fn to_json(
  self : TransformGetTransformResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["transforms"] = self.transforms.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TransformGetTransformResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformGetTransformResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    transforms: @json.from_json(
      obj.get("transforms").unwrap_or(Json::null()),
      path=path.add_key("transforms"),
    ),
  }
}

///|
pub(all) struct TransformGetTransformRequest {
  transform_id : String?
  query : TransformGetTransformQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformGetTransformRequest::new(
  transform_id? : String,
  query? : TransformGetTransformQuery = TransformGetTransformQuery::new(),
) -> TransformGetTransformRequest {
  { transform_id, query }
}

///|
pub async fn Client::transform_get_transform(
  self : Client,
  request : TransformGetTransformRequest,
) -> EsResponse[TransformGetTransformResponse] {
  let params : Map[String, String] = Map([])
  match request.transform_id {
    Some(value) => params["transform_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_transform/{transform_id}", ["transform_id"]),
      PathVariant::new("/_transform", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct TransformGetTransformStatsQuery {
  allow_no_match : Bool?
  from : Int?
  size : Int?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformGetTransformStatsQuery with fn to_json(
  self : TransformGetTransformStatsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformGetTransformStatsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformGetTransformStatsQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformGetTransformStatsQuery::new(
  allow_no_match? : Bool,
  from? : Int,
  size? : Int,
  timeout? : String,
) -> TransformGetTransformStatsQuery {
  { allow_no_match, from, size, timeout }
}

///|
pub fn TransformGetTransformStatsQuery::to_pairs(
  self : TransformGetTransformStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.size {
    Some(value) => push_query_json(pairs, "size", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TransformGetTransformStatsResponse {
  count : Int
  transforms : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for TransformGetTransformStatsResponse with fn to_json(
  self : TransformGetTransformStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["transforms"] = self.transforms.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TransformGetTransformStatsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformGetTransformStatsResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    transforms: @json.from_json(
      obj.get("transforms").unwrap_or(Json::null()),
      path=path.add_key("transforms"),
    ),
  }
}

///|
pub(all) struct TransformGetTransformStatsRequest {
  transform_id : String
  query : TransformGetTransformStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformGetTransformStatsRequest::new(
  transform_id : String,
  query? : TransformGetTransformStatsQuery = TransformGetTransformStatsQuery::new(),
) -> TransformGetTransformStatsRequest {
  { transform_id, query }
}

///|
pub async fn Client::transform_get_transform_stats(
  self : Client,
  request : TransformGetTransformStatsRequest,
) -> EsResponse[TransformGetTransformStatsResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}/_stats", ["transform_id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct TransformPreviewTransformQuery {
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformPreviewTransformQuery with fn to_json(
  self : TransformPreviewTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformPreviewTransformQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformPreviewTransformQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformPreviewTransformQuery::new(
  timeout? : String,
) -> TransformPreviewTransformQuery {
  { timeout, }
}

///|
pub fn TransformPreviewTransformQuery::to_pairs(
  self : TransformPreviewTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TransformPreviewTransformBody {
  dest : Json?
  description : String?
  frequency : Json?
  pivot : Json?
  source : Json?
  settings : Json?
  sync : Json?
  retention_policy : Json?
  latest : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformPreviewTransformBody with fn to_json(
  self : TransformPreviewTransformBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dest {
    Some(value) => obj["dest"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  match self.pivot {
    Some(value) => obj["pivot"] = value.to_json()
    None => ()
  }
  match self.source {
    Some(value) => obj["source"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  match self.sync {
    Some(value) => obj["sync"] = value.to_json()
    None => ()
  }
  match self.retention_policy {
    Some(value) => obj["retention_policy"] = value.to_json()
    None => ()
  }
  match self.latest {
    Some(value) => obj["latest"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformPreviewTransformBody with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformPreviewTransformBody: expected object"),
    )
  }
  {
    dest: match obj.get("dest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dest")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    pivot: match obj.get("pivot") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pivot")))
    },
    source: match obj.get("source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("source")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
    sync: match obj.get("sync") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sync")))
    },
    retention_policy: match obj.get("retention_policy") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retention_policy")))
    },
    latest: match obj.get("latest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("latest")))
    },
  }
}

///|
pub fn TransformPreviewTransformBody::new(
  dest? : Json,
  description? : String,
  frequency? : Json,
  pivot? : Json,
  source? : Json,
  settings? : Json,
  sync? : Json,
  retention_policy? : Json,
  latest? : Json,
) -> TransformPreviewTransformBody {
  {
    dest,
    description,
    frequency,
    pivot,
    source,
    settings,
    sync,
    retention_policy,
    latest,
  }
}

///|
pub(all) struct TransformPreviewTransformResponse {
  generated_dest_index : Json
  preview : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for TransformPreviewTransformResponse with fn to_json(
  self : TransformPreviewTransformResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["generated_dest_index"] = self.generated_dest_index.to_json()
  obj["preview"] = self.preview.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TransformPreviewTransformResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformPreviewTransformResponse: expected object"),
    )
  }
  {
    generated_dest_index: @json.from_json(
      obj.get("generated_dest_index").unwrap_or(Json::null()),
      path=path.add_key("generated_dest_index"),
    ),
    preview: @json.from_json(
      obj.get("preview").unwrap_or(Json::null()),
      path=path.add_key("preview"),
    ),
  }
}

///|
pub(all) struct TransformPreviewTransformRequest {
  transform_id : String?
  query : TransformPreviewTransformQuery
  body : TransformPreviewTransformBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformPreviewTransformRequest::new(
  transform_id? : String,
  query? : TransformPreviewTransformQuery = TransformPreviewTransformQuery::new(),
  body? : TransformPreviewTransformBody,
) -> TransformPreviewTransformRequest {
  { transform_id, query, body }
}

///|
pub async fn Client::transform_preview_transform(
  self : Client,
  request : TransformPreviewTransformRequest,
) -> EsResponse[TransformPreviewTransformResponse] {
  let params : Map[String, String] = Map([])
  match request.transform_id {
    Some(value) => params["transform_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_transform/{transform_id}/_preview", ["transform_id"]),
      PathVariant::new("/_transform/_preview", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TransformPutTransformQuery {
  defer_validation : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformPutTransformQuery with fn to_json(
  self : TransformPutTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.defer_validation {
    Some(value) => obj["defer_validation"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformPutTransformQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TransformPutTransformQuery: expected object"))
  }
  {
    defer_validation: match obj.get("defer_validation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("defer_validation")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformPutTransformQuery::new(
  defer_validation? : Bool,
  timeout? : String,
) -> TransformPutTransformQuery {
  { defer_validation, timeout }
}

///|
pub fn TransformPutTransformQuery::to_pairs(
  self : TransformPutTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.defer_validation {
    Some(value) => push_query_json(pairs, "defer_validation", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TransformPutTransformBody {
  dest : Json
  description : String?
  frequency : Json?
  latest : Json?
  _meta : Json?
  pivot : Json?
  retention_policy : Json?
  settings : Json?
  source : Json
  sync : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformPutTransformBody with fn to_json(
  self : TransformPutTransformBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["dest"] = self.dest.to_json()
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  match self.latest {
    Some(value) => obj["latest"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.pivot {
    Some(value) => obj["pivot"] = value.to_json()
    None => ()
  }
  match self.retention_policy {
    Some(value) => obj["retention_policy"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  obj["source"] = self.source.to_json()
  match self.sync {
    Some(value) => obj["sync"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformPutTransformBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "TransformPutTransformBody: expected object"))
  }
  {
    dest: @json.from_json(
      obj.get("dest").unwrap_or(Json::null()),
      path=path.add_key("dest"),
    ),
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    latest: match obj.get("latest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("latest")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    pivot: match obj.get("pivot") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pivot")))
    },
    retention_policy: match obj.get("retention_policy") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retention_policy")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
    source: @json.from_json(
      obj.get("source").unwrap_or(Json::null()),
      path=path.add_key("source"),
    ),
    sync: match obj.get("sync") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sync")))
    },
  }
}

///|
pub fn TransformPutTransformBody::new(
  dest : Json,
  source : Json,
  description? : String,
  frequency? : Json,
  latest? : Json,
  _meta? : Json,
  pivot? : Json,
  retention_policy? : Json,
  settings? : Json,
  sync? : Json,
) -> TransformPutTransformBody {
  {
    dest,
    description,
    frequency,
    latest,
    _meta,
    pivot,
    retention_policy,
    settings,
    source,
    sync,
  }
}

///|
pub type TransformPutTransformResponse = Json

///|
pub(all) struct TransformPutTransformRequest {
  transform_id : String
  query : TransformPutTransformQuery
  body : TransformPutTransformBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformPutTransformRequest::new(
  transform_id : String,
  body : TransformPutTransformBody,
  query? : TransformPutTransformQuery = TransformPutTransformQuery::new(),
) -> TransformPutTransformRequest {
  { transform_id, query, body }
}

///|
pub async fn Client::transform_put_transform(
  self : Client,
  request : TransformPutTransformRequest,
) -> EsResponse[TransformPutTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}", ["transform_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct TransformResetTransformQuery {
  force : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformResetTransformQuery with fn to_json(
  self : TransformResetTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformResetTransformQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformResetTransformQuery: expected object"),
    )
  }
  {
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformResetTransformQuery::new(
  force? : Bool,
  timeout? : String,
) -> TransformResetTransformQuery {
  { force, timeout }
}

///|
pub fn TransformResetTransformQuery::to_pairs(
  self : TransformResetTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformResetTransformResponse = Json

///|
pub(all) struct TransformResetTransformRequest {
  transform_id : String
  query : TransformResetTransformQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformResetTransformRequest::new(
  transform_id : String,
  query? : TransformResetTransformQuery = TransformResetTransformQuery::new(),
) -> TransformResetTransformRequest {
  { transform_id, query }
}

///|
pub async fn Client::transform_reset_transform(
  self : Client,
  request : TransformResetTransformRequest,
) -> EsResponse[TransformResetTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}/_reset", ["transform_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct TransformScheduleNowTransformQuery {
  timeout : String?
  defer_ : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformScheduleNowTransformQuery with fn to_json(
  self : TransformScheduleNowTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.defer_ {
    Some(value) => obj["defer"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformScheduleNowTransformQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformScheduleNowTransformQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    defer_: match obj.get("defer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("defer")))
    },
  }
}

///|
pub fn TransformScheduleNowTransformQuery::new(
  timeout? : String,
  defer_? : Bool,
) -> TransformScheduleNowTransformQuery {
  { timeout, defer_ }
}

///|
pub fn TransformScheduleNowTransformQuery::to_pairs(
  self : TransformScheduleNowTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.defer_ {
    Some(value) => push_query_json(pairs, "defer", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformScheduleNowTransformBody = Json

///|
pub type TransformScheduleNowTransformResponse = Json

///|
pub(all) struct TransformScheduleNowTransformRequest {
  transform_id : String
  query : TransformScheduleNowTransformQuery
  body : TransformScheduleNowTransformBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformScheduleNowTransformRequest::new(
  transform_id : String,
  query? : TransformScheduleNowTransformQuery = TransformScheduleNowTransformQuery::new(),
  body? : TransformScheduleNowTransformBody,
) -> TransformScheduleNowTransformRequest {
  { transform_id, query, body }
}

///|
pub async fn Client::transform_schedule_now_transform(
  self : Client,
  request : TransformScheduleNowTransformRequest,
) -> EsResponse[TransformScheduleNowTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_transform/{transform_id}/_schedule_now", [
        "transform_id",
      ]),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TransformSetUpgradeModeQuery {
  enabled : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformSetUpgradeModeQuery with fn to_json(
  self : TransformSetUpgradeModeQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.enabled {
    Some(value) => obj["enabled"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformSetUpgradeModeQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformSetUpgradeModeQuery: expected object"),
    )
  }
  {
    enabled: match obj.get("enabled") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("enabled")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformSetUpgradeModeQuery::new(
  enabled? : Bool,
  timeout? : String,
) -> TransformSetUpgradeModeQuery {
  { enabled, timeout }
}

///|
pub fn TransformSetUpgradeModeQuery::to_pairs(
  self : TransformSetUpgradeModeQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.enabled {
    Some(value) => push_query_json(pairs, "enabled", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformSetUpgradeModeResponse = Json

///|
pub(all) struct TransformSetUpgradeModeRequest {
  query : TransformSetUpgradeModeQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformSetUpgradeModeRequest::new(
  query? : TransformSetUpgradeModeQuery = TransformSetUpgradeModeQuery::new(),
) -> TransformSetUpgradeModeRequest {
  { query, }
}

///|
pub async fn Client::transform_set_upgrade_mode(
  self : Client,
  request : TransformSetUpgradeModeRequest,
) -> EsResponse[TransformSetUpgradeModeResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/set_upgrade_mode", [])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct TransformStartTransformQuery {
  timeout : String?
  from : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformStartTransformQuery with fn to_json(
  self : TransformStartTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformStartTransformQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformStartTransformQuery: expected object"),
    )
  }
  {
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
  }
}

///|
pub fn TransformStartTransformQuery::new(
  timeout? : String,
  from? : String,
) -> TransformStartTransformQuery {
  { timeout, from }
}

///|
pub fn TransformStartTransformQuery::to_pairs(
  self : TransformStartTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformStartTransformResponse = Json

///|
pub(all) struct TransformStartTransformRequest {
  transform_id : String
  query : TransformStartTransformQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformStartTransformRequest::new(
  transform_id : String,
  query? : TransformStartTransformQuery = TransformStartTransformQuery::new(),
) -> TransformStartTransformRequest {
  { transform_id, query }
}

///|
pub async fn Client::transform_start_transform(
  self : Client,
  request : TransformStartTransformRequest,
) -> EsResponse[TransformStartTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}/_start", ["transform_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct TransformStopTransformQuery {
  allow_no_match : Bool?
  force : Bool?
  timeout : String?
  wait_for_checkpoint : Bool?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformStopTransformQuery with fn to_json(
  self : TransformStopTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_match {
    Some(value) => obj["allow_no_match"] = value.to_json()
    None => ()
  }
  match self.force {
    Some(value) => obj["force"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_checkpoint {
    Some(value) => obj["wait_for_checkpoint"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformStopTransformQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformStopTransformQuery: expected object"),
    )
  }
  {
    allow_no_match: match obj.get("allow_no_match") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_match")))
    },
    force: match obj.get("force") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("force")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_checkpoint: match obj.get("wait_for_checkpoint") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_checkpoint")))
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn TransformStopTransformQuery::new(
  allow_no_match? : Bool,
  force? : Bool,
  timeout? : String,
  wait_for_checkpoint? : Bool,
  wait_for_completion? : Bool,
) -> TransformStopTransformQuery {
  { allow_no_match, force, timeout, wait_for_checkpoint, wait_for_completion }
}

///|
pub fn TransformStopTransformQuery::to_pairs(
  self : TransformStopTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_match {
    Some(value) => push_query_json(pairs, "allow_no_match", value.to_json())
    None => ()
  }
  match self.force {
    Some(value) => push_query_json(pairs, "force", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_checkpoint {
    Some(value) =>
      push_query_json(pairs, "wait_for_checkpoint", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformStopTransformResponse = Json

///|
pub(all) struct TransformStopTransformRequest {
  transform_id : String
  query : TransformStopTransformQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformStopTransformRequest::new(
  transform_id : String,
  query? : TransformStopTransformQuery = TransformStopTransformQuery::new(),
) -> TransformStopTransformRequest {
  { transform_id, query }
}

///|
pub async fn Client::transform_stop_transform(
  self : Client,
  request : TransformStopTransformRequest,
) -> EsResponse[TransformStopTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}/_stop", ["transform_id"])],
    params,
  )
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct TransformUpdateTransformQuery {
  defer_validation : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformUpdateTransformQuery with fn to_json(
  self : TransformUpdateTransformQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.defer_validation {
    Some(value) => obj["defer_validation"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformUpdateTransformQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformUpdateTransformQuery: expected object"),
    )
  }
  {
    defer_validation: match obj.get("defer_validation") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("defer_validation")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformUpdateTransformQuery::new(
  defer_validation? : Bool,
  timeout? : String,
) -> TransformUpdateTransformQuery {
  { defer_validation, timeout }
}

///|
pub fn TransformUpdateTransformQuery::to_pairs(
  self : TransformUpdateTransformQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.defer_validation {
    Some(value) => push_query_json(pairs, "defer_validation", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct TransformUpdateTransformBody {
  dest : Json?
  description : String?
  frequency : Json?
  _meta : Json?
  source : Json?
  settings : Json?
  sync : Json?
  retention_policy : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformUpdateTransformBody with fn to_json(
  self : TransformUpdateTransformBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dest {
    Some(value) => obj["dest"] = value.to_json()
    None => ()
  }
  match self.description {
    Some(value) => obj["description"] = value.to_json()
    None => ()
  }
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  match self.source {
    Some(value) => obj["source"] = value.to_json()
    None => ()
  }
  match self.settings {
    Some(value) => obj["settings"] = value.to_json()
    None => ()
  }
  match self.sync {
    Some(value) => obj["sync"] = value.to_json()
    None => ()
  }
  match self.retention_policy {
    Some(value) => obj["retention_policy"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformUpdateTransformBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformUpdateTransformBody: expected object"),
    )
  }
  {
    dest: match obj.get("dest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dest")))
    },
    description: match obj.get("description") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("description")))
    },
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
    source: match obj.get("source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("source")))
    },
    settings: match obj.get("settings") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("settings")))
    },
    sync: match obj.get("sync") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sync")))
    },
    retention_policy: match obj.get("retention_policy") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retention_policy")))
    },
  }
}

///|
pub fn TransformUpdateTransformBody::new(
  dest? : Json,
  description? : String,
  frequency? : Json,
  _meta? : Json,
  source? : Json,
  settings? : Json,
  sync? : Json,
  retention_policy? : Json,
) -> TransformUpdateTransformBody {
  {
    dest,
    description,
    frequency,
    _meta,
    source,
    settings,
    sync,
    retention_policy,
  }
}

///|
pub(all) struct TransformUpdateTransformResponse {
  authorization : Json?
  create_time : Int
  description : String
  dest : Json
  frequency : Json?
  id : Json
  latest : Json?
  pivot : Json?
  retention_policy : Json?
  settings : Json
  source : Json
  sync : Json?
  version : Json
  _meta : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformUpdateTransformResponse with fn to_json(
  self : TransformUpdateTransformResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.authorization {
    Some(value) => obj["authorization"] = value.to_json()
    None => ()
  }
  obj["create_time"] = self.create_time.to_json()
  obj["description"] = self.description.to_json()
  obj["dest"] = self.dest.to_json()
  match self.frequency {
    Some(value) => obj["frequency"] = value.to_json()
    None => ()
  }
  obj["id"] = self.id.to_json()
  match self.latest {
    Some(value) => obj["latest"] = value.to_json()
    None => ()
  }
  match self.pivot {
    Some(value) => obj["pivot"] = value.to_json()
    None => ()
  }
  match self.retention_policy {
    Some(value) => obj["retention_policy"] = value.to_json()
    None => ()
  }
  obj["settings"] = self.settings.to_json()
  obj["source"] = self.source.to_json()
  match self.sync {
    Some(value) => obj["sync"] = value.to_json()
    None => ()
  }
  obj["version"] = self.version.to_json()
  match self._meta {
    Some(value) => obj["_meta"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformUpdateTransformResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformUpdateTransformResponse: expected object"),
    )
  }
  {
    authorization: match obj.get("authorization") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("authorization")))
    },
    create_time: @json.from_json(
      obj.get("create_time").unwrap_or(Json::null()),
      path=path.add_key("create_time"),
    ),
    description: @json.from_json(
      obj.get("description").unwrap_or(Json::null()),
      path=path.add_key("description"),
    ),
    dest: @json.from_json(
      obj.get("dest").unwrap_or(Json::null()),
      path=path.add_key("dest"),
    ),
    frequency: match obj.get("frequency") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("frequency")))
    },
    id: @json.from_json(
      obj.get("id").unwrap_or(Json::null()),
      path=path.add_key("id"),
    ),
    latest: match obj.get("latest") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("latest")))
    },
    pivot: match obj.get("pivot") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pivot")))
    },
    retention_policy: match obj.get("retention_policy") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retention_policy")))
    },
    settings: @json.from_json(
      obj.get("settings").unwrap_or(Json::null()),
      path=path.add_key("settings"),
    ),
    source: @json.from_json(
      obj.get("source").unwrap_or(Json::null()),
      path=path.add_key("source"),
    ),
    sync: match obj.get("sync") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sync")))
    },
    version: @json.from_json(
      obj.get("version").unwrap_or(Json::null()),
      path=path.add_key("version"),
    ),
    _meta: match obj.get("_meta") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_meta")))
    },
  }
}

///|
pub(all) struct TransformUpdateTransformRequest {
  transform_id : String
  query : TransformUpdateTransformQuery
  body : TransformUpdateTransformBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformUpdateTransformRequest::new(
  transform_id : String,
  body : TransformUpdateTransformBody,
  query? : TransformUpdateTransformQuery = TransformUpdateTransformQuery::new(),
) -> TransformUpdateTransformRequest {
  { transform_id, query, body }
}

///|
pub async fn Client::transform_update_transform(
  self : Client,
  request : TransformUpdateTransformRequest,
) -> EsResponse[TransformUpdateTransformResponse] {
  let params : Map[String, String] = Map([])
  params["transform_id"] = request.transform_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_transform/{transform_id}/_update", ["transform_id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct TransformUpgradeTransformsQuery {
  dry_run : Bool?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for TransformUpgradeTransformsQuery with fn to_json(
  self : TransformUpgradeTransformsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.dry_run {
    Some(value) => obj["dry_run"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for TransformUpgradeTransformsQuery with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformUpgradeTransformsQuery: expected object"),
    )
  }
  {
    dry_run: match obj.get("dry_run") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("dry_run")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn TransformUpgradeTransformsQuery::new(
  dry_run? : Bool,
  timeout? : String,
) -> TransformUpgradeTransformsQuery {
  { dry_run, timeout }
}

///|
pub fn TransformUpgradeTransformsQuery::to_pairs(
  self : TransformUpgradeTransformsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.dry_run {
    Some(value) => push_query_json(pairs, "dry_run", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type TransformUpgradeTransformsBody = Json

///|
pub(all) struct TransformUpgradeTransformsResponse {
  needs_update : Int
  no_action : Int
  updated : Int
} derive(Eq, Debug)

///|
pub impl ToJson for TransformUpgradeTransformsResponse with fn to_json(
  self : TransformUpgradeTransformsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["needs_update"] = self.needs_update.to_json()
  obj["no_action"] = self.no_action.to_json()
  obj["updated"] = self.updated.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for TransformUpgradeTransformsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "TransformUpgradeTransformsResponse: expected object"),
    )
  }
  {
    needs_update: @json.from_json(
      obj.get("needs_update").unwrap_or(Json::null()),
      path=path.add_key("needs_update"),
    ),
    no_action: @json.from_json(
      obj.get("no_action").unwrap_or(Json::null()),
      path=path.add_key("no_action"),
    ),
    updated: @json.from_json(
      obj.get("updated").unwrap_or(Json::null()),
      path=path.add_key("updated"),
    ),
  }
}

///|
pub(all) struct TransformUpgradeTransformsRequest {
  query : TransformUpgradeTransformsQuery
  body : TransformUpgradeTransformsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn TransformUpgradeTransformsRequest::new(
  query? : TransformUpgradeTransformsQuery = TransformUpgradeTransformsQuery::new(),
  body? : TransformUpgradeTransformsBody,
) -> TransformUpgradeTransformsRequest {
  { query, body }
}

///|
pub async fn Client::transform_upgrade_transforms(
  self : Client,
  request : TransformUpgradeTransformsRequest,
) -> EsResponse[TransformUpgradeTransformsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_transform/_upgrade", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct UpdateQuery {
  if_primary_term : Int?
  if_seq_no : String?
  include_source_on_error : Bool?
  lang : String?
  refresh : String?
  require_alias : Bool?
  retry_on_conflict : Int?
  routing : String?
  timeout : String?
  wait_for_active_shards : String?
  _source : String?
  _source_excludes : String?
  _source_includes : String?
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateQuery with fn to_json(self : UpdateQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.if_primary_term {
    Some(value) => obj["if_primary_term"] = value.to_json()
    None => ()
  }
  match self.if_seq_no {
    Some(value) => obj["if_seq_no"] = value.to_json()
    None => ()
  }
  match self.include_source_on_error {
    Some(value) => obj["include_source_on_error"] = value.to_json()
    None => ()
  }
  match self.lang {
    Some(value) => obj["lang"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.require_alias {
    Some(value) => obj["require_alias"] = value.to_json()
    None => ()
  }
  match self.retry_on_conflict {
    Some(value) => obj["retry_on_conflict"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self._source_excludes {
    Some(value) => obj["_source_excludes"] = value.to_json()
    None => ()
  }
  match self._source_includes {
    Some(value) => obj["_source_includes"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for UpdateQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "UpdateQuery: expected object"))
  }
  {
    if_primary_term: match obj.get("if_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_primary_term")))
    },
    if_seq_no: match obj.get("if_seq_no") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_seq_no")))
    },
    include_source_on_error: match obj.get("include_source_on_error") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("include_source_on_error")),
        )
    },
    lang: match obj.get("lang") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lang")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    require_alias: match obj.get("require_alias") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("require_alias")))
    },
    retry_on_conflict: match obj.get("retry_on_conflict") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("retry_on_conflict")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    _source_excludes: match obj.get("_source_excludes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_excludes")))
    },
    _source_includes: match obj.get("_source_includes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_source_includes")))
    },
  }
}

///|
pub fn UpdateQuery::new(
  if_primary_term? : Int,
  if_seq_no? : String,
  include_source_on_error? : Bool,
  lang? : String,
  refresh? : String,
  require_alias? : Bool,
  retry_on_conflict? : Int,
  routing? : String,
  timeout? : String,
  wait_for_active_shards? : String,
  _source? : String,
  _source_excludes? : String,
  _source_includes? : String,
) -> UpdateQuery {
  {
    if_primary_term,
    if_seq_no,
    include_source_on_error,
    lang,
    refresh,
    require_alias,
    retry_on_conflict,
    routing,
    timeout,
    wait_for_active_shards,
    _source,
    _source_excludes,
    _source_includes,
  }
}

///|
pub fn UpdateQuery::to_pairs(self : UpdateQuery) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.if_primary_term {
    Some(value) => push_query_json(pairs, "if_primary_term", value.to_json())
    None => ()
  }
  match self.if_seq_no {
    Some(value) => push_query_json(pairs, "if_seq_no", value.to_json())
    None => ()
  }
  match self.include_source_on_error {
    Some(value) =>
      push_query_json(pairs, "include_source_on_error", value.to_json())
    None => ()
  }
  match self.lang {
    Some(value) => push_query_json(pairs, "lang", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.require_alias {
    Some(value) => push_query_json(pairs, "require_alias", value.to_json())
    None => ()
  }
  match self.retry_on_conflict {
    Some(value) => push_query_json(pairs, "retry_on_conflict", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self._source {
    Some(value) => push_query_json(pairs, "_source", value.to_json())
    None => ()
  }
  match self._source_excludes {
    Some(value) => push_query_json(pairs, "_source_excludes", value.to_json())
    None => ()
  }
  match self._source_includes {
    Some(value) => push_query_json(pairs, "_source_includes", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct UpdateBody {
  detect_noop : Bool?
  doc : Json?
  doc_as_upsert : Bool?
  script : Json?
  scripted_upsert : Bool?
  _source : Json?
  upsert : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateBody with fn to_json(self : UpdateBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.detect_noop {
    Some(value) => obj["detect_noop"] = value.to_json()
    None => ()
  }
  match self.doc {
    Some(value) => obj["doc"] = value.to_json()
    None => ()
  }
  match self.doc_as_upsert {
    Some(value) => obj["doc_as_upsert"] = value.to_json()
    None => ()
  }
  match self.script {
    Some(value) => obj["script"] = value.to_json()
    None => ()
  }
  match self.scripted_upsert {
    Some(value) => obj["scripted_upsert"] = value.to_json()
    None => ()
  }
  match self._source {
    Some(value) => obj["_source"] = value.to_json()
    None => ()
  }
  match self.upsert {
    Some(value) => obj["upsert"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for UpdateBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "UpdateBody: expected object"))
  }
  {
    detect_noop: match obj.get("detect_noop") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("detect_noop")))
    },
    doc: match obj.get("doc") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("doc")))
    },
    doc_as_upsert: match obj.get("doc_as_upsert") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("doc_as_upsert")))
    },
    script: match obj.get("script") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("script")))
    },
    scripted_upsert: match obj.get("scripted_upsert") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("scripted_upsert")))
    },
    _source: match obj.get("_source") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_source")))
    },
    upsert: match obj.get("upsert") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("upsert")))
    },
  }
}

///|
pub fn UpdateBody::new(
  detect_noop? : Bool,
  doc? : Json,
  doc_as_upsert? : Bool,
  script? : Json,
  scripted_upsert? : Bool,
  _source? : Json,
  upsert? : Json,
) -> UpdateBody {
  { detect_noop, doc, doc_as_upsert, script, scripted_upsert, _source, upsert }
}

///|
pub type UpdateResponse = Json

///|
pub(all) struct UpdateRequest {
  index : String
  id : String
  query : UpdateQuery
  body : UpdateBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn UpdateRequest::new(
  index : String,
  id : String,
  body : UpdateBody,
  query? : UpdateQuery = UpdateQuery::new(),
) -> UpdateRequest {
  { index, id, query, body }
}

///|
pub async fn Client::update(
  self : Client,
  request : UpdateRequest,
) -> EsResponse[UpdateResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_update/{id}", ["index", "id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform_json(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct UpdateByQueryQuery {
  allow_no_indices : Bool?
  analyzer : String?
  analyze_wildcard : Bool?
  conflicts : String?
  default_operator : String?
  df : String?
  expand_wildcards : String?
  from : Int?
  ignore_unavailable : Bool?
  lenient : Bool?
  max_docs : Int?
  pipeline : String?
  preference : String?
  q : String?
  refresh : Bool?
  request_cache : Bool?
  requests_per_second : Double?
  routing : String?
  scroll : String?
  scroll_size : Int?
  search_timeout : String?
  search_type : String?
  slices : String?
  sort : Array[String]?
  stats : Array[String]?
  terminate_after : Int?
  timeout : String?
  version : Bool?
  version_type : Bool?
  wait_for_active_shards : String?
  wait_for_completion : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateByQueryQuery with fn to_json(
  self : UpdateByQueryQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.allow_no_indices {
    Some(value) => obj["allow_no_indices"] = value.to_json()
    None => ()
  }
  match self.analyzer {
    Some(value) => obj["analyzer"] = value.to_json()
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => obj["analyze_wildcard"] = value.to_json()
    None => ()
  }
  match self.conflicts {
    Some(value) => obj["conflicts"] = value.to_json()
    None => ()
  }
  match self.default_operator {
    Some(value) => obj["default_operator"] = value.to_json()
    None => ()
  }
  match self.df {
    Some(value) => obj["df"] = value.to_json()
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => obj["expand_wildcards"] = value.to_json()
    None => ()
  }
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => obj["ignore_unavailable"] = value.to_json()
    None => ()
  }
  match self.lenient {
    Some(value) => obj["lenient"] = value.to_json()
    None => ()
  }
  match self.max_docs {
    Some(value) => obj["max_docs"] = value.to_json()
    None => ()
  }
  match self.pipeline {
    Some(value) => obj["pipeline"] = value.to_json()
    None => ()
  }
  match self.preference {
    Some(value) => obj["preference"] = value.to_json()
    None => ()
  }
  match self.q {
    Some(value) => obj["q"] = value.to_json()
    None => ()
  }
  match self.refresh {
    Some(value) => obj["refresh"] = value.to_json()
    None => ()
  }
  match self.request_cache {
    Some(value) => obj["request_cache"] = value.to_json()
    None => ()
  }
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.routing {
    Some(value) => obj["routing"] = value.to_json()
    None => ()
  }
  match self.scroll {
    Some(value) => obj["scroll"] = value.to_json()
    None => ()
  }
  match self.scroll_size {
    Some(value) => obj["scroll_size"] = value.to_json()
    None => ()
  }
  match self.search_timeout {
    Some(value) => obj["search_timeout"] = value.to_json()
    None => ()
  }
  match self.search_type {
    Some(value) => obj["search_type"] = value.to_json()
    None => ()
  }
  match self.slices {
    Some(value) => obj["slices"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.stats {
    Some(value) => obj["stats"] = value.to_json()
    None => ()
  }
  match self.terminate_after {
    Some(value) => obj["terminate_after"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  match self.version_type {
    Some(value) => obj["version_type"] = value.to_json()
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) => obj["wait_for_active_shards"] = value.to_json()
    None => ()
  }
  match self.wait_for_completion {
    Some(value) => obj["wait_for_completion"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for UpdateByQueryQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "UpdateByQueryQuery: expected object"))
  }
  {
    allow_no_indices: match obj.get("allow_no_indices") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("allow_no_indices")))
    },
    analyzer: match obj.get("analyzer") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("analyzer")))
    },
    analyze_wildcard: match obj.get("analyze_wildcard") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("analyze_wildcard")))
    },
    conflicts: match obj.get("conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("conflicts")))
    },
    default_operator: match obj.get("default_operator") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("default_operator")))
    },
    df: match obj.get("df") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("df")))
    },
    expand_wildcards: match obj.get("expand_wildcards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("expand_wildcards")))
    },
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    ignore_unavailable: match obj.get("ignore_unavailable") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_unavailable")))
    },
    lenient: match obj.get("lenient") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("lenient")))
    },
    max_docs: match obj.get("max_docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("max_docs")))
    },
    pipeline: match obj.get("pipeline") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("pipeline")))
    },
    preference: match obj.get("preference") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("preference")))
    },
    q: match obj.get("q") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("q")))
    },
    refresh: match obj.get("refresh") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("refresh")))
    },
    request_cache: match obj.get("request_cache") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("request_cache")))
    },
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    routing: match obj.get("routing") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("routing")))
    },
    scroll: match obj.get("scroll") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("scroll")))
    },
    scroll_size: match obj.get("scroll_size") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("scroll_size")))
    },
    search_timeout: match obj.get("search_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_timeout")))
    },
    search_type: match obj.get("search_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_type")))
    },
    slices: match obj.get("slices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slices")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    stats: match obj.get("stats") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("stats")))
    },
    terminate_after: match obj.get("terminate_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("terminate_after")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
    version_type: match obj.get("version_type") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_type")))
    },
    wait_for_active_shards: match obj.get("wait_for_active_shards") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("wait_for_active_shards")),
        )
    },
    wait_for_completion: match obj.get("wait_for_completion") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("wait_for_completion")))
    },
  }
}

///|
pub fn UpdateByQueryQuery::new(
  allow_no_indices? : Bool,
  analyzer? : String,
  analyze_wildcard? : Bool,
  conflicts? : String,
  default_operator? : String,
  df? : String,
  expand_wildcards? : String,
  from? : Int,
  ignore_unavailable? : Bool,
  lenient? : Bool,
  max_docs? : Int,
  pipeline? : String,
  preference? : String,
  q? : String,
  refresh? : Bool,
  request_cache? : Bool,
  requests_per_second? : Double,
  routing? : String,
  scroll? : String,
  scroll_size? : Int,
  search_timeout? : String,
  search_type? : String,
  slices? : String,
  sort? : Array[String],
  stats? : Array[String],
  terminate_after? : Int,
  timeout? : String,
  version? : Bool,
  version_type? : Bool,
  wait_for_active_shards? : String,
  wait_for_completion? : Bool,
) -> UpdateByQueryQuery {
  {
    allow_no_indices,
    analyzer,
    analyze_wildcard,
    conflicts,
    default_operator,
    df,
    expand_wildcards,
    from,
    ignore_unavailable,
    lenient,
    max_docs,
    pipeline,
    preference,
    q,
    refresh,
    request_cache,
    requests_per_second,
    routing,
    scroll,
    scroll_size,
    search_timeout,
    search_type,
    slices,
    sort,
    stats,
    terminate_after,
    timeout,
    version,
    version_type,
    wait_for_active_shards,
    wait_for_completion,
  }
}

///|
pub fn UpdateByQueryQuery::to_pairs(
  self : UpdateByQueryQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.allow_no_indices {
    Some(value) => push_query_json(pairs, "allow_no_indices", value.to_json())
    None => ()
  }
  match self.analyzer {
    Some(value) => push_query_json(pairs, "analyzer", value.to_json())
    None => ()
  }
  match self.analyze_wildcard {
    Some(value) => push_query_json(pairs, "analyze_wildcard", value.to_json())
    None => ()
  }
  match self.conflicts {
    Some(value) => push_query_json(pairs, "conflicts", value.to_json())
    None => ()
  }
  match self.default_operator {
    Some(value) => push_query_json(pairs, "default_operator", value.to_json())
    None => ()
  }
  match self.df {
    Some(value) => push_query_json(pairs, "df", value.to_json())
    None => ()
  }
  match self.expand_wildcards {
    Some(value) => push_query_json(pairs, "expand_wildcards", value.to_json())
    None => ()
  }
  match self.from {
    Some(value) => push_query_json(pairs, "from", value.to_json())
    None => ()
  }
  match self.ignore_unavailable {
    Some(value) => push_query_json(pairs, "ignore_unavailable", value.to_json())
    None => ()
  }
  match self.lenient {
    Some(value) => push_query_json(pairs, "lenient", value.to_json())
    None => ()
  }
  match self.max_docs {
    Some(value) => push_query_json(pairs, "max_docs", value.to_json())
    None => ()
  }
  match self.pipeline {
    Some(value) => push_query_json(pairs, "pipeline", value.to_json())
    None => ()
  }
  match self.preference {
    Some(value) => push_query_json(pairs, "preference", value.to_json())
    None => ()
  }
  match self.q {
    Some(value) => push_query_json(pairs, "q", value.to_json())
    None => ()
  }
  match self.refresh {
    Some(value) => push_query_json(pairs, "refresh", value.to_json())
    None => ()
  }
  match self.request_cache {
    Some(value) => push_query_json(pairs, "request_cache", value.to_json())
    None => ()
  }
  match self.requests_per_second {
    Some(value) =>
      push_query_json(pairs, "requests_per_second", value.to_json())
    None => ()
  }
  match self.routing {
    Some(value) => push_query_json(pairs, "routing", value.to_json())
    None => ()
  }
  match self.scroll {
    Some(value) => push_query_json(pairs, "scroll", value.to_json())
    None => ()
  }
  match self.scroll_size {
    Some(value) => push_query_json(pairs, "scroll_size", value.to_json())
    None => ()
  }
  match self.search_timeout {
    Some(value) => push_query_json(pairs, "search_timeout", value.to_json())
    None => ()
  }
  match self.search_type {
    Some(value) => push_query_json(pairs, "search_type", value.to_json())
    None => ()
  }
  match self.slices {
    Some(value) => push_query_json(pairs, "slices", value.to_json())
    None => ()
  }
  match self.sort {
    Some(value) => push_query_json(pairs, "sort", value.to_json())
    None => ()
  }
  match self.stats {
    Some(value) => push_query_json(pairs, "stats", value.to_json())
    None => ()
  }
  match self.terminate_after {
    Some(value) => push_query_json(pairs, "terminate_after", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  match self.version_type {
    Some(value) => push_query_json(pairs, "version_type", value.to_json())
    None => ()
  }
  match self.wait_for_active_shards {
    Some(value) =>
      push_query_json(pairs, "wait_for_active_shards", value.to_json())
    None => ()
  }
  match self.wait_for_completion {
    Some(value) =>
      push_query_json(pairs, "wait_for_completion", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct UpdateByQueryBody {
  max_docs : Int?
  query : Json?
  script : Json?
  slice : Json?
  conflicts : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateByQueryBody with fn to_json(self : UpdateByQueryBody) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.max_docs {
    Some(value) => obj["max_docs"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.script {
    Some(value) => obj["script"] = value.to_json()
    None => ()
  }
  match self.slice {
    Some(value) => obj["slice"] = value.to_json()
    None => ()
  }
  match self.conflicts {
    Some(value) => obj["conflicts"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for UpdateByQueryBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "UpdateByQueryBody: expected object"))
  }
  {
    max_docs: match obj.get("max_docs") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("max_docs")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    script: match obj.get("script") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("script")))
    },
    slice: match obj.get("slice") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slice")))
    },
    conflicts: match obj.get("conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("conflicts")))
    },
  }
}

///|
pub fn UpdateByQueryBody::new(
  max_docs? : Int,
  query? : Json,
  script? : Json,
  slice? : Json,
  conflicts? : Json,
) -> UpdateByQueryBody {
  { max_docs, query, script, slice, conflicts }
}

///|
pub(all) struct UpdateByQueryResponse {
  batches : Int?
  failures : Array[Json]?
  noops : Int?
  deleted : Int?
  requests_per_second : Double?
  retries : Json?
  slices : Array[Json]?
  task : Json?
  timed_out : Bool?
  took : Json?
  total : Int?
  updated : Int?
  version_conflicts : Int?
  throttled : Json?
  throttled_millis : Json?
  throttled_until : Json?
  throttled_until_millis : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateByQueryResponse with fn to_json(
  self : UpdateByQueryResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.batches {
    Some(value) => obj["batches"] = value.to_json()
    None => ()
  }
  match self.failures {
    Some(value) => obj["failures"] = value.to_json()
    None => ()
  }
  match self.noops {
    Some(value) => obj["noops"] = value.to_json()
    None => ()
  }
  match self.deleted {
    Some(value) => obj["deleted"] = value.to_json()
    None => ()
  }
  match self.requests_per_second {
    Some(value) => obj["requests_per_second"] = value.to_json()
    None => ()
  }
  match self.retries {
    Some(value) => obj["retries"] = value.to_json()
    None => ()
  }
  match self.slices {
    Some(value) => obj["slices"] = value.to_json()
    None => ()
  }
  match self.task {
    Some(value) => obj["task"] = value.to_json()
    None => ()
  }
  match self.timed_out {
    Some(value) => obj["timed_out"] = value.to_json()
    None => ()
  }
  match self.took {
    Some(value) => obj["took"] = value.to_json()
    None => ()
  }
  match self.total {
    Some(value) => obj["total"] = value.to_json()
    None => ()
  }
  match self.updated {
    Some(value) => obj["updated"] = value.to_json()
    None => ()
  }
  match self.version_conflicts {
    Some(value) => obj["version_conflicts"] = value.to_json()
    None => ()
  }
  match self.throttled {
    Some(value) => obj["throttled"] = value.to_json()
    None => ()
  }
  match self.throttled_millis {
    Some(value) => obj["throttled_millis"] = value.to_json()
    None => ()
  }
  match self.throttled_until {
    Some(value) => obj["throttled_until"] = value.to_json()
    None => ()
  }
  match self.throttled_until_millis {
    Some(value) => obj["throttled_until_millis"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for UpdateByQueryResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "UpdateByQueryResponse: expected object"))
  }
  {
    batches: match obj.get("batches") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("batches")))
    },
    failures: match obj.get("failures") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("failures")))
    },
    noops: match obj.get("noops") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("noops")))
    },
    deleted: match obj.get("deleted") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("deleted")))
    },
    requests_per_second: match obj.get("requests_per_second") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("requests_per_second")))
    },
    retries: match obj.get("retries") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("retries")))
    },
    slices: match obj.get("slices") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("slices")))
    },
    task: match obj.get("task") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("task")))
    },
    timed_out: match obj.get("timed_out") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("timed_out")))
    },
    took: match obj.get("took") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("took")))
    },
    total: match obj.get("total") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("total")))
    },
    updated: match obj.get("updated") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("updated")))
    },
    version_conflicts: match obj.get("version_conflicts") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("version_conflicts")))
    },
    throttled: match obj.get("throttled") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled")))
    },
    throttled_millis: match obj.get("throttled_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled_millis")))
    },
    throttled_until: match obj.get("throttled_until") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttled_until")))
    },
    throttled_until_millis: match obj.get("throttled_until_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("throttled_until_millis")),
        )
    },
  }
}

///|
pub(all) struct UpdateByQueryRequest {
  index : String
  query : UpdateByQueryQuery
  body : UpdateByQueryBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn UpdateByQueryRequest::new(
  index : String,
  query? : UpdateByQueryQuery = UpdateByQueryQuery::new(),
  body? : UpdateByQueryBody,
) -> UpdateByQueryRequest {
  { index, query, body }
}

///|
pub async fn Client::update_by_query(
  self : Client,
  request : UpdateByQueryRequest,
) -> EsResponse[UpdateByQueryResponse] {
  let params : Map[String, String] = Map([])
  params["index"] = request.index
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/{index}/_update_by_query", ["index"])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct UpdateByQueryRethrottleQuery {
  requests_per_second : Double
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateByQueryRethrottleQuery with fn to_json(
  self : UpdateByQueryRethrottleQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["requests_per_second"] = self.requests_per_second.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for UpdateByQueryRethrottleQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "UpdateByQueryRethrottleQuery: expected object"),
    )
  }
  {
    requests_per_second: @json.from_json(
      obj.get("requests_per_second").unwrap_or(Json::null()),
      path=path.add_key("requests_per_second"),
    ),
  }
}

///|
pub fn UpdateByQueryRethrottleQuery::new(
  requests_per_second : Double,
) -> UpdateByQueryRethrottleQuery {
  { requests_per_second, }
}

///|
pub fn UpdateByQueryRethrottleQuery::to_pairs(
  self : UpdateByQueryRethrottleQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  push_query_json(
    pairs,
    "requests_per_second",
    self.requests_per_second.to_json(),
  )
  pairs
}

///|
pub(all) struct UpdateByQueryRethrottleResponse {
  nodes : Map[String, Json]
} derive(Eq, Debug)

///|
pub impl ToJson for UpdateByQueryRethrottleResponse with fn to_json(
  self : UpdateByQueryRethrottleResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["nodes"] = self.nodes.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for UpdateByQueryRethrottleResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "UpdateByQueryRethrottleResponse: expected object"),
    )
  }
  {
    nodes: @json.from_json(
      obj.get("nodes").unwrap_or(Json::null()),
      path=path.add_key("nodes"),
    ),
  }
}

///|
pub(all) struct UpdateByQueryRethrottleRequest {
  task_id : String
  query : UpdateByQueryRethrottleQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn UpdateByQueryRethrottleRequest::new(
  task_id : String,
  query : UpdateByQueryRethrottleQuery,
) -> UpdateByQueryRethrottleRequest {
  { task_id, query }
}

///|
pub async fn Client::update_by_query_rethrottle(
  self : Client,
  request : UpdateByQueryRethrottleRequest,
) -> EsResponse[UpdateByQueryRethrottleResponse] {
  let params : Map[String, String] = Map([])
  params["task_id"] = request.task_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_update_by_query/{task_id}/_rethrottle", ["task_id"])],
    params,
  )
  self.perform(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct WatcherAckWatchQuery {} derive(Eq, Debug)

///|
pub impl ToJson for WatcherAckWatchQuery with fn to_json(
  _self : WatcherAckWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for WatcherAckWatchQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "WatcherAckWatchQuery: expected object"))
  }
  WatcherAckWatchQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn WatcherAckWatchQuery::new() -> WatcherAckWatchQuery {
  WatcherAckWatchQuery::{  }
}

///|
pub fn WatcherAckWatchQuery::to_pairs(
  _self : WatcherAckWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct WatcherAckWatchResponse {
  status : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherAckWatchResponse with fn to_json(
  self : WatcherAckWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["status"] = self.status.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherAckWatchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherAckWatchResponse: expected object"))
  }
  {
    status: @json.from_json(
      obj.get("status").unwrap_or(Json::null()),
      path=path.add_key("status"),
    ),
  }
}

///|
pub(all) struct WatcherAckWatchRequest {
  watch_id : String
  action_id : String?
  query : WatcherAckWatchQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherAckWatchRequest::new(
  watch_id : String,
  action_id? : String,
  query? : WatcherAckWatchQuery = WatcherAckWatchQuery::new(),
) -> WatcherAckWatchRequest {
  { watch_id, action_id, query }
}

///|
pub async fn Client::watcher_ack_watch(
  self : Client,
  request : WatcherAckWatchRequest,
) -> EsResponse[WatcherAckWatchResponse] {
  let params : Map[String, String] = Map([])
  params["watch_id"] = request.watch_id
  match request.action_id {
    Some(value) => params["action_id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_watcher/watch/{watch_id}/_ack/{action_id}", [
        "watch_id", "action_id",
      ]),
      PathVariant::new("/_watcher/watch/{watch_id}/_ack", ["watch_id"]),
    ],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct WatcherActivateWatchQuery {} derive(Eq, Debug)

///|
pub impl ToJson for WatcherActivateWatchQuery with fn to_json(
  _self : WatcherActivateWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for WatcherActivateWatchQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "WatcherActivateWatchQuery: expected object"))
  }
  WatcherActivateWatchQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn WatcherActivateWatchQuery::new() -> WatcherActivateWatchQuery {
  WatcherActivateWatchQuery::{  }
}

///|
pub fn WatcherActivateWatchQuery::to_pairs(
  _self : WatcherActivateWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct WatcherActivateWatchResponse {
  status : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherActivateWatchResponse with fn to_json(
  self : WatcherActivateWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["status"] = self.status.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherActivateWatchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "WatcherActivateWatchResponse: expected object"),
    )
  }
  {
    status: @json.from_json(
      obj.get("status").unwrap_or(Json::null()),
      path=path.add_key("status"),
    ),
  }
}

///|
pub(all) struct WatcherActivateWatchRequest {
  watch_id : String
  query : WatcherActivateWatchQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherActivateWatchRequest::new(
  watch_id : String,
  query? : WatcherActivateWatchQuery = WatcherActivateWatchQuery::new(),
) -> WatcherActivateWatchRequest {
  { watch_id, query }
}

///|
pub async fn Client::watcher_activate_watch(
  self : Client,
  request : WatcherActivateWatchRequest,
) -> EsResponse[WatcherActivateWatchResponse] {
  let params : Map[String, String] = Map([])
  params["watch_id"] = request.watch_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_watcher/watch/{watch_id}/_activate", ["watch_id"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct WatcherDeactivateWatchQuery {} derive(Eq, Debug)

///|
pub impl ToJson for WatcherDeactivateWatchQuery with fn to_json(
  _self : WatcherDeactivateWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for WatcherDeactivateWatchQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError(
      (path, "WatcherDeactivateWatchQuery: expected object"),
    )
  }
  WatcherDeactivateWatchQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn WatcherDeactivateWatchQuery::new() -> WatcherDeactivateWatchQuery {
  WatcherDeactivateWatchQuery::{  }
}

///|
pub fn WatcherDeactivateWatchQuery::to_pairs(
  _self : WatcherDeactivateWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct WatcherDeactivateWatchResponse {
  status : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherDeactivateWatchResponse with fn to_json(
  self : WatcherDeactivateWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["status"] = self.status.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherDeactivateWatchResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "WatcherDeactivateWatchResponse: expected object"),
    )
  }
  {
    status: @json.from_json(
      obj.get("status").unwrap_or(Json::null()),
      path=path.add_key("status"),
    ),
  }
}

///|
pub(all) struct WatcherDeactivateWatchRequest {
  watch_id : String
  query : WatcherDeactivateWatchQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherDeactivateWatchRequest::new(
  watch_id : String,
  query? : WatcherDeactivateWatchQuery = WatcherDeactivateWatchQuery::new(),
) -> WatcherDeactivateWatchRequest {
  { watch_id, query }
}

///|
pub async fn Client::watcher_deactivate_watch(
  self : Client,
  request : WatcherDeactivateWatchRequest,
) -> EsResponse[WatcherDeactivateWatchResponse] {
  let params : Map[String, String] = Map([])
  params["watch_id"] = request.watch_id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_watcher/watch/{watch_id}/_deactivate", ["watch_id"])],
    params,
  )
  self.perform(EsRequest::new(Put, path, query~))
}

///|
pub(all) struct WatcherDeleteWatchQuery {} derive(Eq, Debug)

///|
pub impl ToJson for WatcherDeleteWatchQuery with fn to_json(
  _self : WatcherDeleteWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for WatcherDeleteWatchQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "WatcherDeleteWatchQuery: expected object"))
  }
  WatcherDeleteWatchQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn WatcherDeleteWatchQuery::new() -> WatcherDeleteWatchQuery {
  WatcherDeleteWatchQuery::{  }
}

///|
pub fn WatcherDeleteWatchQuery::to_pairs(
  _self : WatcherDeleteWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct WatcherDeleteWatchResponse {
  found : Bool
  _id : Json
  _version : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherDeleteWatchResponse with fn to_json(
  self : WatcherDeleteWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  obj["_id"] = self._id.to_json()
  obj["_version"] = self._version.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherDeleteWatchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherDeleteWatchResponse: expected object"))
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
    _id: @json.from_json(
      obj.get("_id").unwrap_or(Json::null()),
      path=path.add_key("_id"),
    ),
    _version: @json.from_json(
      obj.get("_version").unwrap_or(Json::null()),
      path=path.add_key("_version"),
    ),
  }
}

///|
pub(all) struct WatcherDeleteWatchRequest {
  id : String
  query : WatcherDeleteWatchQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherDeleteWatchRequest::new(
  id : String,
  query? : WatcherDeleteWatchQuery = WatcherDeleteWatchQuery::new(),
) -> WatcherDeleteWatchRequest {
  { id, query }
}

///|
pub async fn Client::watcher_delete_watch(
  self : Client,
  request : WatcherDeleteWatchRequest,
) -> EsResponse[WatcherDeleteWatchResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_watcher/watch/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Delete, path, query~))
}

///|
pub(all) struct WatcherExecuteWatchQuery {
  debug : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherExecuteWatchQuery with fn to_json(
  self : WatcherExecuteWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.debug {
    Some(value) => obj["debug"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherExecuteWatchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherExecuteWatchQuery: expected object"))
  }
  {
    debug: match obj.get("debug") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("debug")))
    },
  }
}

///|
pub fn WatcherExecuteWatchQuery::new(debug? : Bool) -> WatcherExecuteWatchQuery {
  { debug, }
}

///|
pub fn WatcherExecuteWatchQuery::to_pairs(
  self : WatcherExecuteWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.debug {
    Some(value) => push_query_json(pairs, "debug", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct WatcherExecuteWatchBody {
  action_modes : Map[String, Json]?
  alternative_input : Map[String, Json]?
  ignore_condition : Bool?
  record_execution : Bool?
  simulated_actions : Json?
  trigger_data : Json?
  watch : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherExecuteWatchBody with fn to_json(
  self : WatcherExecuteWatchBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.action_modes {
    Some(value) => obj["action_modes"] = value.to_json()
    None => ()
  }
  match self.alternative_input {
    Some(value) => obj["alternative_input"] = value.to_json()
    None => ()
  }
  match self.ignore_condition {
    Some(value) => obj["ignore_condition"] = value.to_json()
    None => ()
  }
  match self.record_execution {
    Some(value) => obj["record_execution"] = value.to_json()
    None => ()
  }
  match self.simulated_actions {
    Some(value) => obj["simulated_actions"] = value.to_json()
    None => ()
  }
  match self.trigger_data {
    Some(value) => obj["trigger_data"] = value.to_json()
    None => ()
  }
  match self.watch {
    Some(value) => obj["watch"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherExecuteWatchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherExecuteWatchBody: expected object"))
  }
  {
    action_modes: match obj.get("action_modes") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("action_modes")))
    },
    alternative_input: match obj.get("alternative_input") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("alternative_input")))
    },
    ignore_condition: match obj.get("ignore_condition") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("ignore_condition")))
    },
    record_execution: match obj.get("record_execution") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("record_execution")))
    },
    simulated_actions: match obj.get("simulated_actions") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("simulated_actions")))
    },
    trigger_data: match obj.get("trigger_data") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("trigger_data")))
    },
    watch: match obj.get("watch") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("watch")))
    },
  }
}

///|
pub fn WatcherExecuteWatchBody::new(
  action_modes? : Map[String, Json],
  alternative_input? : Map[String, Json],
  ignore_condition? : Bool,
  record_execution? : Bool,
  simulated_actions? : Json,
  trigger_data? : Json,
  watch? : Json,
) -> WatcherExecuteWatchBody {
  {
    action_modes,
    alternative_input,
    ignore_condition,
    record_execution,
    simulated_actions,
    trigger_data,
    watch,
  }
}

///|
pub(all) struct WatcherExecuteWatchResponse {
  _id : Json
  watch_record : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherExecuteWatchResponse with fn to_json(
  self : WatcherExecuteWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_id"] = self._id.to_json()
  obj["watch_record"] = self.watch_record.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherExecuteWatchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "WatcherExecuteWatchResponse: expected object"),
    )
  }
  {
    _id: @json.from_json(
      obj.get("_id").unwrap_or(Json::null()),
      path=path.add_key("_id"),
    ),
    watch_record: @json.from_json(
      obj.get("watch_record").unwrap_or(Json::null()),
      path=path.add_key("watch_record"),
    ),
  }
}

///|
pub(all) struct WatcherExecuteWatchRequest {
  id : String?
  query : WatcherExecuteWatchQuery
  body : WatcherExecuteWatchBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherExecuteWatchRequest::new(
  id? : String,
  query? : WatcherExecuteWatchQuery = WatcherExecuteWatchQuery::new(),
  body? : WatcherExecuteWatchBody,
) -> WatcherExecuteWatchRequest {
  { id, query, body }
}

///|
pub async fn Client::watcher_execute_watch(
  self : Client,
  request : WatcherExecuteWatchRequest,
) -> EsResponse[WatcherExecuteWatchResponse] {
  let params : Map[String, String] = Map([])
  match request.id {
    Some(value) => params["id"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_watcher/watch/{id}/_execute", ["id"]),
      PathVariant::new("/_watcher/watch/_execute", []),
    ],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct WatcherGetSettingsQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherGetSettingsQuery with fn to_json(
  self : WatcherGetSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherGetSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherGetSettingsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn WatcherGetSettingsQuery::new(
  master_timeout? : String,
) -> WatcherGetSettingsQuery {
  { master_timeout, }
}

///|
pub fn WatcherGetSettingsQuery::to_pairs(
  self : WatcherGetSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type WatcherGetSettingsBody = Json

///|
pub(all) struct WatcherGetSettingsResponse {
  index : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherGetSettingsResponse with fn to_json(
  self : WatcherGetSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["index"] = self.index.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherGetSettingsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherGetSettingsResponse: expected object"))
  }
  {
    index: @json.from_json(
      obj.get("index").unwrap_or(Json::null()),
      path=path.add_key("index"),
    ),
  }
}

///|
pub(all) struct WatcherGetSettingsRequest {
  query : WatcherGetSettingsQuery
  body : WatcherGetSettingsBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherGetSettingsRequest::new(
  query? : WatcherGetSettingsQuery = WatcherGetSettingsQuery::new(),
  body? : WatcherGetSettingsBody,
) -> WatcherGetSettingsRequest {
  { query, body }
}

///|
pub async fn Client::watcher_get_settings(
  self : Client,
  request : WatcherGetSettingsRequest,
) -> EsResponse[WatcherGetSettingsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_watcher/settings", [])], params)
  let body = match request.body {
    Some(value) => JsonBody(value)
    None => NoBody
  }
  self.perform(EsRequest::new(Get, path, query~, body~))
}

///|
pub(all) struct WatcherGetWatchQuery {} derive(Eq, Debug)

///|
pub impl ToJson for WatcherGetWatchQuery with fn to_json(
  _self : WatcherGetWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for WatcherGetWatchQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "WatcherGetWatchQuery: expected object"))
  }
  WatcherGetWatchQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn WatcherGetWatchQuery::new() -> WatcherGetWatchQuery {
  WatcherGetWatchQuery::{  }
}

///|
pub fn WatcherGetWatchQuery::to_pairs(
  _self : WatcherGetWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct WatcherGetWatchResponse {
  found : Bool
  _id : Json
  status : Json?
  watch : Json?
  _primary_term : Int?
  _seq_no : Json?
  _version : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherGetWatchResponse with fn to_json(
  self : WatcherGetWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["found"] = self.found.to_json()
  obj["_id"] = self._id.to_json()
  match self.status {
    Some(value) => obj["status"] = value.to_json()
    None => ()
  }
  match self.watch {
    Some(value) => obj["watch"] = value.to_json()
    None => ()
  }
  match self._primary_term {
    Some(value) => obj["_primary_term"] = value.to_json()
    None => ()
  }
  match self._seq_no {
    Some(value) => obj["_seq_no"] = value.to_json()
    None => ()
  }
  match self._version {
    Some(value) => obj["_version"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherGetWatchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherGetWatchResponse: expected object"))
  }
  {
    found: @json.from_json(
      obj.get("found").unwrap_or(Json::null()),
      path=path.add_key("found"),
    ),
    _id: @json.from_json(
      obj.get("_id").unwrap_or(Json::null()),
      path=path.add_key("_id"),
    ),
    status: match obj.get("status") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("status")))
    },
    watch: match obj.get("watch") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("watch")))
    },
    _primary_term: match obj.get("_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("_primary_term")))
    },
    _seq_no: match obj.get("_seq_no") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_seq_no")))
    },
    _version: match obj.get("_version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("_version")))
    },
  }
}

///|
pub(all) struct WatcherGetWatchRequest {
  id : String
  query : WatcherGetWatchQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherGetWatchRequest::new(
  id : String,
  query? : WatcherGetWatchQuery = WatcherGetWatchQuery::new(),
) -> WatcherGetWatchRequest {
  { id, query }
}

///|
pub async fn Client::watcher_get_watch(
  self : Client,
  request : WatcherGetWatchRequest,
) -> EsResponse[WatcherGetWatchResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_watcher/watch/{id}", ["id"])],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct WatcherPutWatchQuery {
  active : Bool?
  if_primary_term : Int?
  if_seq_no : String?
  version : String?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherPutWatchQuery with fn to_json(
  self : WatcherPutWatchQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.active {
    Some(value) => obj["active"] = value.to_json()
    None => ()
  }
  match self.if_primary_term {
    Some(value) => obj["if_primary_term"] = value.to_json()
    None => ()
  }
  match self.if_seq_no {
    Some(value) => obj["if_seq_no"] = value.to_json()
    None => ()
  }
  match self.version {
    Some(value) => obj["version"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherPutWatchQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherPutWatchQuery: expected object"))
  }
  {
    active: match obj.get("active") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("active")))
    },
    if_primary_term: match obj.get("if_primary_term") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_primary_term")))
    },
    if_seq_no: match obj.get("if_seq_no") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("if_seq_no")))
    },
    version: match obj.get("version") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("version")))
    },
  }
}

///|
pub fn WatcherPutWatchQuery::new(
  active? : Bool,
  if_primary_term? : Int,
  if_seq_no? : String,
  version? : String,
) -> WatcherPutWatchQuery {
  { active, if_primary_term, if_seq_no, version }
}

///|
pub fn WatcherPutWatchQuery::to_pairs(
  self : WatcherPutWatchQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.active {
    Some(value) => push_query_json(pairs, "active", value.to_json())
    None => ()
  }
  match self.if_primary_term {
    Some(value) => push_query_json(pairs, "if_primary_term", value.to_json())
    None => ()
  }
  match self.if_seq_no {
    Some(value) => push_query_json(pairs, "if_seq_no", value.to_json())
    None => ()
  }
  match self.version {
    Some(value) => push_query_json(pairs, "version", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct WatcherPutWatchBody {
  actions : Map[String, Json]?
  condition : Json?
  input : Json?
  metadata : Json?
  throttle_period : Json?
  throttle_period_in_millis : Json?
  transform : Json?
  trigger : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherPutWatchBody with fn to_json(
  self : WatcherPutWatchBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.actions {
    Some(value) => obj["actions"] = value.to_json()
    None => ()
  }
  match self.condition {
    Some(value) => obj["condition"] = value.to_json()
    None => ()
  }
  match self.input {
    Some(value) => obj["input"] = value.to_json()
    None => ()
  }
  match self.metadata {
    Some(value) => obj["metadata"] = value.to_json()
    None => ()
  }
  match self.throttle_period {
    Some(value) => obj["throttle_period"] = value.to_json()
    None => ()
  }
  match self.throttle_period_in_millis {
    Some(value) => obj["throttle_period_in_millis"] = value.to_json()
    None => ()
  }
  match self.transform {
    Some(value) => obj["transform"] = value.to_json()
    None => ()
  }
  match self.trigger {
    Some(value) => obj["trigger"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherPutWatchBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherPutWatchBody: expected object"))
  }
  {
    actions: match obj.get("actions") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("actions")))
    },
    condition: match obj.get("condition") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("condition")))
    },
    input: match obj.get("input") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("input")))
    },
    metadata: match obj.get("metadata") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metadata")))
    },
    throttle_period: match obj.get("throttle_period") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("throttle_period")))
    },
    throttle_period_in_millis: match obj.get("throttle_period_in_millis") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("throttle_period_in_millis")),
        )
    },
    transform: match obj.get("transform") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("transform")))
    },
    trigger: match obj.get("trigger") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("trigger")))
    },
  }
}

///|
pub fn WatcherPutWatchBody::new(
  actions? : Map[String, Json],
  condition? : Json,
  input? : Json,
  metadata? : Json,
  throttle_period? : Json,
  throttle_period_in_millis? : Json,
  transform? : Json,
  trigger? : Json,
) -> WatcherPutWatchBody {
  {
    actions,
    condition,
    input,
    metadata,
    throttle_period,
    throttle_period_in_millis,
    transform,
    trigger,
  }
}

///|
pub(all) struct WatcherPutWatchResponse {
  created : Bool
  _id : Json
  _primary_term : Int
  _seq_no : Json
  _version : Json
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherPutWatchResponse with fn to_json(
  self : WatcherPutWatchResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["created"] = self.created.to_json()
  obj["_id"] = self._id.to_json()
  obj["_primary_term"] = self._primary_term.to_json()
  obj["_seq_no"] = self._seq_no.to_json()
  obj["_version"] = self._version.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherPutWatchResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherPutWatchResponse: expected object"))
  }
  {
    created: @json.from_json(
      obj.get("created").unwrap_or(Json::null()),
      path=path.add_key("created"),
    ),
    _id: @json.from_json(
      obj.get("_id").unwrap_or(Json::null()),
      path=path.add_key("_id"),
    ),
    _primary_term: @json.from_json(
      obj.get("_primary_term").unwrap_or(Json::null()),
      path=path.add_key("_primary_term"),
    ),
    _seq_no: @json.from_json(
      obj.get("_seq_no").unwrap_or(Json::null()),
      path=path.add_key("_seq_no"),
    ),
    _version: @json.from_json(
      obj.get("_version").unwrap_or(Json::null()),
      path=path.add_key("_version"),
    ),
  }
}

///|
pub(all) struct WatcherPutWatchRequest {
  id : String
  query : WatcherPutWatchQuery
  body : WatcherPutWatchBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherPutWatchRequest::new(
  id : String,
  body : WatcherPutWatchBody,
  query? : WatcherPutWatchQuery = WatcherPutWatchQuery::new(),
) -> WatcherPutWatchRequest {
  { id, query, body }
}

///|
pub async fn Client::watcher_put_watch(
  self : Client,
  request : WatcherPutWatchRequest,
) -> EsResponse[WatcherPutWatchResponse] {
  let params : Map[String, String] = Map([])
  params["id"] = request.id
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_watcher/watch/{id}", ["id"])],
    params,
  )
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct WatcherQueryWatchesQuery {} derive(Eq, Debug)

///|
pub impl ToJson for WatcherQueryWatchesQuery with fn to_json(
  _self : WatcherQueryWatchesQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  Json::object(obj)
}

///|
#warnings("-unnecessary_annotation")
pub impl FromJson for WatcherQueryWatchesQuery with fn from_json(json, path) {
  guard json is Object(_) || json is Null else {
    raise JsonDecodeError((path, "WatcherQueryWatchesQuery: expected object"))
  }
  WatcherQueryWatchesQuery::{  }
}

///|
#warnings("-unnecessary_annotation")
pub fn WatcherQueryWatchesQuery::new() -> WatcherQueryWatchesQuery {
  WatcherQueryWatchesQuery::{  }
}

///|
pub fn WatcherQueryWatchesQuery::to_pairs(
  _self : WatcherQueryWatchesQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  pairs
}

///|
pub(all) struct WatcherQueryWatchesBody {
  from : Int?
  size : Int?
  query : Json?
  sort : Json?
  search_after : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherQueryWatchesBody with fn to_json(
  self : WatcherQueryWatchesBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.from {
    Some(value) => obj["from"] = value.to_json()
    None => ()
  }
  match self.size {
    Some(value) => obj["size"] = value.to_json()
    None => ()
  }
  match self.query {
    Some(value) => obj["query"] = value.to_json()
    None => ()
  }
  match self.sort {
    Some(value) => obj["sort"] = value.to_json()
    None => ()
  }
  match self.search_after {
    Some(value) => obj["search_after"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherQueryWatchesBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherQueryWatchesBody: expected object"))
  }
  {
    from: match obj.get("from") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("from")))
    },
    size: match obj.get("size") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("size")))
    },
    query: match obj.get("query") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("query")))
    },
    sort: match obj.get("sort") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("sort")))
    },
    search_after: match obj.get("search_after") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("search_after")))
    },
  }
}

///|
pub fn WatcherQueryWatchesBody::new(
  from? : Int,
  size? : Int,
  query? : Json,
  sort? : Json,
  search_after? : Json,
) -> WatcherQueryWatchesBody {
  { from, size, query, sort, search_after }
}

///|
pub(all) struct WatcherQueryWatchesResponse {
  count : Int
  watches : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherQueryWatchesResponse with fn to_json(
  self : WatcherQueryWatchesResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["count"] = self.count.to_json()
  obj["watches"] = self.watches.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherQueryWatchesResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "WatcherQueryWatchesResponse: expected object"),
    )
  }
  {
    count: @json.from_json(
      obj.get("count").unwrap_or(Json::null()),
      path=path.add_key("count"),
    ),
    watches: @json.from_json(
      obj.get("watches").unwrap_or(Json::null()),
      path=path.add_key("watches"),
    ),
  }
}

///|
pub(all) struct WatcherQueryWatchesRequest {
  query : WatcherQueryWatchesQuery
  body : WatcherQueryWatchesBody?
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherQueryWatchesRequest::new(
  query? : WatcherQueryWatchesQuery = WatcherQueryWatchesQuery::new(),
  body? : WatcherQueryWatchesBody,
) -> WatcherQueryWatchesRequest {
  { query, body }
}

///|
pub async fn Client::watcher_query_watches(
  self : Client,
  request : WatcherQueryWatchesRequest,
) -> EsResponse[WatcherQueryWatchesResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path(
    [PathVariant::new("/_watcher/_query/watches", [])],
    params,
  )
  let body = match request.body {
    Some(value) => JsonBody(value.to_json())
    None => NoBody
  }
  self.perform(EsRequest::new(Post, path, query~, body~))
}

///|
pub(all) struct WatcherStartQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherStartQuery with fn to_json(self : WatcherStartQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherStartQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherStartQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn WatcherStartQuery::new(master_timeout? : String) -> WatcherStartQuery {
  { master_timeout, }
}

///|
pub fn WatcherStartQuery::to_pairs(
  self : WatcherStartQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type WatcherStartResponse = Json

///|
pub(all) struct WatcherStartRequest {
  query : WatcherStartQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherStartRequest::new(
  query? : WatcherStartQuery = WatcherStartQuery::new(),
) -> WatcherStartRequest {
  { query, }
}

///|
pub async fn Client::watcher_start(
  self : Client,
  request : WatcherStartRequest,
) -> EsResponse[WatcherStartResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_watcher/_start", [])], params)
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct WatcherStatsQuery {
  emit_stacktraces : Bool?
  metric : Json?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherStatsQuery with fn to_json(self : WatcherStatsQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.emit_stacktraces {
    Some(value) => obj["emit_stacktraces"] = value.to_json()
    None => ()
  }
  match self.metric {
    Some(value) => obj["metric"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherStatsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherStatsQuery: expected object"))
  }
  {
    emit_stacktraces: match obj.get("emit_stacktraces") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("emit_stacktraces")))
    },
    metric: match obj.get("metric") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("metric")))
    },
  }
}

///|
pub fn WatcherStatsQuery::new(
  emit_stacktraces? : Bool,
  metric? : Json,
) -> WatcherStatsQuery {
  { emit_stacktraces, metric }
}

///|
pub fn WatcherStatsQuery::to_pairs(
  self : WatcherStatsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.emit_stacktraces {
    Some(value) => push_query_json(pairs, "emit_stacktraces", value.to_json())
    None => ()
  }
  match self.metric {
    Some(value) => push_query_json(pairs, "metric", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct WatcherStatsResponse {
  _nodes : Json
  cluster_name : Json
  manually_stopped : Bool
  stats : Array[Json]
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherStatsResponse with fn to_json(
  self : WatcherStatsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["_nodes"] = self._nodes.to_json()
  obj["cluster_name"] = self.cluster_name.to_json()
  obj["manually_stopped"] = self.manually_stopped.to_json()
  obj["stats"] = self.stats.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherStatsResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherStatsResponse: expected object"))
  }
  {
    _nodes: @json.from_json(
      obj.get("_nodes").unwrap_or(Json::null()),
      path=path.add_key("_nodes"),
    ),
    cluster_name: @json.from_json(
      obj.get("cluster_name").unwrap_or(Json::null()),
      path=path.add_key("cluster_name"),
    ),
    manually_stopped: @json.from_json(
      obj.get("manually_stopped").unwrap_or(Json::null()),
      path=path.add_key("manually_stopped"),
    ),
    stats: @json.from_json(
      obj.get("stats").unwrap_or(Json::null()),
      path=path.add_key("stats"),
    ),
  }
}

///|
pub(all) struct WatcherStatsRequest {
  metric : String?
  query : WatcherStatsQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherStatsRequest::new(
  metric? : String,
  query? : WatcherStatsQuery = WatcherStatsQuery::new(),
) -> WatcherStatsRequest {
  { metric, query }
}

///|
pub async fn Client::watcher_stats(
  self : Client,
  request : WatcherStatsRequest,
) -> EsResponse[WatcherStatsResponse] {
  let params : Map[String, String] = Map([])
  match request.metric {
    Some(value) => params["metric"] = value
    None => ()
  }
  let query = request.query.to_pairs()
  let path = select_path(
    [
      PathVariant::new("/_watcher/stats/{metric}", ["metric"]),
      PathVariant::new("/_watcher/stats", []),
    ],
    params,
  )
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct WatcherStopQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherStopQuery with fn to_json(self : WatcherStopQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherStopQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherStopQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn WatcherStopQuery::new(master_timeout? : String) -> WatcherStopQuery {
  { master_timeout, }
}

///|
pub fn WatcherStopQuery::to_pairs(
  self : WatcherStopQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub type WatcherStopResponse = Json

///|
pub(all) struct WatcherStopRequest {
  query : WatcherStopQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherStopRequest::new(
  query? : WatcherStopQuery = WatcherStopQuery::new(),
) -> WatcherStopRequest {
  { query, }
}

///|
pub async fn Client::watcher_stop(
  self : Client,
  request : WatcherStopRequest,
) -> EsResponse[WatcherStopResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_watcher/_stop", [])], params)
  self.perform_json(EsRequest::new(Post, path, query~))
}

///|
pub(all) struct WatcherUpdateSettingsQuery {
  master_timeout : String?
  timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherUpdateSettingsQuery with fn to_json(
  self : WatcherUpdateSettingsQuery,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  match self.timeout {
    Some(value) => obj["timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherUpdateSettingsQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherUpdateSettingsQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
    timeout: match obj.get("timeout") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("timeout")))
    },
  }
}

///|
pub fn WatcherUpdateSettingsQuery::new(
  master_timeout? : String,
  timeout? : String,
) -> WatcherUpdateSettingsQuery {
  { master_timeout, timeout }
}

///|
pub fn WatcherUpdateSettingsQuery::to_pairs(
  self : WatcherUpdateSettingsQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  match self.timeout {
    Some(value) => push_query_json(pairs, "timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct WatcherUpdateSettingsBody {
  index_auto_expand_replicas : String?
  index_number_of_replicas : Int?
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherUpdateSettingsBody with fn to_json(
  self : WatcherUpdateSettingsBody,
) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.index_auto_expand_replicas {
    Some(value) => obj["index.auto_expand_replicas"] = value.to_json()
    None => ()
  }
  match self.index_number_of_replicas {
    Some(value) => obj["index.number_of_replicas"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for WatcherUpdateSettingsBody with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "WatcherUpdateSettingsBody: expected object"))
  }
  {
    index_auto_expand_replicas: match obj.get("index.auto_expand_replicas") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(
            value,
            path=path.add_key("index.auto_expand_replicas"),
          ),
        )
    },
    index_number_of_replicas: match obj.get("index.number_of_replicas") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(
          @json.from_json(value, path=path.add_key("index.number_of_replicas")),
        )
    },
  }
}

///|
pub fn WatcherUpdateSettingsBody::new(
  index_auto_expand_replicas? : String,
  index_number_of_replicas? : Int,
) -> WatcherUpdateSettingsBody {
  { index_auto_expand_replicas, index_number_of_replicas }
}

///|
pub(all) struct WatcherUpdateSettingsResponse {
  acknowledged : Bool
} derive(Eq, Debug)

///|
pub impl ToJson for WatcherUpdateSettingsResponse with fn to_json(
  self : WatcherUpdateSettingsResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["acknowledged"] = self.acknowledged.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for WatcherUpdateSettingsResponse with fn from_json(
  json,
  path,
) {
  guard json is Object(obj) else {
    raise JsonDecodeError(
      (path, "WatcherUpdateSettingsResponse: expected object"),
    )
  }
  {
    acknowledged: @json.from_json(
      obj.get("acknowledged").unwrap_or(Json::null()),
      path=path.add_key("acknowledged"),
    ),
  }
}

///|
pub(all) struct WatcherUpdateSettingsRequest {
  query : WatcherUpdateSettingsQuery
  body : WatcherUpdateSettingsBody
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn WatcherUpdateSettingsRequest::new(
  body : WatcherUpdateSettingsBody,
  query? : WatcherUpdateSettingsQuery = WatcherUpdateSettingsQuery::new(),
) -> WatcherUpdateSettingsRequest {
  { query, body }
}

///|
pub async fn Client::watcher_update_settings(
  self : Client,
  request : WatcherUpdateSettingsRequest,
) -> EsResponse[WatcherUpdateSettingsResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_watcher/settings", [])], params)
  let body = JsonBody(request.body.to_json())
  self.perform(EsRequest::new(Put, path, query~, body~))
}

///|
pub(all) struct XpackInfoQuery {
  categories : Array[String]?
  accept_enterprise : Bool?
  human : Bool?
} derive(Eq, Debug)

///|
pub impl ToJson for XpackInfoQuery with fn to_json(self : XpackInfoQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.categories {
    Some(value) => obj["categories"] = value.to_json()
    None => ()
  }
  match self.accept_enterprise {
    Some(value) => obj["accept_enterprise"] = value.to_json()
    None => ()
  }
  match self.human {
    Some(value) => obj["human"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for XpackInfoQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "XpackInfoQuery: expected object"))
  }
  {
    categories: match obj.get("categories") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("categories")))
    },
    accept_enterprise: match obj.get("accept_enterprise") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("accept_enterprise")))
    },
    human: match obj.get("human") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("human")))
    },
  }
}

///|
pub fn XpackInfoQuery::new(
  categories? : Array[String],
  accept_enterprise? : Bool,
  human? : Bool,
) -> XpackInfoQuery {
  { categories, accept_enterprise, human }
}

///|
pub fn XpackInfoQuery::to_pairs(
  self : XpackInfoQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.categories {
    Some(value) => push_query_json(pairs, "categories", value.to_json())
    None => ()
  }
  match self.accept_enterprise {
    Some(value) => push_query_json(pairs, "accept_enterprise", value.to_json())
    None => ()
  }
  match self.human {
    Some(value) => push_query_json(pairs, "human", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct XpackInfoResponse {
  build : Json
  features : Json
  license : Json
  tagline : String
} derive(Eq, Debug)

///|
pub impl ToJson for XpackInfoResponse with fn to_json(self : XpackInfoResponse) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["build"] = self.build.to_json()
  obj["features"] = self.features.to_json()
  obj["license"] = self.license.to_json()
  obj["tagline"] = self.tagline.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for XpackInfoResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "XpackInfoResponse: expected object"))
  }
  {
    build: @json.from_json(
      obj.get("build").unwrap_or(Json::null()),
      path=path.add_key("build"),
    ),
    features: @json.from_json(
      obj.get("features").unwrap_or(Json::null()),
      path=path.add_key("features"),
    ),
    license: @json.from_json(
      obj.get("license").unwrap_or(Json::null()),
      path=path.add_key("license"),
    ),
    tagline: @json.from_json(
      obj.get("tagline").unwrap_or(Json::null()),
      path=path.add_key("tagline"),
    ),
  }
}

///|
pub(all) struct XpackInfoRequest {
  query : XpackInfoQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn XpackInfoRequest::new(
  query? : XpackInfoQuery = XpackInfoQuery::new(),
) -> XpackInfoRequest {
  { query, }
}

///|
pub async fn Client::xpack_info(
  self : Client,
  request : XpackInfoRequest,
) -> EsResponse[XpackInfoResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_xpack", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}

///|
pub(all) struct XpackUsageQuery {
  master_timeout : String?
} derive(Eq, Debug)

///|
pub impl ToJson for XpackUsageQuery with fn to_json(self : XpackUsageQuery) -> Json {
  let obj : Map[String, Json] = Map([])
  match self.master_timeout {
    Some(value) => obj["master_timeout"] = value.to_json()
    None => ()
  }
  Json::object(obj)
}

///|
pub impl FromJson for XpackUsageQuery with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "XpackUsageQuery: expected object"))
  }
  {
    master_timeout: match obj.get("master_timeout") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("master_timeout")))
    },
  }
}

///|
pub fn XpackUsageQuery::new(master_timeout? : String) -> XpackUsageQuery {
  { master_timeout, }
}

///|
pub fn XpackUsageQuery::to_pairs(
  self : XpackUsageQuery,
) -> Array[(String, String)] {
  let pairs : Array[(String, String)] = []
  match self.master_timeout {
    Some(value) => push_query_json(pairs, "master_timeout", value.to_json())
    None => ()
  }
  pairs
}

///|
pub(all) struct XpackUsageResponse {
  aggregate_metric : Json
  analytics : Json
  archive : Json
  watcher : Json
  ccr : Json
  data_frame : Json?
  data_science : Json?
  data_streams : Json?
  data_tiers : Json
  enrich : Json?
  eql : Json
  flattened : Json?
  graph : Json
  gpu_vector_indexing : Json?
  health_api : Json?
  ilm : Json
  logstash : Json
  ml : Json
  monitoring : Json
  rollup : Json
  runtime_fields : Json?
  spatial : Json
  searchable_snapshots : Json
  security : Json
  slm : Json
  sql : Json
  transform : Json
  vectors : Json?
  voting_only : Json
} derive(Eq, Debug)

///|
pub impl ToJson for XpackUsageResponse with fn to_json(
  self : XpackUsageResponse,
) -> Json {
  let obj : Map[String, Json] = Map([])
  obj["aggregate_metric"] = self.aggregate_metric.to_json()
  obj["analytics"] = self.analytics.to_json()
  obj["archive"] = self.archive.to_json()
  obj["watcher"] = self.watcher.to_json()
  obj["ccr"] = self.ccr.to_json()
  match self.data_frame {
    Some(value) => obj["data_frame"] = value.to_json()
    None => ()
  }
  match self.data_science {
    Some(value) => obj["data_science"] = value.to_json()
    None => ()
  }
  match self.data_streams {
    Some(value) => obj["data_streams"] = value.to_json()
    None => ()
  }
  obj["data_tiers"] = self.data_tiers.to_json()
  match self.enrich {
    Some(value) => obj["enrich"] = value.to_json()
    None => ()
  }
  obj["eql"] = self.eql.to_json()
  match self.flattened {
    Some(value) => obj["flattened"] = value.to_json()
    None => ()
  }
  obj["graph"] = self.graph.to_json()
  match self.gpu_vector_indexing {
    Some(value) => obj["gpu_vector_indexing"] = value.to_json()
    None => ()
  }
  match self.health_api {
    Some(value) => obj["health_api"] = value.to_json()
    None => ()
  }
  obj["ilm"] = self.ilm.to_json()
  obj["logstash"] = self.logstash.to_json()
  obj["ml"] = self.ml.to_json()
  obj["monitoring"] = self.monitoring.to_json()
  obj["rollup"] = self.rollup.to_json()
  match self.runtime_fields {
    Some(value) => obj["runtime_fields"] = value.to_json()
    None => ()
  }
  obj["spatial"] = self.spatial.to_json()
  obj["searchable_snapshots"] = self.searchable_snapshots.to_json()
  obj["security"] = self.security.to_json()
  obj["slm"] = self.slm.to_json()
  obj["sql"] = self.sql.to_json()
  obj["transform"] = self.transform.to_json()
  match self.vectors {
    Some(value) => obj["vectors"] = value.to_json()
    None => ()
  }
  obj["voting_only"] = self.voting_only.to_json()
  Json::object(obj)
}

///|
pub impl FromJson for XpackUsageResponse with fn from_json(json, path) {
  guard json is Object(obj) else {
    raise JsonDecodeError((path, "XpackUsageResponse: expected object"))
  }
  {
    aggregate_metric: @json.from_json(
      obj.get("aggregate_metric").unwrap_or(Json::null()),
      path=path.add_key("aggregate_metric"),
    ),
    analytics: @json.from_json(
      obj.get("analytics").unwrap_or(Json::null()),
      path=path.add_key("analytics"),
    ),
    archive: @json.from_json(
      obj.get("archive").unwrap_or(Json::null()),
      path=path.add_key("archive"),
    ),
    watcher: @json.from_json(
      obj.get("watcher").unwrap_or(Json::null()),
      path=path.add_key("watcher"),
    ),
    ccr: @json.from_json(
      obj.get("ccr").unwrap_or(Json::null()),
      path=path.add_key("ccr"),
    ),
    data_frame: match obj.get("data_frame") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_frame")))
    },
    data_science: match obj.get("data_science") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_science")))
    },
    data_streams: match obj.get("data_streams") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("data_streams")))
    },
    data_tiers: @json.from_json(
      obj.get("data_tiers").unwrap_or(Json::null()),
      path=path.add_key("data_tiers"),
    ),
    enrich: match obj.get("enrich") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("enrich")))
    },
    eql: @json.from_json(
      obj.get("eql").unwrap_or(Json::null()),
      path=path.add_key("eql"),
    ),
    flattened: match obj.get("flattened") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("flattened")))
    },
    graph: @json.from_json(
      obj.get("graph").unwrap_or(Json::null()),
      path=path.add_key("graph"),
    ),
    gpu_vector_indexing: match obj.get("gpu_vector_indexing") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("gpu_vector_indexing")))
    },
    health_api: match obj.get("health_api") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("health_api")))
    },
    ilm: @json.from_json(
      obj.get("ilm").unwrap_or(Json::null()),
      path=path.add_key("ilm"),
    ),
    logstash: @json.from_json(
      obj.get("logstash").unwrap_or(Json::null()),
      path=path.add_key("logstash"),
    ),
    ml: @json.from_json(
      obj.get("ml").unwrap_or(Json::null()),
      path=path.add_key("ml"),
    ),
    monitoring: @json.from_json(
      obj.get("monitoring").unwrap_or(Json::null()),
      path=path.add_key("monitoring"),
    ),
    rollup: @json.from_json(
      obj.get("rollup").unwrap_or(Json::null()),
      path=path.add_key("rollup"),
    ),
    runtime_fields: match obj.get("runtime_fields") {
      Some(Null) => None
      None => None
      Some(value) =>
        Some(@json.from_json(value, path=path.add_key("runtime_fields")))
    },
    spatial: @json.from_json(
      obj.get("spatial").unwrap_or(Json::null()),
      path=path.add_key("spatial"),
    ),
    searchable_snapshots: @json.from_json(
      obj.get("searchable_snapshots").unwrap_or(Json::null()),
      path=path.add_key("searchable_snapshots"),
    ),
    security: @json.from_json(
      obj.get("security").unwrap_or(Json::null()),
      path=path.add_key("security"),
    ),
    slm: @json.from_json(
      obj.get("slm").unwrap_or(Json::null()),
      path=path.add_key("slm"),
    ),
    sql: @json.from_json(
      obj.get("sql").unwrap_or(Json::null()),
      path=path.add_key("sql"),
    ),
    transform: @json.from_json(
      obj.get("transform").unwrap_or(Json::null()),
      path=path.add_key("transform"),
    ),
    vectors: match obj.get("vectors") {
      Some(Null) => None
      None => None
      Some(value) => Some(@json.from_json(value, path=path.add_key("vectors")))
    },
    voting_only: @json.from_json(
      obj.get("voting_only").unwrap_or(Json::null()),
      path=path.add_key("voting_only"),
    ),
  }
}

///|
pub(all) struct XpackUsageRequest {
  query : XpackUsageQuery
} derive(Eq, Debug, ToJson, FromJson)

///|
pub fn XpackUsageRequest::new(
  query? : XpackUsageQuery = XpackUsageQuery::new(),
) -> XpackUsageRequest {
  { query, }
}

///|
pub async fn Client::xpack_usage(
  self : Client,
  request : XpackUsageRequest,
) -> EsResponse[XpackUsageResponse] {
  let params : Map[String, String] = Map([])
  let query = request.query.to_pairs()
  let path = select_path([PathVariant::new("/_xpack/usage", [])], params)
  self.perform(EsRequest::new(Get, path, query~))
}