/
resource_akamai_cloudlets_application_load_balancer.go
661 lines (625 loc) · 23.3 KB
/
resource_akamai_cloudlets_application_load_balancer.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
package cloudlets
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session"
"github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf"
"github.com/akamai/terraform-provider-akamai/v5/pkg/meta"
ozzo "github.com/go-ozzo/ozzo-validation/v4"
"github.com/go-ozzo/ozzo-validation/v4/is"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceCloudletsApplicationLoadBalancer() *schema.Resource {
return &schema.Resource{
CustomizeDiff: customdiff.All(
EnforceVersionChange,
ensureTotalPercentageSum,
),
CreateContext: resourceALBCreate,
ReadContext: resourceALBRead,
UpdateContext: resourceALBUpdate,
DeleteContext: resourceALBDelete,
Schema: map[string]*schema.Schema{
"origin_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The conditional origin's unique identifier",
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: "The load balancer configuration version description",
},
"origin_description": {
Type: schema.TypeString,
Optional: true,
Description: "The load balancer configuration description",
},
"balancing_type": {
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{
"WEIGHTED",
"PERFORMANCE",
}, false)),
Description: "The type of load balancing being performed. Options include WEIGHTED and PERFORMANCE",
},
"data_centers": {
Type: schema.TypeSet,
Required: true,
Description: "The object containing information on conditional origins being used as data centers for an Application Load Balancer implementation. Only Conditional Origins with an originType of CUSTOMER or NETSTORAGE can be used as data centers in an application load balancer configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"latitude": {
Type: schema.TypeFloat,
Required: true,
Description: "The latitude value for the data center. This member supports six decimal places of precision.",
},
"longitude": {
Type: schema.TypeFloat,
Required: true,
Description: "The longitude value for the data center. This member supports six decimal places of precision.",
},
"continent": {
Type: schema.TypeString,
Required: true,
Description: "The continent on which the data center is located",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{
"AF",
"AS",
"EU",
"NA",
"OC",
"OT",
"SA",
}, false)),
},
"country": {
Type: schema.TypeString,
Required: true,
Description: "The country in which the data center is located",
ValidateDiagFunc: func(i interface{}, path cty.Path) diag.Diagnostics {
if err := ozzo.Validate(strings.ToUpper(i.(string)), is.CountryCode2); err != nil {
return diag.FromErr(err)
}
return nil
},
},
"origin_id": {
Type: schema.TypeString,
Required: true,
Description: "The ID of an origin that represents the data center. The conditional origin, which is defined in the Property Manager API, must have an originType of either CUSTOMER or NET_STORAGE",
},
"percent": {
Type: schema.TypeFloat,
Required: true,
Description: "The percent of traffic that is sent to the data center. The total for all data centers must equal 100%.",
},
"cloud_service": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Describes if this datacenter is a cloud service",
},
"liveness_hosts": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "An array of strings that represent the origin servers used to poll the data centers in an application load balancer configuration. These servers support basic HTTP polling.",
},
"hostname": {
Type: schema.TypeString,
Optional: true,
Description: "This should match the 'hostname' value defined for this datacenter in Property Manager",
},
"state_or_province": {
Type: schema.TypeString,
Optional: true,
Description: "The state, province, or region where the data center is located",
},
"city": {
Type: schema.TypeString,
Optional: true,
Description: "The city in which the data center is located.",
},
"cloud_server_host_header_override": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Describes if cloud server host header is overridden",
},
},
},
},
"liveness_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeInt,
Required: true,
Description: "The port for the test object. The default port is 80, which is standard for HTTP. Enter 443 if you are using HTTPS.",
},
"protocol": {
Type: schema.TypeString,
Required: true,
Description: "The protocol or scheme for the database, either HTTP or HTTPS.",
},
"path": {
Type: schema.TypeString,
Required: true,
Description: "The path to the test object used for liveness testing. The function of the test object is to help determine whether the data center is functioning.",
},
"host_header": {
Type: schema.TypeString,
Optional: true,
Description: "The Host header for the liveness HTTP request",
},
"additional_headers": {
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "Maps additional case-insensitive HTTP header names included to the liveness testing requests",
},
"interval": {
Type: schema.TypeInt,
Default: 0,
Optional: true,
Description: "Describes how often the liveness test will be performed. Optional defaults to 60 seconds, minimum is 10 seconds.",
},
"peer_certificate_verification": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Describes whether or not to validate the origin certificate for an HTTPS request",
},
"request_string": {
Type: schema.TypeString,
Optional: true,
Description: "The request which will be used for TCP(S) tests",
},
"response_string": {
Type: schema.TypeString,
Optional: true,
},
"status_3xx_failure": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Set to true to mark the liveness test as failed when the request returns a 3xx (redirection) status code.",
},
"status_4xx_failure": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Set to true to mark the liveness test as failed when the request returns a 4xx (client error) status code.",
},
"status_5xx_failure": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "Set to true to mark the liveness test as failed when the request returns a 5xx (server error) status code.",
},
"timeout": {
Type: schema.TypeFloat,
Default: float64(0),
Optional: true,
Description: "The number of seconds the system waits before failing the liveness test. The default is 25 seconds.",
},
},
},
},
"version": {
Type: schema.TypeInt,
Computed: true,
Description: "The load balancer configuration version",
},
"warnings": {
Type: schema.TypeString,
Computed: true,
Description: "Describes warnings during activation of load balancer configuration",
},
},
Importer: &schema.ResourceImporter{
StateContext: resourceALBImport,
},
}
}
// ensureTotalPercentageSum ensures that all datacenters' percent sum up to 100
// and will veto the diff altogether and abort the plan when above condition is not met
// This is a workaround as CustomizeDiff function in not meant to be used for resource validation
// but there is no easier solution to do it with the current state of terraform sdk
func ensureTotalPercentageSum(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
if dcs, ok := diff.GetOk("data_centers"); ok {
dataCenters := dcs.(*schema.Set).List()
var total float64
for _, dataCenter := range dataCenters {
dc := dataCenter.(map[string]interface{})
percent := dc["percent"].(float64)
total += percent
}
if 100.0 != total {
t := strconv.FormatFloat(total, 'f', -1, 64)
return fmt.Errorf("the total data center percentage must be 100%%: total=%s%%", t)
}
}
return nil
}
// EnforceVersionChange enforces that change to any field will most likely result in creating a new version
func EnforceVersionChange(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
if diff.HasChange("origin_id") ||
diff.HasChange("description") ||
diff.HasChange("balancing_type") ||
diff.HasChange("data_centers") ||
diff.HasChange("liveness_settings") ||
diff.HasChange("version") {
return diff.SetNewComputed("version")
}
return nil
}
func isAkamaized(dc cloudlets.DataCenter, origins []cloudlets.OriginResponse) bool {
for _, o := range origins {
if o.Hostname == dc.Hostname && o.OriginID == dc.OriginID {
return o.Akamaized
}
}
return false
}
func validateLivenessHosts(ctx context.Context, client cloudlets.Cloudlets, d *schema.ResourceData) error {
dcs := getDataCenters(d)
origins, err := client.ListOrigins(ctx, cloudlets.ListOriginsRequest{})
if err != nil {
return err
}
for _, dc := range dcs {
if len(dc.LivenessHosts) > 0 && isAkamaized(dc, origins) {
return fmt.Errorf("'liveness_hosts' field should be omitted for GTM hostname: %q. "+
"Liveness tests for this host can be configured in DNS traffic management", dc.Hostname)
}
}
return nil
}
func resourceALBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
meta := meta.Must(m)
logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationCreate")
// create a context with logging for api calls
ctx = session.ContextWithOptions(
ctx,
session.WithContextLog(logger),
)
client := Client(meta)
logger.Debug("Creating load balancer configuration")
originID, err := tf.GetStringValue("origin_id", d)
if err != nil {
return diag.FromErr(err)
}
originDescription, err := tf.GetStringValue("origin_description", d)
if err != nil && !errors.Is(err, tf.ErrNotFound) {
return diag.FromErr(err)
}
if err := validateLivenessHosts(ctx, client, d); err != nil {
return diag.FromErr(err)
}
createLBConfigResp, err := client.CreateOrigin(ctx, cloudlets.CreateOriginRequest{
OriginID: originID,
Description: cloudlets.Description{
Description: originDescription,
},
})
if err != nil {
return diag.FromErr(err)
}
d.SetId(createLBConfigResp.OriginID)
loadBalancerVersion := getLoadBalancerVersion(d)
createVersionResp, err := client.CreateLoadBalancerVersion(ctx, cloudlets.CreateLoadBalancerVersionRequest{
OriginID: originID,
LoadBalancerVersion: loadBalancerVersion,
})
if err != nil {
return diag.FromErr(err)
}
if err := d.Set("version", createVersionResp.Version); err != nil {
return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()))
}
return resourceALBRead(ctx, d, m)
}
func resourceALBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
meta := meta.Must(m)
logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationRead")
// create a context with logging for api calls
ctx = session.ContextWithOptions(
ctx,
session.WithContextLog(logger),
)
client := Client(meta)
logger.Debug("Reading load balancer configuration")
originID := d.Id()
loadBalancerConfigAttrs := map[string]interface{}{
"origin_id": originID,
}
origin, err := client.GetOrigin(ctx, cloudlets.GetOriginRequest{
OriginID: originID,
})
if err != nil {
return diag.FromErr(err)
}
if err := tf.SetAttrs(d, loadBalancerConfigAttrs); err != nil {
return diag.FromErr(err)
}
version, err := tf.GetIntValue("version", d)
if err != nil {
return diag.FromErr(err)
}
loadBalancerVersion, err := client.GetLoadBalancerVersion(ctx, cloudlets.GetLoadBalancerVersionRequest{
OriginID: originID,
Version: int64(version),
ShouldValidate: true,
})
if err != nil {
return diag.FromErr(err)
}
attrs := make(map[string]interface{})
attrs["origin_description"] = origin.Description
attrs["balancing_type"] = loadBalancerVersion.BalancingType
attrs["version"] = loadBalancerVersion.Version
attrs["description"] = loadBalancerVersion.Description
attrs["data_centers"] = populateDataCenters(loadBalancerVersion.DataCenters)
if loadBalancerVersion.LivenessSettings != nil {
attrs["liveness_settings"] = populateLivenessSettings(loadBalancerVersion.LivenessSettings)
}
var warningsJSON []byte
if len(loadBalancerVersion.Warnings) > 0 {
warningsJSON, err = json.MarshalIndent(loadBalancerVersion.Warnings, "", " ")
if err != nil {
return diag.FromErr(err)
}
}
attrs["warnings"] = string(warningsJSON)
if err := tf.SetAttrs(d, attrs); err != nil {
return diag.FromErr(err)
}
return nil
}
func resourceALBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
meta := meta.Must(m)
logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationUpdate")
// create a context with logging for api calls
ctx = session.ContextWithOptions(
ctx,
session.WithContextLog(logger),
)
client := Client(meta)
logger.Debug("Updating load balancer configuration")
originID := d.Id()
version, err := tf.GetIntValue("version", d)
if err != nil {
return diag.FromErr(err)
}
if err := validateLivenessHosts(ctx, client, d); err != nil {
return diag.FromErr(err)
}
if d.HasChange("origin_description") {
originDescription, err := tf.GetStringValue("origin_description", d)
if err != nil && !errors.Is(err, tf.ErrNotFound) {
return diag.FromErr(err)
}
_, err = client.UpdateOrigin(ctx, cloudlets.UpdateOriginRequest{
OriginID: originID,
Description: cloudlets.Description{
Description: originDescription,
},
})
if err != nil {
return diag.FromErr(err)
}
}
// if version-related attributes have changed, load balancer version has to be either created or updated (depending on whether it's active or not)
if d.HasChanges("description", "balancing_type", "data_centers", "liveness_settings") {
activations, err := client.ListLoadBalancerActivations(ctx, cloudlets.ListLoadBalancerActivationsRequest{OriginID: originID})
if err != nil {
return diag.FromErr(err)
}
var versionActive bool
for _, activation := range activations {
if activation.Version == int64(version) && activation.Status == cloudlets.LoadBalancerActivationStatusActive {
versionActive = true
break
}
}
loadBalancerVersion := getLoadBalancerVersion(d)
var loadBalancerVersionResp *cloudlets.LoadBalancerVersion
if versionActive {
loadBalancerVersionResp, err = client.CreateLoadBalancerVersion(ctx, cloudlets.CreateLoadBalancerVersionRequest{
OriginID: originID,
LoadBalancerVersion: loadBalancerVersion,
})
} else {
loadBalancerVersionResp, err = client.UpdateLoadBalancerVersion(ctx, cloudlets.UpdateLoadBalancerVersionRequest{
OriginID: originID,
ShouldValidate: true,
Version: int64(version),
LoadBalancerVersion: loadBalancerVersion,
})
}
if err != nil {
return diag.FromErr(err)
}
if err := d.Set("version", loadBalancerVersionResp.Version); err != nil {
return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()))
}
}
return resourceALBRead(ctx, d, m)
}
// resourceALBDelete does not call any delete operation in the API, because there is no such operation
// resource will simply be removed from state in that case
// to allow re-using existing config, create function also covers the import functionality, saving the existing origin and version in state
func resourceALBDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
meta := meta.Must(m)
logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationDelete")
logger.Debug("Deleting load balancer configuration")
logger.Info("Cloudlets API does not support load balancer configuration and load balancer configuration version deletion - resource will only be removed from state")
d.SetId("")
return nil
}
// resourceALBImport does a basic import based on the originID specified it imports the latest version
func resourceALBImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
meta := meta.Must(m)
logger := meta.Log("Cloudlets", "resourceALBImport")
logger.Debug("Import ALB")
client := Client(meta)
logger.Debug("Importing load balancer configuration")
originID := d.Id()
if originID == "" {
return nil, fmt.Errorf("origin id cannot be empty")
}
origin, err := client.GetOrigin(ctx, cloudlets.GetOriginRequest{OriginID: originID})
if err != nil {
return nil, err
}
if origin == nil {
return nil, fmt.Errorf("could not find origin with origin_id: %s", originID)
}
versions, err := client.ListLoadBalancerVersions(ctx, cloudlets.ListLoadBalancerVersionsRequest{
OriginID: origin.OriginID,
})
if err != nil {
return nil, err
}
if len(versions) == 0 {
return nil, fmt.Errorf("no load balancer version found for origin_id: %s", originID)
}
var version int64
for _, v := range versions {
if v.Version > version {
version = v.Version
}
}
err = d.Set("version", version)
if err != nil {
return nil, err
}
return []*schema.ResourceData{d}, nil
}
func populateDataCenters(dcs []cloudlets.DataCenter) []interface{} {
dataCentersList := make([]interface{}, 0)
for _, dc := range dcs {
dsMap := map[string]interface{}{
"cloud_service": dc.CloudService,
"liveness_hosts": dc.LivenessHosts,
"latitude": dc.Latitude,
"longitude": dc.Longitude,
"continent": dc.Continent,
"country": dc.Country,
"origin_id": dc.OriginID,
"percent": dc.Percent,
"hostname": dc.Hostname,
"city": dc.City,
"cloud_server_host_header_override": dc.CloudServerHostHeaderOverride,
}
if dc.StateOrProvince != nil {
dsMap["state_or_province"] = *dc.StateOrProvince
}
dataCentersList = append(dataCentersList, dsMap)
}
return dataCentersList
}
func populateLivenessSettings(ls *cloudlets.LivenessSettings) []interface{} {
lsMap := map[string]interface{}{
"port": ls.Port,
"protocol": ls.Protocol,
"host_header": ls.HostHeader,
"additional_headers": ls.AdditionalHeaders,
"interval": ls.Interval,
"path": ls.Path,
"peer_certificate_verification": ls.PeerCertificateVerification,
"request_string": ls.RequestString,
"response_string": ls.ResponseString,
"status_3xx_failure": ls.Status3xxFailure,
"status_4xx_failure": ls.Status4xxFailure,
"status_5xx_failure": ls.Status5xxFailure,
"timeout": ls.Timeout,
}
return []interface{}{lsMap}
}
func getLoadBalancerVersion(d *schema.ResourceData) cloudlets.LoadBalancerVersion {
description := d.Get("description").(string)
balancingType := d.Get("balancing_type").(string)
dataCenters := getDataCenters(d)
livenessSettings := getLivenessSettings(d)
return cloudlets.LoadBalancerVersion{
Description: description,
BalancingType: cloudlets.BalancingType(balancingType),
DataCenters: dataCenters,
LivenessSettings: livenessSettings,
}
}
func getDataCenters(d *schema.ResourceData) []cloudlets.DataCenter {
dataCentersSet := d.Get("data_centers").(*schema.Set)
dataCenters := make([]cloudlets.DataCenter, dataCentersSet.Len())
for i, dc := range dataCentersSet.List() {
dcMap := dc.(map[string]interface{})
livenessHosts := dcMap["liveness_hosts"].([]interface{})
livenessHostsStr := make([]string, len(livenessHosts))
for i, host := range livenessHosts {
livenessHostsStr[i] = host.(string)
}
var stateOrProvince *string
if s := dcMap["state_or_province"].(string); s != "" {
stateOrProvince = &s
}
dataCenters[i] = cloudlets.DataCenter{
City: dcMap["city"].(string),
CloudServerHostHeaderOverride: dcMap["cloud_server_host_header_override"].(bool),
CloudService: dcMap["cloud_service"].(bool),
Continent: dcMap["continent"].(string),
Country: dcMap["country"].(string),
Hostname: dcMap["hostname"].(string),
Latitude: getFloat64PtrValue(dcMap, "latitude"),
LivenessHosts: livenessHostsStr,
Longitude: getFloat64PtrValue(dcMap, "longitude"),
OriginID: dcMap["origin_id"].(string),
Percent: getFloat64PtrValue(dcMap, "percent"),
StateOrProvince: stateOrProvince,
}
}
return dataCenters
}
func getLivenessSettings(d *schema.ResourceData) *cloudlets.LivenessSettings {
lsList, err := tf.GetListValue("liveness_settings", d)
if err != nil {
return nil
}
lsMap := lsList[0].(map[string]interface{})
additionalHeaders := lsMap["additional_headers"].(map[string]interface{})
additionalHeadersStr := make(map[string]string, len(additionalHeaders))
for k, v := range additionalHeaders {
additionalHeadersStr[k] = v.(string)
}
return &cloudlets.LivenessSettings{
HostHeader: lsMap["host_header"].(string),
AdditionalHeaders: additionalHeadersStr,
Interval: lsMap["interval"].(int),
Path: lsMap["path"].(string),
PeerCertificateVerification: lsMap["peer_certificate_verification"].(bool),
Port: lsMap["port"].(int),
Protocol: lsMap["protocol"].(string),
RequestString: lsMap["request_string"].(string),
ResponseString: lsMap["response_string"].(string),
Status3xxFailure: lsMap["status_3xx_failure"].(bool),
Status4xxFailure: lsMap["status_4xx_failure"].(bool),
Status5xxFailure: lsMap["status_5xx_failure"].(bool),
Timeout: lsMap["timeout"].(float64),
}
}