Class: Geoserver::Publish::DataStore

Inherits:
Object
  • Object
show all
Defined in:
lib/geoserver/publish/data_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn = nil) ⇒ DataStore

Returns a new instance of DataStore.



7
8
9
# File 'lib/geoserver/publish/data_store.rb', line 7

def initialize(conn = nil)
  @connection = conn || Geoserver::Publish::Connection.new
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/geoserver/publish/data_store.rb', line 5

def connection
  @connection
end

Instance Method Details

#create(workspace_name:, data_store_name:, url:) ⇒ Object



22
23
24
25
26
# File 'lib/geoserver/publish/data_store.rb', line 22

def create(workspace_name:, data_store_name:, url:)
  path = data_store_url(workspace_name: workspace_name, data_store_name: nil)
  payload = payload_new(data_store_name: data_store_name, url: url)
  connection.post(path: path, payload: payload)
end

#delete(workspace_name:, data_store_name:) ⇒ Object



11
12
13
14
# File 'lib/geoserver/publish/data_store.rb', line 11

def delete(workspace_name:, data_store_name:)
  path = data_store_url(workspace_name: workspace_name, data_store_name: data_store_name)
  connection.delete(path: path)
end

#find(workspace_name:, data_store_name:) ⇒ Object



16
17
18
19
20
# File 'lib/geoserver/publish/data_store.rb', line 16

def find(workspace_name:, data_store_name:)
  path = data_store_url(workspace_name: workspace_name, data_store_name: data_store_name)
  out = connection.get(path: path)
  JSON.parse(out) if out
end

#upload(workspace_name:, data_store_name:, file:, method: "file") ⇒ Object

Upload a shapefile zip to a new datastore # @param workspace_name [String] # @param data_store_name [String] # @param file [String] Depending on value of method:

file == binary stream
url == URL to publicly available shapezip zip.
external == absolute path to existing file

# @param method [String] Can be one of ‘file’, ‘url’, ‘external’.

See: https://docs.geoserver.org/stable/en/api/#1.0.0/datastores.yaml


38
39
40
41
42
# File 'lib/geoserver/publish/data_store.rb', line 38

def upload(workspace_name:, data_store_name:, file:, method: "file")
  content_type = "application/zip"
  path = upload_url(workspace: workspace_name, data_store: data_store_name, method: method)
  connection.put(path: path, payload: file, content_type: content_type)
end