From 2906e8c9ddc0f89d9d4c5647d8b119c5a6e13bc2 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 28 Nov 2023 13:16:19 -0700 Subject: [PATCH] # get rid of low/high level wordings Signed-off-by: Theo Truong --- api_generator/USER_GUIDE.md | 22 +++++++++++----------- api_generator/lib/api_generator.rb | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/api_generator/USER_GUIDE.md b/api_generator/USER_GUIDE.md index b7ca40bd1..ea493bae3 100644 --- a/api_generator/USER_GUIDE.md +++ b/api_generator/USER_GUIDE.md @@ -22,39 +22,39 @@ require './lib/api_generator' generator = ApiGenerator.new('./OpenSearch.openapi.json') ``` -### Generate High-level API Actions +### Generate Spec Methods: -The `generate_high_level` method accepts the path to the root directory of the `opensearch-ruby` gem as a parameter. By default, it points to the parent directory of the folder containing the generator script. For example to generate all actions into the `tmp` directory: +The `generate_spec_methods` method accepts the path to the root directory of the `opensearch-ruby` gem as a parameter. By default, it points to the parent directory of the folder containing the generator script. For example to generate all actions into the `tmp` directory: ```ruby -generator.generate_high_level('./tmp') +generator.generate_spec_methods('./tmp') ``` You can also target a specific API version by passing in the version number as a parameter. For example to generate all actions for version `1.0` into the `tmp` directory: ```ruby -generator.generate_high_level(version: '1.0') +generator.generate_spec_methods(version: '1.0') ``` The generator also support incremental generation. For example, to generate all actions of the `cat` namespace: ```ruby -generator.generate_high_level(namespace: 'cat') +generator.generate_spec_methods(namespace: 'cat') ``` To limit it to specific actions of a namespace: ```ruby -generator.generate_high_level(namespace: 'cat', actions: %w[aliases allocation]) +generator.generate_spec_methods(namespace: 'cat', actions: %w[aliases allocation]) ``` Note that the root namespace is presented by an empty string `''`. For example, to generate all actions of the root namespace for OS version 2.3: ```ruby -generator.generate_high_level(version: '2.3', namespace: '') +generator.generate_spec_methods(version: '2.3', namespace: '') ``` -### Generate low-level API actions: +### Generate Static Methods: -To generate the low level API methods: +To generate static methods: ```ruby -generator.generate_low_level +generator.generate_static_methods ``` -The low level API methods are independent of the Spec. A change in the OpenSearch API Spec will not affect the low level APIs. So, only execute `generate_low_level` if you have made changes to the low-level APIs logic. \ No newline at end of file +The static methods are independent of the Spec. A change in the OpenSearch API Spec will not affect these methods. \ No newline at end of file diff --git a/api_generator/lib/api_generator.rb b/api_generator/lib/api_generator.rb index ce2783278..b9e3a0f6c 100644 --- a/api_generator/lib/api_generator.rb +++ b/api_generator/lib/api_generator.rb @@ -23,12 +23,12 @@ def initialize(openapi_spec) @spec = Openapi3Parser.load_file(openapi_spec) end - # Generate high level API methods from the OpenSearch Specs. + # Generate API methods from the OpenSearch Specs. # @param [String] gem_folder location of the API Gem folder (default to the parent folder of the generator) # @param [String] version target OpenSearch version to generate like "2.5" or "3.0" # @param [String] namespace namespace to generate (Default to all namespaces. Use '' for root) # @param [Array] actions list of actions in the specified namespace to generate (Default to all actions) - def generate_high_level(gem_folder = '../', version: nil, namespace: nil, actions: nil) + def generate_spec_methods(gem_folder = '../', version: nil, namespace: nil, actions: nil) gem_folder = Pathname gem_folder namespaces = existing_namespaces(gem_folder) target_actions(version, namespace, actions).each do |action| @@ -39,9 +39,9 @@ def generate_high_level(gem_folder = '../', version: nil, namespace: nil, action IndexGenerator.new(gem_folder.join('lib/opensearch'), namespaces).generate end - # Generate low level API methods that are independent of the OpenSearch Specs. + # Generate basic HTTP methods that are independent of the OpenSearch Specs. # @param [String] gem_folder location of the API Gem folder (default to the parent folder of the generator) - def generate_low_level(gem_folder = '../') + def generate_static_methods(gem_folder = '../') gem_folder = Pathname gem_folder namespaces = existing_namespaces(gem_folder) low_level_namespace = 'http'