antoineaugusti / updown Goto Github PK
View Code? Open in Web Editor NEWGo client for the Updown API
Home Page: https://updown.io/api
License: MIT License
Go client for the Updown API
Home Page: https://updown.io/api
License: MIT License
Hi @AntoineAugusti,
While using your go module I hit with an issue.
Issue Details
In CheckItem Struct
type CheckItem struct {
// The URL you want to monitor
URL string `json:"url,omitempty"`
// Interval in seconds (30, 60, 120, 300 or 600)
Period int `json:"period,omitempty"`
// APDEX threshold in seconds (0.125, 0.25, 0.5 or 1.0)
Apdex float64 `json:"apdex_t,omitempty"`
// Is the check enabled
Enabled bool `json:"enabled,omitempty"`
// Shall the status page be public
Published bool `json:"published,omitempty"`
// Human readable name
Alias string `json:"alias,omitempty"`
// Search for this string in the page
StringMatch string `json:"string_match,omitempty"`
// Mute notifications until given time, accepts a time, 'recovery' or 'forever'
MuteUntil string `json:"mute_until,omitempty"`
// Disabled monitoring locations. It's an array of abbreviated location names
DisabledLocations []string `json:"disabled_locations,omitempty"`
// The HTTP headers you want in updown requests
CustomHeaders map[string]string `json:"custom_headers,omitempty"`
}
the omitempty
param is causing the struct attributes to omit, like when I assign false
to Published
its gets omitted.
Because of this issue, I am unable to Update Updown's check features.
omitempty
basically causes an issue at this place in your code.
client.go:88
buf := new(bytes.Buffer)
if body != nil {
err := json.NewEncoder(buf).Encode(body)
if err != nil {
return nil, err
}
}
Sample Code
Sample Code given below explain how omitempty
params causes struct attributes to omit.
package main
import (
"encoding/json"
"fmt"
)
func main() {
type CheckItem struct {
// The URL you want to monitor
URL string `json:"url,omitempty"`
// Interval in seconds (30, 60, 120, 300 or 600)
Period int `json:"period,omitempty"`
// APDEX threshold in seconds (0.125, 0.25, 0.5 or 1.0)
Apdex float64 `json:"apdex_t,omitempty"`
// Is the check enabled
Enabled bool `json:"enabled,omitempty"`
// Shall the status page be public
Published bool `json:"published,omitempty"`
// Human readable name
Alias string `json:"alias,omitempty"`
// Search for this string in the page
StringMatch string `json:"string_match,omitempty"`
// Mute notifications until given time, accepts a time, 'recovery' or 'forever'
MuteUntil string `json:"mute_until,omitempty"`
// Disabled monitoring locations. It's an array of abbreviated location names
DisabledLocations []string `json:"disabled_locations,omitempty"`
// The HTTP headers you want in updown requests
CustomHeaders map[string]string `json:"custom_headers,omitempty"`
}
s := CheckItem{Published: true}
fmt.Println(s)
out, err := json.Marshal(s)
if err != nil {
panic(err)
}
fmt.Println(string(out))
}
Help needed in this regards. Thank you
Regards
Irtiza
Hi @AntoineAugusti,
I am using you go package for updown monitor and its rocking. Just want to know is there a way to add email alert addresses either by using your package or updown's REST API.
I am unable to find any resource in that regards, help would be appreciated.
Thank you
Irtiza
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.