Skip to content

Commit

Permalink
update various tick doc comments for cleaner generated tickdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed May 8, 2017
1 parent b3a8bb6 commit 3ad9b41
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
4 changes: 2 additions & 2 deletions http_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func newHTTPPostNode(et *ExecutingTask, n *pipeline.HTTPPostNode, l *log.Logger)
}

// Should only ever be 0 or 1 from validation of n
if len(n.HTTPPostEndpoints) == 1 {
endpointName := n.HTTPPostEndpoints[0].Endpoint
if len(n.Endpoints) == 1 {
endpointName := n.Endpoints[0]
e, ok := et.tm.HTTPPostService.Endpoint(endpointName)
if !ok {
return nil, fmt.Errorf("endpoint '%s' does not exist", endpointName)
Expand Down
16 changes: 11 additions & 5 deletions pipeline/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,14 @@ func (a *AlertNode) Flapping(low, high float64) *AlertNode {
}

// HTTP POST JSON alert data to a specified URL.
// Example with endpoint:
//
// Example:
// stream
// |alert()
// .post()
// .endpoint('example')
// .endpoint('example')
//
// Example with url:
// Example:
// stream
// |alert()
// .post('http://example.com')
Expand All @@ -501,12 +502,16 @@ func (a *AlertNode) Post(urls ...string) *AlertHTTPPostHandler {
return post
}

// Set a header key and value on the post request.
// Setting the Authenticate header is not allowed from within TICKscript,
// please use the configuration file to specify sensitive headers.
//
// Example:
// stream
// |alert()
// .post()
// .endpoint('example')
// .header('a','b')
// .endpoint('example')
// .header('a','b')
// tick:property
func (a *AlertHTTPPostHandler) Header(k, v string) *AlertHTTPPostHandler {
if a.Headers == nil {
Expand All @@ -528,6 +533,7 @@ type AlertHTTPPostHandler struct {
// Name of the endpoint to be used, as is defined in the configuration file
Endpoint string

// tick:ignore
Headers map[string]string `tick:"Header"`
}

Expand Down
31 changes: 10 additions & 21 deletions pipeline/http_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type HTTPPostNode struct {
chainnode

// tick:ignore
HTTPPostEndpoints []*HTTPPostEndpoint `tick:"Endpoint"`
Endpoints []string `tick:"Endpoint"`

// Headers
Headers map[string]string `tick:"Header"`
Expand All @@ -55,15 +55,15 @@ func (p *HTTPPostNode) validate() error {
return fmt.Errorf("httpPost expects 0 or 1 arguments, got %v", len(p.URLs))
}

if len(p.HTTPPostEndpoints) > 1 {
return fmt.Errorf("httpPost expects 0 or 1 endpoints, got %v", len(p.HTTPPostEndpoints))
if len(p.Endpoints) > 1 {
return fmt.Errorf("httpPost expects 0 or 1 endpoints, got %v", len(p.Endpoints))
}

if len(p.URLs) == 0 && len(p.HTTPPostEndpoints) == 0 {
if len(p.URLs) == 0 && len(p.Endpoints) == 0 {
return errors.New("must provide url or endpoint")
}

if len(p.URLs) > 0 && len(p.HTTPPostEndpoints) > 0 {
if len(p.URLs) > 0 && len(p.Endpoints) > 0 {
return errors.New("only one endpoint and url may be specified")
}

Expand All @@ -76,20 +76,17 @@ func (p *HTTPPostNode) validate() error {
return nil
}

// Name of the endpoint to be used, as is defined in the configuration file.
//
// Example:
// stream
// |httpPost()
// .endpoint('example')
//
// tick:property
func (p *HTTPPostNode) Endpoint(endpoint string) *HTTPPostEndpoint {
post := &HTTPPostEndpoint{
HTTPPostNode: p,
Endpoint: endpoint,
}
p.HTTPPostEndpoints = append(p.HTTPPostEndpoints, post)

return post
func (p *HTTPPostNode) Endpoint(endpoint string) *HTTPPostNode {
p.Endpoints = append(p.Endpoints, endpoint)
return p
}

// Example:
Expand All @@ -107,11 +104,3 @@ func (p *HTTPPostNode) Header(k, v string) *HTTPPostNode {

return p
}

// tick:embedded:HTTPPostNode.Endpoint
type HTTPPostEndpoint struct {
*HTTPPostNode

// Name of the endpoint to be used, as is defined in the configuration file
Endpoint string
}
4 changes: 2 additions & 2 deletions tickdoc.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
root = "/kapacitor/v1.2/nodes"
root = "/kapacitor/v1.3/nodes"
page-header = '''---
title: {{ .Title }}
note: Auto generated by tickdoc

menu:
kapacitor_1_2:
kapacitor_1_3:
name: {{ .Name }}
identifier: {{ .Identifier }}
weight: {{ .Weight }}
Expand Down

0 comments on commit 3ad9b41

Please sign in to comment.