Sha256: 754fe8b5f0ae9f9764c0a35b217e99eec3ff09211950358bc3a348385ec73629
Contents?: true
Size: 1.07 KB
Versions: 5
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Geoserver module Publish class Workspace attr_reader :connection def initialize(conn = nil) @connection = conn || Geoserver::Publish::Connection.new end def delete(workspace_name:) path = workspace_url(workspace_name: workspace_name) connection.delete(path: path) end def find(workspace_name:) path = workspace_url(workspace_name: workspace_name) out = connection.get(path: path) JSON.parse(out) if out end def create(workspace_name:) path = workspace_url(workspace_name: nil) connection.post(path: path, payload: payload_new(workspace_name: workspace_name)) end private def payload_new(workspace_name:) { workspace: { name: workspace_name } }.to_json end def workspace_url(workspace_name:) last_path_component = workspace_name ? "/#{workspace_name}" : "" "workspaces#{last_path_component}" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems