public static List<String> toStringList(List<RegistryName> values) { List<String> list = new ArrayList<String>(values.size()); for (RegistryName value : values) { if (value == null) { list.add(""); } else { list.add(value.toString()); } } return list; }
public static String format(String project, String location, String registry) { return newBuilder() .setProject(project) .setLocation(location) .setRegistry(registry) .build() .toString(); }
/** * Gets the access control policy for a resource. Returns an empty policy if the resource exists * and does not have a policy set. * * <p>Sample code: * * <pre><code> * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { * RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); * Policy response = deviceManagerClient.getIamPolicy(resource); * } * </code></pre> * * @param resource REQUIRED: The resource for which the policy is being requested. `resource` is * usually specified as a path. For example, a Project resource is specified as * `projects/{project}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Policy getIamPolicy(RegistryName resource) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(resource == null ? null : resource.toString()) .build(); return getIamPolicy(request); }
/** * Deletes a device registry configuration. * * <p>Sample code: * * <pre><code> * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { * RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); * deviceManagerClient.deleteDeviceRegistry(name); * } * </code></pre> * * @param name The name of the device registry. For example, * `projects/example-project/locations/us-central1/registries/my-registry`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteDeviceRegistry(RegistryName name) { DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.newBuilder() .setName(name == null ? null : name.toString()) .build(); deleteDeviceRegistry(request); }
/** * Gets a device registry configuration. * * <p>Sample code: * * <pre><code> * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { * RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); * DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); * } * </code></pre> * * @param name The name of the device registry. For example, * `projects/example-project/locations/us-central1/registries/my-registry`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final DeviceRegistry getDeviceRegistry(RegistryName name) { GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder() .setName(name == null ? null : name.toString()) .build(); return getDeviceRegistry(request); }
/** * List devices in a device registry. * * <p>Sample code: * * <pre><code> * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { * RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); * for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { * // doThingsWith(element); * } * } * </code></pre> * * @param parent The device registry path. Required. For example, * `projects/my-project/locations/us-central1/registries/my-registry`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListDevicesPagedResponse listDevices(RegistryName parent) { ListDevicesRequest request = ListDevicesRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .build(); return listDevices(request); }
.setResource(resource == null ? null : resource.toString()) .addAllPermissions(permissions) .build();
/** * Creates a device in a device registry. * * <p>Sample code: * * <pre><code> * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { * RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); * Device device = Device.newBuilder().build(); * Device response = deviceManagerClient.createDevice(parent, device); * } * </code></pre> * * @param parent The name of the device registry where this device should be created. For example, * `projects/example-project/locations/us-central1/registries/my-registry`. * @param device The device registration details. The field `name` must be empty. The server * generates `name` from the device registry `id` and the `parent` field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Device createDevice(RegistryName parent, Device device) { CreateDeviceRequest request = CreateDeviceRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setDevice(device) .build(); return createDevice(request); }
/** * Sets the access control policy on the specified resource. Replaces any existing policy. * * <p>Sample code: * * <pre><code> * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { * RegistryName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); * Policy policy = Policy.newBuilder().build(); * Policy response = deviceManagerClient.setIamPolicy(resource, policy); * } * </code></pre> * * @param resource REQUIRED: The resource for which the policy is being specified. `resource` is * usually specified as a path. For example, a Project resource is specified as * `projects/{project}`. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud * Platform services (such as Projects) might reject them. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Policy setIamPolicy(RegistryName resource, Policy policy) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(resource == null ? null : resource.toString()) .setPolicy(policy) .build(); return setIamPolicy(request); }
.setParent(parent == null ? null : parent.toString()) .setGatewayId(gatewayId) .setDeviceId(deviceId)
.setParent(parent == null ? null : parent.toString()) .setGatewayId(gatewayId) .setDeviceId(deviceId)
@Test @SuppressWarnings("all") public void getDeviceRegistryTest() { String id = "id3355"; RegistryName name2 = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); DeviceRegistry expectedResponse = DeviceRegistry.newBuilder().setId(id).setName(name2.toString()).build(); mockDeviceManager.addResponse(expectedResponse); RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); DeviceRegistry actualResponse = client.getDeviceRegistry(name); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockDeviceManager.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetDeviceRegistryRequest actualRequest = (GetDeviceRegistryRequest) actualRequests.get(0); Assert.assertEquals(name, RegistryName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void createDeviceRegistryTest() { String id = "id3355"; RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); DeviceRegistry expectedResponse = DeviceRegistry.newBuilder().setId(id).setName(name.toString()).build(); mockDeviceManager.addResponse(expectedResponse); LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); DeviceRegistry actualResponse = client.createDeviceRegistry(parent, deviceRegistry); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockDeviceManager.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateDeviceRegistryRequest actualRequest = (CreateDeviceRegistryRequest) actualRequests.get(0); Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); Assert.assertEquals(deviceRegistry, actualRequest.getDeviceRegistry()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void updateDeviceRegistryTest() { String id = "id3355"; RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); DeviceRegistry expectedResponse = DeviceRegistry.newBuilder().setId(id).setName(name.toString()).build(); mockDeviceManager.addResponse(expectedResponse); DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); DeviceRegistry actualResponse = client.updateDeviceRegistry(deviceRegistry, updateMask); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockDeviceManager.getRequests(); Assert.assertEquals(1, actualRequests.size()); UpdateDeviceRegistryRequest actualRequest = (UpdateDeviceRegistryRequest) actualRequests.get(0); Assert.assertEquals(deviceRegistry, actualRequest.getDeviceRegistry()); Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
public static List<String> toStringList(List<RegistryName> values) { List<String> list = new ArrayList<String>(values.size()); for (RegistryName value : values) { if (value == null) { list.add(""); } else { list.add(value.toString()); } } return list; }
public static String format(String project, String location, String registry) { return newBuilder() .setProject(project) .setLocation(location) .setRegistry(registry) .build() .toString(); }