@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
public Builder mergeFrom(com.google.logging.v2.CreateLogMetricRequest other) { if (other == com.google.logging.v2.CreateLogMetricRequest.getDefaultInstance()) return this; if (!other.getParent().isEmpty()) { parent_ = other.parent_; onChanged(); } if (other.hasMetric()) { mergeMetric(other.getMetric()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public com.google.logging.v2.CreateLogMetricRequest buildPartial() { com.google.logging.v2.CreateLogMetricRequest result = new com.google.logging.v2.CreateLogMetricRequest(this); result.parent_ = parent_; if (metricBuilder_ == null) { result.metric_ = metric_; } else { result.metric_ = metricBuilder_.build(); } onBuilt(); return result; }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getParentBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); } if (metric_ != null) { output.writeMessage(2, getMetric()); } unknownFields.writeTo(output); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.logging.v2.CreateLogMetricRequest)) { return super.equals(obj); } com.google.logging.v2.CreateLogMetricRequest other = (com.google.logging.v2.CreateLogMetricRequest) obj; boolean result = true; result = result && getParent().equals(other.getParent()); result = result && (hasMetric() == other.hasMetric()); if (hasMetric()) { result = result && getMetric().equals(other.getMetric()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PARENT_FIELD_NUMBER; hash = (53 * hash) + getParent().hashCode(); if (hasMetric()) { hash = (37 * hash) + METRIC_FIELD_NUMBER; hash = (53 * hash) + getMetric().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The resource name of the project in which to create the metric: * "projects/[PROJECT_ID]" * The new metric must be provided in the request. * </pre> * * <code>string parent = 1;</code> */ public Builder clearParent() { parent_ = getDefaultInstance().getParent(); onChanged(); return this; } /**
@Test @SuppressWarnings("all") public void createLogMetricTest() { 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); ParentName parent = ProjectName.of("[PROJECT]"); LogMetric metric = LogMetric.newBuilder().build(); LogMetric actualResponse = client.createLogMetric(parent, metric); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateLogMetricRequest actualRequest = (CreateLogMetricRequest) actualRequests.get(0); Assert.assertEquals(parent, ParentNames.parse(actualRequest.getParent())); Assert.assertEquals(metric, actualRequest.getMetric()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@java.lang.Override public com.google.logging.v2.CreateLogMetricRequest getDefaultInstanceForType() { return com.google.logging.v2.CreateLogMetricRequest.getDefaultInstance(); }
/** * * * <pre> * The new logs-based metric, which must not have an identifier that * already exists. * </pre> * * <code>.google.logging.v2.LogMetric metric = 2;</code> */ public com.google.logging.v2.LogMetricOrBuilder getMetricOrBuilder() { return getMetric(); }
@java.lang.Override public com.google.logging.v2.CreateLogMetricRequest build() { com.google.logging.v2.CreateLogMetricRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getParentBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); } if (metric_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getMetric()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.logging.v2.CreateLogMetricRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
/** * Creates a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * ParentName parent = ProjectName.of("[PROJECT]"); * LogMetric metric = LogMetric.newBuilder().build(); * LogMetric response = metricsClient.createLogMetric(parent, metric); * } * </code></pre> * * @param parent The resource name of the project in which to create the metric: * <p>"projects/[PROJECT_ID]" * <p>The new metric must be provided in the request. * @param metric The new logs-based metric, which must not have an identifier that already exists. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric createLogMetric(ParentName parent, LogMetric metric) { CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setMetric(metric) .build(); return createLogMetric(request); }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.logging.v2.CreateLogMetricRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
/** * Creates a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * ParentName parent = ProjectName.of("[PROJECT]"); * LogMetric metric = LogMetric.newBuilder().build(); * LogMetric response = metricsClient.createLogMetric(parent.toString(), metric); * } * </code></pre> * * @param parent The resource name of the project in which to create the metric: * <p>"projects/[PROJECT_ID]" * <p>The new metric must be provided in the request. * @param metric The new logs-based metric, which must not have an identifier that already exists. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric createLogMetric(String parent, LogMetric metric) { CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder().setParent(parent).setMetric(metric).build(); return createLogMetric(request); }
@Override public ApiFuture<Metric> createAsync(MetricInfo metric) { CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder() .setParent(ProjectName.of(getOptions().getProjectId()).toString()) .setMetric(metric.toPb()) .build(); return transform(rpc.create(request), Metric.fromPbFunction(this)); }
@Test public void testCreateMetric() { LogMetric metricPb = METRIC_INFO.toPb(); ApiFuture<LogMetric> response = ApiFutures.immediateFuture(metricPb); CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder().setParent(PROJECT_PB).setMetric(metricPb).build(); EasyMock.expect(loggingRpcMock.create(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Metric metric = logging.create(METRIC_INFO); assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), metric); }
@Test public void testCreateMetricAsync() throws ExecutionException, InterruptedException { LogMetric metricPb = METRIC_INFO.toPb(); ApiFuture<LogMetric> response = ApiFutures.immediateFuture(metricPb); CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder().setParent(PROJECT_PB).setMetric(metricPb).build(); EasyMock.expect(loggingRpcMock.create(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Metric metric = logging.createAsync(METRIC_INFO).get(); assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), metric); }
/** * Creates a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * ParentName parent = ProjectName.of("[PROJECT]"); * LogMetric metric = LogMetric.newBuilder().build(); * LogMetric response = metricsClient.createLogMetric(parent, metric); * } * </code></pre> * * @param parent The resource name of the project in which to create the metric: * <p>"projects/[PROJECT_ID]" * <p>The new metric must be provided in the request. * @param metric The new logs-based metric, which must not have an identifier that already exists. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric createLogMetric(ParentName parent, LogMetric metric) { CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setMetric(metric) .build(); return createLogMetric(request); }