Documentation ¶
Index ¶
- func BuildDirectoryStructureIfNotExists(path string) error
- func FileExists(filePath string) bool
- func FileExistsAndNotEmpty(filePath string) bool
- func ReAuthenticateSession(opts *SessionOptions)
- func ReadBytesFromFile(path string) ([]byte, error)
- func ReadJSONFromFile(path string, data interface{}) error
- func WithOutCompressSession(opts *SessionOptions)
- func WithoutPersistCookie(opts *SessionOptions)
- func WriteBytesToFile(b []byte, path string) error
- func WriteIndentedJSONToFile(data interface{}, path string) error
- type ClientOpts
- type NuvlaClient
- func (nc *NuvlaClient) Delete(resourceId string) (*http.Response, error)
- func (nc *NuvlaClient) Edit(resourceId string, data map[string]interface{}, toSelect []string) (*http.Response, error)
- func (nc *NuvlaClient) Get(resourceId string, selectFields []string) (*types.NuvlaResource, error)
- func (nc *NuvlaClient) IsAuthenticated() bool
- func (nc *NuvlaClient) LoginApiKeys(key string, secret string) error
- func (nc *NuvlaClient) LoginUser(username string, password string) error
- func (nc *NuvlaClient) Logout() error
- func (nc *NuvlaClient) Operation(resourceId, operation string, data map[string]interface{}) (*http.Response, error)
- func (nc *NuvlaClient) Post(endpoint string, data map[string]interface{}) (*http.Response, error)
- func (nc *NuvlaClient) Put(uri string, data map[string]interface{}, selectFields []string) (*http.Response, error)
- type NuvlaCookies
- type NuvlaSession
- type SessionOptFunc
- type SessionOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
func FileExistsAndNotEmpty ¶
func ReAuthenticateSession ¶ added in v0.2.0
func ReAuthenticateSession(opts *SessionOptions)
func ReadBytesFromFile ¶ added in v0.5.0
func ReadJSONFromFile ¶ added in v0.5.0
func WithOutCompressSession ¶ added in v0.2.0
func WithOutCompressSession(opts *SessionOptions)
func WithoutPersistCookie ¶ added in v0.2.0
func WithoutPersistCookie(opts *SessionOptions)
func WriteBytesToFile ¶ added in v0.5.0
func WriteIndentedJSONToFile ¶ added in v0.5.0
Types ¶
type ClientOpts ¶ added in v0.2.0
type ClientOpts struct { *SessionOptions Credentials types.LogInParams }
func NewClientOpts ¶ added in v0.2.0
func NewClientOpts(credentials types.LogInParams, opts ...SessionOptFunc) *ClientOpts
type NuvlaClient ¶
type NuvlaClient struct { // Session params *NuvlaSession // contains filtered or unexported fields }
func NewNuvlaClient ¶
func NewNuvlaClient(cred types.LogInParams, opts *SessionOptions) *NuvlaClient
func NewNuvlaClientFromOpts ¶
func NewNuvlaClientFromOpts(cred types.LogInParams, opts ...SessionOptFunc) *NuvlaClient
func (*NuvlaClient) Delete ¶
func (nc *NuvlaClient) Delete(resourceId string) (*http.Response, error)
func (*NuvlaClient) Get ¶
func (nc *NuvlaClient) Get(resourceId string, selectFields []string) (*types.NuvlaResource, error)
func (*NuvlaClient) IsAuthenticated ¶
func (nc *NuvlaClient) IsAuthenticated() bool
func (*NuvlaClient) LoginApiKeys ¶
func (nc *NuvlaClient) LoginApiKeys(key string, secret string) error
func (*NuvlaClient) LoginUser ¶
func (nc *NuvlaClient) LoginUser(username string, password string) error
func (*NuvlaClient) Logout ¶
func (nc *NuvlaClient) Logout() error
type NuvlaCookies ¶
type NuvlaCookies struct {
// contains filtered or unexported fields
}
func NewNuvlaCookies ¶
func NewNuvlaCookies(cookieFile string, endpoint string) *NuvlaCookies
NewNuvlaCookies creates a new instance of the NuvlaCookies struct. It takes two parameters: cookieFile and endpoint.
Parameters:
- cookieFile (string): This is the path to the file where jar will be saved or loaded from.
- endpoint (string): This is the URL endpoint for which the jar are relevant.
The function does the following: 1. Creates a new NuvlaCookies instance and sets the cookieFile field. 2. Parses the endpoint string into a url.URL object and sets the endpoint field of the NuvlaCookies instance. 3. Checks if the cookieFile exists and is not empty. If it is, it creates a new cookiejar.Jar, attempts to load jar from the cookieFile into the cookiejar.Jar, and sets the jar field of the NuvlaCookies instance.
Returns:
- A pointer to the newly created NuvlaCookies instance.
Example:
jar := client.NewNuvlaCookies("/path/to/jar.txt", "http://example.com") In this example, a new NuvlaCookies instance is created. The jar relevant to the "http://example.com" endpoint will be saved to or loaded from the "/path/to/jar.txt" file.
func (*NuvlaCookies) Save ¶
func (c *NuvlaCookies) Save() error
func (*NuvlaCookies) SaveIfNeeded ¶
func (c *NuvlaCookies) SaveIfNeeded(newCookie http.CookieJar) error
SaveIfNeeded jar if needed
type NuvlaSession ¶
type NuvlaSession struct {
// contains filtered or unexported fields
}
func NewNuvlaSession ¶
func NewNuvlaSession(sessionAttrs *SessionOptions) *NuvlaSession
func (*NuvlaSession) GetSessionOpts ¶ added in v0.5.0
func (s *NuvlaSession) GetSessionOpts() SessionOptions
func (*NuvlaSession) NeedToLogin ¶
func (s *NuvlaSession) NeedToLogin() bool
func (*NuvlaSession) Request ¶
func (s *NuvlaSession) Request(reqInput *types.RequestOpts) (*http.Response, error)
func (*NuvlaSession) String ¶
func (s *NuvlaSession) String() string
type SessionOptFunc ¶ added in v0.2.0
type SessionOptFunc func(*SessionOptions)
func WithAuthHeader ¶ added in v0.2.0
func WithAuthHeader(authHeader string) SessionOptFunc
func WithCookieFile ¶ added in v0.2.0
func WithCookieFile(cookieFile string) SessionOptFunc
func WithDebugSession ¶ added in v0.2.0
func WithDebugSession(flag bool) SessionOptFunc
func WithEndpoint ¶ added in v0.2.0
func WithEndpoint(endpoint string) SessionOptFunc
func WithInsecureSession ¶ added in v0.2.0
func WithInsecureSession(flag bool) SessionOptFunc
type SessionOptions ¶
type SessionOptions struct { Endpoint string `json:"endpoint"` Insecure bool `json:"insecure"` ReAuthenticate bool `json:"re-authenticate"` PersistCookie bool `json:"persist-cookie"` CookieFile string `json:"cookie-file"` AuthHeader string `json:"auth-header"` Compress bool `json:"compress"` Debug bool `json:"debug"` }
func DefaultSessionOpts ¶ added in v0.2.0
func DefaultSessionOpts() *SessionOptions
func NewSessionOpts ¶
func NewSessionOpts(opts *SessionOptions) *SessionOptions
Click to show internal directories.
Click to hide internal directories.