Example #1
0
    def delete(self):
        stub = reservation_pb2_grpc.ComputeReservationServiceStub(
            channel.Channel())
        request = reservation_pb2.DeleteComputeReservationRequest()
        request.service_account_file = self.service_account_file
        if Primitive.to_proto(self.id):
            request.resource.id = Primitive.to_proto(self.id)

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

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

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

        if ReservationSpecificReservation.to_proto(self.specific_reservation):
            request.resource.specific_reservation.CopyFrom(
                ReservationSpecificReservation.to_proto(
                    self.specific_reservation))
        else:
            request.resource.ClearField("specific_reservation")
        if Primitive.to_proto(self.commitment):
            request.resource.commitment = Primitive.to_proto(self.commitment)

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

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

        response = stub.DeleteComputeReservation(request)
Example #2
0
    def list(self, project, zone, service_account_file=""):
        stub = reservation_pb2_grpc.ComputeReservationServiceStub(
            channel.Channel())
        request = reservation_pb2.ListComputeReservationRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Zone = zone

        return stub.ListComputeReservation(request).items
    def delete(self, project, zone, name, service_account_file=""):
        stub = reservation_pb2_grpc.ComputeReservationServiceStub(
            channel.Channel())
        request = reservation_pb2.DeleteComputeReservationRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Zone = zone

        request.Name = name

        response = stub.DeleteComputeReservation(request)
Example #4
0
    def apply(self):
        stub = reservation_pb2_grpc.ComputeReservationServiceStub(
            channel.Channel())
        request = reservation_pb2.ApplyComputeReservationRequest()
        if Primitive.to_proto(self.id):
            request.resource.id = Primitive.to_proto(self.id)

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

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

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

        if ReservationSpecificReservation.to_proto(self.specific_reservation):
            request.resource.specific_reservation.CopyFrom(
                ReservationSpecificReservation.to_proto(
                    self.specific_reservation))
        else:
            request.resource.ClearField("specific_reservation")
        if Primitive.to_proto(self.commitment):
            request.resource.commitment = Primitive.to_proto(self.commitment)

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

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

        request.service_account_file = self.service_account_file

        response = stub.ApplyComputeReservation(request)
        self.id = Primitive.from_proto(response.id)
        self.self_link = Primitive.from_proto(response.self_link)
        self.zone = Primitive.from_proto(response.zone)
        self.description = Primitive.from_proto(response.description)
        self.name = Primitive.from_proto(response.name)
        self.specific_reservation = ReservationSpecificReservation.from_proto(
            response.specific_reservation)
        self.commitment = Primitive.from_proto(response.commitment)
        self.specific_reservation_required = Primitive.from_proto(
            response.specific_reservation_required)
        self.status = ReservationStatusEnum.from_proto(response.status)
        self.project = Primitive.from_proto(response.project)