Class: Ravendb::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ravendb/api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:) ⇒ Client

Returns a new instance of Client.



13
14
15
# File 'lib/ravendb/api/client.rb', line 13

def initialize(url:)
  @url = URI(url)
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/ravendb/api/client.rb', line 11

def url
  @url
end

Instance Method Details

#create_database(name:, options: {}) ⇒ Object

$body = @{

Settings = @{
"Raven/DataDir" = "~\Databases\$RavenDatabaseName"

“Raven/ActiveBundles” = “PeriodicBackup;DocumentExpiration;SqlReplication” } Disabled = $false }

Invoke-RestMethod -Uri $($HostName):$($Port)/admin/databases/$RavenDatabaseName -Method PUT -Body (ConvertTo-Json $body) test(options: { Settings: ‘test’}) test(options: { :Settings => ‘test’})



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ravendb/api/client.rb', line 40

def create_database(name:, options: {})
  default_options = {
    Settings: { 
      'Raven/ActiveBundles': '', 
      'Raven/DataDir': "~/#{name}" 
    }, 
    Disabled: false
  }

  create_database_options = default_options.merge(options)
  put(url: @url + create_delete_database_endpoint() + name, json_hash: create_database_options)
end

#database_exists?(name:) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ravendb/api/client.rb', line 25

def database_exists?(name:)
  databases.include?(name)
end

#databasesObject



17
18
19
# File 'lib/ravendb/api/client.rb', line 17

def databases
  get(url: @url + get_databases_endpoint())
end

#delete_database(name:) ⇒ Object

Invoke-RestMethod -Uri $($HostName):$($Port)/admin/databases/$RavenDatabaseName`?hard-delete=true -Method Delete



53
54
55
# File 'lib/ravendb/api/client.rb', line 53

def delete_database(name:)
  delete(url: @url + create_delete_database_endpoint() + name)
end

#get_database(name:) ⇒ Object



21
22
23
# File 'lib/ravendb/api/client.rb', line 21

def get_database(name:)
  get(url: @url + create_delete_database_endpoint() + name)
end