Documentation ¶
Index ¶
- Constants
- func GetHostPath(path string) string
- func GetHostRootPath(path string) string
- func GetRootPath(path string) string
- type AuthConfig
- type AuthMethod
- type CloudJwtConfig
- type Config
- type ExtraTLSConfig
- type RequestOption
- type RestApiClient
- func (c RestApiClient) AddQlikOptions(req *http.Request, Opts ...RequestOption)
- func (c *RestApiClient) Do(method, endpoint string, body interface{}, opts ...RequestOption) (*http.Response, []byte, *util.Result)
- func (c *RestApiClient) DoRequest(req *http.Request) (*http.Response, []byte, *util.Result)
- func (c *RestApiClient) GenerateCloudJWT() *util.Result
- func (c *RestApiClient) GenerateManagedJWT() *util.Result
- func (c RestApiClient) GetCloudCsrfToken() string
- func (c RestApiClient) GetCookieJar() http.CookieJar
- func (c *RestApiClient) GetHttpClient() *http.Client
- func (c RestApiClient) GetJWT() string
- func (c RestApiClient) GetUrl(endpoint string) string
- func (c *RestApiClient) NewRawRequest(method, url string, body interface{}) (*http.Request, *util.Result)
- func (c *RestApiClient) NewRequest(method, endpoint string, body interface{}, Opts ...RequestOption) (*http.Request, *util.Result)
- func (c *RestApiClient) SetCookieJar(jar http.CookieJar)
- func (c *RestApiClient) StartCloudJWTSession() *util.Result
Constants ¶
View Source
const ( REQ_ROOT_PATH_PREFIX string = "^" REQ_HOST_PATH_PREFIX string = "*" )
View Source
const (
QlikXrfKey string = "abcdefghijklmnop"
)
Variables ¶
This section is empty.
Functions ¶
func GetHostPath ¶
func GetHostRootPath ¶
func GetRootPath ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct { Method AuthMethod `json:"method" yaml:"method" bson:"method"` Xrf bool `json:"xrf" yaml:"xrf" bson:"xrf"` User *qlik.User `json:"user,omitempty" yaml:"user,omitempty" bson:"user,omitempty"` Certs *crypto.Certificates `json:"certs,omitempty" yaml:"certs" bson:"certs,omitempty"` Token *string `json:"token,omitempty" yaml:"token,omitempty" bson:"token,omitempty"` CloudJwt *CloudJwtConfig `json:"cloud_jwt,omitempty" yaml:"cloud_jwt,omitempty" bson:"cloud_jwt,omitempty"` }
type AuthMethod ¶
type AuthMethod string
const ( AuthMethodCert AuthMethod = "cert" AuthMethodJWT AuthMethod = "jwt" AuthMethodAPIKey AuthMethod = "api_key" AuthMethodWebTicket AuthMethod = "webticket" )
type CloudJwtConfig ¶
type CloudJwtConfig struct { KeyId string `json:"key_id,omitempty" yaml:"key_id,omitempty" bson:"key_id,omitempty"` Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty" bson:"issuer,omitempty"` WebIntegrationID string `json:"web_integration_id,omitempty" yaml:"web_integration_id,omitempty" bson:"web_integration_id,omitempty"` UserName string `json:"user_id,omitempty" yaml:"user_id,omitempty" bson:"user_name,omitempty"` UserEmail string `json:"user_email,omitempty" yaml:"user_email,omitempty" bson:"user_email,omitempty"` UserSub string `json:"user_sub,omitempty" yaml:"user_sub,omitempty" bson:"user_sub,omitempty"` }
func (CloudJwtConfig) GenerateJWT ¶
func (c CloudJwtConfig) GenerateJWT(key *rsa.PrivateKey) (string, *util.Result)
func (CloudJwtConfig) IsValid ¶
func (c CloudJwtConfig) IsValid() bool
func (CloudJwtConfig) NewPayload ¶
func (c CloudJwtConfig) NewPayload() *qlik.CloudJwtClaim
type Config ¶
type Config struct { BaseUrl string `json:"base_url,omitempty" yaml:"base_url,omitempty" bson:"base_url,omitempty"` APIPrefix *string `json:"api_prefix,omitempty" yaml:"api_prefix,omitempty" bson:"api_prefix,omitempty"` Auth *AuthConfig `json:"auth" yaml:"auth,omitempty" bson:"auth,omitempty"` IsCloud *bool `json:"is_cloud,omitempty" yaml:"is_cloud,omitempty" bson:"is_cloud,omitempty"` VirtualProxy *string `json:"virtual_proxy,omitempty" yaml:"virtual_proxy,omitempty" bson:"virtual_proxy,omitempty"` ExtraTlsConfig *ExtraTLSConfig `json:"extra_tls_config,omitempty" yaml:"extra_tls_config,omitempty" bson:"extra_tls_config,omitempty"` TimeoutSec *int `json:"timeout_sec,omitempty" yaml:"timeout_sec,omitempty" bson:"timeout_sec,omitempty"` ExtraHeaders map[string]string `json:"extra_headers,omitempty" yaml:"extra_headers,omitempty" bson:"extra_headers,omitempty"` LogFileName *string `json:"log_file_name,omitempty" yaml:"log_file_name,omitempty" bson:"log_file_name,omitempty"` Cookie http.CookieJar `json:"-" yaml:"-" bson:"-"` }
type ExtraTLSConfig ¶
type ExtraTLSConfig struct {
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty" yaml:"insecure_skip_verify,omitempty" bson:"insecure_skip_verify,omitempty"`
}
func (ExtraTLSConfig) Apply ¶
func (c ExtraTLSConfig) Apply(cfg *tls.Config)
type RequestOption ¶
func WithHeader ¶
func WithHeader(k, v string) RequestOption
func WithHeaders ¶
func WithHeaders(headers map[string]string) RequestOption
func WithParam ¶
func WithParam(k, v string) RequestOption
func WithParams ¶
func WithParams(params map[string]string) RequestOption
type RestApiClient ¶
type RestApiClient struct { Config Config `json:"config" yaml:"config" bson:"config"` Logger *zerolog.Logger `json:"-" yaml:"-" bson:"-"` // contains filtered or unexported fields }
func (RestApiClient) AddQlikOptions ¶
func (c RestApiClient) AddQlikOptions(req *http.Request, Opts ...RequestOption)
func (*RestApiClient) Do ¶
func (c *RestApiClient) Do(method, endpoint string, body interface{}, opts ...RequestOption) (*http.Response, []byte, *util.Result)
func (*RestApiClient) GenerateCloudJWT ¶
func (c *RestApiClient) GenerateCloudJWT() *util.Result
func (*RestApiClient) GenerateManagedJWT ¶
func (c *RestApiClient) GenerateManagedJWT() *util.Result
func (RestApiClient) GetCloudCsrfToken ¶
func (c RestApiClient) GetCloudCsrfToken() string
func (RestApiClient) GetCookieJar ¶
func (c RestApiClient) GetCookieJar() http.CookieJar
func (*RestApiClient) GetHttpClient ¶
func (c *RestApiClient) GetHttpClient() *http.Client
func (RestApiClient) GetJWT ¶
func (c RestApiClient) GetJWT() string
func (RestApiClient) GetUrl ¶
func (c RestApiClient) GetUrl(endpoint string) string
GetUrl endpoint starts with `*` means host endpoint (ignore any port number) endpoint starts with `^` means root endpoint (from / path) `*^` is accepted as host root endpoint `^*` is invalid
func (*RestApiClient) NewRawRequest ¶
func (*RestApiClient) NewRequest ¶
func (c *RestApiClient) NewRequest(method, endpoint string, body interface{}, Opts ...RequestOption) (*http.Request, *util.Result)
NewRequest accept object as body since it set json content type header in constructor
func (*RestApiClient) SetCookieJar ¶
func (c *RestApiClient) SetCookieJar(jar http.CookieJar)
func (*RestApiClient) StartCloudJWTSession ¶
func (c *RestApiClient) StartCloudJWTSession() *util.Result
Click to show internal directories.
Click to hide internal directories.