dotcommonitor

package module
v0.0.0-...-9815327 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go API client for dotcom-monitor

dotcom-monitor API

Overview

Golang API client for https://www.dotcom-monitor.com/. Only cover Device and Task, other endpoints might be added in the future.

Installation

Put the package under your project folder and add the following in import:

import "github.com/gfleury/go-dotcom-monitor"

There is an example under cmd/main.go(cmd/main.go).

Documentation for API Endpoints

All URIs are relative to https://api.dotcom-monitor.com/config_api_v1

Class Method HTTP request Description
DeviceApi AddDevice Put /devices Get device list by platform.
DeviceApi DeleteDevice Delete /device/{device_id} Get Device info.
DeviceApi DisableDeviceAlert Post /device/{device_id}/DisableAlert/ Get Device info.
DeviceApi EditDevice Post /device/{device_id} Edit device list by platform.
DeviceApi GetDevice Get /device/{device_id} Get Device info.
DeviceApi GetDevicesPlataform Get /devices/{platform} Get device list by platform.
DeviceApi GetTasks Get /device/{device_id}/tasks Get Device tasks.
PlatformsApi GetPlataforms Get /platforms Return list of available platforms
TaskApi AddTask Put /tasks Create new task.
TaskApi DeleteTask Delete /task/{task_id} Delete Task info.
TaskApi EditTask Post /task/{task_id} Edit task.
TaskApi GetTask Get /task/{task_id} Get Task info.
TaskApi GetTasks Get /device/{device_id}/tasks Get Device tasks.

Documentation For Models

Documentation For Authentication

Authentication

  • Type: User/Password

Example

basicAuth := dotcommonitor.BasicAuth{UserName: "", Password: ""}
response, _, err := client.LoginApi.Login(ctx, basicAuth)
...
r, err := client.Service.Operation(ctx, args)

Author

George Fleury

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	DeviceApi *DeviceApiService

	PlatformsApi *PlatformsApiService

	TaskApi *TaskApiService

	LoginApi *LoginApiService

	LocationApi *LocationApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the dotcom-monitor API v1.0.0 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type AlertSilencePeriod

type AlertSilencePeriod struct {
	AlertSilenceMin int32 `json:"Alert_Silence_min,omitempty"`
}

type BasicAuth

type BasicAuth struct {
	UserName string `json:"UserName,omitempty"`
	Password string `json:"Password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type Device

type Device struct {
	AvoidSimultaneousChecks bool                 `json:"Avoid_Simultaneous_Checks,omitempty"`
	AlertSilenceMin         int32                `json:"Alert_Silence_Min,omitempty"`
	FalsePositiveCheck      bool                 `json:"False_Positive_Check,omitempty"`
	Locations               []int32              `json:"Locations,omitempty"`
	SendUptimeAlert         bool                 `json:"Send_Uptime_Alert,omitempty"`
	StatusDescription       string               `json:"Status_Description,omitempty"`
	Postpone                bool                 `json:"Postpone"`
	OwnerDeviceId           int32                `json:"Owner_Device_Id,omitempty"`
	Frequency               int32                `json:"Frequency,omitempty"`
	FilterId                int32                `json:"Filter_Id,omitempty"`
	SchedulerId             int32                `json:"Scheduler_Id,omitempty"`
	NumberOfTasks           int32                `json:"Number_Of_Tasks,omitempty"`
	Id                      int32                `json:"Id,omitempty"`
	PlatformId              int32                `json:"Platform_Id,omitempty"`
	PackageId               int32                `json:"Package_Id,omitempty"`
	Name                    string               `json:"Name,omitempty"`
	Notifications           *DeviceNotifications `json:"Notifications,omitempty"`
}

type DeviceApiService

type DeviceApiService service

func (*DeviceApiService) AddDevice

func (a *DeviceApiService) AddDevice(ctx context.Context, device Device) (Result, *http.Response, error)

DeviceApiService Get device list by platform. Get device list by platform.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param device Device Object

@return Result

func (*DeviceApiService) DeleteDevice

func (a *DeviceApiService) DeleteDevice(ctx context.Context, deviceId string) (Result, *http.Response, error)

DeviceApiService Get Device info. Get Device info.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param deviceId device id

@return Result

func (*DeviceApiService) DisableDeviceAlert

func (a *DeviceApiService) DisableDeviceAlert(ctx context.Context, deviceId string, localVarOptionals *DisableDeviceAlertOpts) (Result, *http.Response, error)

func (*DeviceApiService) EditDevice

func (a *DeviceApiService) EditDevice(ctx context.Context, deviceId string, device Device) (Result, *http.Response, error)

DeviceApiService Edit device list by platform. Edit device list by platform.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param deviceId Device id
  • @param device Device Object

@return Result

func (*DeviceApiService) GetDevice

func (a *DeviceApiService) GetDevice(ctx context.Context, deviceId string) (interface{}, *http.Response, error)

DeviceApiService Get Device info. Get Device info.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param deviceId device id

@return interface{}

func (*DeviceApiService) GetDevicesPlataform

func (a *DeviceApiService) GetDevicesPlataform(ctx context.Context, platform string) ([]int32, *http.Response, error)

DeviceApiService Get device list by platform. Get device list by platform.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param platform Platform name

@return []int32

func (*DeviceApiService) GetTasks

func (a *DeviceApiService) GetTasks(ctx context.Context, deviceId string) ([]int32, *http.Response, error)

DeviceApiService Get Device tasks. Get Device tasks.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param deviceId device id

@return []int32

type DeviceNotifications

type DeviceNotifications struct {
	EMailFlag               bool                                    `json:"E_Mail_Flag"`
	EMailAddress            string                                  `json:"E_Mail_Address,omitempty"`
	EMailTimeIntervalMin    int32                                   `json:"E_Mail_TimeInterval_Min,omitempty"`
	WLDeviceFlag            bool                                    `json:"WL_Device_Flag"`
	WLDeviceEmailAddress    string                                  `json:"WL_Device_Email_Address,omitempty"`
	WLDeviceTimeIntervalMin int32                                   `json:"WL_Device_TimeInterval_Min,omitempty"`
	PagerFlag               bool                                    `json:"Pager_Flag"`
	PagerAreaCode           string                                  `json:"Pager_Area_Code,omitempty"`
	PagerPhone              string                                  `json:"Pager_Phone,omitempty"`
	PagerNumCode            string                                  `json:"Pager_Num_Code,omitempty"`
	PagerTimeIntervalMin    int32                                   `json:"Pager_TimeInterval_Min,omitempty"`
	PhoneFlag               bool                                    `json:"Phone_Flag"`
	PhoneAreaCode           string                                  `json:"Phone_Area_Code,omitempty"`
	PhonePhone              string                                  `json:"Phone_Phone,omitempty"`
	PhoneTimeIntervalMin    int32                                   `json:"Phone_TimeInterval_Min,omitempty"`
	SMSFlag                 bool                                    `json:"SMS_Flag"`
	SMSPhone                string                                  `json:"SMS_Phone,omitempty"`
	SMSTimeIntervalMin      int32                                   `json:"SMS_TimeInterval_Min,omitempty"`
	ScriptFlag              bool                                    `json:"Script_Flag"`
	ScriptBatchFileName     string                                  `json:"Script_Batch_File_Name,omitempty"`
	ScriptTimeIntervalMin   int32                                   `json:"Script_TimeInterval_Min,omitempty"`
	SNMPTimeIntervalMin     int32                                   `json:"SNMP_TimeInterval_Min,omitempty"`
	NotificationGroups      []DeviceNotificationsNotificationGroups `json:"Notification_Groups"`
}

type DeviceNotificationsNotificationGroups

type DeviceNotificationsNotificationGroups struct {
	Id           int32 `json:"Id,omitempty"`
	TimeShiftMin int32 `json:"Time_Shift_Min,omitempty"`
}

type DisableDeviceAlertOpts

type DisableDeviceAlertOpts struct {
	AlertSilencePeriod optional.Interface
}

type GenericSwaggerError

type GenericSwaggerError struct {
	// contains filtered or unexported fields
}

GenericSwaggerError Provides access to the body, error and model on returned errors.

func (GenericSwaggerError) Body

func (e GenericSwaggerError) Body() []byte

Body returns the raw bytes of the response

func (GenericSwaggerError) Error

func (e GenericSwaggerError) Error() string

Error returns non-empty string if there was an error.

func (GenericSwaggerError) Model

func (e GenericSwaggerError) Model() interface{}

Model returns the unpacked model of the error

type Location

type Location struct {
	Id        int32  `json:"Id,omitempty"`
	Name      string `json:"Name,omitempty"`
	Available bool   `json:"Available"`
	IsDeleted bool   `json:"IsDeleted"`
	IsPrivate bool   `json:"IsPrivate"`
}

type LocationApiService

type LocationApiService service

func (*LocationApiService) GetLocations

func (a *LocationApiService) GetLocations(ctx context.Context, platformName string) ([]Location, *http.Response, error)

LocationApiService Get location list by platform. Get location list by platform.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param platformName Platform name

@return []Location

type LoginApiService

type LoginApiService service

func (*LoginApiService) Login

func (a *LoginApiService) Login(ctx context.Context, credential BasicAuth) (Result, *http.Response, error)

LoginApiService Get device list by platform. Get device list by platform.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param device Device Object

@return Result

type Platform

type Platform struct {
	Id        int32              `json:"Id,omitempty"`
	Name      string             `json:"Name,omitempty"`
	Available bool               `json:"Available,omitempty"`
	Packages  []PlatformPackages `json:"Packages,omitempty"`
}

type PlatformPackages

type PlatformPackages struct {
	PackageId   int32  `json:"Package_Id,omitempty"`
	PackageName string `json:"Package_Name,omitempty"`
	PlatformId  int32  `json:"Platform_Id,omitempty"`
}

type PlatformsApiService

type PlatformsApiService service

func (*PlatformsApiService) GetPlataforms

func (a *PlatformsApiService) GetPlataforms(ctx context.Context) ([]Platform, *http.Response, error)

PlatformsApiService Return list of available platforms Return list of available platforms.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().

@return []Platform

type Result

type Result struct {
	Success bool  `json:"Success,omitempty"`
	Result  int32 `json:"Result,omitempty"`
}

type Task

type Task struct {
	RequestType         string          `json:"RequestType,omitempty"`
	Url                 string          `json:"Url,omitempty"`
	Keyword1            string          `json:"Keyword1"`
	Keyword2            string          `json:"Keyword2"`
	Keyword3            string          `json:"Keyword3"`
	UserName            string          `json:"UserName"`
	UserPass            string          `json:"UserPass"`
	FullPageDownload    bool            `json:"FullPageDownload"`
	DownloadHtml        bool            `json:"Download_Html"`
	DownloadFrames      bool            `json:"Download_Frames"`
	DownloadStyleSheets bool            `json:"Download_StyleSheets"`
	DownloadScripts     bool            `json:"Download_Scripts"`
	DownloadImages      bool            `json:"Download_Images"`
	DownloadObjects     bool            `json:"Download_Objects"`
	DownloadApplets     bool            `json:"Download_Applets"`
	DownloadAdditional  bool            `json:"Download_Additional"`
	GetParams           []TaskGetParams `json:"GetParams"`
	PostParams          []TaskGetParams `json:"PostParams"`
	HeaderParams        []TaskGetParams `json:"HeaderParams"`
	PrepareScript       string          `json:"PrepareScript"`
	DNSResolveMode      string          `json:"DNSResolveMode"`
	DNSserverIP         *string         `json:"DNSserverIP"`
	DeviceId            int32           `json:"Device_Id,omitempty"`
	TaskTypeId          int32           `json:"Task_Type_Id,omitempty"`
	Name                string          `json:"Name,omitempty"`
	Timeout             int32           `json:"Timeout,omitempty"`
}

type TaskApiService

type TaskApiService service

func (*TaskApiService) AddTask

func (a *TaskApiService) AddTask(ctx context.Context, device Task) (Result, *http.Response, error)

TaskApiService Create new task. Create new task.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param device Task Object

@return Result

func (*TaskApiService) DeleteTask

func (a *TaskApiService) DeleteTask(ctx context.Context, taskId string) (Result, *http.Response, error)

TaskApiService Delete Task info. Delete Task info.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param taskId task id

@return Result

func (*TaskApiService) EditTask

func (a *TaskApiService) EditTask(ctx context.Context, taskId string, task Task) (Result, *http.Response, error)

TaskApiService Edit task. Edit task.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param taskId Task id
  • @param task Task Object

@return Result

func (*TaskApiService) GetTask

func (a *TaskApiService) GetTask(ctx context.Context, taskId string) (Task, *http.Response, error)

TaskApiService Get Task info. Get Task info.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param taskId task id

@return Task

func (*TaskApiService) GetTasks

func (a *TaskApiService) GetTasks(ctx context.Context, deviceId string) ([]int32, *http.Response, error)

TaskApiService Get Device tasks. Get Device tasks.

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param deviceId device id

@return []int32

type TaskGetParams

type TaskGetParams struct {
	Name  string `json:"Name,omitempty"`
	Value string `json:"Value,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址