23
23
from google .cloud .aiplatform .compat .types import (
24
24
matching_engine_deployed_index_ref as gca_matching_engine_deployed_index_ref ,
25
25
matching_engine_index as gca_matching_engine_index ,
26
+ encryption_spec as gca_encryption_spec ,
26
27
)
27
28
from google .cloud .aiplatform import initializer
28
29
from google .cloud .aiplatform .matching_engine import (
@@ -109,6 +110,7 @@ def _create(
109
110
request_metadata : Optional [Sequence [Tuple [str , str ]]] = (),
110
111
sync : bool = True ,
111
112
index_update_method : Optional [str ] = None ,
113
+ encryption_spec_key_name : Optional [str ] = None ,
112
114
) -> "MatchingEngineIndex" :
113
115
"""Creates a MatchingEngineIndex resource.
114
116
@@ -162,6 +164,18 @@ def _create(
162
164
Optional. The update method to use with this index. Choose
163
165
stream_update or batch_update. If not set, batch update will be
164
166
used by default.
167
+ encryption_spec_key_name (str):
168
+ Optional. The Cloud KMS resource identifier of the customer
169
+ managed encryption key used to protect the index. Has the
170
+ form:
171
+ ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
172
+ The key needs to be in the same region as where the compute
173
+ resource is created.
174
+
175
+ If set, this index and all sub-resources of this index will be
176
+ secured by this key.
177
+ The key needs to be in the same region as where the index is
178
+ created.
165
179
166
180
Returns:
167
181
MatchingEngineIndex - Index resource object
@@ -181,6 +195,9 @@ def _create(
181
195
"contentsDeltaUri" : contents_delta_uri ,
182
196
},
183
197
index_update_method = index_update_method_enum ,
198
+ encryption_spec = gca_encryption_spec .EncryptionSpec (
199
+ kms_key_name = encryption_spec_key_name
200
+ ),
184
201
)
185
202
186
203
if labels :
@@ -394,6 +411,7 @@ def create_tree_ah_index(
394
411
request_metadata : Optional [Sequence [Tuple [str , str ]]] = (),
395
412
sync : bool = True ,
396
413
index_update_method : Optional [str ] = None ,
414
+ encryption_spec_key_name : Optional [str ] = None ,
397
415
) -> "MatchingEngineIndex" :
398
416
"""Creates a MatchingEngineIndex resource that uses the tree-AH algorithm.
399
417
@@ -472,6 +490,18 @@ def create_tree_ah_index(
472
490
Optional. The update method to use with this index. Choose
473
491
STREAM_UPDATE or BATCH_UPDATE. If not set, batch update will be
474
492
used by default.
493
+ encryption_spec_key_name (str):
494
+ Optional. The Cloud KMS resource identifier of the customer
495
+ managed encryption key used to protect the index. Has the
496
+ form:
497
+ ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
498
+ The key needs to be in the same region as where the compute
499
+ resource is created.
500
+
501
+ If set, this index and all sub-resources of this index will be
502
+ secured by this key.
503
+ The key needs to be in the same region as where the index is
504
+ created.
475
505
476
506
Returns:
477
507
MatchingEngineIndex - Index resource object
@@ -502,6 +532,7 @@ def create_tree_ah_index(
502
532
request_metadata = request_metadata ,
503
533
sync = sync ,
504
534
index_update_method = index_update_method ,
535
+ encryption_spec_key_name = encryption_spec_key_name ,
505
536
)
506
537
507
538
@classmethod
@@ -521,6 +552,7 @@ def create_brute_force_index(
521
552
request_metadata : Optional [Sequence [Tuple [str , str ]]] = (),
522
553
sync : bool = True ,
523
554
index_update_method : Optional [str ] = None ,
555
+ encryption_spec_key_name : Optional [str ] = None ,
524
556
) -> "MatchingEngineIndex" :
525
557
"""Creates a MatchingEngineIndex resource that uses the brute force algorithm.
526
558
@@ -588,6 +620,18 @@ def create_brute_force_index(
588
620
Optional. The update method to use with this index. Choose
589
621
stream_update or batch_update. If not set, batch update will be
590
622
used by default.
623
+ encryption_spec_key_name (str):
624
+ Optional. The Cloud KMS resource identifier of the customer
625
+ managed encryption key used to protect the index. Has the
626
+ form:
627
+ ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
628
+ The key needs to be in the same region as where the compute
629
+ resource is created.
630
+
631
+ If set, this index and all sub-resources of this index will be
632
+ secured by this key.
633
+ The key needs to be in the same region as where the index is
634
+ created.
591
635
592
636
Returns:
593
637
MatchingEngineIndex - Index resource object
@@ -614,6 +658,7 @@ def create_brute_force_index(
614
658
request_metadata = request_metadata ,
615
659
sync = sync ,
616
660
index_update_method = index_update_method ,
661
+ encryption_spec_key_name = encryption_spec_key_name ,
617
662
)
618
663
619
664
0 commit comments