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