Esempio n. 1
0
    def list(self, project, service_account_file=""):
        stub = log_metric_pb2_grpc.LoggingLogMetricServiceStub(channel.Channel())
        request = log_metric_pb2.ListLoggingLogMetricRequest()
        request.service_account_file = service_account_file
        request.Project = project

        return stub.ListLoggingLogMetric(request).items
Esempio n. 2
0
    def apply(self):
        stub = log_metric_pb2_grpc.LoggingLogMetricServiceStub(channel.Channel())
        request = log_metric_pb2.ApplyLoggingLogMetricRequest()
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

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

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

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

        if LogMetricMetricDescriptor.to_proto(self.metric_descriptor):
            request.resource.metric_descriptor.CopyFrom(
                LogMetricMetricDescriptor.to_proto(self.metric_descriptor)
            )
        else:
            request.resource.ClearField("metric_descriptor")
        if Primitive.to_proto(self.value_extractor):
            request.resource.value_extractor = Primitive.to_proto(self.value_extractor)

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

        if LogMetricBucketOptions.to_proto(self.bucket_options):
            request.resource.bucket_options.CopyFrom(
                LogMetricBucketOptions.to_proto(self.bucket_options)
            )
        else:
            request.resource.ClearField("bucket_options")
        if Primitive.to_proto(self.resolution):
            request.resource.resolution = Primitive.to_proto(self.resolution)

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

        request.service_account_file = self.service_account_file

        response = stub.ApplyLoggingLogMetric(request)
        self.name = Primitive.from_proto(response.name)
        self.description = Primitive.from_proto(response.description)
        self.filter = Primitive.from_proto(response.filter)
        self.disabled = Primitive.from_proto(response.disabled)
        self.metric_descriptor = LogMetricMetricDescriptor.from_proto(
            response.metric_descriptor
        )
        self.value_extractor = Primitive.from_proto(response.value_extractor)
        self.label_extractors = Primitive.from_proto(response.label_extractors)
        self.bucket_options = LogMetricBucketOptions.from_proto(response.bucket_options)
        self.create_time = Primitive.from_proto(response.create_time)
        self.update_time = Primitive.from_proto(response.update_time)
        self.resolution = Primitive.from_proto(response.resolution)
        self.project = Primitive.from_proto(response.project)
Esempio n. 3
0
    def delete(self, project, name, service_account_file=""):
        stub = log_metric_pb2_grpc.LoggingLogMetricServiceStub(
            channel.Channel())
        request = log_metric_pb2.DeleteLoggingLogMetricRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Name = name

        response = stub.DeleteLoggingLogMetric(request)