...
1 package managedvirtualnetwork
2
3
4
5
6
7
8
9 import (
10 "context"
11 "encoding/json"
12 "github.com/Azure/go-autorest/autorest"
13 "github.com/Azure/go-autorest/autorest/to"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/managedvirtualnetwork"
20
21
22 type ManagedPrivateEndpoint struct {
23 autorest.Response `json:"-"`
24
25 ID *string `json:"id,omitempty"`
26
27 Name *string `json:"name,omitempty"`
28
29 Type *string `json:"type,omitempty"`
30
31 Properties *ManagedPrivateEndpointProperties `json:"properties,omitempty"`
32 }
33
34
35 func (mpe ManagedPrivateEndpoint) MarshalJSON() ([]byte, error) {
36 objectMap := make(map[string]interface{})
37 if mpe.Properties != nil {
38 objectMap["properties"] = mpe.Properties
39 }
40 return json.Marshal(objectMap)
41 }
42
43
44 type ManagedPrivateEndpointConnectionState struct {
45
46 Status *string `json:"status,omitempty"`
47
48 Description *string `json:"description,omitempty"`
49
50 ActionsRequired *string `json:"actionsRequired,omitempty"`
51 }
52
53
54 func (mpecs ManagedPrivateEndpointConnectionState) MarshalJSON() ([]byte, error) {
55 objectMap := make(map[string]interface{})
56 if mpecs.Description != nil {
57 objectMap["description"] = mpecs.Description
58 }
59 if mpecs.ActionsRequired != nil {
60 objectMap["actionsRequired"] = mpecs.ActionsRequired
61 }
62 return json.Marshal(objectMap)
63 }
64
65
66 type ManagedPrivateEndpointListResponse struct {
67 autorest.Response `json:"-"`
68
69 Value *[]ManagedPrivateEndpoint `json:"value,omitempty"`
70
71 NextLink *string `json:"nextLink,omitempty"`
72 }
73
74
75 func (mpelr ManagedPrivateEndpointListResponse) MarshalJSON() ([]byte, error) {
76 objectMap := make(map[string]interface{})
77 if mpelr.Value != nil {
78 objectMap["value"] = mpelr.Value
79 }
80 return json.Marshal(objectMap)
81 }
82
83
84
85 type ManagedPrivateEndpointListResponseIterator struct {
86 i int
87 page ManagedPrivateEndpointListResponsePage
88 }
89
90
91
92 func (iter *ManagedPrivateEndpointListResponseIterator) NextWithContext(ctx context.Context) (err error) {
93 if tracing.IsEnabled() {
94 ctx = tracing.StartSpan(ctx, fqdn+"/ManagedPrivateEndpointListResponseIterator.NextWithContext")
95 defer func() {
96 sc := -1
97 if iter.Response().Response.Response != nil {
98 sc = iter.Response().Response.Response.StatusCode
99 }
100 tracing.EndSpan(ctx, sc, err)
101 }()
102 }
103 iter.i++
104 if iter.i < len(iter.page.Values()) {
105 return nil
106 }
107 err = iter.page.NextWithContext(ctx)
108 if err != nil {
109 iter.i--
110 return err
111 }
112 iter.i = 0
113 return nil
114 }
115
116
117
118
119 func (iter *ManagedPrivateEndpointListResponseIterator) Next() error {
120 return iter.NextWithContext(context.Background())
121 }
122
123
124 func (iter ManagedPrivateEndpointListResponseIterator) NotDone() bool {
125 return iter.page.NotDone() && iter.i < len(iter.page.Values())
126 }
127
128
129 func (iter ManagedPrivateEndpointListResponseIterator) Response() ManagedPrivateEndpointListResponse {
130 return iter.page.Response()
131 }
132
133
134
135 func (iter ManagedPrivateEndpointListResponseIterator) Value() ManagedPrivateEndpoint {
136 if !iter.page.NotDone() {
137 return ManagedPrivateEndpoint{}
138 }
139 return iter.page.Values()[iter.i]
140 }
141
142
143 func NewManagedPrivateEndpointListResponseIterator(page ManagedPrivateEndpointListResponsePage) ManagedPrivateEndpointListResponseIterator {
144 return ManagedPrivateEndpointListResponseIterator{page: page}
145 }
146
147
148 func (mpelr ManagedPrivateEndpointListResponse) IsEmpty() bool {
149 return mpelr.Value == nil || len(*mpelr.Value) == 0
150 }
151
152
153 func (mpelr ManagedPrivateEndpointListResponse) hasNextLink() bool {
154 return mpelr.NextLink != nil && len(*mpelr.NextLink) != 0
155 }
156
157
158
159 func (mpelr ManagedPrivateEndpointListResponse) managedPrivateEndpointListResponsePreparer(ctx context.Context) (*http.Request, error) {
160 if !mpelr.hasNextLink() {
161 return nil, nil
162 }
163 return autorest.Prepare((&http.Request{}).WithContext(ctx),
164 autorest.AsJSON(),
165 autorest.AsGet(),
166 autorest.WithBaseURL(to.String(mpelr.NextLink)))
167 }
168
169
170 type ManagedPrivateEndpointListResponsePage struct {
171 fn func(context.Context, ManagedPrivateEndpointListResponse) (ManagedPrivateEndpointListResponse, error)
172 mpelr ManagedPrivateEndpointListResponse
173 }
174
175
176
177 func (page *ManagedPrivateEndpointListResponsePage) NextWithContext(ctx context.Context) (err error) {
178 if tracing.IsEnabled() {
179 ctx = tracing.StartSpan(ctx, fqdn+"/ManagedPrivateEndpointListResponsePage.NextWithContext")
180 defer func() {
181 sc := -1
182 if page.Response().Response.Response != nil {
183 sc = page.Response().Response.Response.StatusCode
184 }
185 tracing.EndSpan(ctx, sc, err)
186 }()
187 }
188 for {
189 next, err := page.fn(ctx, page.mpelr)
190 if err != nil {
191 return err
192 }
193 page.mpelr = next
194 if !next.hasNextLink() || !next.IsEmpty() {
195 break
196 }
197 }
198 return nil
199 }
200
201
202
203
204 func (page *ManagedPrivateEndpointListResponsePage) Next() error {
205 return page.NextWithContext(context.Background())
206 }
207
208
209 func (page ManagedPrivateEndpointListResponsePage) NotDone() bool {
210 return !page.mpelr.IsEmpty()
211 }
212
213
214 func (page ManagedPrivateEndpointListResponsePage) Response() ManagedPrivateEndpointListResponse {
215 return page.mpelr
216 }
217
218
219 func (page ManagedPrivateEndpointListResponsePage) Values() []ManagedPrivateEndpoint {
220 if page.mpelr.IsEmpty() {
221 return nil
222 }
223 return *page.mpelr.Value
224 }
225
226
227 func NewManagedPrivateEndpointListResponsePage(cur ManagedPrivateEndpointListResponse, getNextPage func(context.Context, ManagedPrivateEndpointListResponse) (ManagedPrivateEndpointListResponse, error)) ManagedPrivateEndpointListResponsePage {
228 return ManagedPrivateEndpointListResponsePage{
229 fn: getNextPage,
230 mpelr: cur,
231 }
232 }
233
234
235 type ManagedPrivateEndpointProperties struct {
236
237 PrivateLinkResourceID *string `json:"privateLinkResourceId,omitempty"`
238
239 GroupID *string `json:"groupId,omitempty"`
240
241 ProvisioningState *string `json:"provisioningState,omitempty"`
242
243 ConnectionState *ManagedPrivateEndpointConnectionState `json:"connectionState,omitempty"`
244
245 IsReserved *bool `json:"isReserved,omitempty"`
246 }
247
248
249 func (mpep ManagedPrivateEndpointProperties) MarshalJSON() ([]byte, error) {
250 objectMap := make(map[string]interface{})
251 if mpep.PrivateLinkResourceID != nil {
252 objectMap["privateLinkResourceId"] = mpep.PrivateLinkResourceID
253 }
254 if mpep.GroupID != nil {
255 objectMap["groupId"] = mpep.GroupID
256 }
257 if mpep.ConnectionState != nil {
258 objectMap["connectionState"] = mpep.ConnectionState
259 }
260 return json.Marshal(objectMap)
261 }
262
View as plain text