Documentation
¶
Index ¶
- func AddGeoServerLayerGroup(pzAddr, authKey string) (string, error)
- func DownloadByID(dataID, filename, subFold, pzAddr, authKey string) (string, error)
- func DownloadByURL(url, filename, subFold, authKey string) (string, error)
- func DownloadBytes(dataID, pzAddr, authKey string) ([]byte, error)
- func ErrWithTrace(errStr string) error
- func FindMySvc(svcName, pzAddr, authKey string) (string, error)
- func GetJobID(resp *http.Response) (string, error)
- func GetMockReadCloser(bodyString string) io.ReadCloser
- func HTTPClient() *http.Client
- func HTTPOut(w http.ResponseWriter, output string, code int)
- func Ingest(fName, fType, pzAddr, sourceName, version, authKey string, ingData []byte, ...) (string, error)
- func IngestFile(fName, subFold, fType, pzAddr, sourceName, version, authKey string, ...) (string, error)
- func ManageRegistration(svcName, svcDesc, svcURL, pzAddr, svcVers, authKey string, ...) error
- func Preflight(w http.ResponseWriter, r *http.Request) bool
- func PrintJSON(w http.ResponseWriter, output interface{}, httpStatus int) []byte
- func PsuUUID() (string, error)
- func ReadBodyJSON(output interface{}, body io.ReadCloser) ([]byte, error)
- func ReqByObjJSON(method, addr, authKey string, inpObj, outpObj interface{}) ([]byte, error)
- func RequestKnownJSON(method, bodyStr, address, authKey string, outpObj interface{}) ([]byte, error)
- func SetHTTPClient(newClient *http.Client)
- func SetMockClient(outputs []string, status int)
- func SliceToCommaSep(inSlice []string) string
- func SubmitMultipart(bodyStr, address, filename, authKey string, fileData []byte) (*http.Response, error)
- func SubmitSinglePart(method, bodyStr, url, authKey string) (*http.Response, error)
- func TestPiazzaAuth(pzGateway, auth string) error
- func TraceErr(err error) error
- func TraceStr(errStr string) string
- func UpdateFileMeta(dataID, pzAddr, authKey string, newMeta map[string]string) error
- func WriteEventTypes(writer http.ResponseWriter, request *http.Request)
- type Alert
- type AlertList
- type ClassType
- type CompClause
- type DataDesc
- type DataResult
- type DataType
- type DeplStrct
- type Error
- type Event
- type EventList
- type EventResponse
- type EventType
- type EventTypeList
- type EventTypeMap
- type EventTypeResponse
- type FakeRespWriter
- type FileDataList
- type FileLoc
- type HTTPError
- type IngestReq
- type JobData
- type JobInitResp
- type JobProg
- type JobStatusResp
- type NumKeyVal
- type PagStruct
- type QueryClause
- type ResMeta
- type Semaphore
- type Service
- type ServiceResponse
- type SpatMeta
- type SvcList
- type TrigCondition
- type TrigJob
- type Trigger
- type TriggerList
- type TriggerResponse
- type TxtKeyVal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGeoServerLayerGroup ¶
AddGeoServerLayerGroup takes the bare-bones contact information for the local Piazza instance, submits a request for a new geoserver layer group, and returns the identifying uuid for that layer group (or an error).
func DownloadByID ¶
DownloadByID retrieves a file from Pz using the file access API
func DownloadByURL ¶
DownloadByURL retrieves a file from the given URL
func DownloadBytes ¶
DownloadBytes retrieves a file from Pz using the file access API and then returns the results as a byte slice
func ErrWithTrace ¶
ErrWithTrace is a simple utility function for generating an error based on a string and while adding filename and line number.
func FindMySvc ¶
FindMySvc Searches Pz for a service matching the input information. If it finds one, it returns the service ID. If it does not, returns an empty string. Currently searches on service name and submitting user.
func GetJobID ¶
GetJobID is a simple function to extract the job ID from the standard response to job-creating Pz calls
func GetMockReadCloser ¶
func GetMockReadCloser(bodyString string) io.ReadCloser
GetMockReadCloser generates a mocked but valid ReadCloser object that will provide the given strign when read. It is intended to support testing of functions that serve http requests
func HTTPClient ¶
HTTPClient is a factory method for a http.Client suitable for common operations
func HTTPOut ¶
func HTTPOut(w http.ResponseWriter, output string, code int)
HTTPOut outputs the given string on the given responseWriter with the given http code. It is nearly identical in behavior to http.Error, except that it doesn't modify the headers otherwise, allowing us to maintain the Content-Type of application/json, and make things a bit easier for our service consumers to digest.
func Ingest ¶
func Ingest(fName, fType, pzAddr, sourceName, version, authKey string, ingData []byte, props map[string]string) (string, error)
Ingest ingests the given bytes to Piazza.
func IngestFile ¶
func IngestFile(fName, subFold, fType, pzAddr, sourceName, version, authKey string, props map[string]string) (string, error)
IngestFile ingests the given file to Piazza
func ManageRegistration ¶
func ManageRegistration(svcName, svcDesc, svcURL, pzAddr, svcVers, authKey string, attributes map[string]string) error
ManageRegistration Handles Pz registration for a service. It checks the current service list to see if it has been registered already. If it has not, it performs initial registration. If it has not, it re-registers. Best practice is to do this every time your service starts up. For those of you code-reading, the filter is still somewhat rudimentary. It will improve as better tools become available.
func Preflight ¶
func Preflight(w http.ResponseWriter, r *http.Request) bool
Preflight sets up the CORS stuff and returns TRUE if this is an OPTIONS request
func PrintJSON ¶
func PrintJSON(w http.ResponseWriter, output interface{}, httpStatus int) []byte
PrintJSON marshals the given object, turns it into a string, and feeds it to the given ResponseWriter.
func PsuUUID ¶
PsuUUID makes a psuedo-UUID. It may not achieve cryptographic levels of randomness, and it won't respond properly to standard ways of pulling data out of UUIDs, but it works just fine at generating effectively unique IDs for practical purposes.
func ReadBodyJSON ¶
func ReadBodyJSON(output interface{}, body io.ReadCloser) ([]byte, error)
ReadBodyJSON takes the body of either a request object or a response object, pulls out the body, and attempts to interpret it as JSON into the given interface format. It's mostly there as a minor simplifying function.
func ReqByObjJSON ¶
ReqByObjJSON is much like RequestKnownJSON, except that it takes an interface (which it then json-marshals) as its input, rather than an already-marshaled string
func RequestKnownJSON ¶
func RequestKnownJSON(method, bodyStr, address, authKey string, outpObj interface{}) ([]byte, error)
RequestKnownJSON submits an http request where the response is assumed to be JSON for which the format is known. Given an object of the appropriate format for said response JSON, an address to call and an authKey to send, it will submit the get request, unmarshal the result into the given object, and return. It returns the response buffer, in case it is needed for debugging purposes.
func SetHTTPClient ¶
SetHTTPClient is used to set the current http client. This is mostly useful for testing purposes
func SetMockClient ¶
SetMockClient is a utility function for testing purposes. When called, it sets the current pzsvc client to a mock client. That client will accept any input, and immediately respond. It's responses are determined by the given string slice - it iterates through them one at a time until done, with the http status as whatever is provided as such, and returns the rudimentary string "{}" for any remaining calls. Intended to simplify testing in the face of a requirement for multiple http calls. Explicitly including an empty string in the list will permit a single call to pass out through the standard path.
func SliceToCommaSep ¶
SliceToCommaSep takes a string slice, and turns it into a comma-separated list of strings, suitable for JSON.
func SubmitMultipart ¶
func SubmitMultipart(bodyStr, address, filename, authKey string, fileData []byte) (*http.Response, error)
SubmitMultipart sends a multi-part POST call, including an optional uploaded file, and returns the response. Primarily intended to support Ingest calls.
func SubmitSinglePart ¶
SubmitSinglePart sends a single-part GET/POST/PUT/DELETE call to the target URL and returns the result. Includes the necessary headers.
func TestPiazzaAuth ¶
TestPiazzaAuth returns an error if it is unable to authenticate with the gateway and authorization provided
func TraceErr ¶
TraceErr is a simple utility function for adding a local filename and line number on to the beginning of an error message before passing it along.
func TraceStr ¶
TraceStr is a simple utility function that adds filename and line number to a string. Primarily intended for error messages, though it is also useful in logging.
func UpdateFileMeta ¶
UpdateFileMeta updates the metadata for a given dataID in the S3 bucket
func WriteEventTypes ¶
func WriteEventTypes(writer http.ResponseWriter, request *http.Request)
WriteEventTypes returns the event types known to bf-handle
Types ¶
type Alert ¶
type Alert struct {
AlertID string `json:"alertId,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
EventID string `json:"eventId,omitempty"`
JobID string `json:"jobId,omitempty"`
TriggerID string `json:"triggerId,omitempty"`
}
Alert is the response object to a Get Alert call when given an alertID. It is also used to represent alerts in the search and list alerts calls
type AlertList ¶
type AlertList struct {
Type string `json:"type,omitempty"`
Data []Alert `json:"data,omitempty"`
Pagination PagStruct `json:"pagination,omitempty"`
}
AlertList is the representation of a list of alert objects.
type ClassType ¶
type ClassType struct {
Classification string `json:"classification,omitempty"`
}
ClassType holds classification data
type CompClause ¶
type CompClause struct {
LTE interface{} `json:"lte,omitempty"`
GTE interface{} `json:"gte,omitempty"`
Format string `json:"format,omitempty"`
}
CompClause ...
type DataDesc ¶
type DataDesc struct {
DataID string `json:"dataId,omitempty"`
DataType DataType `json:"dataType,omitempty"`
ResMeta ResMeta `json:"metadata,omitempty"`
SpatMeta *SpatMeta `json:"spatialMetadata,omitempty"`
}
DataDesc is the identifying information for a specific uploaded file or data block. It is an important part of ingest requests, and the core of the response object for file metadata requests.
func GetFileMeta ¶
GetFileMeta retrieves the metadata for a given dataID in the S3 bucket
type DataResult ¶
type DataResult struct {
DataID string `json:"dataId,omitempty"` // Impl01
Deployment DeplStrct `json:"deployment,omitempty"` // Impl02
Details string `json:"details,omitempty"` // Impl03
Message string `json:"message,omitempty"` // Impl03
JobID string `json:"jobId,omitempty"` // Impl04
Text string `json:"text,omitempty"` // Impl05
}
DataResult is a hack to handle the fact that the backend we're addressing uses a lot of inheritence here. Any one of five different classes could fill the slots set aside for DataResult objects in a job response. Impl01 is for ingest actions. Impl02 is for deployment to geoserver. Impl03 is for errors that occur doing one of the others. Impl04 and Impl05 are currently unknown.
func GetJobResponse ¶
func GetJobResponse(jobID, pzAddr, authKey string) (*DataResult, error)
GetJobResponse will repeatedly poll the job status on the given job Id until job completion, then acquires and returns the DataResult.
type DataType ¶
type DataType struct {
Content string `json:"content,omitempty"` // the data itself, for those types small enough
Type string `json:"type,omitempty"` // see "current options", above
MimeType string `json:"mimeType,omitempty"` // mimetype corresponding to the type
Location *FileLoc `json:"location,omitempty"` // where the data is, for those stored in shared folder/S3.
DatTabName string `json:"databaseTableName,omitempty"` // geojson/shapefile, and only some of those.
GeoJContent string `json:"geoJsonContent,omitempty"` // geojson, and only some of those.
LitType string `json:"literalType,omitempty"` // literal: DOUBLE,FLOAT,SHORT,LONG,BYTE,CHAR,BOOLEAN,STRING
Database string `json:"database,omitempty"` // postgis
Table string `json:"table,omitempty"` // postgis
FeatureType string `json:"featureType,omitempty"` // wfs
URL string `json:"url,omitempty"` // wfs
Version string `json:"version,omitempty"` // wfs
}
DataType is highly polymorphic, and refers to a specific block of data. It defines the information specific to the type of that data block. Current options are 'body', 'geojson', 'literal', 'pointcloud', 'postgis', 'raster', 'shapefile', 'text' , 'urlparameter', and 'wfs'
type DeplStrct ¶
type DeplStrct struct {
CapabilitiesURL string `json:"capabilitiesUrl,omitempty"`
DataID string `json:"dataId,omitempty"`
DeplID string `json:"deploymentId,omitempty"`
Host string `json:"host,omitempty"`
Layer string `json:"layer,omitempty"`
Port string `json:"port,omitempty"`
}
DeplStrct is an important part of the job status response for "deploy to geoserver" calls.
func DeployToGeoServer ¶
DeployToGeoServer calls the Pz "provision" endpoint - causing the file indicated by dataId to be deployed to the local GeoServer instance, and returning the ID of the new layer. If lGroupID is included, the layer is also added to the layer group with that ID.
type Error ¶
type Error struct {
Message string `json:"error"`
}
Error is a type designed for easy serialization to JSON
type Event ¶
type Event struct {
EventID string `json:"eventId"`
EventTypeID string `json:"eventTypeId" binding:"required"`
Data map[string]interface{} `json:"data"`
CreatedBy string `json:"createdBy"`
CreatedOn time.Time `json:"createdOn"`
CronSchedule string `json:"cronSchedule"`
}
Event is the definition of a Pz Event.
type EventList ¶
type EventList struct {
Type string `json:"type,omitempty"`
Data []Event `json:"data,omitempty"`
Pagination PagStruct `json:"pagination,omitempty"`
}
EventList is the representation of a list of Event objects.
type EventResponse ¶
EventResponse is solely the response for adding a new Event
type EventType ¶
type EventType struct {
EventTypeID string `json:"eventTypeId"`
Name string `json:"name" binding:"required"`
Mapping map[string]interface{} `json:"mapping" binding:"required"`
CreatedBy string `json:"createdBy"`
CreatedOn time.Time `json:"createdOn"`
}
EventType is the definition of a Pz EventType.
func AddEventType ¶
AddEventType adds the requested EventType and returns a pointer to what was created
type EventTypeList ¶
type EventTypeList struct {
Type string `json:"type,omitempty"`
Data []EventType `json:"data,omitempty"`
Pagination PagStruct `json:"pagination,omitempty"`
}
EventTypeList is the representation of a list of EventType objects.
type EventTypeMap ¶
EventTypeMap is the definition of an EventTypeMap.
func GetEventTypeMap ¶
func GetEventTypeMap() EventTypeMap
GetEventTypeMap returns the EventTypeMap. This should not be modified.
type EventTypeResponse ¶
EventTypeResponse is solely the response for adding a new EventType
type FakeRespWriter ¶
FakeRespWriter is for testing purposes
func GetMockResponseWriter ¶
func GetMockResponseWriter() (*FakeRespWriter, string, int)
GetMockResponseWriter returns a simple fake response writer object for testing purposes
func (*FakeRespWriter) Header ¶
func (frw *FakeRespWriter) Header() http.Header
Header returns an empty header
func (*FakeRespWriter) Write ¶
func (frw *FakeRespWriter) Write(byts []byte) (int, error)
Write sets the output string
func (*FakeRespWriter) WriteHeader ¶
func (frw *FakeRespWriter) WriteHeader(status int)
WriteHeader stores the status code
type FileDataList ¶
type FileDataList struct {
Type string `json:"type,omitempty"`
Data []DataDesc `json:"data,omitempty"`
Pagination PagStruct `json:"pagination,omitempty"`
}
FileDataList is a list of DataDesc objects. It is the response object when searching for lists of file metadata, using the /data endpoint
type FileLoc ¶
type FileLoc struct {
FileName string `json:"fileName,omitempty"`
FileSize int `json:"fileSize,omitempty"`
Type string `json:"type,omitempty"` // "share" or "s3"
BucketName string `json:"bucketName,omitempty"` // Impl01
DomainName string `json:"domainName,omitempty"` // Impl01
FilePath string `json:"filePath,omitempty"` // Impl02
}
FileLoc contains information on where a file is located. it's represented as an interface in the Pz code, and can be implemented in one of two ways. Impl01 is the S3 bucket file store implementation. Impl02 is the shared folder implementation.
type IngestReq ¶
type IngestReq struct {
Data DataDesc `json:"data,omitempty"`
Host bool `json:"host,omitempty"`
Type string `json:"type,omitempty"` // "ingest"
}
IngestReq is the base object used to ingest a file to Piazza.
type JobData ¶
type JobData struct {
ServiceID string `json:"serviceId,omitempty"`
DataInputs map[string]DataType `json:"dataInputs"`
DataOutput []DataType `json:"dataOutput,omitempty"`
}
JobData ...
type JobInitResp ¶
type JobInitResp struct {
Data struct {
JobID string `json:"jobId,omitempty"`
} `json:"data,omitempty"`
}
JobInitResp is the immediate response object to all of the asynch "create job" calls (service calls and ingests, mostly). It can also be used as a request object for "repeat previously submitted job" calls
type JobProg ¶
type JobProg struct {
PercentComplete int `json:"percentComplete,omitempty"`
TimeRemaining string `json:"timeRemaining,omitempty"`
TimeSpent string `json:"timeSpent,omitempty"`
}
JobProg is Pz's way of indicating job progress
type JobStatusResp ¶
type JobStatusResp struct {
CreatedBy string `json:"createdBy,omitempty"`
JobID string `json:"jobId,omitempty"`
JobType string `json:"jobType,omitempty"`
Progress JobProg `json:"progress,omitempty"`
Result *DataResult `json:"result,omitempty"`
Status string `json:"status,omitempty"`
}
JobStatusResp is the response object to a Get Job Status call.
type PagStruct ¶
type PagStruct struct {
Count int `json:"count,omitempty"`
Order string `json:"order,omitempty"`
Page int `json:"page,omitempty"`
PerPage int `json:"perPage,omitempty"`
SortBy string `json:"sortBy,omitempty"`
}
PagStruct is the Pz pagination data format. It is attached to all list-type structs.
type QueryClause ¶
type QueryClause struct {
Match map[string]string `json:"match,omitempty"`
Range map[string]CompClause `json:"range,omitempty"`
}
QueryClause ...
type ResMeta ¶
type ResMeta struct {
Availability string
ClassType ClassType `json:"classType,omitempty"`
CliCertReq bool `json:"clientCertRequired,omitempty"`
Contacts string `json:"contacts,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
CreatedOn string `json:"createdOn,omitempty"`
CredReq bool `json:"credentialsRequired,omitempty"`
Description string `json:"description,omitempty"`
Format string `json:"format,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Name string `json:"name,omitempty"`
NetworkAvail string `json:"networkAvailable,omitempty"`
NumKeyValList []NumKeyVal `json:"numericKeyValueList,omitempty"`
PreAuthReq bool `json:"preAuthRequired,omitempty"`
QOS string `json:"qos,omitempty"`
Reason string `json:"reason,omitempty"`
StatusType string `json:"statusType,omitempty"`
Tags string `json:"tags,omitempty"`
TxtKeyValList []TxtKeyVal `json:"textKeyValueList,omitempty"`
Version string `json:"version,omitempty"`
}
ResMeta holds a resource metadata. It's used broadly Worth noting that Pz pays no attention to the contents of the Metadata map field except to act as a passthrough. Among other things, it's the request object for the "Change metadata" PUT request.
type Semaphore ¶
type Semaphore chan empty
Semaphore is a structure that allows limited resources to be allocated across multiple threads. Semaphores that are left nil provide no restriction to behavior.
type Service ¶
type Service struct {
ContractURL string `json:"contractUrl,omitempty"`
Hearbeat int `json:"heartbeat,omitempty"`
Method string `json:"method,omitempty"`
ResMeta ResMeta `json:"resourceMetadata,omitempty"`
ServiceID string `json:"serviceId,omitempty"`
Timeout int `json:"timeout,omitempty"`
URL string `json:"url,omitempty"`
}
Service is the Pz representation of a registered service. Used as the payload in register service and update service jobs. Also used in the response to the List Service job.
type ServiceResponse ¶
ServiceResponse is solely the response for adding a new Service
type SpatMeta ¶
type SpatMeta struct {
CoordRefSystem string `json:"coordinateReferenceSystem,omitempty"`
EpsgCode int `json:"epsgCode,omitempty"`
MinX float64 `json:"minX,omitempty"`
MinY float64 `json:"minY,omitempty"`
MinZ float64 `json:"minZ,omitempty"`
MaxX float64 `json:"maxX,omitempty"`
MaxY float64 `json:"maxY,omitempty"`
MaxZ float64 `json:"maxZ,omitempty"`
NumFeatures int `json:"numFeatures,omitempty"`
}
SpatMeta contains information on the spatial metadata (location) of a given image/feature/etc. It is usually autogenerated
type SvcList ¶
type SvcList struct {
Type string `json:"type,omitempty"`
Data []Service `json:"data,omitempty"`
Pagination PagStruct `json:"pagination,omitempty"`
}
SvcList is the Pz representation of a list of service objects. It's the response object for a list/search services call
type TrigCondition ¶
type TrigCondition struct {
Query struct {
Bool struct {
Filter []QueryClause `json:"filter"`
} `json:"bool"`
} `json:"query"`
}
TrigCondition ...
type TrigJob ¶
type TrigJob struct {
JobType struct {
Type string `json:"type,omitempty"`
Data JobData `json:"data,omitempty"`
} `json:"jobType,omitempty"`
}
TrigJob ...
type Trigger ¶
type Trigger struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
EventTypeID string `json:"eventTypeId"`
Condition TrigCondition `json:"condition"`
Job TrigJob `json:"job"`
CreatedBy string `json:"createdBy,omitempty"`
CreatedOn string `json:"createdOn,omitempty"`
TriggerID string `json:"triggerId,omitempty"`
}
Trigger is the response object to a Get Trigger call when given a triggerID. It is also used to represent triggers in the list and search trigger calls. Additionally, it is used when creating or modifying a trigger. Due to the complexity of the Trigger object, many of its component parts have been defined in a separate file. Please see elasticSearchModel.go for those.
type TriggerList ¶
type TriggerList struct {
Type string `json:"type,omitempty"`
Data []Trigger `json:"data,omitempty"`
Pagination PagStruct `json:"pagination,omitempty"`
}
TriggerList is the representation of a list of trigger objects.
type TriggerResponse ¶
TriggerResponse is solely the response for adding a new Service
func AddTrigger ¶
func AddTrigger(trigger Trigger, pzGateway, auth string) (TriggerResponse, error)
AddTrigger adds the requested Trigger and returns what was created