Documentation ¶
Index ¶
- Constants
- func AddOptions(s string, opt interface{}) (string, error)
- func EncodeJson(v interface{}) (*bytes.Buffer, error)
- func EncodeURL(body interface{}) (*strings.Reader, error)
- type Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) NewJSONEncodedRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error)
- func (c *Client) NewURLEncodedRequest(method, urlStr string, body interface{}) (*http.Request, error)
- type ErrorResponse
- type Service
- type Status
Constants ¶
const ( MediaTypePlain = "text/plain" MediaTypeXml = "application/xml" MediaTypeJson = "application/json" MediaTypeForm = "application/x-www-form-urlencoded" )
Variables ¶
This section is empty.
Functions ¶
func AddOptions ¶
func EncodeJson ¶
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL should always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating with the Artifactory API. UserAgent string // contains filtered or unexported fields }
func NewClient ¶
NewClient creates a Client from a provided base url for an artifactory instance and a service Client
func (*Client) Do ¶
Do executes a give request with the given context. If the parameter v is a writer the body will be written to it in raw format, else v is assumed to be a struct to unmarshal the body into assuming JSON format. If v is nil then the body is not read and can be manually parsed from the response
func (*Client) NewJSONEncodedRequest ¶
func (c *Client) NewJSONEncodedRequest(method, urlStr string, body interface{}) (*http.Request, error)
NewJSONEncodedRequest is a wrapper around Client.NewRequest which encodes the body as a JSON object
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is included as the request body.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response `json:"-"` // HTTP response that caused this error Errors []Status `json:"errors,omitempty"` // Individual errors }
ErrorResponse reports one or more errors caused by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string