@@ -5,63 +5,65 @@ import (
55 "fmt"
66 "io/ioutil"
77 "net/http"
8+
9+ "github.com/draios/terraform-provider-sysdig/sysdig/monitor/model"
810)
911
10- func (client * sysdigMonitorClient ) GetDashboardByID (ctx context.Context , ID int ) (Dashboard , error ) {
12+ func (client * sysdigMonitorClient ) GetDashboardByID (ctx context.Context , ID int ) (* model. Dashboard , error ) {
1113 res , err := client .doSysdigMonitorRequest (ctx , http .MethodGet , client .getDashboardUrl (ID ), nil )
1214 if err != nil {
13- return Dashboard {} , err
15+ return nil , err
1416 }
1517 defer res .Body .Close ()
1618
1719 body , err := ioutil .ReadAll (res .Body )
1820 if err != nil {
19- return Dashboard {} , nil
21+ return nil , nil
2022 }
2123
2224 if res .StatusCode != http .StatusOK {
23- return Dashboard {} , fmt .Errorf (string (body ))
25+ return nil , fmt .Errorf (string (body ))
2426 }
2527
26- return DashboardFromJSON (body ), nil
28+ return model . DashboardFromJSON (body ), nil
2729}
2830
29- func (client * sysdigMonitorClient ) CreateDashboard (ctx context.Context , dashboard Dashboard ) (Dashboard , error ) {
31+ func (client * sysdigMonitorClient ) CreateDashboard (ctx context.Context , dashboard * model. Dashboard ) (* model. Dashboard , error ) {
3032 res , err := client .doSysdigMonitorRequest (ctx , http .MethodPost , client .getDashboardsUrl (), dashboard .ToJSON ())
3133 if err != nil {
32- return Dashboard {} , err
34+ return nil , err
3335 }
3436 defer res .Body .Close ()
3537
3638 body , err := ioutil .ReadAll (res .Body )
3739 if err != nil {
38- return Dashboard {} , err
40+ return nil , err
3941 }
4042
4143 if res .StatusCode != http .StatusOK && res .StatusCode != http .StatusCreated {
42- return Dashboard {} , fmt .Errorf (string (body ))
44+ return nil , fmt .Errorf (string (body ))
4345 }
4446
45- return DashboardFromJSON (body ), nil
47+ return model . DashboardFromJSON (body ), nil
4648}
4749
48- func (client * sysdigMonitorClient ) UpdateDashboard (ctx context.Context , dashboard Dashboard ) (Dashboard , error ) {
50+ func (client * sysdigMonitorClient ) UpdateDashboard (ctx context.Context , dashboard * model. Dashboard ) (* model. Dashboard , error ) {
4951 res , err := client .doSysdigMonitorRequest (ctx , http .MethodPut , client .getDashboardUrl (dashboard .ID ), dashboard .ToJSON ())
5052 if err != nil {
51- return Dashboard {} , err
53+ return nil , err
5254 }
5355 defer res .Body .Close ()
5456
5557 body , err := ioutil .ReadAll (res .Body )
5658 if err != nil {
57- return Dashboard {} , err
59+ return nil , err
5860 }
5961
6062 if res .StatusCode != http .StatusOK && res .StatusCode != http .StatusCreated {
61- return Dashboard {} , fmt .Errorf (string (body ))
63+ return nil , fmt .Errorf (string (body ))
6264 }
6365
64- return DashboardFromJSON (body ), nil
66+ return model . DashboardFromJSON (body ), nil
6567}
6668
6769func (client * sysdigMonitorClient ) DeleteDashboard (ctx context.Context , ID int ) error {
0 commit comments