Documentation
¶
Overview ¶
Copyright (c) 2018-2021 Zededa, Inc. SPDX-License-Identifier: Apache-2.0
Index ¶
- func IsObjectNotFound(resp *http.Response) bool
- func UrlForNameOrId(name, id string) (string, error)
- func UrlForObjectRequest(urlExtension, name, id, reqType string) string
- type Client
- func (client *Client) CreateObj(typeUrl string, reqBody interface{}) (*http.Response, *swagger_models.ZsrvResponse, error)
- func (client *Client) DeleteObj(typeUrl, id string) (*http.Response, *swagger_models.ZsrvResponse, error)
- func (client *Client) GetObj(typeUrl, name, id string, status bool, rspBody interface{}) (*http.Response, error)
- func (client *Client) SendReq(method, urlExtension string, data interface{}, rspData interface{}) (*http.Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsObjectNotFound ¶ added in v1.0.1
func UrlForObjectRequest ¶
UrlForObjectRequest
Types ¶
type Client ¶
type Client struct { Bearer runtime.ClientAuthInfoWriter HttpClient *http.Client // If bearerToken is not empty, it is used for Auth. This is the token // obtained from zedcontrol UI ( user profile page ). // Else, Login is done using username and password. bearerToken is set from // response of Login. BearerToken string BaseUrl string XRequestIdPrefix string // Set this flag for debugging information to be printed Debug bool }
func (*Client) CreateObj ¶
func (client *Client) CreateObj(typeUrl string, reqBody interface{}) ( *http.Response, *swagger_models.ZsrvResponse, error)
CreateObj
typeUrl - Ex: "devices", "apps", "instances" etc id - ID of the object to delete
func (*Client) DeleteObj ¶
func (client *Client) DeleteObj(typeUrl, id string) ( *http.Response, *swagger_models.ZsrvResponse, error)
DeleteObj
typeUrl - Ex: "devices", "apps", "instances" etc id - ID of the object to delete
func (*Client) GetObj ¶
func (client *Client) GetObj(typeUrl, name, id string, status bool, rspBody interface{}) (*http.Response, error)
GetObj
typeUrl - Ex: "devices", "apps", "instances" etc
rspBody -> pointer to the expected response body. Response body would be unmarshalled into this.
Ex: rspData := &swagger_models.DeviceConfig{} client.GetObj("devices", "testDevice", "", false, rspData)
func (*Client) SendReq ¶
func (client *Client) SendReq(method, urlExtension string, data interface{}, rspData interface{}) (*http.Response, error)
SendReq
Return Values: Returns the http.Response received and any errors encountered in the process. If Response is Successful ( isHttpStatusCodeSuccess(resp.StatusCode)), returns nil as error. Caller can use err == nil to check for a successful response.
Click to show internal directories.
Click to hide internal directories.