public Builder mergeFrom(com.google.cloud.iot.v1.CreateDeviceRequest other) { if (other == com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance()) return this; if (!other.getParent().isEmpty()) { parent_ = other.parent_; onChanged(); } if (other.hasDevice()) { mergeDevice(other.getDevice()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.cloud.iot.v1.CreateDeviceRequest buildPartial() { com.google.cloud.iot.v1.CreateDeviceRequest result = new com.google.cloud.iot.v1.CreateDeviceRequest(this); result.parent_ = parent_; if (deviceBuilder_ == null) { result.device_ = device_; } else { result.device_ = deviceBuilder_.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 (device_ != null) { output.writeMessage(2, getDevice()); } unknownFields.writeTo(output); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.iot.v1.CreateDeviceRequest)) { return super.equals(obj); } com.google.cloud.iot.v1.CreateDeviceRequest other = (com.google.cloud.iot.v1.CreateDeviceRequest) obj; boolean result = true; result = result && getParent().equals(other.getParent()); result = result && (hasDevice() == other.hasDevice()); if (hasDevice()) { result = result && getDevice().equals(other.getDevice()); } 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 (hasDevice()) { hash = (37 * hash) + DEVICE_FIELD_NUMBER; hash = (53 * hash) + getDevice().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * The name of the device registry where this device should be created. * For example, * `projects/example-project/locations/us-central1/registries/my-registry`. * </pre> * * <code>string parent = 1;</code> */ public Builder clearParent() { parent_ = getDefaultInstance().getParent(); onChanged(); return this; } /**
@Test @SuppressWarnings("all") public void createDeviceTest() { String id = "id3355"; DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); long numId = 1034366860L; boolean blocked = true; Device expectedResponse = Device.newBuilder() .setId(id) .setName(name.toString()) .setNumId(numId) .setBlocked(blocked) .build(); mockDeviceManager.addResponse(expectedResponse); RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); Device device = Device.newBuilder().build(); Device actualResponse = client.createDevice(parent, device); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockDeviceManager.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateDeviceRequest actualRequest = (CreateDeviceRequest) actualRequests.get(0); Assert.assertEquals(parent, RegistryName.parse(actualRequest.getParent())); Assert.assertEquals(device, actualRequest.getDevice()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Override public Map<String, String> extract(CreateDeviceRequest request) { ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put("parent", String.valueOf(request.getParent())); return params.build(); } })
@java.lang.Override public com.google.cloud.iot.v1.CreateDeviceRequest getDefaultInstanceForType() { return com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance(); }
/** * * * <pre> * The device registration details. The field `name` must be empty. The server * generates `name` from the device registry `id` and the * `parent` field. * </pre> * * <code>.google.cloud.iot.v1.Device device = 2;</code> */ public com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder() { return getDevice(); }
@java.lang.Override public com.google.cloud.iot.v1.CreateDeviceRequest build() { com.google.cloud.iot.v1.CreateDeviceRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } 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 (hasDevice()) { hash = (37 * hash) + DEVICE_FIELD_NUMBER; hash = (53 * hash) + getDevice().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.iot.v1.CreateDeviceRequest)) { return super.equals(obj); } com.google.cloud.iot.v1.CreateDeviceRequest other = (com.google.cloud.iot.v1.CreateDeviceRequest) obj; boolean result = true; result = result && getParent().equals(other.getParent()); result = result && (hasDevice() == other.hasDevice()); if (hasDevice()) { result = result && getDevice().equals(other.getDevice()); } result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * The name of the device registry where this device should be created. * For example, * `projects/example-project/locations/us-central1/registries/my-registry`. * </pre> * * <code>string parent = 1;</code> */ public Builder clearParent() { parent_ = getDefaultInstance().getParent(); onChanged(); return this; } /**
@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 (device_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDevice()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(
/** * * * <pre> * The device registration details. The field `name` must be empty. The server * generates `name` from the device registry `id` and the * `parent` field. * </pre> * * <code>.google.cloud.iot.v1.Device device = 2;</code> */ public com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder() { return getDevice(); }
@java.lang.Override public com.google.cloud.iot.v1.CreateDeviceRequest build() { com.google.cloud.iot.v1.CreateDeviceRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
public Builder mergeFrom(com.google.cloud.iot.v1.CreateDeviceRequest other) { if (other == com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance()) return this; if (!other.getParent().isEmpty()) { parent_ = other.parent_; onChanged(); } if (other.hasDevice()) { mergeDevice(other.getDevice()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }