Class: ThreeScaleToolbox::Commands::ImportCommand::OpenAPI::OpenAPISubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command, ResourceReader
Defined in:
lib/3scale_toolbox/commands/import_command/openapi.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResourceReader

#load_resource, #read_content, #read_file, #read_stdin, #read_url

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/3scale_toolbox/commands/import_command/openapi.rb', line 21

def self.command
  Cri::Command.define do
    name        'openapi'
    usage       'openapi [opts] -d <destination> <spec> (/path/to/your/spec/file.[json|yaml|yml] OR http[s]://domain/resource/path.[json|yaml|yml])'
    summary     'Import API defintion in OpenAPI specification from a local file or URL'
    description 'Using an API definition format like OpenAPI, import to your 3scale API directly from a local OpenAPI spec compliant file or a remote URL'

    option  :d, :destination, '3scale target instance. Format: "http[s]://<authentication>@3scale_domain"', argument: :required
    option  :t, 'target_system_name', 'Target system name', argument: :required
    flag    nil, 'activedocs-hidden', 'Create ActiveDocs in hidden state'
    flag    nil, 'skip-openapi-validation', 'Skip OpenAPI schema validation'
    flag    nil, 'prefix-matching', 'Use prefix matching instead of strict matching on mapping rules derived from openapi operations'
    option  nil, 'oidc-issuer-endpoint', 'OIDC Issuer Endpoint', argument: :required
    option  nil, 'default-credentials-userkey', 'Default credentials policy userkey', argument: :required
    option  nil, 'override-private-basepath', 'Override the basepath for the private URLs', argument: :required
    option  nil, 'override-public-basepath', 'Override the basepath for the public URLs', argument: :required
    option  nil, 'staging-public-base-url', 'Custom public staging URL', argument: :required
    option  nil, 'production-public-base-url', 'Custom public production URL', argument: :required
    option  nil, 'override-private-base-url', 'Custom private base URL', argument: :required
    option nil, 'backend-api-secret-token', 'Custom secret token sent by the API gateway to the backend API',argument: :required
    option nil, 'backend-api-host-header', 'Custom host header sent by the API gateway to the backend API', argument: :required
    param   :openapi_resource

    runner OpenAPISubcommand
  end
end

Instance Method Details

#runObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/3scale_toolbox/commands/import_command/openapi.rb', line 48

def run
  tasks = []
  tasks << CreateServiceStep.new(context)
  # other tasks might read proxy settings (CreateActiveDocsStep does)
  tasks << UpdateServiceProxyStep.new(context)
  tasks << CreateMethodsStep.new(context)
  tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::DestroyMappingRulesTask.new(context)
  tasks << CreateMappingRulesStep.new(context)
  tasks << CreateActiveDocsStep.new(context)
  tasks << UpdateServiceOidcConfStep.new(context)
  tasks << UpdatePoliciesStep.new(context)

  # run tasks
  tasks.each(&:call)

  # This should be the last step
  ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::BumpProxyVersionTask.new(service: context[:target]).call
end