Skip to content

Commit

Permalink
Merge pull request #223 from sujithramagesh/EUM_TERRAFORM_PROVIDER_BR…
Browse files Browse the repository at this point in the history
…ANCH

Changes for Web Transaction Browser, FTP Transfer and ISP Resource.
  • Loading branch information
jim-billy-zoho authored Dec 26, 2023
2 parents 5eb2191 + 583e31c commit 4cae34b
Show file tree
Hide file tree
Showing 39 changed files with 5,087 additions and 94 deletions.
3 changes: 3 additions & 0 deletions api/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ const (
HEARTBEAT MonitorType = "HEARTBEAT"
DNS MonitorType = "DNS"
DOMAINEXPIRY MonitorType = "DOMAINEXPIRY"
REALBROWSER MonitorType = "REALBROWSER"
FTP MonitorType = "FTP"
ISP MonitorType = "ISP"
)
60 changes: 60 additions & 0 deletions api/endpoints/fake/ftp_transfer_monitors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package fake

import (
"github.com/site24x7/terraform-provider-site24x7/api"
"github.com/site24x7/terraform-provider-site24x7/api/endpoints/monitors"
"github.com/stretchr/testify/mock"
)

var _ monitors.FTPTransferMonitors = &FTPTransferMonitors{}

type FTPTransferMonitors struct {
mock.Mock
}

func (e *FTPTransferMonitors) Get(monitorID string) (*api.FTPTransferMonitor, error) {
args := e.Called(monitorID)
if obj, ok := args.Get(0).(*api.FTPTransferMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *FTPTransferMonitors) Create(monitor *api.FTPTransferMonitor) (*api.FTPTransferMonitor, error) {
args := e.Called(monitor)
if obj, ok := args.Get(0).(*api.FTPTransferMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *FTPTransferMonitors) Update(monitor *api.FTPTransferMonitor) (*api.FTPTransferMonitor, error) {
args := e.Called(monitor)
if obj, ok := args.Get(0).(*api.FTPTransferMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *FTPTransferMonitors) Delete(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}

func (e *FTPTransferMonitors) List() ([]*api.FTPTransferMonitor, error) {
args := e.Called()
if obj, ok := args.Get(0).([]*api.FTPTransferMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *FTPTransferMonitors) Activate(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}

func (e *FTPTransferMonitors) Suspend(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}
60 changes: 60 additions & 0 deletions api/endpoints/fake/isp_monitors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package fake

import (
"github.com/site24x7/terraform-provider-site24x7/api"
"github.com/site24x7/terraform-provider-site24x7/api/endpoints/monitors"
"github.com/stretchr/testify/mock"
)

var _ monitors.ISPMonitors = &ISPMonitors{}

type ISPMonitors struct {
mock.Mock
}

func (e *ISPMonitors) Get(monitorID string) (*api.ISPMonitor, error) {
args := e.Called(monitorID)
if obj, ok := args.Get(0).(*api.ISPMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *ISPMonitors) Create(monitor *api.ISPMonitor) (*api.ISPMonitor, error) {
args := e.Called(monitor)
if obj, ok := args.Get(0).(*api.ISPMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *ISPMonitors) Update(monitor *api.ISPMonitor) (*api.ISPMonitor, error) {
args := e.Called(monitor)
if obj, ok := args.Get(0).(*api.ISPMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *ISPMonitors) Delete(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}

func (e *ISPMonitors) List() ([]*api.ISPMonitor, error) {
args := e.Called()
if obj, ok := args.Get(0).([]*api.ISPMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *ISPMonitors) Activate(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}

func (e *ISPMonitors) Suspend(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}
62 changes: 62 additions & 0 deletions api/endpoints/fake/web_transaction_browser_monitors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package fake

import (
"github.com/site24x7/terraform-provider-site24x7/api"
"github.com/site24x7/terraform-provider-site24x7/api/endpoints/monitors"
"github.com/stretchr/testify/mock"
)

var _ monitors.WebTransactionBrowserMonitors = &WebTransactionBrowserMonitors{}

//var _ monitors.WebTransactionBrowserMonitorsUpdate = &WebTransactionBrowserMonitorsUpdate{}

type WebTransactionBrowserMonitors struct {
mock.Mock
}

func (e *WebTransactionBrowserMonitors) Get(monitorID string) (*api.WebTransactionBrowserMonitor, error) {
args := e.Called(monitorID)
if obj, ok := args.Get(0).(*api.WebTransactionBrowserMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *WebTransactionBrowserMonitors) Create(monitor *api.WebTransactionBrowserMonitor) (*api.WebTransactionBrowserMonitor, error) {
args := e.Called(monitor)
if obj, ok := args.Get(0).(*api.WebTransactionBrowserMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *WebTransactionBrowserMonitors) Update(monitor *api.WebTransactionBrowserMonitor) (*api.WebTransactionBrowserMonitor, error) {
args := e.Called(monitor)
if obj, ok := args.Get(0).(*api.WebTransactionBrowserMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *WebTransactionBrowserMonitors) Delete(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}

func (e *WebTransactionBrowserMonitors) List() ([]*api.WebTransactionBrowserMonitor, error) {
args := e.Called()
if obj, ok := args.Get(0).([]*api.WebTransactionBrowserMonitor); ok {
return obj, args.Error(1)
}
return nil, args.Error(1)
}

func (e *WebTransactionBrowserMonitors) Activate(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}

func (e *WebTransactionBrowserMonitors) Suspend(monitorID string) error {
args := e.Called(monitorID)
return args.Error(0)
}
103 changes: 103 additions & 0 deletions api/endpoints/monitors/ftp_transfer_impl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package monitors

import (
"github.com/site24x7/terraform-provider-site24x7/api"
"github.com/site24x7/terraform-provider-site24x7/rest"
)

type FTPTransferMonitors interface {
Get(monitorID string) (*api.FTPTransferMonitor, error)
Create(monitor *api.FTPTransferMonitor) (*api.FTPTransferMonitor, error)
Update(monitor *api.FTPTransferMonitor) (*api.FTPTransferMonitor, error)
Delete(monitorID string) error
List() ([]*api.FTPTransferMonitor, error)
Activate(monitorID string) error
Suspend(monitorID string) error
}

type ftptransfermonitors struct {
client rest.Client
}

func NewFTPTransferMonitors(client rest.Client) FTPTransferMonitors {
return &ftptransfermonitors{
client: client,
}
}

func (c *ftptransfermonitors) Get(monitorID string) (*api.FTPTransferMonitor, error) {
monitor := &api.FTPTransferMonitor{}
err := c.client.
Get().
Resource("monitors").
ResourceID(monitorID).
Do().
Parse(monitor)

return monitor, err
}

func (c *ftptransfermonitors) Create(monitor *api.FTPTransferMonitor) (*api.FTPTransferMonitor, error) {
newMonitor := &api.FTPTransferMonitor{}
err := c.client.
Post().
Resource("monitors").
AddHeader("Content-Type", "application/json;charset=UTF-8").
Body(monitor).
Do().
Parse(newMonitor)

return newMonitor, err
}

func (c *ftptransfermonitors) Update(monitor *api.FTPTransferMonitor) (*api.FTPTransferMonitor, error) {
updatedMonitor := &api.FTPTransferMonitor{}
err := c.client.
Put().
Resource("monitors").
ResourceID(monitor.MonitorID).
AddHeader("Content-Type", "application/json;charset=UTF-8").
Body(monitor).
Do().
Parse(updatedMonitor)

return updatedMonitor, err
}

func (c *ftptransfermonitors) Delete(monitorID string) error {
return c.client.
Delete().
Resource("monitors").
ResourceID(monitorID).
Do().
Err()
}

func (c *ftptransfermonitors) List() ([]*api.FTPTransferMonitor, error) {
ftptransfermonitors := []*api.FTPTransferMonitor{}
err := c.client.
Get().
Resource("monitors").
Do().
Parse(&ftptransfermonitors)

return ftptransfermonitors, err
}

func (c *ftptransfermonitors) Activate(monitorID string) error {
return c.client.
Put().
Resource("monitors/activate").
ResourceID(monitorID).
Do().
Err()
}

func (c *ftptransfermonitors) Suspend(monitorID string) error {
return c.client.
Put().
Resource("monitors/suspend").
ResourceID(monitorID).
Do().
Err()
}
Loading

0 comments on commit 4cae34b

Please sign in to comment.