1# Copyright 2020 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# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 
    16 
    17"""Client and server classes corresponding to protobuf-defined services.""" 
    18import grpc 
    19from google.longrunning import ( 
    20    operations_proto_pb2 as google_dot_longrunning_dot_operations__pb2, 
    21) 
    22from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 
    23 
    24 
    25class OperationsStub(object): 
    26    """Manages long-running operations with an API service. 
    27 
    28    When an API method normally takes long time to complete, it can be designed 
    29    to return [Operation][google.longrunning.Operation] to the client, and the client can use this 
    30    interface to receive the real response asynchronously by polling the 
    31    operation resource, or pass the operation resource to another API (such as 
    32    Google Cloud Pub/Sub API) to receive the response.  Any API service that 
    33    returns long-running operations should implement the `Operations` interface 
    34    so developers can have a consistent client experience. 
    35    """ 
    36 
    37    def __init__(self, channel): 
    38        """Constructor. 
    39 
    40        Args: 
    41            channel: A grpc.Channel. 
    42        """ 
    43        self.ListOperations = channel.unary_unary( 
    44            "/google.longrunning.Operations/ListOperations", 
    45            request_serializer=google_dot_longrunning_dot_operations__pb2.ListOperationsRequest.SerializeToString, 
    46            response_deserializer=google_dot_longrunning_dot_operations__pb2.ListOperationsResponse.FromString, 
    47        ) 
    48        self.GetOperation = channel.unary_unary( 
    49            "/google.longrunning.Operations/GetOperation", 
    50            request_serializer=google_dot_longrunning_dot_operations__pb2.GetOperationRequest.SerializeToString, 
    51            response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, 
    52        ) 
    53        self.DeleteOperation = channel.unary_unary( 
    54            "/google.longrunning.Operations/DeleteOperation", 
    55            request_serializer=google_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.SerializeToString, 
    56            response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, 
    57        ) 
    58        self.CancelOperation = channel.unary_unary( 
    59            "/google.longrunning.Operations/CancelOperation", 
    60            request_serializer=google_dot_longrunning_dot_operations__pb2.CancelOperationRequest.SerializeToString, 
    61            response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, 
    62        ) 
    63        self.WaitOperation = channel.unary_unary( 
    64            "/google.longrunning.Operations/WaitOperation", 
    65            request_serializer=google_dot_longrunning_dot_operations__pb2.WaitOperationRequest.SerializeToString, 
    66            response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, 
    67        ) 
    68 
    69 
    70class OperationsServicer(object): 
    71    """Manages long-running operations with an API service. 
    72 
    73    When an API method normally takes long time to complete, it can be designed 
    74    to return [Operation][google.longrunning.Operation] to the client, and the client can use this 
    75    interface to receive the real response asynchronously by polling the 
    76    operation resource, or pass the operation resource to another API (such as 
    77    Google Cloud Pub/Sub API) to receive the response.  Any API service that 
    78    returns long-running operations should implement the `Operations` interface 
    79    so developers can have a consistent client experience. 
    80    """ 
    81 
    82    def ListOperations(self, request, context): 
    83        """Lists operations that match the specified filter in the request. If the 
    84        server doesn't support this method, it returns `UNIMPLEMENTED`. 
    85 
    86        NOTE: the `name` binding allows API services to override the binding 
    87        to use different resource name schemes, such as `users/*/operations`. To 
    88        override the binding, API services can add a binding such as 
    89        `"/v1/{name=users/*}/operations"` to their service configuration. 
    90        For backwards compatibility, the default name includes the operations 
    91        collection id, however overriding users must ensure the name binding 
    92        is the parent resource, without the operations collection id. 
    93        """ 
    94        context.set_code(grpc.StatusCode.UNIMPLEMENTED) 
    95        context.set_details("Method not implemented!") 
    96        raise NotImplementedError("Method not implemented!") 
    97 
    98    def GetOperation(self, request, context): 
    99        """Gets the latest state of a long-running operation.  Clients can use this 
    100        method to poll the operation result at intervals as recommended by the API 
    101        service. 
    102        """ 
    103        context.set_code(grpc.StatusCode.UNIMPLEMENTED) 
    104        context.set_details("Method not implemented!") 
    105        raise NotImplementedError("Method not implemented!") 
    106 
    107    def DeleteOperation(self, request, context): 
    108        """Deletes a long-running operation. This method indicates that the client is 
    109        no longer interested in the operation result. It does not cancel the 
    110        operation. If the server doesn't support this method, it returns 
    111        `google.rpc.Code.UNIMPLEMENTED`. 
    112        """ 
    113        context.set_code(grpc.StatusCode.UNIMPLEMENTED) 
    114        context.set_details("Method not implemented!") 
    115        raise NotImplementedError("Method not implemented!") 
    116 
    117    def CancelOperation(self, request, context): 
    118        """Starts asynchronous cancellation on a long-running operation.  The server 
    119        makes a best effort to cancel the operation, but success is not 
    120        guaranteed.  If the server doesn't support this method, it returns 
    121        `google.rpc.Code.UNIMPLEMENTED`.  Clients can use 
    122        [Operations.GetOperation][google.longrunning.Operations.GetOperation] or 
    123        other methods to check whether the cancellation succeeded or whether the 
    124        operation completed despite cancellation. On successful cancellation, 
    125        the operation is not deleted; instead, it becomes an operation with 
    126        an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, 
    127        corresponding to `Code.CANCELLED`. 
    128        """ 
    129        context.set_code(grpc.StatusCode.UNIMPLEMENTED) 
    130        context.set_details("Method not implemented!") 
    131        raise NotImplementedError("Method not implemented!") 
    132 
    133    def WaitOperation(self, request, context): 
    134        """Waits until the specified long-running operation is done or reaches at most 
    135        a specified timeout, returning the latest state.  If the operation is 
    136        already done, the latest state is immediately returned.  If the timeout 
    137        specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 
    138        timeout is used.  If the server does not support this method, it returns 
    139        `google.rpc.Code.UNIMPLEMENTED`. 
    140        Note that this method is on a best-effort basis.  It may return the latest 
    141        state before the specified timeout (including immediately), meaning even an 
    142        immediate response is no guarantee that the operation is done. 
    143        """ 
    144        context.set_code(grpc.StatusCode.UNIMPLEMENTED) 
    145        context.set_details("Method not implemented!") 
    146        raise NotImplementedError("Method not implemented!") 
    147 
    148 
    149def add_OperationsServicer_to_server(servicer, server): 
    150    rpc_method_handlers = { 
    151        "ListOperations": grpc.unary_unary_rpc_method_handler( 
    152            servicer.ListOperations, 
    153            request_deserializer=google_dot_longrunning_dot_operations__pb2.ListOperationsRequest.FromString, 
    154            response_serializer=google_dot_longrunning_dot_operations__pb2.ListOperationsResponse.SerializeToString, 
    155        ), 
    156        "GetOperation": grpc.unary_unary_rpc_method_handler( 
    157            servicer.GetOperation, 
    158            request_deserializer=google_dot_longrunning_dot_operations__pb2.GetOperationRequest.FromString, 
    159            response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, 
    160        ), 
    161        "DeleteOperation": grpc.unary_unary_rpc_method_handler( 
    162            servicer.DeleteOperation, 
    163            request_deserializer=google_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.FromString, 
    164            response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, 
    165        ), 
    166        "CancelOperation": grpc.unary_unary_rpc_method_handler( 
    167            servicer.CancelOperation, 
    168            request_deserializer=google_dot_longrunning_dot_operations__pb2.CancelOperationRequest.FromString, 
    169            response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, 
    170        ), 
    171        "WaitOperation": grpc.unary_unary_rpc_method_handler( 
    172            servicer.WaitOperation, 
    173            request_deserializer=google_dot_longrunning_dot_operations__pb2.WaitOperationRequest.FromString, 
    174            response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, 
    175        ), 
    176    } 
    177    generic_handler = grpc.method_handlers_generic_handler( 
    178        "google.longrunning.Operations", rpc_method_handlers 
    179    ) 
    180    server.add_generic_rpc_handlers((generic_handler,)) 
    181 
    182 
    183# This class is part of an EXPERIMENTAL API. 
    184class Operations(object): 
    185    """Manages long-running operations with an API service. 
    186 
    187    When an API method normally takes long time to complete, it can be designed 
    188    to return [Operation][google.longrunning.Operation] to the client, and the client can use this 
    189    interface to receive the real response asynchronously by polling the 
    190    operation resource, or pass the operation resource to another API (such as 
    191    Google Cloud Pub/Sub API) to receive the response.  Any API service that 
    192    returns long-running operations should implement the `Operations` interface 
    193    so developers can have a consistent client experience. 
    194    """ 
    195 
    196    @staticmethod 
    197    def ListOperations( 
    198        request, 
    199        target, 
    200        options=(), 
    201        channel_credentials=None, 
    202        call_credentials=None, 
    203        insecure=False, 
    204        compression=None, 
    205        wait_for_ready=None, 
    206        timeout=None, 
    207        metadata=None, 
    208    ): 
    209        return grpc.experimental.unary_unary( 
    210            request, 
    211            target, 
    212            "/google.longrunning.Operations/ListOperations", 
    213            google_dot_longrunning_dot_operations__pb2.ListOperationsRequest.SerializeToString, 
    214            google_dot_longrunning_dot_operations__pb2.ListOperationsResponse.FromString, 
    215            options, 
    216            channel_credentials, 
    217            insecure, 
    218            call_credentials, 
    219            compression, 
    220            wait_for_ready, 
    221            timeout, 
    222            metadata, 
    223        ) 
    224 
    225    @staticmethod 
    226    def GetOperation( 
    227        request, 
    228        target, 
    229        options=(), 
    230        channel_credentials=None, 
    231        call_credentials=None, 
    232        insecure=False, 
    233        compression=None, 
    234        wait_for_ready=None, 
    235        timeout=None, 
    236        metadata=None, 
    237    ): 
    238        return grpc.experimental.unary_unary( 
    239            request, 
    240            target, 
    241            "/google.longrunning.Operations/GetOperation", 
    242            google_dot_longrunning_dot_operations__pb2.GetOperationRequest.SerializeToString, 
    243            google_dot_longrunning_dot_operations__pb2.Operation.FromString, 
    244            options, 
    245            channel_credentials, 
    246            insecure, 
    247            call_credentials, 
    248            compression, 
    249            wait_for_ready, 
    250            timeout, 
    251            metadata, 
    252        ) 
    253 
    254    @staticmethod 
    255    def DeleteOperation( 
    256        request, 
    257        target, 
    258        options=(), 
    259        channel_credentials=None, 
    260        call_credentials=None, 
    261        insecure=False, 
    262        compression=None, 
    263        wait_for_ready=None, 
    264        timeout=None, 
    265        metadata=None, 
    266    ): 
    267        return grpc.experimental.unary_unary( 
    268            request, 
    269            target, 
    270            "/google.longrunning.Operations/DeleteOperation", 
    271            google_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.SerializeToString, 
    272            google_dot_protobuf_dot_empty__pb2.Empty.FromString, 
    273            options, 
    274            channel_credentials, 
    275            insecure, 
    276            call_credentials, 
    277            compression, 
    278            wait_for_ready, 
    279            timeout, 
    280            metadata, 
    281        ) 
    282 
    283    @staticmethod 
    284    def CancelOperation( 
    285        request, 
    286        target, 
    287        options=(), 
    288        channel_credentials=None, 
    289        call_credentials=None, 
    290        insecure=False, 
    291        compression=None, 
    292        wait_for_ready=None, 
    293        timeout=None, 
    294        metadata=None, 
    295    ): 
    296        return grpc.experimental.unary_unary( 
    297            request, 
    298            target, 
    299            "/google.longrunning.Operations/CancelOperation", 
    300            google_dot_longrunning_dot_operations__pb2.CancelOperationRequest.SerializeToString, 
    301            google_dot_protobuf_dot_empty__pb2.Empty.FromString, 
    302            options, 
    303            channel_credentials, 
    304            insecure, 
    305            call_credentials, 
    306            compression, 
    307            wait_for_ready, 
    308            timeout, 
    309            metadata, 
    310        ) 
    311 
    312    @staticmethod 
    313    def WaitOperation( 
    314        request, 
    315        target, 
    316        options=(), 
    317        channel_credentials=None, 
    318        call_credentials=None, 
    319        insecure=False, 
    320        compression=None, 
    321        wait_for_ready=None, 
    322        timeout=None, 
    323        metadata=None, 
    324    ): 
    325        return grpc.experimental.unary_unary( 
    326            request, 
    327            target, 
    328            "/google.longrunning.Operations/WaitOperation", 
    329            google_dot_longrunning_dot_operations__pb2.WaitOperationRequest.SerializeToString, 
    330            google_dot_longrunning_dot_operations__pb2.Operation.FromString, 
    331            options, 
    332            channel_credentials, 
    333            insecure, 
    334            call_credentials, 
    335            compression, 
    336            wait_for_ready, 
    337            timeout, 
    338            metadata, 
    339        )