Class: ThreeScaleToolbox::Commands::ImportCommand::OpenAPI::CreateServiceStep

Inherits:
Object
  • Object
show all
Includes:
Step
Defined in:
lib/3scale_toolbox/commands/import_command/openapi/create_service_step.rb

Instance Attribute Summary

Attributes included from Step

#context

Instance Method Summary collapse

Methods included from Step

#api_spec, #backend, #backend=, #backend_api_host_header, #backend_api_secret_token, #base_path, #build_3scale_operations, #default_credentials_userkey, #host, #initialize, #logger, #oidc_issuer_endpoint, #oidc_issuer_type, #operations, #override_private_base_url, #override_private_basepath, #override_public_basepath, #prefix_matching, #private_base_path, #private_endpoint, #production_public_base_url, #public_base_path, #report, #resource, #service, #service=, #staging_public_base_url, #target_system_name, #threescale_client

Instance Method Details

#callObject

Creates service with a given system_name If service already exists, update basic settings like name and description



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/3scale_toolbox/commands/import_command/openapi/create_service_step.rb', line 11

def call
  # Update service and update context
  self.service = Entities::Service.find_by_system_name(remote: threescale_client,
                                                       system_name: service_system_name)
  if service.nil?
    # Create service and update context
    self.service = Entities::Service.create(remote: threescale_client,
                                            service_params: service_settings)
    logger.info "Created service id: #{service.id}, name: #{service_name}"
  else
    service.update(service_settings)
    logger.info "Updated service id: #{service.id}, name: #{service_name}"
  end

  report['id'] = service.id
  report['system_name'] = service.system_name
  report['name'] = service.name
  report['backend_version'] = api_spec.service_backend_version
end