Documentation ¶
Overview ¶
Package client implements a set of common functionality that are used by DC/OS SDK commands to talk to schedulers built using the SDK or other DC/OS components (e.g. Cosmos). Cluster URL and other global values are pulled from the dcos-commons/cli/config package and populated by the values configured using the DC/OS CLI itself.
Index ¶
- Variables
- func CheckHTTPResponse(response *http.Response) ([]byte, error)
- func CreateHTTPRawRequest(method string, url *url.URL, payload, accept, contentType string) *http.Request
- func CreateHTTPURLRequest(method string, url *url.URL, payload, accept, contentType string) *http.Request
- func CreateServiceHTTPDataRequest(method, urlPath, jsonPayload, contentType string) *http.Request
- func CreateServiceHTTPJSONRequest(method, urlPath, jsonPayload string) *http.Request
- func CreateServiceHTTPQueryRequest(method, urlPath, urlQuery string) *http.Request
- func CreateServiceHTTPRequest(method, urlPath string) *http.Request
- func CreateServiceURL(urlPath, urlQuery string) *url.URL
- func CreateURL(baseURL, urlPath, urlQuery string) *url.URL
- func GetDCOSURL() string
- func GetValueFromJSON(jsonBytes map[string]interface{}, field string) ([]byte, error)
- func GetValueFromJSONResponse(responseBytes []byte, field string) ([]byte, error)
- func HTTPCosmosPostJSON(urlPath, jsonPayload string) ([]byte, error)
- func HTTPQuery(request *http.Request) *http.Response
- func HTTPServiceDelete(urlPath string) ([]byte, error)
- func HTTPServiceDeleteData(urlPath, payload, contentType string) ([]byte, error)
- func HTTPServiceDeleteJSON(urlPath, jsonPayload string) ([]byte, error)
- func HTTPServiceDeleteQuery(urlPath, urlQuery string) ([]byte, error)
- func HTTPServiceGet(urlPath string) ([]byte, error)
- func HTTPServiceGetData(urlPath, payload, contentType string) ([]byte, error)
- func HTTPServiceGetJSON(urlPath, jsonPayload string) ([]byte, error)
- func HTTPServiceGetQuery(urlPath, urlQuery string) ([]byte, error)
- func HTTPServicePost(urlPath string) ([]byte, error)
- func HTTPServicePostData(urlPath, payload, contentType string) ([]byte, error)
- func HTTPServicePostJSON(urlPath, jsonPayload string) ([]byte, error)
- func HTTPServicePostQuery(urlPath, urlQuery string) ([]byte, error)
- func HTTPServicePut(urlPath string) ([]byte, error)
- func HTTPServicePutData(urlPath, payload, contentType string) ([]byte, error)
- func HTTPServicePutJSON(urlPath, jsonPayload string) ([]byte, error)
- func HTTPServicePutQuery(urlPath, urlQuery string) ([]byte, error)
- func JSONBytesToArray(bytes []byte) ([]string, error)
- func OptionalCLIConfigValue(name string) string
- func PrettyPrintSlice(slice []string) string
- func PrintJSONBytes(responseBytes []byte)
- func PrintResponseText(body []byte)
- func PrintVerbose(format string, a ...interface{}) (int, error)
- func RequiredCLIConfigValue(name string, description string, errorInstruction string) string
- func RunCLICommand(arg ...string) (string, error)
- func SetCustomResponseCheck(check responseCheck)
- func UnmarshalJSON(jsonBytes []byte) (map[string]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
var PrintMessage = printMessage
PrintMessage is a placeholder function that wraps a call to fmt.Println(fmt.Sprintf()) to allow assertions against captured output.
var PrintMessageAndExit = printMessageAndExit
PrintMessageAndExit is a placeholder function that wraps a call to PrintMessage() before exiting to allow assertions against captured output.
Functions ¶
func CheckHTTPResponse ¶
CheckHTTPResponse checks the HTTP response
func CreateHTTPRawRequest ¶
func CreateHTTPRawRequest(method string, url *url.URL, payload, accept, contentType string) *http.Request
CreateHTTPRawRequest creates an HTTP request
func CreateHTTPURLRequest ¶
func CreateHTTPURLRequest(method string, url *url.URL, payload, accept, contentType string) *http.Request
CreateHTTPURLRequest creates a HTTP url request which includes cluster auth headers as needed.
func CreateServiceHTTPDataRequest ¶
CreateServiceHTTPDataRequest creates a service HTTP data request
func CreateServiceHTTPJSONRequest ¶
CreateServiceHTTPJSONRequest creates a service HTTP JSON request
func CreateServiceHTTPQueryRequest ¶
CreateServiceHTTPQueryRequest creates a service HTTP query request
func CreateServiceHTTPRequest ¶
CreateServiceHTTPRequest creates a service HTTP request
func CreateServiceURL ¶
CreateServiceURL creates a service URL of the form http://clusterurl.com/service/<servicename>/<urlPath>[?urlQuery]
func GetDCOSURL ¶
func GetDCOSURL() string
GetDCOSURL gets the DC/OS cluster URL in the form of "http://cluster-host.com"
func GetValueFromJSON ¶
GetValueFromJSON retrieves the value of a specific field from an unmarshaled map[string]interface of JSON. If the field does not exist, this returns nil.
func GetValueFromJSONResponse ¶
GetValueFromJSONResponse is a utility function to unmarshal a []byte of JSON and fetch the value of a specific field from it.
func HTTPCosmosPostJSON ¶
HTTPCosmosPostJSON triggers a HTTP POST request containing jsonPayload to https://dcos.cluster/cosmos/service/<urlPath>
func HTTPServiceDelete ¶
HTTPServiceDelete triggers a HTTP DELETE request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceDeleteData ¶
HTTPServiceDeleteData triggers a HTTP DELETE request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceDeleteJSON ¶
HTTPServiceDeleteJSON triggers a HTTP DELETE request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceDeleteQuery ¶
HTTPServiceDeleteQuery triggers a HTTP DELETE request with query parameters to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>?<urlQuery>
func HTTPServiceGet ¶
HTTPServiceGet triggers a HTTP GET request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceGetData ¶
HTTPServiceGetData triggers a HTTP GET request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceGetJSON ¶
HTTPServiceGetJSON triggers a HTTP GET request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceGetQuery ¶
HTTPServiceGetQuery triggers a HTTP GET request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>
func HTTPServicePost ¶
HTTPServicePost triggers a HTTP POST request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePostData ¶
HTTPServicePostData triggers a HTTP POST request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePostJSON ¶
HTTPServicePostJSON triggers a HTTP POST request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePostQuery ¶
HTTPServicePostQuery triggers a HTTP POST request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>
func HTTPServicePut ¶
HTTPServicePut triggers a HTTP PUT request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePutData ¶
HTTPServicePutData triggers a HTTP PUT request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePutJSON ¶
HTTPServicePutJSON triggers a HTTP PUT request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePutQuery ¶
HTTPServicePutQuery triggers a HTTP PUT request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>
func JSONBytesToArray ¶
JSONBytesToArray is a utility method for unmarshaling a JSON string array
func OptionalCLIConfigValue ¶
OptionalCLIConfigValue retrieves the CLI configuration for name. If no value can be retrieved, this returns an empty string.
func PrettyPrintSlice ¶
PrettyPrintSlice takes a slice (e.g. [0 1 2]), sorts it and returns a pretty printed string in the same style as a JSON string array (e.g. ["0", "1", "2"]).
func PrintJSONBytes ¶
func PrintJSONBytes(responseBytes []byte)
PrintJSONBytes pretty prints responseBytes assuming it is valid JSON. If not valid, an error message will be printed and the original data will be printed.
func PrintResponseText ¶
func PrintResponseText(body []byte)
PrintResponseText prints out a byte array as text.
func PrintVerbose ¶
PrintVerbose prints a message using PrintMessage iff config.Verbose is enabled
func RequiredCLIConfigValue ¶
RequiredCLIConfigValue gets config values from the DC/OS CLI
func RunCLICommand ¶
RunCLICommand runs a DC/OS CLI command
func SetCustomResponseCheck ¶
func SetCustomResponseCheck(check responseCheck)
SetCustomResponseCheck sets a custom responseCheck that can be used for more advanced handling of HTTP responses.
func UnmarshalJSON ¶
UnmarshalJSON unmarshals a []byte of JSON into a map[string]interface{} for easy handling of JSON responses that have variable fields.
Types ¶
This section is empty.