def delete(self):
        stub = autoscaling_policy_pb2_grpc.DataprocAutoscalingPolicyServiceStub(
            channel.Channel())
        request = autoscaling_policy_pb2.DeleteDataprocAutoscalingPolicyRequest(
        )
        request.service_account_file = self.service_account_file
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if AutoscalingPolicyBasicAlgorithm.to_proto(self.basic_algorithm):
            request.resource.basic_algorithm.CopyFrom(
                AutoscalingPolicyBasicAlgorithm.to_proto(self.basic_algorithm))
        else:
            request.resource.ClearField("basic_algorithm")
        if AutoscalingPolicyWorkerConfig.to_proto(self.worker_config):
            request.resource.worker_config.CopyFrom(
                AutoscalingPolicyWorkerConfig.to_proto(self.worker_config))
        else:
            request.resource.ClearField("worker_config")
        if AutoscalingPolicySecondaryWorkerConfig.to_proto(
                self.secondary_worker_config):
            request.resource.secondary_worker_config.CopyFrom(
                AutoscalingPolicySecondaryWorkerConfig.to_proto(
                    self.secondary_worker_config))
        else:
            request.resource.ClearField("secondary_worker_config")
        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if Primitive.to_proto(self.location):
            request.resource.location = Primitive.to_proto(self.location)

        response = stub.DeleteDataprocAutoscalingPolicy(request)
    def list(self, project, location, service_account_file=""):
        stub = autoscaling_policy_pb2_grpc.DataprocAutoscalingPolicyServiceStub(
            channel.Channel())
        request = autoscaling_policy_pb2.ListDataprocAutoscalingPolicyRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        return stub.ListDataprocAutoscalingPolicy(request).items
Example #3
0
    def delete(self, project, location, name, service_account_file=""):
        stub = autoscaling_policy_pb2_grpc.DataprocAutoscalingPolicyServiceStub(
            channel.Channel())
        request = autoscaling_policy_pb2.DeleteDataprocAutoscalingPolicyRequest(
        )
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        request.Name = name

        response = stub.DeleteDataprocAutoscalingPolicy(request)