2015-09-06 20:29:51 +00:00
|
|
|
package api
|
|
|
|
|
2016-10-29 00:16:56 +00:00
|
|
|
import "io"
|
|
|
|
|
2015-09-06 20:29:51 +00:00
|
|
|
// Raw can be used to do raw queries against custom endpoints
|
|
|
|
type Raw struct {
|
|
|
|
c *Client
|
|
|
|
}
|
|
|
|
|
|
|
|
// Raw returns a handle to query endpoints
|
|
|
|
func (c *Client) Raw() *Raw {
|
|
|
|
return &Raw{c}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Query is used to do a GET request against an endpoint
|
|
|
|
// and deserialize the response into an interface using
|
|
|
|
// standard Nomad conventions.
|
|
|
|
func (raw *Raw) Query(endpoint string, out interface{}, q *QueryOptions) (*QueryMeta, error) {
|
|
|
|
return raw.c.query(endpoint, out, q)
|
|
|
|
}
|
|
|
|
|
2016-10-29 00:16:56 +00:00
|
|
|
// Response is used to make a GET request against an endpoint and returns the
|
|
|
|
// response body
|
|
|
|
func (raw *Raw) Response(endpoint string, q *QueryOptions) (io.ReadCloser, error) {
|
|
|
|
return raw.c.rawQuery(endpoint, q)
|
|
|
|
}
|
|
|
|
|
2015-09-06 20:29:51 +00:00
|
|
|
// Write is used to do a PUT request against an endpoint
|
|
|
|
// and serialize/deserialized using the standard Nomad conventions.
|
|
|
|
func (raw *Raw) Write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error) {
|
|
|
|
return raw.c.write(endpoint, in, out, q)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete is used to do a DELETE request against an endpoint
|
|
|
|
// and serialize/deserialized using the standard Nomad conventions.
|
|
|
|
func (raw *Raw) Delete(endpoint string, out interface{}, q *WriteOptions) (*WriteMeta, error) {
|
2022-07-06 14:30:11 +00:00
|
|
|
return raw.c.delete(endpoint, nil, out, q)
|
2015-09-06 20:29:51 +00:00
|
|
|
}
|