File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ # [START genappbuilder_cancel_operation]
17
+ from google .cloud import discoveryengine
18
+ from google .longrunning import operations_pb2
19
+
20
+ # TODO(developer): Uncomment these variables before running the sample.
21
+ # Example: `projects/{project}/locations/{location}/collections/{default_collection}/dataStores/{search_engine_id}/branches/{0}/operations/{operation_id}`
22
+ # operation_name = "YOUR_OPERATION_NAME"
23
+
24
+
25
+ def cancel_operation_sample (operation_name : str ) -> None :
26
+ # Create a client
27
+ client = discoveryengine .DocumentServiceClient ()
28
+
29
+ # Make CancelOperation request
30
+ request = operations_pb2 .CancelOperationRequest (name = operation_name )
31
+ client .cancel_operation (request = request )
32
+
33
+ return
34
+
35
+
36
+ # [END genappbuilder_cancel_operation]
Original file line number Diff line number Diff line change 15
15
16
16
import os
17
17
18
+ from discoveryengine import cancel_operation_sample
18
19
from discoveryengine import get_operation_sample
19
20
from discoveryengine import list_operations_sample
20
21
from discoveryengine import poll_operation_sample
@@ -59,3 +60,11 @@ def test_poll_operation():
59
60
except NotFound as e :
60
61
print (e .message )
61
62
pass
63
+
64
+
65
+ def test_cancel_operation ():
66
+ try :
67
+ cancel_operation_sample .cancel_operation_sample (operation_name = operation_name )
68
+ except NotFound as e :
69
+ print (e .message )
70
+ pass
Original file line number Diff line number Diff line change 1
- google-cloud-discoveryengine == 0.13.4
1
+ google-cloud-discoveryengine == 0.13.8
You can’t perform that action at this time.
0 commit comments