@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * * * <pre> * The resource name of the desired metric: * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" * </pre> * * <code>string metric_name = 1;</code> */ public Builder clearMetricName() { metricName_ = getDefaultInstance().getMetricName(); onChanged(); return this; } /**
@java.lang.Override public com.google.logging.v2.GetLogMetricRequest buildPartial() { com.google.logging.v2.GetLogMetricRequest result = new com.google.logging.v2.GetLogMetricRequest(this); result.metricName_ = metricName_; onBuilt(); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + METRIC_NAME_FIELD_NUMBER; hash = (53 * hash) + getMetricName().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
@java.lang.Override public com.google.logging.v2.GetLogMetricRequest getDefaultInstanceForType() { return com.google.logging.v2.GetLogMetricRequest.getDefaultInstance(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.logging.v2.GetLogMetricRequest)) { return super.equals(obj); } com.google.logging.v2.GetLogMetricRequest other = (com.google.logging.v2.GetLogMetricRequest) obj; boolean result = true; result = result && getMetricName().equals(other.getMetricName()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getMetricNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, metricName_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public com.google.logging.v2.GetLogMetricRequest build() { com.google.logging.v2.GetLogMetricRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.logging.v2.GetLogMetricRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
@Test @SuppressWarnings("all") public void getLogMetricTest() { MetricName name = ProjectMetricName.of("[PROJECT]", "[METRIC]"); String description = "description-1724546052"; String filter = "filter-1274492040"; String valueExtractor = "valueExtractor2047672534"; LogMetric expectedResponse = LogMetric.newBuilder() .setName(name.toString()) .setDescription(description) .setFilter(filter) .setValueExtractor(valueExtractor) .build(); mockMetricsServiceV2.addResponse(expectedResponse); MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); LogMetric actualResponse = client.getLogMetric(metricName); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetLogMetricRequest actualRequest = (GetLogMetricRequest) actualRequests.get(0); Assert.assertEquals(metricName, MetricNames.parse(actualRequest.getMetricName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getMetricNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, metricName_); } unknownFields.writeTo(output); }
/** * Gets a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); * LogMetric response = metricsClient.getLogMetric(metricName); * } * </code></pre> * * @param metricName The resource name of the desired metric: * <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric getLogMetric(MetricName metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() .setMetricName(metricName == null ? null : metricName.toString()) .build(); return getLogMetric(request); }
public Builder mergeFrom(com.google.logging.v2.GetLogMetricRequest other) { if (other == com.google.logging.v2.GetLogMetricRequest.getDefaultInstance()) return this; if (!other.getMetricName().isEmpty()) { metricName_ = other.metricName_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.logging.v2.GetLogMetricRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
/** * Gets a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); * LogMetric response = metricsClient.getLogMetric(metricName.toString()); * } * </code></pre> * * @param metricName The resource name of the desired metric: * <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric getLogMetric(String metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(metricName).build(); return getLogMetric(request); }
@Test public void testGetMetric_Null() { ApiFuture<LogMetric> response = ApiFutures.immediateFuture(null); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); assertNull(logging.getMetric(METRIC_NAME)); }
@Override public ApiFuture<Metric> getMetricAsync(String metric) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() .setMetricName(ProjectMetricName.of(getOptions().getProjectId(), metric).toString()) .build(); return transform(rpc.get(request), Metric.fromPbFunction(this)); }
@Test public void testGetMetricAsync_Null() throws ExecutionException, InterruptedException { ApiFuture<LogMetric> response = ApiFutures.immediateFuture(null); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); assertNull(logging.getMetricAsync(METRIC_NAME).get()); }
@Test public void testGetMetric() { LogMetric sinkPb = METRIC_INFO.toPb(); ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Metric sink = logging.getMetric(METRIC_NAME); assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink); }