geoserver

package module
Version: v0.0.0-...-7de3b7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 17 Imported by: 1

README

Go Report Card GitHub license GitHub issues Coverage Status Build Status Documentation GitHub forks GitHub stars Twitter

Geoserver

geoserver Is a Go Package For Manipulating a GeoServer Instance via the GeoServer REST API.


How to install:

  • go get -v gopkg.in/hishamkaram/geoserver.v1
    • now you can import the package from gopkg.in/hishamkaram/geoserver.v1, example:
      import (
        ...
        "gopkg.in/hishamkaram/geoserver.v1"
        ...
      )
      

usage:

  • Create new Catalog (which contains all available operations):
    • gsCatalog := geoserver.GetCatalog("http://localhost:8080/geoserver13/", "admin", "geoserver")
  • Use catalog Methods to Perform a Geoserver REST Operation:
    • Create New workspace:
      created, err := gsCatalog.CreateWorkspace("golang")
      if err != nil {
        fmt.Printf("\nError:%s\n", err)
      }
      fmt.Println(strconv.FormatBool(created))
      

      output if created:

      INFO[31-03-2018 16:26:35] url:http://localhost:8080/geoserver13/rest/workspaces	response Status=201  
      true
      

      output if error:

      INFO[31-03-2018 16:26:37] url:http://localhost:8080/geoserver13/rest/workspaces	response Status=401  
      WARN[31-03-2018 16:26:37] <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Workspace &#39;golang&#39; already exists</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat/9.0.6</h3></body></html> 
      
      Error:Unauthorized
      false
      
  • Get Layers through GetLayers take workspace as paramter if empty workspace will be ignored and geoserver will return all public layers
    layers, err := gsCatalog.GetLayers("")
    if err != nil {
      fmt.Printf("\nError:%s\n", err)
    }
    for _, lyr := range layers {
      fmt.Printf("\nName:%s  href:%s\n", lyr.Name, lyr.Href)
    }
    

    output:

    INFO[31-03-2018 19:04:44] url:http://localhost:8080/geoserver13/rest/layers	response Status=200  
    
    Name:tiger:giant_polygon  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Agiant_polygon.json
    
    Name:tiger:poi  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Apoi.json
    
    Name:tiger:poly_landmarks  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Apoly_landmarks.json
    
    Name:tiger:tiger_roads  href:http://localhost:8080/geoserver13/rest/layers/tiger%3Atiger_roads.json
    
    Name:nurc:Arc_Sample  href:http://localhost:8080/geoserver13/rest/layers/nurc%3AArc_Sample.json
    
    Name:nurc:Img_Sample  href:http://localhost:8080/geoserver13/rest/layers/nurc%3AImg_Sample.json
    
    Name:nurc:Pk50095  href:http://localhost:8080/geoserver13/rest/layers/nurc%3APk50095.json
    
    Name:nurc:mosaic  href:http://localhost:8080/geoserver13/rest/layers/nurc%3Amosaic.json
    ......
    
  • Get Specific Layer from Geoserver:
    layer, err := gsCatalog.GetLayer("nurc", "Arc_Sample")
    if err != nil {
      fmt.Printf("\nError:%s\n", err)
    } else {
      fmt.Printf("%+v\n", layer)
    }
    

    output:

    INFO[31-03-2018 20:12:07] url:http://localhost:8080/geoserver13/rest/workspaces/nurc/layers/Arc_Sample	response Status=200  
    {Name:Arc_Sample Path:/ Type:RASTER DefaultStyle:{Class: Name:rain Href:http://localhost:8080/geoserver13/rest/styles/rain.json} Styles:{Class:linked-hash-set Style:[{Class: Name:raster Href:http://localhost:8080/geoserver13/rest/styles/raster.json}]} Resource:{Class:coverage Name:nurc:Arc_Sample Href:http://localhost:8080/geoserver13/rest/workspaces/nurc/coveragestores/arcGridSample/coverages/Arc_Sample.json} Queryable:false Opaque:false Attribution:{Title: Href: LogoURL: LogoType: LogoWidth:0 LogoHeight:0}}
    
  • You can find more examples by check testing files
  • You can find all supported operations on Godocs

TESTING
Go Version Geoserver Version Tested
1 1.13.x 2.13.x ✔️
2 1.13.x 2.14.x ✔️
3 1.14.x 2.13.x ✔️
4 1.14.x 2.14.x ✔️
5 1.15.x 2.13.x ✔️
6 1.15.x 2.14.x ✔️

Documentation

Documentation

Index

Constants

View Source
const (
	AclOpRead  = "r" //acl read operation
	AclOpWrite = "w" //acl write operation
	AclOpAdmin = "a" //acl administer operation
)

Variables

This section is empty.

Functions

func GetLogger

func GetLogger() (logger *logrus.Logger)

GetLogger return logger

func IsEmpty

func IsEmpty(object interface{}) bool

IsEmpty helper function to check if obj/struct is nil/empty

Types

type AboutService

type AboutService interface {
	//IsRunning check if geoserver is running return true and error if if error occure
	IsRunning() (running bool, err error)
}

AboutService define all geoserver About operations

type AclRule

type AclRule struct {
	Workspace string       // workspace name or '*' for any workspace
	Layer     string       // layer name or '*' for any layer
	Operation aclOperation // operation
	Roles     []string     // list of roles allowed to perform the operation, null or empty array equal "*"
}

AclRule represents geoserver acl rule, Workspace and Layer contains workspace and layer names or "*" for any entity, Operation contains on of: AclOpRead, AclOpWrite, AclOpAdmin Roles contains array of role names the operation is allowed to

func StringToAclRule

func StringToAclRule(rule string, roles string) (aclRule AclRule, err error)

StringToAclRule parse and convert aclRule from string representation to AclRule struct

func (AclRule) ToStrings

func (aclRule AclRule) ToStrings() (ruleString string, rolesString string)

ToStrings convert aclRule to string representation a geoserver expects

type Attribute

type Attribute struct {
	Name      string `json:"name,omitempty"`
	MinOccurs int16  `json:"minOccurs,omitempty"`
	MaxOccurs int16  `json:"maxOccurs,omitempty"`
	Nillable  bool   `json:"nillable,omitempty"`
	Binding   string `json:"binding,omitempty"`
	Length    int16  `json:"length,omitempty"`
}

Attribute is geoserver FeatureType Attribute

type Attributes

type Attributes struct {
	Attribute []*Attribute `json:"attribute,omitempty"`
}

Attributes is the geoserver feature type attributes

type Attribution

type Attribution struct {
	Title      string `json:"title,omitempty"`
	Href       string `json:"href,omitempty"`
	LogoURL    string `json:"logoURL,omitempty"`
	LogoType   string `json:"logoType,omitempty"`
	LogoWidth  int    `json:"logoWidth,omitempty"`
	LogoHeight int    `json:"logoHeight,omitempty"`
}

Attribution of resource

type BoundingBox

type BoundingBox struct {
	Minx float64 `json:"minx,omitempty"`
	Maxx float64 `json:"maxx,omitempty"`
	Miny float64 `json:"miny,omitempty"`
	Maxy float64 `json:"maxy,omitempty"`
}

BoundingBox is geoserver Bounding Box for FeatureType

type CRSType

type CRSType struct {
	Class string `json:"@class,omitempty"`
	Value string `json:"$,omitempty"`
}

CRSType geoserver crs response

func (*CRSType) MarshalJSON

func (u *CRSType) MarshalJSON() ([]byte, error)

MarshalJSON custom crs serialization

func (*CRSType) UnmarshalJSON

func (u *CRSType) UnmarshalJSON(data []byte) error

UnmarshalJSON custom deserialization to handle published layers of group

type Catalog

Catalog is geoserver interface that define all operatoins

type ConfigurationService

type ConfigurationService interface {
	RestConfigrationCache() (success bool, err error)
	ReloadConfigration() (success bool, err error)
}

ConfigurationService define geoserver Configuration operations

type Coverage

type Coverage struct {
	Name                 string             `json:"name,omitempty"`
	NativeCoverageName   string             `json:"nativeCoverageName,omitempty"`
	NativeName           string             `json:"nativeName,omitempty"`
	NativeFormat         string             `json:"nativeFormat,omitempty"`
	Namespace            *Resource          `json:"namespace,omitempty"`
	Title                string             `json:"title,omitempty"`
	Description          string             `json:"description,omitempty"`
	Abstract             string             `json:"abstract,omitempty"`
	Keywords             *Keywords          `json:"keywords,omitempty"`
	NativeCRS            *CRSType           `json:"nativeCRS,omitempty"`
	Srs                  string             `json:"srs,omitempty"`
	Enabled              bool               `json:"enabled,omitempty"`
	NativeBoundingBox    *NativeBoundingBox `json:"nativeBoundingBox,omitempty"`
	LatLonBoundingBox    *LatLonBoundingBox `json:"latLonBoundingBox,omitempty"`
	ProjectionPolicy     string             `json:"projectionPolicy,omitempty"`
	Store                *Resource          `json:"store,omitempty"`
	CqlFilter            string             `json:"cqlFilter,omitempty"`
	OverridingServiceSRS bool               `json:"overridingServiceSRS,omitempty"`
}

Coverage is geoserver Coverage (raster layer) data struct

type CoverageStore

type CoverageStore struct {
	Name        string    `json:"name,omitempty"`
	URL         string    `json:"url,omitempty"`
	Description string    `json:"description,omitempty"`
	Type        string    `json:"type,omitempty"`
	Enabled     bool      `json:"enabled,omitempty"`
	Workspace   *Resource `json:"workspace,omitempty"`
	Default     bool      `json:"_default,omitempty"`
	Coverages   string    `json:"coverages,omitempty"`
}

CoverageStore geoserver coverage store

type CoverageStoreRequestBody

type CoverageStoreRequestBody struct {
	CoverageStore *CoverageStore `json:"coverageStore,omitempty"`
}

CoverageStoreRequestBody geoserver coverage store to send to api

type CoverageStoresService

type CoverageStoresService interface {
	GetCoverageStores(workspaceName string) (coverageStores []*Resource, err error)
	GetCoverageStore(workspaceName string, gridName string) (coverageStore *CoverageStore, err error)
	CreateCoverageStore(workspaceName string, coverageStore CoverageStore) (created bool, err error)
	UpdateCoverageStore(workspaceName string, coverageStore CoverageStore) (modified bool, err error)
	DeleteCoverageStore(workspaceName string, coverageStore string, recurse bool) (deleted bool, err error)
}

CoverageStoresService define all geoserver CoverageStores operations

type DataLinks struct {
	DataLink []*MetadataLink `json:"org.geoserver.catalog.impl.DataLinkInfoImpl,omitempty"`
}

DataLinks is the geoserver FeatureType Datalinks

type Datastore

type Datastore struct {
	Name                 string                    `json:"name,omitempty"`
	Href                 string                    `json:"href,omitempty"`
	Type                 string                    `json:"type,omitempty"`
	Enabled              bool                      `json:"enabled,omitempty"`
	Workspace            *Workspace                `json:"workspace,omitempty"`
	Default              bool                      `json:"_default,omitempty"`
	FeatureTypes         string                    `json:"featureTypes,omitempty"`
	ConnectionParameters DatastoreConnectionParams `json:"connectionParameters,omitempty"`
}

Datastore holds geoserver store information

type DatastoreConnection

type DatastoreConnection struct {
	Name     string
	Host     string
	Port     int
	DBName   string
	DBSchema string
	DBUser   string
	DBPass   string
	Type     string
	Options  []Entry //additional options
}

DatastoreConnection holds parameters to create new datastore in geoserver

func (DatastoreConnection) GetDatastoreObj

func (connection DatastoreConnection) GetDatastoreObj() (datastore Datastore)

GetDatastoreObj return datastore Object to send to geoserver rest

type DatastoreConnectionParams

type DatastoreConnectionParams struct {
	Entry []*Entry `json:"entry,omitempty"`
}

DatastoreConnectionParams in datastore json

type DatastoreConnector

type DatastoreConnector interface {
	GetDatastoreObj() (datastore Datastore)
}

DatastoreConnector interface to datastore connection object

type DatastoreDetails

type DatastoreDetails struct {
	Datastore *Datastore `json:"dataStore"`
}

DatastoreDetails this struct to send and accept json data from/to geoserver

type DatastoreJNDIConnection

type DatastoreJNDIConnection struct {
	Name              string
	Type              string //dbtype
	JndiReferenceName string //
	Options           []Entry
}

DatastoreJNDIConnection holds parameters to create new datastore using JNDI connection pool see https://docs.geoserver.org/stable/en/user/tutorials/tomcat-jndi/tomcat-jndi.html

func (DatastoreJNDIConnection) GetDatastoreObj

func (connection DatastoreJNDIConnection) GetDatastoreObj() (datastore Datastore)

GetDatastoreObj return datastore Object to send to geoserver

type DatastoreService

type DatastoreService interface {

	// DatastoreExists checks if a datastore exists in a workspace else return error
	DatastoreExists(workspaceName string, datastoreName string, quietOnNotFound bool) (exists bool, err error)

	// GetDatastores return datastores in a workspace else return error
	GetDatastores(workspaceName string) (datastores []*Resource, err error)

	// GetDatastoreDetails get specific datastore from geoserver else return error
	GetDatastoreDetails(workspaceName string, datastoreName string) (datastore *Datastore, err error)

	//CreateDatastore create a datastore under provided workspace
	CreateDatastore(datastoreConnection DatastoreConnection, workspaceName string) (created bool, err error)

	// DeleteDatastore deletes a datastore from geoserver else return error
	DeleteDatastore(workspaceName string, datastoreName string, recurse bool) (deleted bool, err error)
}

DatastoreService define all geoserver datastore operations

type Entry

type Entry struct {
	Key   string `json:"@key,omitempty"`
	Value string `json:"$,omitempty"`
}

Entry is geoserver Entry

type FeatureType

type FeatureType struct {
	Name                   string             `json:"name,omitempty"`
	NativeName             string             `json:"nativeName,omitempty"`
	Namespace              *Resource          `json:"namespace,omitempty"`
	Title                  string             `json:"title,omitempty"`
	Abstract               string             `json:"abstract,omitempty"`
	Keywords               *Keywords          `json:"keywords,omitempty"`
	Metadatalinks          *MetadataLinks     `json:"metadatalinks,omitempty"`
	DataLinks              *DataLinks         `json:"dataLinks,omitempty"`
	NativeCRS              *CRSType           `json:"nativeCRS,omitempty"`
	Srs                    string             `json:"srs,omitempty"`
	Enabled                bool               `json:"enabled,omitempty"`
	NativeBoundingBox      *NativeBoundingBox `json:"nativeBoundingBox,omitempty"`
	LatLonBoundingBox      *LatLonBoundingBox `json:"latLonBoundingBox,omitempty"`
	ProjectionPolicy       string             `json:"projectionPolicy,omitempty"`
	Metadata               *Metadata          `json:"metadata,omitempty"`
	Store                  *Resource          `json:"store,omitempty"`
	CqlFilter              string             `json:"cqlFilter,omitempty"`
	MaxFeatures            int32              `json:"maxFeatures,omitempty"`
	NumDecimals            float32            `json:"numDecimals,omitempty"`
	ResponseSRS            *ResponseSRS       `json:"responseSRS,omitempty"`
	CircularArcPresent     bool               `json:"circularArcPresent,omitempty"`
	OverridingServiceSRS   bool               `json:"overridingServiceSRS,omitempty"`
	SkipNumberMatched      bool               `json:"skipNumberMatched,omitempty"`
	LinearizationTolerance bool               `json:"linearizationTolerance,omitempty"`
	Attributes             *Attributes        `json:"attributes,omitempty"`
}

FeatureType is geoserver FeatureType

type FeatureTypeService

type FeatureTypeService interface {
	GetFeatureTypes(workspaceName string, datastoreName string) (featureTypes []*Resource, err error)
	GetFeatureType(workspaceName string, datastoreName string, featureTypeName string) (featureType *FeatureType, err error)
	DeleteFeatureType(workspaceName string, datastoreName string, featureTypeName string, recurse bool) (deleted bool, err error)
}

FeatureTypeService define all geoserver featuretype operations

type FeatureTypes

type FeatureTypes struct {
	FeatureType []*Resource `json:"featureType,omitempty"`
}

FeatureTypes holds a list of geoserver styles

type FeatureTypesRequestBody

type FeatureTypesRequestBody struct {
	FeatureType *FeatureType `json:"featureTypes,omitempty"`
}

FeatureTypesRequestBody is the api body

type FeatureTypesResponseBody

type FeatureTypesResponseBody struct {
	FeatureTypes *FeatureTypes `json:"featureTypes,omitempty"`
}

FeatureTypesResponseBody is the api body

type GeoServer

type GeoServer struct {
	WorkspaceName string `yaml:"workspace"`
	ServerURL     string `yaml:"geoserver_url"`
	Username      string `yaml:"username"`
	Password      string `yaml:"password"`
	HttpClient    *http.Client
	// contains filtered or unexported fields
}

GeoServer is the configuration Object

func GetCatalog

func GetCatalog(geoserverURL string, username string, password string) (catalog *GeoServer)

GetCatalog return geoserver catalog instance, this fuction take geoserverURL('http://localhost:8080/geoserver/') , geoserver username, geoserver password return geoserver structObj

func (*GeoServer) AddLayersAclRule

func (g *GeoServer) AddLayersAclRule(aclRule AclRule) (done bool, err error)

AddLayersAclRule adds acl rule err is an error if error occurred else err is nil

func (*GeoServer) AddUserRole

func (g *GeoServer) AddUserRole(roleName string, userName string) (created bool, err error)

AddUserRole adds (associates) role with name roleName to the user with name userName returns true/false if added or not, err is an error if error occurred else err is nil

func (*GeoServer) CreateCoverageStore

func (g *GeoServer) CreateCoverageStore(workspaceName string, coverageStore CoverageStore) (created bool, err error)

CreateCoverageStore create coverage store in geoserver and return created one else return error

func (*GeoServer) CreateDatastore

func (g *GeoServer) CreateDatastore(datastoreConnection DatastoreConnector, workspaceName string) (created bool, err error)

CreateDatastore create a datastore under provided workspace

func (*GeoServer) CreateFeatureType

func (g *GeoServer) CreateFeatureType(workspaceName string, datastoreName string, featureType *FeatureType) (created bool, err error)

CreateFeatureType creates featureType in workspace and datastore Creating featureType is only allowed to database related datastores (like postgresql, etc) if error occurred err will be return and nil for featrueTypes

func (*GeoServer) CreateGroup

func (g *GeoServer) CreateGroup(groupName string, serviceName string) (created bool, err error)

CreateGroup creates group with name groupName for service serviceName, if service is empty creates user for default service returns true/false if created or not, err is an error if error occurred else err is nil

func (*GeoServer) CreateLayerGroup

func (g *GeoServer) CreateLayerGroup(workspaceName string, layerGroup *LayerGroup) (created bool, err error)

CreateLayerGroup create specific LayerGroup in geoserver return created=true else created=false and the error, if workspace is "" the it will return geoserver public layer with ${layerName}

func (*GeoServer) CreateNamespace

func (g *GeoServer) CreateNamespace(Prefix string, URI string) (created bool, err error)

CreateNamespace creates a Namespace and return if created or not else return error

func (*GeoServer) CreateRole

func (g *GeoServer) CreateRole(roleName string) (created bool, err error)

CreateRole creates role with name roleName returns true/false if created or not, err is an error if error occurred else err is nil

func (*GeoServer) CreateStyle

func (g *GeoServer) CreateStyle(workspaceName string, styleName string) (created bool, err error)

CreateStyle create geoserver empty sld with name and filename is(${styleName.sld}), if workspace is "" will create geoserver public style

func (*GeoServer) CreateUser

func (g *GeoServer) CreateUser(userName string, password string, serviceName string) (created bool, err error)

CreateUser creates user with name userName and password for service serviceName, if service is empty creates user for default service returns true/false if created or not, err is an error if error occurred else err is nil

func (*GeoServer) CreateWorkspace

func (g *GeoServer) CreateWorkspace(workspaceName string) (created bool, err error)

CreateWorkspace creates a workspace and return if created or not else return error

func (*GeoServer) DatastoreExists

func (g *GeoServer) DatastoreExists(workspaceName string, datastoreName string, quietOnNotFound bool) (exists bool, err error)

DatastoreExists checks if a datastore exists in a workspace else return error

func (*GeoServer) DeSerializeJSON

func (g *GeoServer) DeSerializeJSON(response []byte, structObj interface{}) (err error)

DeSerializeJSON json struct to struct

func (*GeoServer) DeleteCoverage

func (g *GeoServer) DeleteCoverage(workspaceName string, layerName string, recurse bool) (deleted bool, err error)

DeleteCoverage removes the coverage, err is an error if error occurred else err is nil

func (*GeoServer) DeleteCoverageStore

func (g *GeoServer) DeleteCoverageStore(workspaceName string, coverageStore string, recurse bool) (deleted bool, err error)

DeleteCoverageStore delete coverage store from geoserver else return error

func (*GeoServer) DeleteDatastore

func (g *GeoServer) DeleteDatastore(workspaceName string, datastoreName string, recurse bool) (deleted bool, err error)

DeleteDatastore deletes a datastore from geoserver else return error

func (*GeoServer) DeleteFeatureType

func (g *GeoServer) DeleteFeatureType(workspaceName string, datastoreName string, featureTypeName string, recurse bool) (deleted bool, err error)

DeleteFeatureType Delete FeatureType from geoserver given that workspaceName, datastoreName, featureTypeName if featuretype deleted successfully will return true and nil for err if error occurred will return false and error for err

func (*GeoServer) DeleteGroup

func (g *GeoServer) DeleteGroup(groupName string, serviceName string) (done bool, err error)

DeleteGroup deletes the group with name groupName returns true/false if deleted or not, err is an error if error occurred else err is nil

func (*GeoServer) DeleteLayer

func (g *GeoServer) DeleteLayer(workspaceName string, layerName string, recurse bool) (deleted bool, err error)

DeleteLayer delete geoserver layer and its reources else return error, if workspace is "" will delete public layer with name ${layerName} if exists

func (*GeoServer) DeleteLayerGroup

func (g *GeoServer) DeleteLayerGroup(workspaceName string, layerGroupName string) (deleted bool, err error)

DeleteLayerGroup delete geoserver layergroup else return error, if workspace is "" will delete public layergroup with name ${layerGroupName} if exists

func (*GeoServer) DeleteLayersAclRule

func (g *GeoServer) DeleteLayersAclRule(aclRule AclRule) (done bool, err error)

DeleteLayersAclRule deletes acl rule returns true/false if deleted or not, err is an error if error occurred else err is nil

func (*GeoServer) DeleteNamespace

func (g *GeoServer) DeleteNamespace(Prefix string) (deleted bool, err error)

DeleteNamespace delete geoserver Namespace and its reources else return error

func (*GeoServer) DeleteRole

func (g *GeoServer) DeleteRole(roleName string) (done bool, err error)

DeleteRole deletes the role with name roleName returns true/false if deleted or not, err is an error if error occurred else err is nil

func (*GeoServer) DeleteStyle

func (g *GeoServer) DeleteStyle(workspaceName string, styleName string, purge bool) (deleted bool, err error)

DeleteStyle delete geoserver style, if workspace is "" will delete geoserver public style , return err if error occurred

func (*GeoServer) DeleteUser

func (g *GeoServer) DeleteUser(userName string, serviceName string) (done bool, err error)

DeleteUser deletes the user with name userName for service serviceName, if service is empty creates user for default service returns true/false if deleted or not, err is an error if error occurred else err is nil

func (*GeoServer) DeleteUserRole

func (g *GeoServer) DeleteUserRole(roleName string, userName string) (done bool, err error)

DeleteUserRole deletes (disassociates) role with name roleName from the user with name userName returns true/false if deleted or not, err is an error if error occurred else err is nil

func (*GeoServer) DeleteWorkspace

func (g *GeoServer) DeleteWorkspace(workspaceName string, recurse bool) (deleted bool, err error)

DeleteWorkspace delete geoserver workspace and its reources else return error

func (*GeoServer) DoRequest

func (g *GeoServer) DoRequest(request HTTPRequest) (responseText []byte, statusCode int)

DoRequest Send request and return result and statusCode

func (*GeoServer) GetCapabilities

func (g *GeoServer) GetCapabilities(workspaceName string) (cap *wms.Capabilities, err error)

GetCapabilities Retrieves metadata about the service, including supported operations and parameters, and a list of the available layers

func (*GeoServer) GetCoverage

func (g *GeoServer) GetCoverage(workspaceName string, coverageName string) (coverage *Coverage, err error)

GetCoverage returns the coverage with name coverageName err is an error if error occurred else err is nil

func (*GeoServer) GetCoverageStore

func (g *GeoServer) GetCoverageStore(workspaceName string, gridName string) (coverageStore *CoverageStore, err error)

GetCoverageStore return coverage store from a workspace, err is an error if error occurred else err is nil

func (*GeoServer) GetCoverageStores

func (g *GeoServer) GetCoverageStores(workspaceName string) (coverageStores []*Resource, err error)

GetCoverageStores return all coverage store as resources, err is an error if error occurred else err is nil

func (*GeoServer) GetCoverages

func (g *GeoServer) GetCoverages(workspaceName string) (coverages []*Resource, err error)

GetCoverages returns all published raster layers (coverages) for workspace as resources, err is an error if error occurred else err is nil

func (*GeoServer) GetDatastoreDetails

func (g *GeoServer) GetDatastoreDetails(workspaceName string, datastoreName string) (datastore *Datastore, err error)

GetDatastoreDetails get specific datastore from geoserver else return error

func (*GeoServer) GetDatastores

func (g *GeoServer) GetDatastores(workspaceName string) (datastores []*Resource, err error)

GetDatastores return datastores in a workspace else return error

func (*GeoServer) GetError

func (g *GeoServer) GetError(statusCode int, text []byte) (err error)

GetError this return the proper error message

func (*GeoServer) GetFeatureType

func (g *GeoServer) GetFeatureType(workspaceName string, datastoreName string, featureTypeName string) (featureType *FeatureType, err error)

GetFeatureType it return geoserver FeatureType and nil err if success else nil for fetureType error for err

func (*GeoServer) GetFeatureTypes

func (g *GeoServer) GetFeatureTypes(workspaceName string, datastoreName string) (featureTypes []*Resource, err error)

GetFeatureTypes return all featureTypes in workspace and datastore if error occurred err will be return and nil for featrueTypes

func (*GeoServer) GetGeoserverRequest

func (g *GeoServer) GetGeoserverRequest(
	targetURL string,
	method string,
	accept string,
	data io.Reader,
	contentType string) (request *http.Request)

GetGeoserverRequest creates a HTTP request with geoserver credintails and header

func (*GeoServer) GetGroups

func (g *GeoServer) GetGroups(service string) (users []User, err error)

GetGroups returns all groups for service, if service is empty, returns groups for default service err is an error if error occurred else err is nil

func (*GeoServer) GetLayer

func (g *GeoServer) GetLayer(workspaceName string, layerName string) (layer *Layer, err error)

GetLayer get specific Layer in a workspace from geoserver else return error, if workspace is "" the it will return geoserver public layer with ${layerName}

func (*GeoServer) GetLayerGroup

func (g *GeoServer) GetLayerGroup(workspaceName string, layerGroupName string) (layerGroup *LayerGroup, err error)

GetLayerGroup get specific LayerGroup in a workspace from geoserver else return error, if workspace is "" the it will return geoserver public layer with ${layerName}

func (*GeoServer) GetLayerGroups

func (g *GeoServer) GetLayerGroups(workspaceName string) (layerGroups []*Resource, err error)

GetLayerGroups get all layergroups from workspace in geoserver else return error, if workspace is "" the it will return all public layers in geoserver

func (*GeoServer) GetLayers

func (g *GeoServer) GetLayers(workspaceName string) (layers []*Resource, err error)

GetLayers get all layers from workspace in geoserver else return error, if workspace is "" the it will return all public layers in geoserver

func (*GeoServer) GetLayersAclRules

func (g *GeoServer) GetLayersAclRules() (rules []AclRule, err error)

GetLayersAclRules returns array of all registered acl rules for all layers err is an error if error occurred else err is nil

func (*GeoServer) GetNamespace

func (g *GeoServer) GetNamespace(Prefix string) (namespace Namespace, err error)

GetNamespace get geoserver Namespace else return error

func (*GeoServer) GetNamespaces

func (g *GeoServer) GetNamespaces() (namespaces []*Namespace, err error)

GetNamespaces get geoserver namespaces else return error

func (*GeoServer) GetRoles

func (g *GeoServer) GetRoles() (roles []string, err error)

GetRoles returns all roles err is an error if error occurred else err is nil

func (*GeoServer) GetStoreCoverages

func (g *GeoServer) GetStoreCoverages(workspaceName string, coverageStore string) (coverages []string, err error)

GetStoreCoverages returns a list for all coverages (raster layers) names including unpublished for coverageStore, err is an error if error occurred else err is nil

func (*GeoServer) GetStyle

func (g *GeoServer) GetStyle(workspaceName string, styleName string) (style *Style, err error)

GetStyle return specific of geoserver style, if workspace is "" will return non-workspce styles

func (*GeoServer) GetStyles

func (g *GeoServer) GetStyles(workspaceName string) (styles []*Resource, err error)

GetStyles return list of geoserver styles and err if error occurred, if workspace is "" will return non-workspce styles

func (*GeoServer) GetUserRoles

func (g *GeoServer) GetUserRoles(user string) (roles []string, err error)

GetUserRoles returns all roles for user err is an error if error occurred else err is nil

func (*GeoServer) GetUsers

func (g *GeoServer) GetUsers(service string) (users []User, err error)

GetUsers returns all users for service, if service is empty, returns users for default service err is an error if error occurred else err is nil

func (*GeoServer) GetWorkspace

func (g *GeoServer) GetWorkspace(workspaceName string) (workspace Workspace, err error)

GetWorkspace get geoserver workspace else return error

func (*GeoServer) GetWorkspaces

func (g *GeoServer) GetWorkspaces() (workspaces []*Resource, err error)

GetWorkspaces get geoserver workspaces else return error

func (*GeoServer) GetshpFiledsName

func (g *GeoServer) GetshpFiledsName(filename string) string

GetshpFiledsName datastore name from shapefile name

func (*GeoServer) IsRunning

func (g *GeoServer) IsRunning() (running bool, err error)

IsRunning check if geoserver is running \n return true if geoserver running, and false if not runnging, err is an error if error occurredÎ

func (*GeoServer) LoadConfig

func (g *GeoServer) LoadConfig(configFile string) (geoserver *GeoServer, err error)

LoadConfig load geoserver config from yaml file

func (*GeoServer) NamespaceExists

func (g *GeoServer) NamespaceExists(Prefix string) (exists bool, err error)

NamespaceExists check if Namespace in geoserver or not else return error

func (*GeoServer) ParseURL

func (g *GeoServer) ParseURL(urlParts ...string) (parsedURL string)

ParseURL this function join urlParts with geoserver url

func (*GeoServer) PublishCoverage

func (g *GeoServer) PublishCoverage(workspaceName string, coverageStoreName string, coverageName string, publishName string) (published bool, err error)

PublishCoverage publishes coverage from coverageStore coverageName - the name of the layer in the coverageStore (use GetStoreCoverages to get them), publishName - the name it was presented at geoserver

func (*GeoServer) PublishGeoTiffLayer

func (g *GeoServer) PublishGeoTiffLayer(workspaceName string, coverageStoreName string, publishName string, fileName string) (published bool, err error)

PublishGeoTiffLayer publishes geotiff to geoserver

func (*GeoServer) PublishPostgisLayer

func (g *GeoServer) PublishPostgisLayer(workspaceName string, datastoreName string, publishName string, tableName string) (published bool, err error)

PublishPostgisLayer publish postgis table to geoserver

func (*GeoServer) ReloadConfigration

func (g *GeoServer) ReloadConfigration() (success bool, err error)

ReloadConfigration Reloads the GeoServer catalog and configuration from disk. This operation is used in cases where an external tool has modified the on-disk configuration. This operation will also force GeoServer to drop any internal caches and reconnect to all data stores.

func (*GeoServer) RestConfigrationCache

func (g *GeoServer) RestConfigrationCache() (success bool, err error)

RestConfigrationCache Resets all store, raster, and schema caches. This operation is used to force GeoServer to drop all caches and store connections and reconnect to each of them the next time they are needed by a request. This is useful in case the stores themselves cache some information about the data structures they manage that may have changed in the meantime.

func (*GeoServer) SerializeStruct

func (g *GeoServer) SerializeStruct(structObj interface{}) ([]byte, error)

SerializeStruct convert struct to json

func (*GeoServer) StyleExists

func (g *GeoServer) StyleExists(workspaceName string, styleName string) (exists bool, err error)

StyleExists return true if style exists in geoserver

func (*GeoServer) UpdateCoverage

func (g *GeoServer) UpdateCoverage(workspaceName string, coverage *Coverage) (modified bool, err error)

UpdateCoverage updates geoserver coverage (raster layer), else returns error,

func (*GeoServer) UpdateCoverageStore

func (g *GeoServer) UpdateCoverageStore(workspaceName string, coverageStore CoverageStore) (modified bool, err error)

UpdateCoverageStore parital update coverage store in geoserver else return error

func (*GeoServer) UpdateLayer

func (g *GeoServer) UpdateLayer(workspaceName string, layerName string, layer Layer) (modified bool, err error)

UpdateLayer partial update geoserver layer else return error, if workspace is "" the it will update public layer with name ${layerName} in geoserver

func (*GeoServer) UploadShapeFile

func (g *GeoServer) UploadShapeFile(fileURI string, workspaceName string, datastoreName string) (uploaded bool, err error)

UploadShapeFile upload shapefile to geoserver

func (*GeoServer) UploadStyle

func (g *GeoServer) UploadStyle(data io.Reader, workspaceName string, styleName string, overwrite bool) (success bool, err error)

UploadStyle upload geoserver sld, if workspace is "" will upload geoserver public style sld , return err if error occurred

func (*GeoServer) WorkspaceExists

func (g *GeoServer) WorkspaceExists(workspaceName string) (exists bool, err error)

WorkspaceExists check if workspace in geoserver or not else return error

type GroupPublishableItem

type GroupPublishableItem struct {
	Type string `json:"@type,omitempty" xml:"type"`
	Name string `json:"name,omitempty" xml:"name"`
	Href string `json:"href,omitempty" xml:"href"`
}

GroupPublishableItem geoserver Group

type HTTPRequest

type HTTPRequest struct {
	URL      string
	Accept   string
	Query    map[string]string
	Data     io.Reader
	DataType string
	Method   string
}

HTTPRequest is an http request object

type Keywords

type Keywords struct {
	String []string `json:"string,omitempty"`
}

Keywords is the geoserver Keywords

type LanguageVersion

type LanguageVersion struct {
	Version string `json:"version,omitempty"`
}

LanguageVersion style version

type LatLonBoundingBox

type LatLonBoundingBox struct {
	BoundingBox
	Crs *CRSType `json:"crs,omitempty"`
}

LatLonBoundingBox is geoserver LatLonBoundingBox for FeatureType

type Layer

type Layer struct {
	Name         string    `json:"name,omitempty"`
	Path         string    `json:"path,omitempty"`
	Type         string    `json:"type,omitempty"`
	DefaultStyle *Resource `json:"defaultStyle,omitempty"`
	Styles       *struct {
		Class string     `json:"@class,omitempty"`
		Style []Resource `json:"style,omitempty"`
	} `json:"styles,omitempty"`
	Resource    Resource     `json:"resource,omitempty"`
	Queryable   bool         `json:"queryable,omitempty"`
	Opaque      bool         `json:"opaque,omitempty"`
	Attribution *Attribution `json:"attribution,omitempty"`
}

Layer geoserver layers

type LayerGroup

type LayerGroup struct {
	Name          string             `json:"name,omitempty" xml:"name"`
	Mode          string             `json:"mode,omitempty" xml:"mode"`
	Title         string             `json:"title,omitempty" xml:"title"`
	Workspace     *Resource          `json:"workspace,omitempty" xml:"workspace"`
	Publishables  Publishables       `json:"publishables,omitempty" xml:"publishables"`
	Styles        LayerGroupStyles   `json:"styles,omitempty" xml:"styles"`
	Bounds        NativeBoundingBox  `json:"bounds,omitempty" xml:"bounds"`
	MetadataLinks []*MetadataLink    `json:"metadataLinks,omitempty" xml:"metadataLinks"`
	Keywords      LayerGroupKeywords `json:"keywords,omitempty" xml:"keywords"`
}

LayerGroup geoserver layergroup details

type LayerGroupKeywords

type LayerGroupKeywords struct {
	Keyword []*string `json:"keyword,omitempty"`
}

LayerGroupKeywords geoserver layergroups keywords

type LayerGroupService

type LayerGroupService interface {
	GetLayerGroups(workspaceName string) (layerGroups []*Resource, err error)
	GetLayerGroup(workspaceName string, layerGroupName string) (layer *LayerGroup, err error)
	CreateLayerGroup(workspaceName string, layerGroup *LayerGroup) (created bool, err error)
	DeleteLayerGroup(workspaceName string, layerGroupName string) (deleted bool, err error)
}

LayerGroupService define geoserver layergroup operations

type LayerGroupStyles

type LayerGroupStyles struct {
	Style []*Resource `json:"style,omitempty" xml:"style"`
}

LayerGroupStyles geoserver layergroup styles

type LayerRequestBody

type LayerRequestBody struct {
	Layer Layer `json:"layer,omitempty"`
}

LayerRequestBody api json

type LayerService

type LayerService interface {

	//GetLayers  get all layers from workspace in geoserver else return error
	GetLayers(workspaceName string) (layers []*Resource, err error)

	// GetshpFiledsName datastore name from shapefile name
	GetshpFiledsName(filename string) string

	// UploadShapeFile upload shapefile to geoserver
	UploadShapeFile(fileURI string, workspaceName string, datastoreName string) (uploaded bool, err error)

	//GetLayer get specific Layer from geoserver else return error
	GetLayer(workspaceName string, layerName string) (layer *Layer, err error)

	//UpdateLayer partial update geoserver layer else return error
	UpdateLayer(workspaceName string, layerName string, layer Layer) (modified bool, err error)

	//DeleteLayer delete geoserver layer and its reources else return error
	DeleteLayer(workspaceName string, layerName string, recurse bool) (deleted bool, err error)

	PublishPostgisLayer(workspaceName string, datastoreName string, publishName string, tableName string) (published bool, err error)

	PublishGeoTiffLayer(workspaceName string, coveragestoreName string, publishName string, fileName string) (published bool, err error)
}

LayerService define geoserver layers operations

type Metadata

type Metadata struct {
	Entry []*Entry `json:"entry,omitempty"`
}

Metadata is the geoserver Metadata

type MetadataLink struct {
	Type         string `json:"type,omitempty"`
	MetadataType string `json:"metadataType,omitempty"`
	Content      string `json:"content,omitempty"`
}

MetadataLink is geoserver metadata link

type MetadataLinks struct {
	MetadataLink []*MetadataLink `json:"metadataLink,omitempty"`
}

MetadataLinks is the geoserver metadata links

type Namespace

type Namespace struct {
	Prefix   string `json:"prefix,omitempty"`
	URI      string `json:"uri,omitempty"`
	Href     string `json:"href,omitempty"`
	Isolated bool   `json:"isolated,omitempty"`
}

Namespace is the Namespace Object

type NamespaceRequestBody

type NamespaceRequestBody struct {
	Namespace *Namespace `json:"namespace,omitempty"`
}

NamespaceRequestBody is the api body

type NamespaceService

type NamespaceService interface {

	// NamespaceExists check if Namespace in geoserver or not else return error
	NamespaceExists(Prefix string) (exists bool, err error)

	// GetNamespaces get geoserver Namespaces else return error
	GetNamespaces() (namespaces []*Namespace, err error)

	// GetNamespace get geoserver Namespaces else return error
	GetNamespace(Prefix string) (namespace Namespace, err error)

	// CreateNamespace creates a Namespace else return error
	CreateNamespace(Prefix string, URI string) (created bool, err error)

	//DeleteNamespace delete geoserver Namespace and its reources else return error
	DeleteNamespace(Prefix string) (deleted bool, err error)
}

NamespaceService define all geoserver namespace operations

type NativeBoundingBox

type NativeBoundingBox struct {
	BoundingBox
	Crs *CRSType `json:"crs,omitempty"`
}

NativeBoundingBox is geoserver NativeBoundingBox for FeatureType

type PublishPostgisLayerRequest

type PublishPostgisLayerRequest struct {
	FeatureType *FeatureType `json:"featureType,omitempty"`
}

PublishPostgisLayerRequest is the api body

type Publishables

type Publishables struct {
	Published PublishedGroupLayers `json:"published" xml:"published"`
}

Publishables Geoserver Published Layers

type PublishedGroupLayers

type PublishedGroupLayers []*GroupPublishableItem

PublishedGroupLayers geoserver published layers

func (*PublishedGroupLayers) UnmarshalJSON

func (u *PublishedGroupLayers) UnmarshalJSON(data []byte) error

UnmarshalJSON custom deserialization to handle published layers of group

type Resource

type Resource struct {
	Class string `json:"@class,omitempty"`
	Name  string `json:"name,omitempty"`
	Href  string `json:"href,omitempty"`
}

Resource geoserver resource

type ResponseSRS

type ResponseSRS struct {
	String []int `json:"string,omitempty"`
}

ResponseSRS is the geoserver ResponseSRS

type Style

type Style struct {
	Name            string           `json:"name,omitempty"`
	Format          string           `json:"format,omitempty"`
	Filename        string           `json:"filename,omitempty"`
	LanguageVersion *LanguageVersion `json:"languageVersion,omitempty"`
}

Style holds geoserver style

type StyleRequestBody

type StyleRequestBody struct {
	Style *Style `json:"style,omitempty"`
}

StyleRequestBody is the api body

type StyleService

type StyleService interface {
	GetStyles(workspaceName string) (styles []*Resource, err error)

	CreateStyle(workspaceName string, styleName string) (created bool, err error)

	UploadStyle(data io.Reader, workspaceName string, styleName string, overwrite bool) (success bool, err error)

	DeleteStyle(workspaceName string, styleName string, purge bool) (deleted bool, err error)

	GetStyle(workspaceName string, styleName string) (style *Style, err error)

	StyleExists(workspaceName string, styleName string) (exists bool, err error)
}

StyleService define all geoserver style operations

type Styles

type Styles struct {
	Style []Style `json:"styles,omitempty"`
}

Styles holds a list of geoserver styles

type User

type User struct {
	Name     string `json:"userName"`
	Enabled  bool   `json:"enabled"`
	Password string `json:"password,omitempty"`
}

type UtilsInterface

type UtilsInterface interface {
	DoRequest(request HTTPRequest) (responseText []byte, statusCode int)
	SerializeStruct(structObj interface{}) ([]byte, error)
	DeSerializeJSON(response []byte, structObj interface{}) (err error)
	ParseURL(urlParts ...string) (parsedURL string)
}

UtilsInterface contians common function used to help you deal with data and geoserver api

type Workspace

type Workspace struct {
	Name           string `json:"name,omitempty"`
	Isolated       bool   `json:"isolated,omitempty"`
	DataStores     string `json:"dataStores,omitempty"`
	CoverageStores string `json:"coverageStores,omitempty"`
	WmsStores      string `json:"wmsStores,omitempty"`
	WmtsStores     string `json:"wmtsStores,omitempty"`
}

Workspace is the Workspace Object

type WorkspaceRequestBody

type WorkspaceRequestBody struct {
	Workspace *Workspace `json:"workspace,omitempty"`
}

WorkspaceRequestBody is the api body

type WorkspaceService

type WorkspaceService interface {

	// WorkspaceExists check if workspace in geoserver or not else return error
	WorkspaceExists(workspaceName string) (exists bool, err error)

	// GetWorkspaces get geoserver workspaces else return error
	GetWorkspaces() (workspaces []*Resource, err error)

	// GetWorkspace get geoserver workspaces else return error
	GetWorkspace(workspaceName string) (workspace Workspace, err error)

	// CreateWorkspace creates a workspace else return error
	CreateWorkspace(workspaceName string) (created bool, err error)

	//DeleteWorkspace delete geoserver workspace and its reources else return error
	DeleteWorkspace(workspaceName string, recurse bool) (deleted bool, err error)
}

WorkspaceService define all geoserver workspace operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL