Mercurial > gemma
view pkg/imports/wg.go @ 1810:7ee9bdaac336
Waterway gauge import: Added support for username/password.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 15 Jan 2019 18:09:10 +0100 |
parents | 77582da3adb0 |
children | 4910bcfab319 |
line wrap: on
line source
// This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> package imports import ( "context" "database/sql" "errors" "log" "gemma.intevation.de/gemma/pkg/common" "gemma.intevation.de/gemma/pkg/soap" "gemma.intevation.de/gemma/pkg/soap/erdms" ) type WaterwayGauge struct { // URL is the URL of the SOAP service. URL string `json:"url"` // Username is the username used to authenticate. Username string `json:"username"` // Passwort is the password to authenticate. Password string `json:"password"` // Insecure indicates if HTTPS traffic // should validate certificates or not. Insecure bool `json:"insecure"` } const WGJobKind JobKind = "wg" type wgJobCreator struct{} func init() { RegisterJobCreator(WGJobKind, wgJobCreator{}) } func (wgJobCreator) Description() string { return "waterway gauges" } func (wgJobCreator) AutoAccept() bool { return false } func (wgJobCreator) Create(_ JobKind, data string) (Job, error) { wg := new(WaterwayGauge) if err := common.FromJSONString(data, wg); err != nil { return nil, err } return wg, nil } func (wgJobCreator) Depends() []string { return []string{ "gauges", } } func (wgJobCreator) StageDone( ctx context.Context, tx *sql.Tx, id int64, ) error { // TODO: Implement me! return nil } func (*WaterwayGauge) CleanUp() error { return nil } func (wg *WaterwayGauge) Do( ctx context.Context, importID int64, conn *sql.Conn, feedback Feedback, ) (interface{}, error) { var auth *soap.BasicAuth if wg.Username != "" { auth = &soap.BasicAuth{ Login: wg.Username, Password: wg.Password, } } client := erdms.NewRefService(wg.URL, wg.Insecure, auth) request := &erdms.GetRisDataXML{ GetRisDataXMLType: &erdms.GetRisDataXMLType{ Subcode: "AT%", Funcode: "wtwgag", }, } log.Printf("user: %s password: %s\n", wg.Username, wg.Password) data, err := client.GetRisDataXML(request) if err != nil { log.Printf("error: %v\n", err) return nil, err } _ = data // TODO: Implement me! return nil, errors.New("Not implemented, yet!") }