Class: Geoserver::Publish::Style

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

Overview

Class for interacting with GeoServer Styles API. NOTE This assumes only the top level styles path /styles and does not work with workspace and layer based styles.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn = nil) ⇒ Style

Returns a new instance of Style.



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

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

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



9
10
11
# File 'lib/geoserver/publish/style.rb', line 9

def connection
  @connection
end

Instance Method Details

#create(style_name:, filename:, additional_payload: nil) ⇒ Object

Create will update the GeoServer catalog, but not provide the style



28
29
30
31
32
# File 'lib/geoserver/publish/style.rb', line 28

def create(style_name:, filename:, additional_payload: nil)
  path = style_url(style_name: nil)
  payload = payload_new(style_name: style_name, filename: filename, payload: additional_payload)
  connection.post(path: path, payload: payload)
end

#delete(style_name:) ⇒ Object



15
16
17
18
# File 'lib/geoserver/publish/style.rb', line 15

def delete(style_name:)
  path = style_url(style_name: style_name)
  connection.delete(path: path)
end

#find(style_name:) ⇒ Object



20
21
22
23
24
# File 'lib/geoserver/publish/style.rb', line 20

def find(style_name:)
  path = style_url(style_name: style_name)
  out = connection.get(path: path)
  JSON.parse(out) if out
end

#update(style_name:, filename:, payload:) ⇒ Object

Update requires and uses the payload to upload an SLD



36
37
38
39
# File 'lib/geoserver/publish/style.rb', line 36

def update(style_name:, filename:, payload:)
  path = style_url(style_name: style_name)
  connection.put(path: path, payload: payload, content_type: "application/vnd.ogc.sld+xml")
end