-
Notifications
You must be signed in to change notification settings - Fork 176
/
adhoc.go
38 lines (32 loc) · 973 Bytes
/
adhoc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package v2
import (
"errors"
"fmt"
"net/url"
)
// FixtureAdhocRequest returns a testing fixture for an AdhocRequest struct.
func FixtureAdhocRequest(name string, subscriptions []string) *AdhocRequest {
return &AdhocRequest{
ObjectMeta: NewObjectMeta(name, "default"),
Subscriptions: subscriptions,
}
}
// SetNamespace sets the namespace of the resource.
func (a *AdhocRequest) SetNamespace(namespace string) {
return
}
// StorePrefix returns the path prefix to this resource in the store
func (a *AdhocRequest) StorePrefix() string {
return ""
}
// Validate returns an error if the name is not provided.
func (a *AdhocRequest) Validate() error {
if a.Name == "" {
return errors.New("must provide check name")
}
return nil
}
// URIPath is the URI path component to the adhoc request.
func (a *AdhocRequest) URIPath() string {
return fmt.Sprintf("/api/core/v2/namespaces/%s/checks/%s/execute", url.PathEscape(a.Namespace), url.PathEscape(a.Name))
}