-
Notifications
You must be signed in to change notification settings - Fork 11
/
global_load_balancer_v1.go
1201 lines (1012 loc) · 38.9 KB
/
global_load_balancer_v1.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* IBM OpenAPI SDK Code Generator Version: 3.20.0-debb9f29-20201203-202043
*/
// Package globalloadbalancerv1 : Operations and models for the GlobalLoadBalancerV1 service
package globalloadbalancerv1
import (
"context"
"encoding/json"
"fmt"
"net/http"
"reflect"
"time"
"github.com/IBM/go-sdk-core/v5/core"
common "github.com/IBM/networking-go-sdk/common"
)
// GlobalLoadBalancerV1 : Global Load Balancer
//
// Version: 1.0.1
type GlobalLoadBalancerV1 struct {
Service *core.BaseService
// Full CRN of the service instance.
Crn *string
// zone identifier.
ZoneIdentifier *string
}
// DefaultServiceURL is the default URL to make service requests to.
const DefaultServiceURL = "https://api.cis.cloud.ibm.com"
// DefaultServiceName is the default key used to find external configuration information.
const DefaultServiceName = "global_load_balancer"
// GlobalLoadBalancerV1Options : Service options
type GlobalLoadBalancerV1Options struct {
ServiceName string
URL string
Authenticator core.Authenticator
// Full CRN of the service instance.
Crn *string `validate:"required"`
// zone identifier.
ZoneIdentifier *string `validate:"required"`
}
// NewGlobalLoadBalancerV1UsingExternalConfig : constructs an instance of GlobalLoadBalancerV1 with passed in options and external configuration.
func NewGlobalLoadBalancerV1UsingExternalConfig(options *GlobalLoadBalancerV1Options) (globalLoadBalancer *GlobalLoadBalancerV1, err error) {
if options.ServiceName == "" {
options.ServiceName = DefaultServiceName
}
if options.Authenticator == nil {
options.Authenticator, err = core.GetAuthenticatorFromEnvironment(options.ServiceName)
if err != nil {
return
}
}
globalLoadBalancer, err = NewGlobalLoadBalancerV1(options)
if err != nil {
return
}
err = globalLoadBalancer.Service.ConfigureService(options.ServiceName)
if err != nil {
return
}
if options.URL != "" {
err = globalLoadBalancer.Service.SetServiceURL(options.URL)
}
return
}
// NewGlobalLoadBalancerV1 : constructs an instance of GlobalLoadBalancerV1 with passed in options.
func NewGlobalLoadBalancerV1(options *GlobalLoadBalancerV1Options) (service *GlobalLoadBalancerV1, err error) {
serviceOptions := &core.ServiceOptions{
URL: DefaultServiceURL,
Authenticator: options.Authenticator,
}
err = core.ValidateStruct(options, "options")
if err != nil {
return
}
baseService, err := core.NewBaseService(serviceOptions)
if err != nil {
return
}
if options.URL != "" {
err = baseService.SetServiceURL(options.URL)
if err != nil {
return
}
}
service = &GlobalLoadBalancerV1{
Service: baseService,
Crn: options.Crn,
ZoneIdentifier: options.ZoneIdentifier,
}
return
}
// GetServiceURLForRegion returns the service URL to be used for the specified region
func GetServiceURLForRegion(region string) (string, error) {
return "", fmt.Errorf("service does not support regional URLs")
}
// Clone makes a copy of "globalLoadBalancer" suitable for processing requests.
func (globalLoadBalancer *GlobalLoadBalancerV1) Clone() *GlobalLoadBalancerV1 {
if core.IsNil(globalLoadBalancer) {
return nil
}
clone := *globalLoadBalancer
clone.Service = globalLoadBalancer.Service.Clone()
return &clone
}
// SetServiceURL sets the service URL
func (globalLoadBalancer *GlobalLoadBalancerV1) SetServiceURL(url string) error {
return globalLoadBalancer.Service.SetServiceURL(url)
}
// GetServiceURL returns the service URL
func (globalLoadBalancer *GlobalLoadBalancerV1) GetServiceURL() string {
return globalLoadBalancer.Service.GetServiceURL()
}
// SetDefaultHeaders sets HTTP headers to be sent in every request
func (globalLoadBalancer *GlobalLoadBalancerV1) SetDefaultHeaders(headers http.Header) {
globalLoadBalancer.Service.SetDefaultHeaders(headers)
}
// SetEnableGzipCompression sets the service's EnableGzipCompression field
func (globalLoadBalancer *GlobalLoadBalancerV1) SetEnableGzipCompression(enableGzip bool) {
globalLoadBalancer.Service.SetEnableGzipCompression(enableGzip)
}
// GetEnableGzipCompression returns the service's EnableGzipCompression field
func (globalLoadBalancer *GlobalLoadBalancerV1) GetEnableGzipCompression() bool {
return globalLoadBalancer.Service.GetEnableGzipCompression()
}
// EnableRetries enables automatic retries for requests invoked for this service instance.
// If either parameter is specified as 0, then a default value is used instead.
func (globalLoadBalancer *GlobalLoadBalancerV1) EnableRetries(maxRetries int, maxRetryInterval time.Duration) {
globalLoadBalancer.Service.EnableRetries(maxRetries, maxRetryInterval)
}
// DisableRetries disables automatic retries for requests invoked for this service instance.
func (globalLoadBalancer *GlobalLoadBalancerV1) DisableRetries() {
globalLoadBalancer.Service.DisableRetries()
}
// ListAllLoadBalancers : List all load balancers
// List configured load balancers.
func (globalLoadBalancer *GlobalLoadBalancerV1) ListAllLoadBalancers(listAllLoadBalancersOptions *ListAllLoadBalancersOptions) (result *ListLoadBalancersResp, response *core.DetailedResponse, err error) {
return globalLoadBalancer.ListAllLoadBalancersWithContext(context.Background(), listAllLoadBalancersOptions)
}
// ListAllLoadBalancersWithContext is an alternate form of the ListAllLoadBalancers method which supports a Context parameter
func (globalLoadBalancer *GlobalLoadBalancerV1) ListAllLoadBalancersWithContext(ctx context.Context, listAllLoadBalancersOptions *ListAllLoadBalancersOptions) (result *ListLoadBalancersResp, response *core.DetailedResponse, err error) {
err = core.ValidateStruct(listAllLoadBalancersOptions, "listAllLoadBalancersOptions")
if err != nil {
return
}
pathParamsMap := map[string]string{
"crn": *globalLoadBalancer.Crn,
"zone_identifier": *globalLoadBalancer.ZoneIdentifier,
}
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalLoadBalancer.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalLoadBalancer.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/load_balancers`, pathParamsMap)
if err != nil {
return
}
for headerName, headerValue := range listAllLoadBalancersOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
sdkHeaders := common.GetSdkHeaders("global_load_balancer", "V1", "ListAllLoadBalancers")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
request, err := builder.Build()
if err != nil {
return
}
var rawResponse map[string]json.RawMessage
response, err = globalLoadBalancer.Service.Request(request, &rawResponse)
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListLoadBalancersResp)
if err != nil {
return
}
response.Result = result
return
}
// CreateLoadBalancer : Create load balancer
// Create a load balancer for a given zone. The zone should be active before placing an order of a load balancer.
func (globalLoadBalancer *GlobalLoadBalancerV1) CreateLoadBalancer(createLoadBalancerOptions *CreateLoadBalancerOptions) (result *LoadBalancersResp, response *core.DetailedResponse, err error) {
return globalLoadBalancer.CreateLoadBalancerWithContext(context.Background(), createLoadBalancerOptions)
}
// CreateLoadBalancerWithContext is an alternate form of the CreateLoadBalancer method which supports a Context parameter
func (globalLoadBalancer *GlobalLoadBalancerV1) CreateLoadBalancerWithContext(ctx context.Context, createLoadBalancerOptions *CreateLoadBalancerOptions) (result *LoadBalancersResp, response *core.DetailedResponse, err error) {
err = core.ValidateStruct(createLoadBalancerOptions, "createLoadBalancerOptions")
if err != nil {
return
}
pathParamsMap := map[string]string{
"crn": *globalLoadBalancer.Crn,
"zone_identifier": *globalLoadBalancer.ZoneIdentifier,
}
builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalLoadBalancer.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalLoadBalancer.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/load_balancers`, pathParamsMap)
if err != nil {
return
}
for headerName, headerValue := range createLoadBalancerOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
sdkHeaders := common.GetSdkHeaders("global_load_balancer", "V1", "CreateLoadBalancer")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
builder.AddHeader("Content-Type", "application/json")
body := make(map[string]interface{})
if createLoadBalancerOptions.Name != nil {
body["name"] = createLoadBalancerOptions.Name
}
if createLoadBalancerOptions.FallbackPool != nil {
body["fallback_pool"] = createLoadBalancerOptions.FallbackPool
}
if createLoadBalancerOptions.DefaultPools != nil {
body["default_pools"] = createLoadBalancerOptions.DefaultPools
}
if createLoadBalancerOptions.Description != nil {
body["description"] = createLoadBalancerOptions.Description
}
if createLoadBalancerOptions.TTL != nil {
body["ttl"] = createLoadBalancerOptions.TTL
}
if createLoadBalancerOptions.RegionPools != nil {
body["region_pools"] = createLoadBalancerOptions.RegionPools
}
if createLoadBalancerOptions.PopPools != nil {
body["pop_pools"] = createLoadBalancerOptions.PopPools
}
if createLoadBalancerOptions.Proxied != nil {
body["proxied"] = createLoadBalancerOptions.Proxied
}
if createLoadBalancerOptions.Enabled != nil {
body["enabled"] = createLoadBalancerOptions.Enabled
}
if createLoadBalancerOptions.SessionAffinity != nil {
body["session_affinity"] = createLoadBalancerOptions.SessionAffinity
}
if createLoadBalancerOptions.SteeringPolicy != nil {
body["steering_policy"] = createLoadBalancerOptions.SteeringPolicy
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
return
}
request, err := builder.Build()
if err != nil {
return
}
var rawResponse map[string]json.RawMessage
response, err = globalLoadBalancer.Service.Request(request, &rawResponse)
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLoadBalancersResp)
if err != nil {
return
}
response.Result = result
return
}
// EditLoadBalancer : Edit load balancer
// Edit porperties of an existing load balancer.
func (globalLoadBalancer *GlobalLoadBalancerV1) EditLoadBalancer(editLoadBalancerOptions *EditLoadBalancerOptions) (result *LoadBalancersResp, response *core.DetailedResponse, err error) {
return globalLoadBalancer.EditLoadBalancerWithContext(context.Background(), editLoadBalancerOptions)
}
// EditLoadBalancerWithContext is an alternate form of the EditLoadBalancer method which supports a Context parameter
func (globalLoadBalancer *GlobalLoadBalancerV1) EditLoadBalancerWithContext(ctx context.Context, editLoadBalancerOptions *EditLoadBalancerOptions) (result *LoadBalancersResp, response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(editLoadBalancerOptions, "editLoadBalancerOptions cannot be nil")
if err != nil {
return
}
err = core.ValidateStruct(editLoadBalancerOptions, "editLoadBalancerOptions")
if err != nil {
return
}
pathParamsMap := map[string]string{
"crn": *globalLoadBalancer.Crn,
"zone_identifier": *globalLoadBalancer.ZoneIdentifier,
"load_balancer_identifier": *editLoadBalancerOptions.LoadBalancerIdentifier,
}
builder := core.NewRequestBuilder(core.PUT)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalLoadBalancer.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalLoadBalancer.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/load_balancers/{load_balancer_identifier}`, pathParamsMap)
if err != nil {
return
}
for headerName, headerValue := range editLoadBalancerOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
sdkHeaders := common.GetSdkHeaders("global_load_balancer", "V1", "EditLoadBalancer")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
builder.AddHeader("Content-Type", "application/json")
body := make(map[string]interface{})
if editLoadBalancerOptions.Name != nil {
body["name"] = editLoadBalancerOptions.Name
}
if editLoadBalancerOptions.FallbackPool != nil {
body["fallback_pool"] = editLoadBalancerOptions.FallbackPool
}
if editLoadBalancerOptions.DefaultPools != nil {
body["default_pools"] = editLoadBalancerOptions.DefaultPools
}
if editLoadBalancerOptions.Description != nil {
body["description"] = editLoadBalancerOptions.Description
}
if editLoadBalancerOptions.TTL != nil {
body["ttl"] = editLoadBalancerOptions.TTL
}
if editLoadBalancerOptions.RegionPools != nil {
body["region_pools"] = editLoadBalancerOptions.RegionPools
}
if editLoadBalancerOptions.PopPools != nil {
body["pop_pools"] = editLoadBalancerOptions.PopPools
}
if editLoadBalancerOptions.Proxied != nil {
body["proxied"] = editLoadBalancerOptions.Proxied
}
if editLoadBalancerOptions.Enabled != nil {
body["enabled"] = editLoadBalancerOptions.Enabled
}
if editLoadBalancerOptions.SessionAffinity != nil {
body["session_affinity"] = editLoadBalancerOptions.SessionAffinity
}
if editLoadBalancerOptions.SteeringPolicy != nil {
body["steering_policy"] = editLoadBalancerOptions.SteeringPolicy
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
return
}
request, err := builder.Build()
if err != nil {
return
}
var rawResponse map[string]json.RawMessage
response, err = globalLoadBalancer.Service.Request(request, &rawResponse)
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLoadBalancersResp)
if err != nil {
return
}
response.Result = result
return
}
// DeleteLoadBalancer : Delete load balancer
// Delete a load balancer.
func (globalLoadBalancer *GlobalLoadBalancerV1) DeleteLoadBalancer(deleteLoadBalancerOptions *DeleteLoadBalancerOptions) (result *DeleteLoadBalancersResp, response *core.DetailedResponse, err error) {
return globalLoadBalancer.DeleteLoadBalancerWithContext(context.Background(), deleteLoadBalancerOptions)
}
// DeleteLoadBalancerWithContext is an alternate form of the DeleteLoadBalancer method which supports a Context parameter
func (globalLoadBalancer *GlobalLoadBalancerV1) DeleteLoadBalancerWithContext(ctx context.Context, deleteLoadBalancerOptions *DeleteLoadBalancerOptions) (result *DeleteLoadBalancersResp, response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(deleteLoadBalancerOptions, "deleteLoadBalancerOptions cannot be nil")
if err != nil {
return
}
err = core.ValidateStruct(deleteLoadBalancerOptions, "deleteLoadBalancerOptions")
if err != nil {
return
}
pathParamsMap := map[string]string{
"crn": *globalLoadBalancer.Crn,
"zone_identifier": *globalLoadBalancer.ZoneIdentifier,
"load_balancer_identifier": *deleteLoadBalancerOptions.LoadBalancerIdentifier,
}
builder := core.NewRequestBuilder(core.DELETE)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalLoadBalancer.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalLoadBalancer.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/load_balancers/{load_balancer_identifier}`, pathParamsMap)
if err != nil {
return
}
for headerName, headerValue := range deleteLoadBalancerOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
sdkHeaders := common.GetSdkHeaders("global_load_balancer", "V1", "DeleteLoadBalancer")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
request, err := builder.Build()
if err != nil {
return
}
var rawResponse map[string]json.RawMessage
response, err = globalLoadBalancer.Service.Request(request, &rawResponse)
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteLoadBalancersResp)
if err != nil {
return
}
response.Result = result
return
}
// GetLoadBalancerSettings : Get load balancer
// For a given zone identifier and load balancer id, get the load balancer settings.
func (globalLoadBalancer *GlobalLoadBalancerV1) GetLoadBalancerSettings(getLoadBalancerSettingsOptions *GetLoadBalancerSettingsOptions) (result *LoadBalancersResp, response *core.DetailedResponse, err error) {
return globalLoadBalancer.GetLoadBalancerSettingsWithContext(context.Background(), getLoadBalancerSettingsOptions)
}
// GetLoadBalancerSettingsWithContext is an alternate form of the GetLoadBalancerSettings method which supports a Context parameter
func (globalLoadBalancer *GlobalLoadBalancerV1) GetLoadBalancerSettingsWithContext(ctx context.Context, getLoadBalancerSettingsOptions *GetLoadBalancerSettingsOptions) (result *LoadBalancersResp, response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(getLoadBalancerSettingsOptions, "getLoadBalancerSettingsOptions cannot be nil")
if err != nil {
return
}
err = core.ValidateStruct(getLoadBalancerSettingsOptions, "getLoadBalancerSettingsOptions")
if err != nil {
return
}
pathParamsMap := map[string]string{
"crn": *globalLoadBalancer.Crn,
"zone_identifier": *globalLoadBalancer.ZoneIdentifier,
"load_balancer_identifier": *getLoadBalancerSettingsOptions.LoadBalancerIdentifier,
}
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalLoadBalancer.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalLoadBalancer.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/load_balancers/{load_balancer_identifier}`, pathParamsMap)
if err != nil {
return
}
for headerName, headerValue := range getLoadBalancerSettingsOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
sdkHeaders := common.GetSdkHeaders("global_load_balancer", "V1", "GetLoadBalancerSettings")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
request, err := builder.Build()
if err != nil {
return
}
var rawResponse map[string]json.RawMessage
response, err = globalLoadBalancer.Service.Request(request, &rawResponse)
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLoadBalancersResp)
if err != nil {
return
}
response.Result = result
return
}
// CreateLoadBalancerOptions : The CreateLoadBalancer options.
type CreateLoadBalancerOptions struct {
// name.
Name *string `json:"name,omitempty"`
// fallback pool.
FallbackPool *string `json:"fallback_pool,omitempty"`
// default pools.
DefaultPools []string `json:"default_pools,omitempty"`
// desc.
Description *string `json:"description,omitempty"`
// ttl.
TTL *int64 `json:"ttl,omitempty"`
// region pools.
RegionPools interface{} `json:"region_pools,omitempty"`
// pop pools.
PopPools interface{} `json:"pop_pools,omitempty"`
// proxied.
Proxied *bool `json:"proxied,omitempty"`
// enabled/disabled.
Enabled *bool `json:"enabled,omitempty"`
// session affinity.
SessionAffinity *string `json:"session_affinity,omitempty"`
// steering policy.
SteeringPolicy *string `json:"steering_policy,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the CreateLoadBalancerOptions.SessionAffinity property.
// session affinity.
const (
CreateLoadBalancerOptions_SessionAffinity_Cookie = "cookie"
CreateLoadBalancerOptions_SessionAffinity_IpCookie = "ip_cookie"
CreateLoadBalancerOptions_SessionAffinity_None = "none"
)
// Constants associated with the CreateLoadBalancerOptions.SteeringPolicy property.
// steering policy.
const (
CreateLoadBalancerOptions_SteeringPolicy_DynamicLatency = "dynamic_latency"
CreateLoadBalancerOptions_SteeringPolicy_Geo = "geo"
CreateLoadBalancerOptions_SteeringPolicy_Off = "off"
CreateLoadBalancerOptions_SteeringPolicy_Random = "random"
)
// NewCreateLoadBalancerOptions : Instantiate CreateLoadBalancerOptions
func (*GlobalLoadBalancerV1) NewCreateLoadBalancerOptions() *CreateLoadBalancerOptions {
return &CreateLoadBalancerOptions{}
}
// SetName : Allow user to set Name
func (options *CreateLoadBalancerOptions) SetName(name string) *CreateLoadBalancerOptions {
options.Name = core.StringPtr(name)
return options
}
// SetFallbackPool : Allow user to set FallbackPool
func (options *CreateLoadBalancerOptions) SetFallbackPool(fallbackPool string) *CreateLoadBalancerOptions {
options.FallbackPool = core.StringPtr(fallbackPool)
return options
}
// SetDefaultPools : Allow user to set DefaultPools
func (options *CreateLoadBalancerOptions) SetDefaultPools(defaultPools []string) *CreateLoadBalancerOptions {
options.DefaultPools = defaultPools
return options
}
// SetDescription : Allow user to set Description
func (options *CreateLoadBalancerOptions) SetDescription(description string) *CreateLoadBalancerOptions {
options.Description = core.StringPtr(description)
return options
}
// SetTTL : Allow user to set TTL
func (options *CreateLoadBalancerOptions) SetTTL(ttl int64) *CreateLoadBalancerOptions {
options.TTL = core.Int64Ptr(ttl)
return options
}
// SetRegionPools : Allow user to set RegionPools
func (options *CreateLoadBalancerOptions) SetRegionPools(regionPools interface{}) *CreateLoadBalancerOptions {
options.RegionPools = regionPools
return options
}
// SetPopPools : Allow user to set PopPools
func (options *CreateLoadBalancerOptions) SetPopPools(popPools interface{}) *CreateLoadBalancerOptions {
options.PopPools = popPools
return options
}
// SetProxied : Allow user to set Proxied
func (options *CreateLoadBalancerOptions) SetProxied(proxied bool) *CreateLoadBalancerOptions {
options.Proxied = core.BoolPtr(proxied)
return options
}
// SetEnabled : Allow user to set Enabled
func (options *CreateLoadBalancerOptions) SetEnabled(enabled bool) *CreateLoadBalancerOptions {
options.Enabled = core.BoolPtr(enabled)
return options
}
// SetSessionAffinity : Allow user to set SessionAffinity
func (options *CreateLoadBalancerOptions) SetSessionAffinity(sessionAffinity string) *CreateLoadBalancerOptions {
options.SessionAffinity = core.StringPtr(sessionAffinity)
return options
}
// SetSteeringPolicy : Allow user to set SteeringPolicy
func (options *CreateLoadBalancerOptions) SetSteeringPolicy(steeringPolicy string) *CreateLoadBalancerOptions {
options.SteeringPolicy = core.StringPtr(steeringPolicy)
return options
}
// SetHeaders : Allow user to set Headers
func (options *CreateLoadBalancerOptions) SetHeaders(param map[string]string) *CreateLoadBalancerOptions {
options.Headers = param
return options
}
// DeleteLoadBalancerOptions : The DeleteLoadBalancer options.
type DeleteLoadBalancerOptions struct {
// load balancer identifier.
LoadBalancerIdentifier *string `json:"load_balancer_identifier" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
}
// NewDeleteLoadBalancerOptions : Instantiate DeleteLoadBalancerOptions
func (*GlobalLoadBalancerV1) NewDeleteLoadBalancerOptions(loadBalancerIdentifier string) *DeleteLoadBalancerOptions {
return &DeleteLoadBalancerOptions{
LoadBalancerIdentifier: core.StringPtr(loadBalancerIdentifier),
}
}
// SetLoadBalancerIdentifier : Allow user to set LoadBalancerIdentifier
func (options *DeleteLoadBalancerOptions) SetLoadBalancerIdentifier(loadBalancerIdentifier string) *DeleteLoadBalancerOptions {
options.LoadBalancerIdentifier = core.StringPtr(loadBalancerIdentifier)
return options
}
// SetHeaders : Allow user to set Headers
func (options *DeleteLoadBalancerOptions) SetHeaders(param map[string]string) *DeleteLoadBalancerOptions {
options.Headers = param
return options
}
// DeleteLoadBalancersRespResult : result.
type DeleteLoadBalancersRespResult struct {
// identifier.
ID *string `json:"id" validate:"required"`
}
// UnmarshalDeleteLoadBalancersRespResult unmarshals an instance of DeleteLoadBalancersRespResult from the specified map of raw messages.
func UnmarshalDeleteLoadBalancersRespResult(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(DeleteLoadBalancersRespResult)
err = core.UnmarshalPrimitive(m, "id", &obj.ID)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}
// EditLoadBalancerOptions : The EditLoadBalancer options.
type EditLoadBalancerOptions struct {
// load balancer identifier.
LoadBalancerIdentifier *string `json:"load_balancer_identifier" validate:"required,ne="`
// name.
Name *string `json:"name,omitempty"`
// fallback pool.
FallbackPool *string `json:"fallback_pool,omitempty"`
// default pools.
DefaultPools []string `json:"default_pools,omitempty"`
// desc.
Description *string `json:"description,omitempty"`
// ttl.
TTL *int64 `json:"ttl,omitempty"`
// region pools.
RegionPools interface{} `json:"region_pools,omitempty"`
// pop pools.
PopPools interface{} `json:"pop_pools,omitempty"`
// proxied.
Proxied *bool `json:"proxied,omitempty"`
// enabled/disabled.
Enabled *bool `json:"enabled,omitempty"`
// session affinity.
SessionAffinity *string `json:"session_affinity,omitempty"`
// steering policy.
SteeringPolicy *string `json:"steering_policy,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the EditLoadBalancerOptions.SessionAffinity property.
// session affinity.
const (
EditLoadBalancerOptions_SessionAffinity_Cookie = "cookie"
EditLoadBalancerOptions_SessionAffinity_IpCookie = "ip_cookie"
EditLoadBalancerOptions_SessionAffinity_None = "none"
)
// Constants associated with the EditLoadBalancerOptions.SteeringPolicy property.
// steering policy.
const (
EditLoadBalancerOptions_SteeringPolicy_DynamicLatency = "dynamic_latency"
EditLoadBalancerOptions_SteeringPolicy_Geo = "geo"
EditLoadBalancerOptions_SteeringPolicy_Off = "off"
EditLoadBalancerOptions_SteeringPolicy_Random = "random"
)
// NewEditLoadBalancerOptions : Instantiate EditLoadBalancerOptions
func (*GlobalLoadBalancerV1) NewEditLoadBalancerOptions(loadBalancerIdentifier string) *EditLoadBalancerOptions {
return &EditLoadBalancerOptions{
LoadBalancerIdentifier: core.StringPtr(loadBalancerIdentifier),
}
}
// SetLoadBalancerIdentifier : Allow user to set LoadBalancerIdentifier
func (options *EditLoadBalancerOptions) SetLoadBalancerIdentifier(loadBalancerIdentifier string) *EditLoadBalancerOptions {
options.LoadBalancerIdentifier = core.StringPtr(loadBalancerIdentifier)
return options
}
// SetName : Allow user to set Name
func (options *EditLoadBalancerOptions) SetName(name string) *EditLoadBalancerOptions {
options.Name = core.StringPtr(name)
return options
}
// SetFallbackPool : Allow user to set FallbackPool
func (options *EditLoadBalancerOptions) SetFallbackPool(fallbackPool string) *EditLoadBalancerOptions {
options.FallbackPool = core.StringPtr(fallbackPool)
return options
}
// SetDefaultPools : Allow user to set DefaultPools
func (options *EditLoadBalancerOptions) SetDefaultPools(defaultPools []string) *EditLoadBalancerOptions {
options.DefaultPools = defaultPools
return options
}
// SetDescription : Allow user to set Description
func (options *EditLoadBalancerOptions) SetDescription(description string) *EditLoadBalancerOptions {
options.Description = core.StringPtr(description)
return options
}
// SetTTL : Allow user to set TTL
func (options *EditLoadBalancerOptions) SetTTL(ttl int64) *EditLoadBalancerOptions {
options.TTL = core.Int64Ptr(ttl)
return options
}
// SetRegionPools : Allow user to set RegionPools
func (options *EditLoadBalancerOptions) SetRegionPools(regionPools interface{}) *EditLoadBalancerOptions {
options.RegionPools = regionPools
return options
}
// SetPopPools : Allow user to set PopPools
func (options *EditLoadBalancerOptions) SetPopPools(popPools interface{}) *EditLoadBalancerOptions {
options.PopPools = popPools
return options
}
// SetProxied : Allow user to set Proxied
func (options *EditLoadBalancerOptions) SetProxied(proxied bool) *EditLoadBalancerOptions {
options.Proxied = core.BoolPtr(proxied)
return options
}
// SetEnabled : Allow user to set Enabled
func (options *EditLoadBalancerOptions) SetEnabled(enabled bool) *EditLoadBalancerOptions {
options.Enabled = core.BoolPtr(enabled)
return options
}
// SetSessionAffinity : Allow user to set SessionAffinity
func (options *EditLoadBalancerOptions) SetSessionAffinity(sessionAffinity string) *EditLoadBalancerOptions {
options.SessionAffinity = core.StringPtr(sessionAffinity)
return options
}
// SetSteeringPolicy : Allow user to set SteeringPolicy
func (options *EditLoadBalancerOptions) SetSteeringPolicy(steeringPolicy string) *EditLoadBalancerOptions {
options.SteeringPolicy = core.StringPtr(steeringPolicy)
return options
}
// SetHeaders : Allow user to set Headers
func (options *EditLoadBalancerOptions) SetHeaders(param map[string]string) *EditLoadBalancerOptions {
options.Headers = param
return options
}
// GetLoadBalancerSettingsOptions : The GetLoadBalancerSettings options.
type GetLoadBalancerSettingsOptions struct {
// load balancer identifier.
LoadBalancerIdentifier *string `json:"load_balancer_identifier" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
}
// NewGetLoadBalancerSettingsOptions : Instantiate GetLoadBalancerSettingsOptions
func (*GlobalLoadBalancerV1) NewGetLoadBalancerSettingsOptions(loadBalancerIdentifier string) *GetLoadBalancerSettingsOptions {
return &GetLoadBalancerSettingsOptions{
LoadBalancerIdentifier: core.StringPtr(loadBalancerIdentifier),
}
}
// SetLoadBalancerIdentifier : Allow user to set LoadBalancerIdentifier
func (options *GetLoadBalancerSettingsOptions) SetLoadBalancerIdentifier(loadBalancerIdentifier string) *GetLoadBalancerSettingsOptions {
options.LoadBalancerIdentifier = core.StringPtr(loadBalancerIdentifier)
return options
}
// SetHeaders : Allow user to set Headers
func (options *GetLoadBalancerSettingsOptions) SetHeaders(param map[string]string) *GetLoadBalancerSettingsOptions {
options.Headers = param
return options
}
// ListAllLoadBalancersOptions : The ListAllLoadBalancers options.
type ListAllLoadBalancersOptions struct {
// Allows users to set headers on API requests
Headers map[string]string
}
// NewListAllLoadBalancersOptions : Instantiate ListAllLoadBalancersOptions
func (*GlobalLoadBalancerV1) NewListAllLoadBalancersOptions() *ListAllLoadBalancersOptions {
return &ListAllLoadBalancersOptions{}
}
// SetHeaders : Allow user to set Headers
func (options *ListAllLoadBalancersOptions) SetHeaders(param map[string]string) *ListAllLoadBalancersOptions {
options.Headers = param
return options
}
// DeleteLoadBalancersResp : delete load balancers response.
type DeleteLoadBalancersResp struct {
// success respose.
Success *bool `json:"success" validate:"required"`
// errors.
Errors [][]string `json:"errors" validate:"required"`
// messages.
Messages [][]string `json:"messages" validate:"required"`
// result.
Result *DeleteLoadBalancersRespResult `json:"result" validate:"required"`
}
// UnmarshalDeleteLoadBalancersResp unmarshals an instance of DeleteLoadBalancersResp from the specified map of raw messages.
func UnmarshalDeleteLoadBalancersResp(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(DeleteLoadBalancersResp)
err = core.UnmarshalPrimitive(m, "success", &obj.Success)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "errors", &obj.Errors)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "messages", &obj.Messages)
if err != nil {
return
}
err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalDeleteLoadBalancersRespResult)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}
// ListLoadBalancersResp : load balancer list response.
type ListLoadBalancersResp struct {
// success response.
Success *bool `json:"success" validate:"required"`
// errors.
Errors [][]string `json:"errors" validate:"required"`
// messages.
Messages [][]string `json:"messages" validate:"required"`
// result.
Result []LoadBalancerPack `json:"result" validate:"required"`
// result information.
ResultInfo *ResultInfo `json:"result_info" validate:"required"`
}
// UnmarshalListLoadBalancersResp unmarshals an instance of ListLoadBalancersResp from the specified map of raw messages.
func UnmarshalListLoadBalancersResp(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(ListLoadBalancersResp)
err = core.UnmarshalPrimitive(m, "success", &obj.Success)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "errors", &obj.Errors)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "messages", &obj.Messages)
if err != nil {
return
}
err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalLoadBalancerPack)
if err != nil {
return
}
err = core.UnmarshalModel(m, "result_info", &obj.ResultInfo, UnmarshalResultInfo)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}