opensearch-api-specification icon indicating copy to clipboard operation
opensearch-api-specification copied to clipboard

[PROPOSAL] Standardize operation groups

Open dblock opened this issue 7 months ago • 0 comments

What/Why

What are you proposing?

Coming from https://github.com/opensearch-project/documentation-website/issues/7700 it may make sense to organize the documentation by operation group. Currently this list looks very inconsistent.

["info", "ping", "indices", "bulk", "cat", "cluster", "nodes", "count", "dangling_indices", "delete_by_query_rethrottle", "field_caps", "ingest", "mget", "msearch", "msearch_template", "mtermvectors", "security", "knn", "ml", "notifications", "rollups", "transforms", "rank_eval", "reindex", "reindex_rethrottle", "remote_store", "render_search_template", "get_script_context", "get_script_languages", "get_script", "put_script", "delete_script", "scripts_painless_execute", "search", "search_shards", "search_pipeline", "delete_pit", "get_all_pits", "delete_all_pits", "scroll", "clear_scroll", "search_template", "snapshot", "tasks", "update_by_query_rethrottle", "create", "delete_by_query", "index", "get", "exists", "delete", "explain", "create_pit", "get_source", "exists_source", "termvectors", "update_by_query", "update"]

Groups such as indices or bulk make sense, but get_script or put_script should probably be script, etc.

What problems are you trying to solve?

Make it easy to machine-generate documentation that's well organized.

What is the developer experience going to be?

I attempted to check groups with the following code.

  validate_operation_group (): ValidationError | undefined {
    if (!this.group || this.group === '') { return this.error('Missing x-operation-group property') }
    if (!GROUP_REGEX.test(this.group)) { return this.error(`Invalid x-operation-group '${this.group}'. Must match regex: /${GROUP_REGEX.source}/.`) }
    const parts = _.map(_.remove(this.path.split('/'), (part) => {
      if (part[0] == '{' && part[part.length - 1] == '}') return false
      if (part == '_plugins') return false
      if (part.length == 0) return false
      return true
    }), (item) => item.replace(/_/, ''))
    const operation_group = `${parts.shift()}.${_.join(parts, '_')}`
    if (! this.group.startsWith(operation_group)) { return this.error(`Invalid x-operation-group '${this.group}'. Must start with: ${operation_group}.`) }
  }

That almost worked, however in the security namespace we have legacy functions that are correctly grouped with legacy in them while newer functions that map to internalusers are correctly labeled as users.

Any remaining open questions?

What should the standard naming for groups be?

dblock avatar Jul 15 '24 13:07 dblock