geoserver-publish 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f15ea83139e028c59e3dc2d3d121524eee34cd5507edd3e1963cbf3e8815e885
4
- data.tar.gz: 6c7d862f595948a9ad717029fbbb0cfa8fa8a6307104a7710456c28d480b1646
3
+ metadata.gz: 3f75a947e8c4f8e534b9c70c8d64cf9a9acca4f470a06fc6b97f7984b972676a
4
+ data.tar.gz: f62d9445453833b878fb3936a963b3d108caa434262b024e356381cea253d373
5
5
  SHA512:
6
- metadata.gz: 7aeac6c7210f23f29cda6e4fc31cc07ab4dbcc21f412b8fdf13344e7a7c0ac74241f3c9595bba9c66297b04e25f05e7d01f3d924ad874cd59029ade2dc28abeb
7
- data.tar.gz: 00d8b594bc21686173925af5b88e50787189cd1ba57583218c11f66cba91e46c41f68f2dd10cf1ff4421962df786f5719fa14930dd191dcda5b8729625c7b278
6
+ metadata.gz: d1b1e5ca1616070526efd041f4f5480ab28303437a7c772ebf697b1a250fdd287302d1afa57ef27a636da109e30ca0746233ab042c7f0fd982653a127c887d12
7
+ data.tar.gz: 4b10920c31d5a2b288dea8baf42eb66d8a0502519a368ccc0834142d734e93ff30ae31731225251081f7357f8ed4af885b63970c57f0266951e4c6bd4ac7c9d0
data/README.md CHANGED
@@ -54,6 +54,16 @@ sld = File.read("./spec/fixtures/files/payload/raster_layer.sld")
54
54
  Geoserver::Publish::Style.new.update(style_name: "raster_layer", filename: "raster_layer.sld", payload: sld)
55
55
  ```
56
56
 
57
+ #### GeoWebCache
58
+
59
+ The GeoWebCache REST API can also be used. Note: there is usually a different url that is used.
60
+
61
+ ```ruby
62
+ c = Geoserver::Publish::Connection.new({"url" => "http://localhost:8080/geoserver/gwc/rest", "user"=>"admin",
63
+ "password"=>"geoserver"})
64
+ Geoserver::Publish::Geowebcache.new(c).masstruncate(layer_name: 'nurc:Pk50095')
65
+ ```
66
+
57
67
  ## Configuration
58
68
 
59
69
  #### Default
@@ -13,6 +13,7 @@ module Geoserver
13
13
  require "geoserver/publish/create"
14
14
  require "geoserver/publish/data_store"
15
15
  require "geoserver/publish/feature_type"
16
+ require "geoserver/publish/geowebcache"
16
17
  require "geoserver/publish/layer"
17
18
  require "geoserver/publish/style"
18
19
  require "geoserver/publish/version"
@@ -25,13 +25,13 @@ module Geoserver
25
25
  response.body if response.status == 200
26
26
  end
27
27
 
28
- def post(path:, payload:)
28
+ def post(path:, payload:, content_type: "application/json")
29
29
  response = faraday_connection.post do |req|
30
30
  req.url path
31
- req.headers["Content-Type"] = "application/json"
31
+ req.headers["Content-Type"] = content_type
32
32
  req.body = payload
33
33
  end
34
- return true if response.status == 201 || response.status == 401
34
+ return true if response.status == 201 || response.status == 401 || response.status == 200
35
35
  raise Geoserver::Publish::Error, response.reason_phrase
36
36
  end
37
37
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Geoserver
4
+ module Publish
5
+ class Geowebcache
6
+ attr_reader :connection
7
+
8
+ def initialize(conn = nil)
9
+ @connection = conn || Geoserver::Publish::Connection.new
10
+ end
11
+
12
+ ##
13
+ # This will masstruncate all caches for a given layer. Note: that this
14
+ # implementation differs from the GWC Rest documentation which seems to be
15
+ # wrong. See: https://github.com/GeoWebCache/geowebcache/issues/785
16
+ def masstruncate(layer_name:, request_type: "truncateLayer")
17
+ payload = "<#{request_type}><layerName>#{layer_name}</layerName></#{request_type}>"
18
+ connection.post(
19
+ path: "masstruncate",
20
+ payload: payload,
21
+ content_type: "text/xml"
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Geoserver
3
3
  module Publish
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoserver-publish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eliot Jordan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2020-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -99,6 +99,7 @@ files:
99
99
  - lib/geoserver/publish/create.rb
100
100
  - lib/geoserver/publish/data_store.rb
101
101
  - lib/geoserver/publish/feature_type.rb
102
+ - lib/geoserver/publish/geowebcache.rb
102
103
  - lib/geoserver/publish/layer.rb
103
104
  - lib/geoserver/publish/style.rb
104
105
  - lib/geoserver/publish/version.rb