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-pro-cli-0.0.16 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.15 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.14 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.13 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.12 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.11 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.10 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.9 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.8 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.7 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.6 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.5 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.4 lib/vendor/core/ey-core/requests/create_logical_database.rb
ey-pro-cli-0.0.3 lib/vendor/core/ey-core/requests/create_logical_database.rb