/
alertconfig_client.go
116 lines (100 loc) · 4.26 KB
/
alertconfig_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/***************************************************************************
* ------------------------------------------------------------------------
* Copyright 2020 VMware, Inc. All rights reserved. VMware Confidential
* ------------------------------------------------------------------------
*/
package clients
// This file is auto-generated.
// Please contact avi-sdk@avinetworks.com for any change requests.
import (
"github.com/avinetworks/sdk/go/models"
"github.com/avinetworks/sdk/go/session"
)
// AlertConfigClient is a client for avi AlertConfig resource
type AlertConfigClient struct {
aviSession *session.AviSession
}
// NewAlertConfigClient creates a new client for AlertConfig resource
func NewAlertConfigClient(aviSession *session.AviSession) *AlertConfigClient {
return &AlertConfigClient{aviSession: aviSession}
}
func (client *AlertConfigClient) getAPIPath(uuid string) string {
path := "api/alertconfig"
if uuid != "" {
path += "/" + uuid
}
return path
}
// GetAll is a collection API to get a list of AlertConfig objects
func (client *AlertConfigClient) GetAll(options ...session.ApiOptionsParams) ([]*models.AlertConfig, error) {
var plist []*models.AlertConfig
err := client.aviSession.GetCollection(client.getAPIPath(""), &plist, options...)
return plist, err
}
// Get an existing AlertConfig by uuid
func (client *AlertConfigClient) Get(uuid string, options ...session.ApiOptionsParams) (*models.AlertConfig, error) {
var obj *models.AlertConfig
err := client.aviSession.Get(client.getAPIPath(uuid), &obj, options...)
return obj, err
}
// GetByName - Get an existing AlertConfig by name
func (client *AlertConfigClient) GetByName(name string, options ...session.ApiOptionsParams) (*models.AlertConfig, error) {
var obj *models.AlertConfig
err := client.aviSession.GetObjectByName("alertconfig", name, &obj, options...)
return obj, err
}
// GetObject - Get an existing AlertConfig by filters like name, cloud, tenant
// Api creates AlertConfig object with every call.
func (client *AlertConfigClient) GetObject(options ...session.ApiOptionsParams) (*models.AlertConfig, error) {
var obj *models.AlertConfig
newOptions := make([]session.ApiOptionsParams, len(options)+1)
for i, p := range options {
newOptions[i] = p
}
newOptions[len(options)] = session.SetResult(&obj)
err := client.aviSession.GetObject("alertconfig", newOptions...)
return obj, err
}
// Create a new AlertConfig object
func (client *AlertConfigClient) Create(obj *models.AlertConfig, options ...session.ApiOptionsParams) (*models.AlertConfig, error) {
var robj *models.AlertConfig
err := client.aviSession.Post(client.getAPIPath(""), obj, &robj, options...)
return robj, err
}
// Update an existing AlertConfig object
func (client *AlertConfigClient) Update(obj *models.AlertConfig, options ...session.ApiOptionsParams) (*models.AlertConfig, error) {
var robj *models.AlertConfig
path := client.getAPIPath(*obj.UUID)
err := client.aviSession.Put(path, obj, &robj, options...)
return robj, err
}
// Patch an existing AlertConfig object specified using uuid
// patchOp: Patch operation - add, replace, or delete
// patch: Patch payload should be compatible with the models.AlertConfig
// or it should be json compatible of form map[string]interface{}
func (client *AlertConfigClient) Patch(uuid string, patch interface{}, patchOp string, options ...session.ApiOptionsParams) (*models.AlertConfig, error) {
var robj *models.AlertConfig
path := client.getAPIPath(uuid)
err := client.aviSession.Patch(path, patch, patchOp, &robj, options...)
return robj, err
}
// Delete an existing AlertConfig object with a given UUID
func (client *AlertConfigClient) Delete(uuid string, options ...session.ApiOptionsParams) error {
if len(options) == 0 {
return client.aviSession.Delete(client.getAPIPath(uuid))
} else {
return client.aviSession.DeleteObject(client.getAPIPath(uuid), options...)
}
}
// DeleteByName - Delete an existing AlertConfig object with a given name
func (client *AlertConfigClient) DeleteByName(name string, options ...session.ApiOptionsParams) error {
res, err := client.GetByName(name, options...)
if err != nil {
return err
}
return client.Delete(*res.UUID, options...)
}
// GetAviSession
func (client *AlertConfigClient) GetAviSession() *session.AviSession {
return client.aviSession
}