-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathcompute.py
More file actions
7964 lines (7367 loc) · 397 KB
/
Copy pathcompute.py
File metadata and controls
7964 lines (7367 loc) · 397 KB
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
from collections import defaultdict
import logging
import ipaddress
from datetime import datetime
from typing import ClassVar, Dict, Optional, List, Tuple, Type, Any
from urllib.parse import urlparse
from attr import define, field
from fix_plugin_gcp.gcp_client import GcpApiSpec, InternalZoneProp
from fix_plugin_gcp.resources.base import GcpResource, GcpDeprecationStatus, GraphBuilder, GcpMonitoringQuery
from fix_plugin_gcp.resources.billing import GcpSku
from fix_plugin_gcp.resources.monitoring import STANDART_STAT_MAP, PERCENTILE_STAT_MAP, normalizer_factory
from fixlib.baseresources import (
BaseAutoScalingGroup,
BaseBucket,
BaseCertificate,
BaseFirewall,
BaseGateway,
BaseHealthCheck,
BaseIPAddress,
BaseInstanceType,
BaseLoadBalancer,
BaseNetwork,
BaseSnapshot,
BaseSubnet,
BaseTunnel,
BaseVolumeType,
MetricName,
ModelReference,
BaseVolume,
VolumeStatus,
BaseInstance,
InstanceStatus,
PhantomBaseResource,
)
from fixlib.json_bender import Bender, S, Bend, ForallBend, MapDict, F, MapEnum, AsInt
from fixlib.types import Json
from fix_plugin_gcp.utils import get_universe_domain_api
log = logging.getLogger("fix.plugins.gcp")
# This service is called Compute Engine in the GCP API.
# https://cloud.google.com/kubernetes-engine/docs
service_name = "compute"
def health_check_types() -> Tuple[Type[GcpResource], ...]:
return GcpHealthCheck, GcpHttpsHealthCheck, GcpHttpHealthCheck
@define(eq=False, slots=False)
class GcpAcceleratorType(GcpResource):
kind: ClassVar[str] = "gcp_accelerator_type"
_kind_display: ClassVar[str] = "GCP Accelerator Type"
_kind_description: ClassVar[str] = "GCP Accelerator Type refers to specialized hardware components available in Google Cloud Platform. These accelerators, such as GPUs and TPUs, enhance computational performance for specific workloads like machine learning, data processing, and scientific simulations. Users can attach accelerators to virtual machines to boost processing speed and efficiency for their applications and tasks." # fmt: skip
_docs_url: ClassVar[str] = "https://cloud.google.com/compute/docs/gpus"
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "type", "group": "compute"}
api_spec: ClassVar[GcpApiSpec] = GcpApiSpec(
service=service_name,
version="v1",
accessors=["acceleratorTypes"],
action="aggregatedList",
request_parameter={"project": "{project}"},
request_parameter_in={"project"},
response_path="items",
response_regional_sub_path="acceleratorTypes",
mutate_iam_permissions=[],
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("name").or_else(S("id")).or_else(S("selfLink")),
"tags": S("labels", default={}),
"name": S("name"),
"ctime": S("creationTimestamp"),
"description": S("description"),
"link": S("selfLink"),
"label_fingerprint": S("labelFingerprint"),
"deprecation_status": S("deprecated", default={}) >> Bend(GcpDeprecationStatus.mapping),
"type_maximum_cards_per_instance": S("maximumCardsPerInstance"),
}
type_maximum_cards_per_instance: Optional[int] = field(default=None)
def get_ip_address_type(ip_address: str) -> str:
try:
version = ipaddress.ip_address(ip_address).version
address_type_map = {4: "ipv4", 6: "ipv6"}
return address_type_map[version]
except Exception as e:
log.warning(f"An error occured while setting ip address version: {e}")
return ""
@define(eq=False, slots=False)
class GcpAddress(GcpResource, BaseIPAddress):
kind: ClassVar[str] = "gcp_address"
_kind_display: ClassVar[str] = "GCP Address"
_kind_description: ClassVar[str] = "GCP Address is a Google Cloud Platform resource that provides static external IP addresses for virtual machine instances and network load balancers. It assigns permanent IP addresses to resources, ensuring consistent accessibility even when instances are stopped and restarted. GCP Address supports both regional and global IP addresses, facilitating network configuration and management in cloud environments." # fmt: skip
_docs_url: ClassVar[str] = "https://cloud.google.com/compute/docs/ip-addresses"
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "dns", "group": "networking"}
_reference_kinds: ClassVar[ModelReference] = {
"predecessors": {"default": ["gcp_subnetwork"]},
"successors": {
"delete": ["gcp_subnetwork"],
},
}
api_spec: ClassVar[GcpApiSpec] = GcpApiSpec(
service=service_name,
version="v1",
accessors=["addresses"],
action="aggregatedList",
request_parameter={"project": "{project}"},
request_parameter_in={"project"},
response_path="items",
response_regional_sub_path="addresses",
get_identifier="address",
mutate_iam_permissions=["compute.addresses.delete"],
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("name").or_else(S("id")).or_else(S("selfLink")),
"tags": S("labels", default={}),
"name": S("name"),
"ctime": S("creationTimestamp"),
"description": S("description"),
"link": S("selfLink"),
"label_fingerprint": S("labelFingerprint"),
"deprecation_status": S("deprecated", default={}) >> Bend(GcpDeprecationStatus.mapping),
"address": S("address"),
"address_type": S("addressType"),
"ip_version": S("ipVersion"),
"ipv6_endpoint_type": S("ipv6EndpointType"),
"network": S("network"),
"network_tier": S("networkTier"),
"prefix_length": S("prefixLength"),
"purpose": S("purpose"),
"status": S("status"),
"subnetwork": S("subnetwork"),
"users": S("users", default=[]),
"ip_address": S("address"),
# Since GCP API does not provide the IP version directly, we determine it ourselves
# by using the 'get_ip_address_type'
"ip_address_family": S("address") >> F(get_ip_address_type),
}
address: Optional[str] = field(default=None)
address_type: Optional[str] = field(default=None)
ip_version: Optional[str] = field(default=None)
ipv6_endpoint_type: Optional[str] = field(default=None)
network: Optional[str] = field(default=None)
network_tier: Optional[str] = field(default=None)
prefix_length: Optional[int] = field(default=None)
purpose: Optional[str] = field(default=None)
status: Optional[str] = field(default=None)
subnetwork: Optional[str] = field(default=None)
users: Optional[List[str]] = field(default=None)
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if self.subnetwork:
builder.dependant_node(self, reverse=True, clazz=GcpSubnetwork, link=self.subnetwork)
@define(eq=False, slots=False)
class GcpAutoscalingPolicyCpuUtilization:
kind: ClassVar[str] = "gcp_autoscaling_policy_cpu_utilization"
kind_display: ClassVar[str] = "GCP Autoscaling Policy - CPU Utilization"
kind_description: ClassVar[str] = (
"GCP Autoscaling Policy - CPU Utilization is a resource in Google Cloud"
" Platform that allows for automatic scaling of resources based on CPU"
" utilization metrics. This helps optimize resource allocation and ensures"
" optimal performance."
)
mapping: ClassVar[Dict[str, Bender]] = {
"predictive_method": S("predictiveMethod"),
"utilization_target": S("utilizationTarget"),
}
predictive_method: Optional[str] = field(default=None)
utilization_target: Optional[float] = field(default=None)
@define(eq=False, slots=False)
class GcpAutoscalingPolicyCustomMetricUtilization:
kind: ClassVar[str] = "gcp_autoscaling_policy_custom_metric_utilization"
kind_display: ClassVar[str] = "GCP Autoscaling Policy Custom Metric Utilization"
kind_description: ClassVar[str] = (
"GCP Autoscaling Policy Custom Metric Utilization is a feature in Google"
" Cloud Platform that allows users to define custom metrics to automatically"
" scale resources based on specific utilization levels."
)
mapping: ClassVar[Dict[str, Bender]] = {
"filter": S("filter"),
"metric": S("metric"),
"single_instance_assignment": S("singleInstanceAssignment"),
"utilization_target": S("utilizationTarget"),
"utilization_target_type": S("utilizationTargetType"),
}
filter: Optional[str] = field(default=None)
metric: Optional[str] = field(default=None)
single_instance_assignment: Optional[float] = field(default=None)
utilization_target: Optional[float] = field(default=None)
utilization_target_type: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpFixedOrPercent:
kind: ClassVar[str] = "gcp_fixed_or_percent"
kind_display: ClassVar[str] = "GCP Fixed or Percent"
kind_description: ClassVar[str] = (
"GCP Fixed or Percent refers to a configuration within GCP's autoscaling policy that allows"
" for scale-in control based on either a fixed number or a percentage of instances."
)
mapping: ClassVar[Dict[str, Bender]] = {"calculated": S("calculated"), "fixed": S("fixed"), "percent": S("percent")}
calculated: Optional[int] = field(default=None)
fixed: Optional[int] = field(default=None)
percent: Optional[int] = field(default=None)
@define(eq=False, slots=False)
class GcpAutoscalingPolicyScaleInControl:
kind: ClassVar[str] = "gcp_autoscaling_policy_scale_in_control"
kind_display: ClassVar[str] = "GCP Autoscaling Policy Scale In Control"
kind_description: ClassVar[str] = (
"The GCP Autoscaling Policy Scale In Control allows users to control how"
" instances are scaled in during autoscaling events in the Google Cloud"
" Platform."
)
mapping: ClassVar[Dict[str, Bender]] = {
"max_scaled_in_replicas": S("maxScaledInReplicas", default={}) >> Bend(GcpFixedOrPercent.mapping),
"time_window_sec": S("timeWindowSec"),
}
max_scaled_in_replicas: Optional[GcpFixedOrPercent] = field(default=None)
time_window_sec: Optional[int] = field(default=None)
@define(eq=False, slots=False)
class GcpAutoscalingPolicyScalingSchedule:
kind: ClassVar[str] = "gcp_autoscaling_policy_scaling_schedule"
kind_display: ClassVar[str] = "GCP Autoscaling Policy Scaling Schedule"
kind_description: ClassVar[str] = (
"A scaling schedule is used in Google Cloud Platform (GCP) autoscaling"
" policies to define when and how many instances should be added or removed"
" from an autoscaling group based on predefined time intervals or conditions."
)
mapping: ClassVar[Dict[str, Bender]] = {
"description": S("description"),
"disabled": S("disabled"),
"duration_sec": S("durationSec"),
"min_required_replicas": S("minRequiredReplicas"),
"schedule": S("schedule"),
"time_zone": S("timeZone"),
}
description: Optional[str] = field(default=None)
disabled: Optional[bool] = field(default=None)
duration_sec: Optional[int] = field(default=None)
min_required_replicas: Optional[int] = field(default=None)
schedule: Optional[str] = field(default=None)
time_zone: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpAutoscalingPolicy:
kind: ClassVar[str] = "gcp_autoscaling_policy"
kind_display: ClassVar[str] = "GCP Autoscaling Policy"
kind_description: ClassVar[str] = (
"Autoscaling policies in Google Cloud Platform allow automatic adjustment of"
" resources based on predefined conditions, ensuring efficient utilization and"
" responsiveness in handling varying workloads."
)
mapping: ClassVar[Dict[str, Bender]] = {
"cool_down_period_sec": S("coolDownPeriodSec"),
"cpu_utilization": S("cpuUtilization", default={}) >> Bend(GcpAutoscalingPolicyCpuUtilization.mapping),
"custom_metric_utilizations": S("customMetricUtilizations", default=[])
>> ForallBend(GcpAutoscalingPolicyCustomMetricUtilization.mapping),
"load_balancing_utilization": S("loadBalancingUtilization", "utilizationTarget"),
"max_num_replicas": S("maxNumReplicas"),
"min_num_replicas": S("minNumReplicas"),
"mode": S("mode"),
"scale_in_control": S("scaleInControl", default={}) >> Bend(GcpAutoscalingPolicyScaleInControl.mapping),
"scaling_schedules": S("scalingSchedules", default={})
>> MapDict(value_bender=Bend(GcpAutoscalingPolicyScalingSchedule.mapping)),
}
cool_down_period_sec: Optional[int] = field(default=None)
cpu_utilization: Optional[GcpAutoscalingPolicyCpuUtilization] = field(default=None)
custom_metric_utilizations: Optional[List[GcpAutoscalingPolicyCustomMetricUtilization]] = field(default=None)
load_balancing_utilization: Optional[float] = field(default=None)
max_num_replicas: Optional[int] = field(default=None)
min_num_replicas: Optional[int] = field(default=None)
mode: Optional[str] = field(default=None)
scale_in_control: Optional[GcpAutoscalingPolicyScaleInControl] = field(default=None)
scaling_schedules: Optional[Dict[str, GcpAutoscalingPolicyScalingSchedule]] = field(default=None)
@define(eq=False, slots=False)
class GcpScalingScheduleStatus:
kind: ClassVar[str] = "gcp_scaling_schedule_status"
kind_display: ClassVar[str] = "GCP Scaling Schedule Status"
kind_description: ClassVar[str] = (
"GCP Scaling Schedule Status represents the current status of a scaling"
" schedule in Google Cloud Platform, providing information about when and how"
" the scaling is performed."
)
mapping: ClassVar[Dict[str, Bender]] = {
"last_start_time": S("lastStartTime"),
"next_start_time": S("nextStartTime"),
"scaling_schedule_status_state": S("state"),
}
last_start_time: Optional[datetime] = field(default=None)
next_start_time: Optional[datetime] = field(default=None)
scaling_schedule_status_state: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpAutoscalerStatusDetails:
kind: ClassVar[str] = "gcp_autoscaler_status_details"
kind_display: ClassVar[str] = "GCP Autoscaler Status Details"
kind_description: ClassVar[str] = (
"Autoscaler Status Details provide information about the scaling behavior of"
" an autoscaler in the Google Cloud Platform."
)
mapping: ClassVar[Dict[str, Bender]] = {"message": S("message"), "type": S("type")}
message: Optional[str] = field(default=None)
type: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpAutoscaler(GcpResource, BaseAutoScalingGroup):
kind: ClassVar[str] = "gcp_autoscaler"
_kind_display: ClassVar[str] = "GCP Autoscaler"
_kind_description: ClassVar[str] = "GCP Autoscaler is a Google Cloud Platform service that adjusts the number of virtual machine instances in a managed instance group based on workload demands. It monitors resource usage and automatically adds or removes instances to maintain performance and optimize costs. Users can set scaling policies and thresholds to control the autoscaling behavior." # fmt: skip
_docs_url: ClassVar[str] = "https://cloud.google.com/compute/docs/autoscaler"
_kind_service: ClassVar[Optional[str]] = service_name
_reference_kinds: ClassVar[ModelReference] = {
"successors": {
"default": ["gcp_instance_group_manager"],
"delete": ["gcp_instance_group_manager"],
}
}
api_spec: ClassVar[GcpApiSpec] = GcpApiSpec(
service=service_name,
version="v1",
accessors=["autoscalers"],
action="aggregatedList",
request_parameter={"project": "{project}"},
request_parameter_in={"project"},
response_path="items",
response_regional_sub_path="autoscalers",
mutate_iam_permissions=["compute.autoscalers.update", "compute.autoscalers.delete"],
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("name").or_else(S("id")).or_else(S("selfLink")),
"tags": S("labels", default={}),
"name": S("name"),
"ctime": S("creationTimestamp"),
"description": S("description"),
"link": S("selfLink"),
"label_fingerprint": S("labelFingerprint"),
"deprecation_status": S("deprecated", default={}) >> Bend(GcpDeprecationStatus.mapping),
"autoscaler_autoscaling_policy": S("autoscalingPolicy", default={}) >> Bend(GcpAutoscalingPolicy.mapping),
"autoscaler_recommended_size": S("recommendedSize") >> AsInt(),
"autoscaler_scaling_schedule_status": S("scalingScheduleStatus", default={})
>> MapDict(value_bender=Bend(GcpScalingScheduleStatus.mapping)),
"autoscaler_status": S("status"),
"autoscaler_status_details": S("statusDetails", default=[]) >> ForallBend(GcpAutoscalerStatusDetails.mapping),
"autoscaler_target": S("target"),
"min_size": S("autoscalingPolicy", "minNumReplicas") >> AsInt(),
"max_size": S("autoscalingPolicy" "maxNumReplicas") >> AsInt(),
}
autoscaler_autoscaling_policy: Optional[GcpAutoscalingPolicy] = field(default=None)
autoscaler_recommended_size: Optional[int] = field(default=None)
autoscaler_scaling_schedule_status: Optional[Dict[str, GcpScalingScheduleStatus]] = field(default=None)
autoscaler_status: Optional[str] = field(default=None)
autoscaler_status_details: Optional[List[GcpAutoscalerStatusDetails]] = field(default=None)
autoscaler_target: Optional[str] = field(default=None)
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if self.autoscaler_target:
builder.dependant_node(
self, delete_same_as_default=True, clazz=GcpInstanceGroupManager, link=self.autoscaler_target
)
@define(eq=False, slots=False)
class GcpBackendBucketCdnPolicyCacheKeyPolicy:
kind: ClassVar[str] = "gcp_backend_bucket_cdn_policy_cache_key_policy"
kind_display: ClassVar[str] = "GCP Backend Bucket CDN Policy Cache Key Policy"
kind_description: ClassVar[str] = (
"The GCP Backend Bucket CDN Policy Cache Key Policy is a policy that"
" specifies how content is cached on the CDN (Content Delivery Network) for a"
" backend bucket in Google Cloud Platform (GCP)."
)
mapping: ClassVar[Dict[str, Bender]] = {
"include_http_headers": S("includeHttpHeaders", default=[]),
"query_string_whitelist": S("queryStringWhitelist", default=[]),
}
include_http_headers: Optional[List[str]] = field(default=None)
query_string_whitelist: Optional[List[str]] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendBucketCdnPolicyNegativeCachingPolicy:
kind: ClassVar[str] = "gcp_backend_bucket_cdn_policy_negative_caching_policy"
kind_display: ClassVar[str] = "GCP Backend Bucket CDN Policy Negative Caching Policy"
kind_description: ClassVar[str] = (
"This resource represents the negative caching policy of a CDN policy for a"
" Google Cloud Platform backend bucket. Negative caching allows the CDN to"
" cache and serve error responses to clients, improving performance and"
" reducing load on the backend servers."
)
mapping: ClassVar[Dict[str, Bender]] = {"code": S("code"), "ttl": S("ttl")}
code: Optional[int] = field(default=None)
ttl: Optional[int] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendBucketCdnPolicy:
kind: ClassVar[str] = "gcp_backend_bucket_cdn_policy"
kind_display: ClassVar[str] = "GCP Backend Bucket CDN Policy"
kind_description: ClassVar[str] = (
"CDN Policy is a feature in Google Cloud Platform that allows you to"
" configure the behavior of the Content Delivery Network (CDN) for a Backend"
" Bucket. It includes settings such as cache expiration, cache control, and"
" content encoding."
)
mapping: ClassVar[Dict[str, Bender]] = {
"bypass_cache_on_request_headers": S("bypassCacheOnRequestHeaders", default=[]) >> ForallBend(S("headerName")),
"cache_key_policy": S("cacheKeyPolicy", default={}) >> Bend(GcpBackendBucketCdnPolicyCacheKeyPolicy.mapping),
"cache_mode": S("cacheMode"),
"client_ttl": S("clientTtl"),
"default_ttl": S("defaultTtl"),
"max_ttl": S("maxTtl"),
"negative_caching": S("negativeCaching"),
"negative_caching_policy": S("negativeCachingPolicy", default=[])
>> ForallBend(GcpBackendBucketCdnPolicyNegativeCachingPolicy.mapping),
"request_coalescing": S("requestCoalescing"),
"serve_while_stale": S("serveWhileStale"),
"signed_url_cache_max_age_sec": S("signedUrlCacheMaxAgeSec"),
"signed_url_key_names": S("signedUrlKeyNames", default=[]),
}
bypass_cache_on_request_headers: Optional[List[str]] = field(default=None)
cache_key_policy: Optional[GcpBackendBucketCdnPolicyCacheKeyPolicy] = field(default=None)
cache_mode: Optional[str] = field(default=None)
client_ttl: Optional[int] = field(default=None)
default_ttl: Optional[int] = field(default=None)
max_ttl: Optional[int] = field(default=None)
negative_caching: Optional[bool] = field(default=None)
negative_caching_policy: Optional[List[GcpBackendBucketCdnPolicyNegativeCachingPolicy]] = field(default=None)
request_coalescing: Optional[bool] = field(default=None)
serve_while_stale: Optional[int] = field(default=None)
signed_url_cache_max_age_sec: Optional[str] = field(default=None)
signed_url_key_names: Optional[List[str]] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendBucket(GcpResource, BaseBucket):
kind: ClassVar[str] = "gcp_backend_bucket"
_kind_display: ClassVar[str] = "GCP Backend Bucket"
_kind_description: ClassVar[str] = "GCP Backend Bucket is a Cloud Storage bucket that serves as the backend for a Google Cloud Load Balancer. It stores and delivers static content to users, reducing load on application servers. Backend Buckets can handle large files and high traffic volumes, improving website performance and reducing costs by offloading static content delivery from compute resources." # fmt: skip
_docs_url: ClassVar[str] = "https://cloud.google.com/load-balancing/docs/backend-bucket"
_kind_service: ClassVar[Optional[str]] = service_name
api_spec: ClassVar[GcpApiSpec] = GcpApiSpec(
service=service_name,
version="v1",
accessors=["backendBuckets"],
action="list",
request_parameter={"project": "{project}"},
request_parameter_in={"project"},
response_path="items",
response_regional_sub_path=None,
mutate_iam_permissions=["compute.backendBuckets.update", "compute.backendBuckets.delete"],
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id").or_else(S("bucketName")).or_else(S("selfLink")),
"tags": S("labels", default={}),
"name": S("bucketName"),
"ctime": S("creationTimestamp"),
"description": S("description"),
"link": S("selfLink"),
"label_fingerprint": S("labelFingerprint"),
"deprecation_status": S("deprecated", default={}) >> Bend(GcpDeprecationStatus.mapping),
"bucket_name": S("bucketName"),
"backend_bucket_cdn_policy": S("cdnPolicy", default={}) >> Bend(GcpBackendBucketCdnPolicy.mapping),
"compression_mode": S("compressionMode"),
"custom_response_headers": S("customResponseHeaders", default=[]),
"edge_security_policy": S("edgeSecurityPolicy"),
"enable_cdn": S("enableCdn"),
}
bucket_name: Optional[str] = field(default=None)
backend_bucket_cdn_policy: Optional[GcpBackendBucketCdnPolicy] = field(default=None)
compression_mode: Optional[str] = field(default=None)
custom_response_headers: Optional[List[str]] = field(default=None)
edge_security_policy: Optional[str] = field(default=None)
enable_cdn: Optional[bool] = field(default=None)
@define(eq=False, slots=False)
class GcpBackend:
kind: ClassVar[str] = "gcp_backend"
kind_display: ClassVar[str] = "GCP Backend"
kind_description: ClassVar[str] = (
"A GCP backend refers to the infrastructure and services that power"
" applications and services on the Google Cloud Platform. It includes compute,"
" storage, networking, and other resources needed to support the backend"
" operations of GCP applications."
)
mapping: ClassVar[Dict[str, Bender]] = {
"balancing_mode": S("balancingMode"),
"capacity_scaler": S("capacityScaler"),
"description": S("description"),
"failover": S("failover"),
"group": S("group"),
"max_connections": S("maxConnections"),
"max_connections_per_endpoint": S("maxConnectionsPerEndpoint"),
"max_connections_per_instance": S("maxConnectionsPerInstance"),
"max_rate": S("maxRate"),
"max_rate_per_endpoint": S("maxRatePerEndpoint"),
"max_rate_per_instance": S("maxRatePerInstance"),
"max_utilization": S("maxUtilization"),
}
balancing_mode: Optional[str] = field(default=None)
capacity_scaler: Optional[float] = field(default=None)
description: Optional[str] = field(default=None)
failover: Optional[bool] = field(default=None)
group: Optional[str] = field(default=None)
max_connections: Optional[int] = field(default=None)
max_connections_per_endpoint: Optional[int] = field(default=None)
max_connections_per_instance: Optional[int] = field(default=None)
max_rate: Optional[int] = field(default=None)
max_rate_per_endpoint: Optional[float] = field(default=None)
max_rate_per_instance: Optional[float] = field(default=None)
max_utilization: Optional[float] = field(default=None)
@define(eq=False, slots=False)
class GcpCacheKeyPolicy:
kind: ClassVar[str] = "gcp_cache_key_policy"
kind_display: ClassVar[str] = "GCP Cache Key Policy"
kind_description: ClassVar[str] = (
"A cache key policy in Google Cloud Platform (GCP) is used to define the"
" criteria for caching content in a cache storage system."
)
mapping: ClassVar[Dict[str, Bender]] = {
"include_host": S("includeHost"),
"include_http_headers": S("includeHttpHeaders", default=[]),
"include_named_cookies": S("includeNamedCookies", default=[]),
"include_protocol": S("includeProtocol"),
"include_query_string": S("includeQueryString"),
"query_string_blacklist": S("queryStringBlacklist", default=[]),
"query_string_whitelist": S("queryStringWhitelist", default=[]),
}
include_host: Optional[bool] = field(default=None)
include_http_headers: Optional[List[str]] = field(default=None)
include_named_cookies: Optional[List[str]] = field(default=None)
include_protocol: Optional[bool] = field(default=None)
include_query_string: Optional[bool] = field(default=None)
query_string_blacklist: Optional[List[str]] = field(default=None)
query_string_whitelist: Optional[List[str]] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceCdnPolicyNegativeCachingPolicy:
kind: ClassVar[str] = "gcp_backend_service_cdn_policy_negative_caching_policy"
kind_display: ClassVar[str] = "GCP Backend Service CDN Policy - Negative Caching Policy"
kind_description: ClassVar[str] = (
"Negative Caching Policy is a feature of the GCP Backend Service CDN Policy"
" that allows caching of responses with error status codes, reducing the load"
" on the origin server for subsequent requests."
)
mapping: ClassVar[Dict[str, Bender]] = {"code": S("code"), "ttl": S("ttl")}
code: Optional[int] = field(default=None)
ttl: Optional[int] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceCdnPolicy:
kind: ClassVar[str] = "gcp_backend_service_cdn_policy"
kind_display: ClassVar[str] = "GCP Backend Service CDN Policy"
kind_description: ClassVar[str] = (
"A CDN Policy is a configuration that specifies how a content delivery"
" network (CDN) delivers content for a backend service in Google Cloud"
" Platform (GCP). It includes rules for cache settings, cache key"
" preservation, and request routing."
)
mapping: ClassVar[Dict[str, Bender]] = {
"bypass_cache_on_request_headers": S("bypassCacheOnRequestHeaders", default=[]) >> ForallBend(S("headerName")),
"cache_key_policy": S("cacheKeyPolicy", default={}) >> Bend(GcpCacheKeyPolicy.mapping),
"cache_mode": S("cacheMode"),
"client_ttl": S("clientTtl"),
"default_ttl": S("defaultTtl"),
"max_ttl": S("maxTtl"),
"negative_caching": S("negativeCaching"),
"negative_caching_policy": S("negativeCachingPolicy", default=[])
>> ForallBend(GcpBackendServiceCdnPolicyNegativeCachingPolicy.mapping),
"request_coalescing": S("requestCoalescing"),
"serve_while_stale": S("serveWhileStale"),
"signed_url_cache_max_age_sec": S("signedUrlCacheMaxAgeSec"),
"signed_url_key_names": S("signedUrlKeyNames", default=[]),
}
bypass_cache_on_request_headers: Optional[List[str]] = field(default=None)
cache_key_policy: Optional[GcpCacheKeyPolicy] = field(default=None)
cache_mode: Optional[str] = field(default=None)
client_ttl: Optional[int] = field(default=None)
default_ttl: Optional[int] = field(default=None)
max_ttl: Optional[int] = field(default=None)
negative_caching: Optional[bool] = field(default=None)
negative_caching_policy: Optional[List[GcpBackendServiceCdnPolicyNegativeCachingPolicy]] = field(default=None)
request_coalescing: Optional[bool] = field(default=None)
serve_while_stale: Optional[int] = field(default=None)
signed_url_cache_max_age_sec: Optional[str] = field(default=None)
signed_url_key_names: Optional[List[str]] = field(default=None)
@define(eq=False, slots=False)
class GcpCircuitBreakers:
kind: ClassVar[str] = "gcp_circuit_breakers"
kind_display: ClassVar[str] = "GCP Circuit Breakers"
kind_description: ClassVar[str] = (
"GCP Backend Service Circuit Breakers set limits on connections, pending"
" requests, and retries to prevent overloading backend resources."
)
mapping: ClassVar[Dict[str, Bender]] = {
"max_connections": S("maxConnections"),
"max_pending_requests": S("maxPendingRequests"),
"max_requests": S("maxRequests"),
"max_requests_per_connection": S("maxRequestsPerConnection"),
"max_retries": S("maxRetries"),
}
max_connections: Optional[int] = field(default=None)
max_pending_requests: Optional[int] = field(default=None)
max_requests: Optional[int] = field(default=None)
max_requests_per_connection: Optional[int] = field(default=None)
max_retries: Optional[int] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceConnectionTrackingPolicy:
kind: ClassVar[str] = "gcp_backend_service_connection_tracking_policy"
kind_display: ClassVar[str] = "GCP Backend Service Connection Tracking Policy"
kind_description: ClassVar[str] = (
"GCP Backend Service Connection Tracking Policy defines the parameters for managing connections,"
" including persistence on unhealthy backends, affinity strength, idle timeout, and tracking mode."
)
mapping: ClassVar[Dict[str, Bender]] = {
"connection_persistence_on_unhealthy_backends": S("connectionPersistenceOnUnhealthyBackends"),
"enable_strong_affinity": S("enableStrongAffinity"),
"idle_timeout_sec": S("idleTimeoutSec"),
"tracking_mode": S("trackingMode"),
}
connection_persistence_on_unhealthy_backends: Optional[str] = field(default=None)
enable_strong_affinity: Optional[bool] = field(default=None)
idle_timeout_sec: Optional[int] = field(default=None)
tracking_mode: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpDuration:
kind: ClassVar[str] = "gcp_duration"
kind_display: ClassVar[str] = "GCP Duration"
kind_description: ClassVar[str] = "Duration represents a length of time in Google Cloud Platform (GCP) services."
mapping: ClassVar[Dict[str, Bender]] = {"nanos": S("nanos"), "seconds": S("seconds")}
nanos: Optional[int] = field(default=None)
seconds: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpConsistentHashLoadBalancerSettingsHttpCookie:
kind: ClassVar[str] = "gcp_consistent_hash_load_balancer_settings_http_cookie"
kind_display: ClassVar[str] = "GCP Consistent Hash Load Balancer with HTTP Cookie"
kind_description: ClassVar[str] = (
"Consistent Hash Load Balancer with HTTP Cookie is a load balancing setting"
" in Google Cloud Platform (GCP) that uses consistent hashing with the HTTP"
" cookie to route requests to backend services."
)
mapping: ClassVar[Dict[str, Bender]] = {
"name": S("name"),
"path": S("path"),
"ttl": S("ttl", default={}) >> Bend(GcpDuration.mapping),
}
name: Optional[str] = field(default=None)
path: Optional[str] = field(default=None)
ttl: Optional[GcpDuration] = field(default=None)
@define(eq=False, slots=False)
class GcpConsistentHashLoadBalancerSettings:
kind: ClassVar[str] = "gcp_consistent_hash_load_balancer_settings"
kind_display: ClassVar[str] = "GCP Consistent Hash Load Balancer Settings"
kind_description: ClassVar[str] = (
"Consistent Hash Load Balancer Settings in Google Cloud Platform (GCP) allow"
" you to route incoming requests to different backend instances based on the"
" hashed value of certain request components, providing a consistent routing"
" mechanism."
)
mapping: ClassVar[Dict[str, Bender]] = {
"http_cookie": S("httpCookie", default={}) >> Bend(GcpConsistentHashLoadBalancerSettingsHttpCookie.mapping),
"http_header_name": S("httpHeaderName"),
"minimum_ring_size": S("minimumRingSize"),
}
http_cookie: Optional[GcpConsistentHashLoadBalancerSettingsHttpCookie] = field(default=None)
http_header_name: Optional[str] = field(default=None)
minimum_ring_size: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceFailoverPolicy:
kind: ClassVar[str] = "gcp_backend_service_failover_policy"
kind_display: ClassVar[str] = "GCP Backend Service Failover Policy"
kind_description: ClassVar[str] = (
"A failover policy for Google Cloud Platform backend services, which"
" determines how traffic is redirected to different backends in the event of a"
" failure."
)
mapping: ClassVar[Dict[str, Bender]] = {
"disable_connection_drain_on_failover": S("disableConnectionDrainOnFailover"),
"drop_traffic_if_unhealthy": S("dropTrafficIfUnhealthy"),
"failover_ratio": S("failoverRatio"),
}
disable_connection_drain_on_failover: Optional[bool] = field(default=None)
drop_traffic_if_unhealthy: Optional[bool] = field(default=None)
failover_ratio: Optional[float] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceIAP:
kind: ClassVar[str] = "gcp_backend_service_iap"
kind_display: ClassVar[str] = "GCP Backend Service IAP"
kind_description: ClassVar[str] = (
"GCP Backend Service IAP is a feature in Google Cloud Platform that provides"
" Identity-Aware Proxy (IAP) for a backend service, allowing fine-grained"
" access control to the backend resources based on user identity and context."
)
mapping: ClassVar[Dict[str, Bender]] = {
"enabled": S("enabled"),
"oauth2_client_id": S("oauth2ClientId"),
"oauth2_client_secret": S("oauth2ClientSecret"),
"oauth2_client_secret_sha256": S("oauth2ClientSecretSha256"),
}
enabled: Optional[bool] = field(default=None)
oauth2_client_id: Optional[str] = field(default=None)
oauth2_client_secret: Optional[str] = field(default=None)
oauth2_client_secret_sha256: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceLocalityLoadBalancingPolicyConfigCustomPolicy:
kind: ClassVar[str] = "gcp_backend_service_locality_load_balancing_policy_config_custom_policy"
kind_display: ClassVar[str] = "GCP Backend Service Locality Load Balancing Policy Config Custom Policy"
kind_description: ClassVar[str] = (
"This resource allows customization of the locality load balancing policy"
" configuration for a Google Cloud Platform (GCP) Backend Service. Locality"
" load balancing is a policy that optimizes traffic distribution based on the"
" proximity of backend services to clients, improving the overall performance"
" and latency of the system."
)
mapping: ClassVar[Dict[str, Bender]] = {"data": S("data"), "name": S("name")}
data: Optional[str] = field(default=None)
name: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceLocalityLoadBalancingPolicyConfig:
kind: ClassVar[str] = "gcp_backend_service_locality_load_balancing_policy_config"
kind_display: ClassVar[str] = "GCP Backend Service Locality Load Balancing Policy Config"
kind_description: ClassVar[str] = (
"This is a configuration for the locality load balancing policy in Google"
" Cloud Platform's Backend Service, which enables routing of traffic to"
" backend instances based on their geographical locality for better"
" performance and availability."
)
mapping: ClassVar[Dict[str, Bender]] = {
"custom_policy": S("customPolicy", default={})
>> Bend(GcpBackendServiceLocalityLoadBalancingPolicyConfigCustomPolicy.mapping),
"policy": S("policy", "name"),
}
custom_policy: Optional[GcpBackendServiceLocalityLoadBalancingPolicyConfigCustomPolicy] = field(default=None)
policy: Optional[str] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendServiceLogConfig:
kind: ClassVar[str] = "gcp_backend_service_log_config"
kind_display: ClassVar[str] = "GCP Backend Service Log Config"
kind_description: ClassVar[str] = (
"Backend Service Log Config allows you to configure logging for a Google"
" Cloud Platform (GCP) backend service, providing visibility into the requests"
" and responses processed by the service."
)
mapping: ClassVar[Dict[str, Bender]] = {"enable": S("enable"), "sample_rate": S("sampleRate")}
enable: Optional[bool] = field(default=None)
sample_rate: Optional[float] = field(default=None)
@define(eq=False, slots=False)
class GcpOutlierDetection:
kind: ClassVar[str] = "gcp_outlier_detection"
kind_display: ClassVar[str] = "GCP Outlier Detection"
kind_description: ClassVar[str] = (
"GCP Outlier Detection is a service feature within Google Cloud's Backend Services that identifies"
" instances in a load balancing pool which are performing suboptimally and temporarily removes them"
" from the service rotation based on various health checks and error thresholds."
)
mapping: ClassVar[Dict[str, Bender]] = {
"base_ejection_time": S("baseEjectionTime", default={}) >> Bend(GcpDuration.mapping),
"consecutive_errors": S("consecutiveErrors"),
"consecutive_gateway_failure": S("consecutiveGatewayFailure"),
"enforcing_consecutive_errors": S("enforcingConsecutiveErrors"),
"enforcing_consecutive_gateway_failure": S("enforcingConsecutiveGatewayFailure"),
"enforcing_success_rate": S("enforcingSuccessRate"),
"interval": S("interval", default={}) >> Bend(GcpDuration.mapping),
"max_ejection_percent": S("maxEjectionPercent"),
"success_rate_minimum_hosts": S("successRateMinimumHosts"),
"success_rate_request_volume": S("successRateRequestVolume"),
"success_rate_stdev_factor": S("successRateStdevFactor"),
}
base_ejection_time: Optional[GcpDuration] = field(default=None)
consecutive_errors: Optional[int] = field(default=None)
consecutive_gateway_failure: Optional[int] = field(default=None)
enforcing_consecutive_errors: Optional[int] = field(default=None)
enforcing_consecutive_gateway_failure: Optional[int] = field(default=None)
enforcing_success_rate: Optional[int] = field(default=None)
interval: Optional[GcpDuration] = field(default=None)
max_ejection_percent: Optional[int] = field(default=None)
success_rate_minimum_hosts: Optional[int] = field(default=None)
success_rate_request_volume: Optional[int] = field(default=None)
success_rate_stdev_factor: Optional[int] = field(default=None)
@define(eq=False, slots=False)
class GcpSecuritySettings:
kind: ClassVar[str] = "gcp_security_settings"
kind_display: ClassVar[str] = "GCP Security Settings"
kind_description: ClassVar[str] = (
"GCP Security Settings refers to the configuration options and policies that"
" are put in place to ensure the security of resources and data on the Google"
" Cloud Platform."
)
mapping: ClassVar[Dict[str, Bender]] = {
"client_tls_policy": S("clientTlsPolicy"),
"subject_alt_names": S("subjectAltNames", default=[]),
}
client_tls_policy: Optional[str] = field(default=None)
subject_alt_names: Optional[List[str]] = field(default=None)
@define(eq=False, slots=False)
class GcpBackendService(GcpResource):
kind: ClassVar[str] = "gcp_backend_service"
_kind_display: ClassVar[str] = "GCP Backend Service"
_kind_description: ClassVar[str] = "GCP Backend Service is a Google Cloud Platform component that distributes incoming network traffic across multiple backend instances. It handles load balancing, health checks, and traffic routing for applications and services. Backend Service defines how traffic reaches the backend instances and can be used with various load balancing options in GCP." # fmt: skip
_docs_url: ClassVar[str] = "https://cloud.google.com/load-balancing/docs/backend-service"
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "load_balancer", "group": "networking"}
_reference_kinds: ClassVar[ModelReference] = {
"predecessors": {
"default": ["gcp_network"],
"delete": [
"gcp_instance_group",
"gcp_network_endpoint_group",
"gcp_health_check",
"gcp_http_health_check",
"gcp_https_health_check",
],
},
"successors": {
"default": [
"gcp_instance_group",
"gcp_network_endpoint_group",
"gcp_health_check",
"gcp_http_health_check",
"gcp_https_health_check",
],
"delete": ["gcp_target_tcp_proxy", "gcp_target_ssl_proxy"],
},
}
api_spec: ClassVar[GcpApiSpec] = GcpApiSpec(
service=service_name,
version="v1",
accessors=["backendServices"],
action="aggregatedList",
request_parameter={"project": "{project}"},
request_parameter_in={"project"},
response_path="items",
response_regional_sub_path="backendServices",
mutate_iam_permissions=["compute.backendServices.update", "compute.backendServices.delete"],
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("name").or_else(S("id")).or_else(S("selfLink")),
"tags": S("labels", default={}),
"name": S("name"),
"ctime": S("creationTimestamp"),
"description": S("description"),
"link": S("selfLink"),
"label_fingerprint": S("labelFingerprint"),
"deprecation_status": S("deprecated", default={}) >> Bend(GcpDeprecationStatus.mapping),
"affinity_cookie_ttl_sec": S("affinityCookieTtlSec"),
"backend_service_backends": S("backends", default=[]) >> ForallBend(GcpBackend.mapping),
"backend_service_cdn_policy": S("cdnPolicy", default={}) >> Bend(GcpBackendServiceCdnPolicy.mapping),
"circuit_breakers": S("circuitBreakers", default={}) >> Bend(GcpCircuitBreakers.mapping),
"compression_mode": S("compressionMode"),
"connection_draining": S("connectionDraining", "drainingTimeoutSec"),
"connection_tracking_policy": S("connectionTrackingPolicy", default={})
>> Bend(GcpBackendServiceConnectionTrackingPolicy.mapping),
"consistent_hash": S("consistentHash", default={}) >> Bend(GcpConsistentHashLoadBalancerSettings.mapping),
"custom_request_headers": S("customRequestHeaders", default=[]),
"custom_response_headers": S("customResponseHeaders", default=[]),
"edge_security_policy": S("edgeSecurityPolicy"),
"enable_cdn": S("enableCDN"),
"failover_policy": S("failoverPolicy", default={}) >> Bend(GcpBackendServiceFailoverPolicy.mapping),
"fingerprint": S("fingerprint"),
"health_checks": S("healthChecks", default=[]),
"iap": S("iap", default={}) >> Bend(GcpBackendServiceIAP.mapping),
"load_balancing_scheme": S("loadBalancingScheme"),
"locality_lb_policies": S("localityLbPolicies", default=[])
>> ForallBend(GcpBackendServiceLocalityLoadBalancingPolicyConfig.mapping),
"locality_lb_policy": S("localityLbPolicy"),
"backend_service_log_config": S("logConfig", default={}) >> Bend(GcpBackendServiceLogConfig.mapping),
"max_stream_duration": S("maxStreamDuration", default={}) >> Bend(GcpDuration.mapping),
"network": S("network"),
"outlier_detection": S("outlierDetection", default={}) >> Bend(GcpOutlierDetection.mapping),
"port": S("port"),
"port_name": S("portName"),
"protocol": S("protocol"),
"security_policy": S("securityPolicy"),
"security_settings": S("securitySettings", default={}) >> Bend(GcpSecuritySettings.mapping),
"service_bindings": S("serviceBindings", default=[]),
"session_affinity": S("sessionAffinity"),
"subsetting": S("subsetting", "policy"),
"timeout_sec": S("timeoutSec"),
}
affinity_cookie_ttl_sec: Optional[int] = field(default=None)
backend_service_backends: Optional[List[GcpBackend]] = field(default=None)
backend_service_cdn_policy: Optional[GcpBackendServiceCdnPolicy] = field(default=None)
circuit_breakers: Optional[GcpCircuitBreakers] = field(default=None)
compression_mode: Optional[str] = field(default=None)
connection_draining: Optional[int] = field(default=None)
connection_tracking_policy: Optional[GcpBackendServiceConnectionTrackingPolicy] = field(default=None)
consistent_hash: Optional[GcpConsistentHashLoadBalancerSettings] = field(default=None)
custom_request_headers: Optional[List[str]] = field(default=None)
custom_response_headers: Optional[List[str]] = field(default=None)
edge_security_policy: Optional[str] = field(default=None)
enable_cdn: Optional[bool] = field(default=None)
failover_policy: Optional[GcpBackendServiceFailoverPolicy] = field(default=None)
fingerprint: Optional[str] = field(default=None)
health_checks: Optional[List[str]] = field(default=None)
iap: Optional[GcpBackendServiceIAP] = field(default=None)
load_balancing_scheme: Optional[str] = field(default=None)
locality_lb_policies: Optional[List[GcpBackendServiceLocalityLoadBalancingPolicyConfig]] = field(default=None)
locality_lb_policy: Optional[str] = field(default=None)
backend_service_log_config: Optional[GcpBackendServiceLogConfig] = field(default=None)
max_stream_duration: Optional[GcpDuration] = field(default=None)
network: Optional[str] = field(default=None)
outlier_detection: Optional[GcpOutlierDetection] = field(default=None)
port: Optional[int] = field(default=None)
port_name: Optional[str] = field(default=None)
protocol: Optional[str] = field(default=None)
security_policy: Optional[str] = field(default=None)
security_settings: Optional[GcpSecuritySettings] = field(default=None)
service_bindings: Optional[List[str]] = field(default=None)
session_affinity: Optional[str] = field(default=None)
subsetting: Optional[str] = field(default=None)
timeout_sec: Optional[int] = field(default=None)
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
for check in self.health_checks or []:
builder.dependant_node(self, clazz=health_check_types(), link=check)
for backend in self.backend_service_backends or []:
if backend.group:
builder.dependant_node(self, link=backend.group)
if self.network:
builder.add_edge(self, reverse=True, clazz=GcpNetwork, link=self.network)
resource_group_map: Dict[str, str] = {
"local-ssd": "LocalSSD",
"pd-balanced": "SSD",
"pd-ssd": "SSD",
"pd-standard": "PDStandard",
}
@define(eq=False, slots=False)
class GcpDiskType(GcpResource, BaseVolumeType):
kind: ClassVar[str] = "gcp_disk_type"
_kind_display: ClassVar[str] = "GCP Disk Type"
_kind_description: ClassVar[str] = "GCP Disk Type refers to the storage options available for virtual machine instances in Google Cloud Platform. It includes persistent disks like standard HDD, balanced SSD, and performance SSD, as well as local SSDs. These disk types offer different performance characteristics and price points, catering to various workload requirements and storage needs in cloud computing environments." # fmt: skip
_docs_url: ClassVar[str] = "https://cloud.google.com/compute/docs/disks#disk-types"
_kind_service: ClassVar[Optional[str]] = service_name
_metadata: ClassVar[Dict[str, Any]] = {"icon": "type", "group": "storage"}
api_spec: ClassVar[GcpApiSpec] = GcpApiSpec(
service=service_name,
version="v1",
accessors=["diskTypes"],
action="aggregatedList",
request_parameter={"project": "{project}"},
request_parameter_in={"project"},
response_path="items",
response_regional_sub_path="diskTypes",
mutate_iam_permissions=[], # can not be mutated