Sha256: 6da6ee748dddb28401be3790d6996db8f5653c0cb7deee52f100affe0ed0c428
Contents?: true
Size: 1.93 KB
Versions: 6
Compression:
Stored size: 1.93 KB
Contents
module ThreeScaleToolbox module Commands module ImportCommand module OpenAPI class CreateServiceStep include Step ## # Creates service with a given system_name # If service already exists, update basic settings like name and description 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) puts "Created service id: #{service.id}, name: #{service_name}" else service.update(service_settings) puts "Updated service id: #{service.id}, name: #{service_name}" end end private def service_system_name target_system_name || service_name.downcase.gsub(/[^\w]/, '_') end def service_settings default_service_settings.tap do |svc| svc['name'] = service_name svc['description'] = service_description svc['backend_version'] = backend_version svc['system_name'] = service_system_name svc['deployment_option'] = 'self_managed' if !production_public_base_url.nil? || !staging_public_base_url.nil? end end def default_service_settings {} end def service_name api_spec.title end def service_description api_spec.description end def backend_version api_spec.backend_version end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems