Documentation
¶
Index ¶
- func ReAuthenticateSession(opts *SessionOptions)
- func SanitiseEndpoint(endpoint string) string
- func WithOutCompressSession(opts *SessionOptions)
- func WithoutPersistCookie(opts *SessionOptions)
- type NuvlaClient
- func (nc *NuvlaClient) Add(ctx context.Context, resourceType resources.NuvlaResourceType, ...) (*types.NuvlaID, error)
- func (nc *NuvlaClient) BulkOperation(ctx context.Context, resourceId string, operation string, ...) (*http.Response, error)
- func (nc *NuvlaClient) BulkPost(ctx context.Context, endpoint string, data []map[string]interface{}) (*http.Response, error)
- func (nc *NuvlaClient) Delete(ctx context.Context, resourceId string) (*http.Response, error)
- func (nc *NuvlaClient) Edit(ctx context.Context, resourceId string, data map[string]interface{}, ...) (*http.Response, error)
- func (nc *NuvlaClient) Get(ctx context.Context, 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(ctx context.Context, resourceId, operation string, data map[string]interface{}) (*http.Response, error)
- func (nc *NuvlaClient) Post(ctx context.Context, endpoint string, data map[string]interface{}) (*http.Response, error)
- func (nc *NuvlaClient) Put(ctx context.Context, uri string, data interface{}, selectFields []string) (*http.Response, error)
- func (nc *NuvlaClient) Search(ctx context.Context, resourceType string, opts *SearchOptions) (*resources.NuvlaResourceCollection, error)
- type NuvlaCookies
- type NuvlaSession
- type SearchOptions
- type SessionOptFunc
- type SessionOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReAuthenticateSession ¶ added in v0.2.0
func ReAuthenticateSession(opts *SessionOptions)
func SanitiseEndpoint ¶ added in v0.7.11
func WithOutCompressSession ¶ added in v0.2.0
func WithOutCompressSession(opts *SessionOptions)
func WithoutPersistCookie ¶ added in v0.2.0
func WithoutPersistCookie(opts *SessionOptions)
Types ¶
type NuvlaClient ¶
type NuvlaClient struct { // Session params *NuvlaSession SessionOpts SessionOptions Credentials types.LogInParams }
func NewNuvlaClient ¶
func NewNuvlaClient(cred types.LogInParams, opts *SessionOptions) *NuvlaClient
func NewNuvlaClientFromOpts ¶
func NewNuvlaClientFromOpts(cred types.LogInParams, opts ...SessionOptFunc) *NuvlaClient
func (*NuvlaClient) Add ¶ added in v0.7.0
func (nc *NuvlaClient) Add(ctx context.Context, resourceType resources.NuvlaResourceType, data map[string]interface{}) (*types.NuvlaID, error)
Add creates a new resource of the given type and returns its ID
func (*NuvlaClient) BulkOperation ¶ added in v0.7.7
func (*NuvlaClient) Get ¶
func (nc *NuvlaClient) Get(ctx context.Context, 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
func (*NuvlaClient) Post ¶
func (nc *NuvlaClient) Post(ctx context.Context, endpoint string, data map[string]interface{}) (*http.Response, error)
Post executes the post http method Data can be any type, but it will be marshaled into JSON
func (*NuvlaClient) Search ¶ added in v0.6.0
func (nc *NuvlaClient) Search(ctx context.Context, resourceType string, opts *SearchOptions) (*resources.NuvlaResourceCollection, 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(ctx context.Context, reqInput *types.RequestOpts) (*http.Response, error)
func (*NuvlaSession) String ¶
func (s *NuvlaSession) String() string
type SearchOptions ¶ added in v0.6.0
type SearchOptions struct { First int `json:"first"` Last int `json:"last"` Filter string `json:"filter"` Fields string `json:"fields"` OrderBy string `json:"orderby"` Select []string `json:"select"` Aggregation string `json:"aggregation"` }
func NewDefaultSearchOptions ¶ added in v0.6.0
func NewDefaultSearchOptions() *SearchOptions
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