Пример #1
0
    def list(self, project, location, service_account_file=""):
        stub = instance_pb2_grpc.RedisInstanceServiceStub(channel.Channel())
        request = instance_pb2.ListRedisInstanceRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        return stub.ListRedisInstance(request).items
    def delete(self, project, location, name, service_account_file=""):
        stub = instance_pb2_grpc.RedisInstanceServiceStub(channel.Channel())
        request = instance_pb2.DeleteRedisInstanceRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        request.Name = name

        response = stub.DeleteRedisInstance(request)
Пример #3
0
    def apply(self):
        stub = instance_pb2_grpc.RedisInstanceServiceStub(channel.Channel())
        request = instance_pb2.ApplyRedisInstanceRequest()
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

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

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

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

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

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

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

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

        if InstanceTierEnum.to_proto(self.tier):
            request.resource.tier = InstanceTierEnum.to_proto(self.tier)

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

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

        if InstanceConnectModeEnum.to_proto(self.connect_mode):
            request.resource.connect_mode = InstanceConnectModeEnum.to_proto(
                self.connect_mode)

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

        if InstanceTransitEncryptionModeEnum.to_proto(
                self.transit_encryption_mode):
            request.resource.transit_encryption_mode = InstanceTransitEncryptionModeEnum.to_proto(
                self.transit_encryption_mode)

        if InstanceMaintenancePolicy.to_proto(self.maintenance_policy):
            request.resource.maintenance_policy.CopyFrom(
                InstanceMaintenancePolicy.to_proto(self.maintenance_policy))
        else:
            request.resource.ClearField("maintenance_policy")
        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)

        request.service_account_file = self.service_account_file

        response = stub.ApplyRedisInstance(request)
        self.name = Primitive.from_proto(response.name)
        self.display_name = Primitive.from_proto(response.display_name)
        self.labels = Primitive.from_proto(response.labels)
        self.location_id = Primitive.from_proto(response.location_id)
        self.alternative_location_id = Primitive.from_proto(
            response.alternative_location_id)
        self.redis_version = Primitive.from_proto(response.redis_version)
        self.reserved_ip_range = Primitive.from_proto(
            response.reserved_ip_range)
        self.host = Primitive.from_proto(response.host)
        self.port = Primitive.from_proto(response.port)
        self.current_location_id = Primitive.from_proto(
            response.current_location_id)
        self.create_time = Primitive.from_proto(response.create_time)
        self.state = InstanceStateEnum.from_proto(response.state)
        self.status_message = Primitive.from_proto(response.status_message)
        self.redis_configs = Primitive.from_proto(response.redis_configs)
        self.tier = InstanceTierEnum.from_proto(response.tier)
        self.memory_size_gb = Primitive.from_proto(response.memory_size_gb)
        self.authorized_network = Primitive.from_proto(
            response.authorized_network)
        self.persistence_iam_identity = Primitive.from_proto(
            response.persistence_iam_identity)
        self.connect_mode = InstanceConnectModeEnum.from_proto(
            response.connect_mode)
        self.auth_enabled = Primitive.from_proto(response.auth_enabled)
        self.server_ca_certs = InstanceServerCaCertsArray.from_proto(
            response.server_ca_certs)
        self.transit_encryption_mode = InstanceTransitEncryptionModeEnum.from_proto(
            response.transit_encryption_mode)
        self.maintenance_policy = InstanceMaintenancePolicy.from_proto(
            response.maintenance_policy)
        self.maintenance_schedule = InstanceMaintenanceSchedule.from_proto(
            response.maintenance_schedule)
        self.project = Primitive.from_proto(response.project)
        self.location = Primitive.from_proto(response.location)
Пример #4
0
    def delete(self):
        stub = instance_pb2_grpc.RedisInstanceServiceStub(channel.Channel())
        request = instance_pb2.DeleteRedisInstanceRequest()
        request.service_account_file = self.service_account_file
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

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

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

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

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

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

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

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

        if InstanceTierEnum.to_proto(self.tier):
            request.resource.tier = InstanceTierEnum.to_proto(self.tier)

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

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

        if InstanceConnectModeEnum.to_proto(self.connect_mode):
            request.resource.connect_mode = InstanceConnectModeEnum.to_proto(
                self.connect_mode)

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

        if InstanceTransitEncryptionModeEnum.to_proto(
                self.transit_encryption_mode):
            request.resource.transit_encryption_mode = InstanceTransitEncryptionModeEnum.to_proto(
                self.transit_encryption_mode)

        if InstanceMaintenancePolicy.to_proto(self.maintenance_policy):
            request.resource.maintenance_policy.CopyFrom(
                InstanceMaintenancePolicy.to_proto(self.maintenance_policy))
        else:
            request.resource.ClearField("maintenance_policy")
        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.DeleteRedisInstance(request)