Sha256: 013dafeb3567f8e05751dd74b3cb20e01593d2ce8c7b91ec0ee4f7996f2d60cf

Contents?: true

Size: 1.66 KB

Versions: 54

Compression:

Stored size: 1.66 KB

Contents

class Ey::Core::Client
  class Real
    def create_logical_database(params={})
      request(
        :method => :post,
        :path   => "/logical-databases",
        :url    => params.delete("url"),
        :body   => params,
      )
    end
  end

  class Mock
    def create_logical_database(_params={})
      params = Cistern::Hash.stringify_keys(_params)
      database_service_id = resource_identity(params["url"]) || require_parameters(params, "database_service")
      logical_database_name = require_parameters(params["logical_database"], "name")

      request_id  = self.uuid
      resource_id = self.serial_id

      find(:database_services, database_service_id)

      resource = {
        "name" => logical_database_name,
        "username" => "eyuser#{SecureRandom.hex(4)}",
        "password" => SecureRandom.hex(16),
      }.merge(params["logical_database"]).merge(
        "id"           => resource_id,
        "resource_url" => "/logical-databases/#{resource_id}",
        "service"      => url_for("/database-services/#{database_service_id}"),
        "deleted_at"   => nil,
        )

      request = {
        "id"           => request_id,
        "type"         => "provision_logical_database",
        "successful"   => "true",
        "started_at"   => Time.now,
        "finished_at"  => nil,
        "resource_url" => resource["resource_url"],
        "resource"     => [:logical_databases, resource_id, resource],
      }

      self.data[:requests][request_id] = request

      response_hash = request.dup
      response_hash.delete("resource")

      response(
        :body    => {"request" => response_hash},
        :status  => 201,
      )
    end
  end
end

Version data entries

54 entries across 54 versions & 3 rubygems

Version Path
ey-core-3.6.0.autoscaling1 lib/ey-core/requests/create_logical_database.rb
ey-core-3.6.4 lib/ey-core/requests/create_logical_database.rb
ey-core-3.6.3 lib/ey-core/requests/create_logical_database.rb
ey-core-3.6.1 lib/ey-core/requests/create_logical_database.rb
groove-ey-core-3.6.3 lib/ey-core/requests/create_logical_database.rb
groove-ey-core-3.6.2 lib/ey-core/requests/create_logical_database.rb
groove-ey-core-3.6.1 lib/ey-core/requests/create_logical_database.rb
ey-core-3.5.0 lib/ey-core/requests/create_logical_database.rb
ey-core-3.4.4 lib/ey-core/requests/create_logical_database.rb
ey-core-3.4.2 lib/ey-core/requests/create_logical_database.rb
ey-core-3.4.1 lib/ey-core/requests/create_logical_database.rb
ey-core-3.4.0 lib/ey-core/requests/create_logical_database.rb
ey-core-3.3.1 lib/ey-core/requests/create_logical_database.rb
ey-core-3.3.0 lib/ey-core/requests/create_logical_database.rb
ey-core-3.2.6 lib/ey-core/requests/create_logical_database.rb
ey-core-3.2.5 lib/ey-core/requests/create_logical_database.rb
ey-core-3.2.4 lib/ey-core/requests/create_logical_database.rb
ey-core-3.2.3 lib/ey-core/requests/create_logical_database.rb
ey-core-3.2.2 lib/ey-core/requests/create_logical_database.rb
ey-core-3.2.1 lib/ey-core/requests/create_logical_database.rb