/** Adds or replaces metadata entries. */ public Metadata putAll(Map<String, String> input) { for (Map.Entry<String, String> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } return this; }
newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser()));
/** Adds or replaces metadata entries. */ public Metadata putAll(Map<String, String> input) { for (Map.Entry<String, String> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } return this; }
newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser()));
/** Adds or replaces metadata entries. */ public Metadata putAll(Map<String, String> input) { for (Map.Entry<String, String> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } return this; }
newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser()));
/** Adds or replaces metadata entries. */ public Metadata putAll(Map<String, String> input) { for (Map.Entry<String, String> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } return this; }
metadata.put("windows-keys", new GsonBuilder().disableHtmlEscaping().create().toJson(extractKeyMetadata(keys, userName, email))); } catch (NoSuchAlgorithmException e) { Throwables.propagate(e);
metadata.put("windows-keys", new GsonBuilder().disableHtmlEscaping().create().toJson(extractKeyMetadata(keys, userName, email))); } catch (NoSuchAlgorithmException e) { Throwables.propagate(e);
metadata.put("windows-keys", new GsonBuilder().disableHtmlEscaping().create().toJson(extractKeyMetadata(keys, userName, email))); } catch (NoSuchAlgorithmException e) { Throwables.propagate(e);
metadata.put("windows-keys", new GsonBuilder().disableHtmlEscaping().create().toJson(extractKeyMetadata(keys, userName, email))); } catch (NoSuchAlgorithmException e) { Throwables.propagate(e);
@Test(groups = "live", dependsOnMethods = "getProject") public void addItemToMetadata() { initialMetadataSize = project.commonInstanceMetadata().size(); initialFingerprint = project.commonInstanceMetadata().fingerprint(); Metadata metadata = project.commonInstanceMetadata().put(METADATA_ITEM_KEY, METADATA_ITEM_VALUE); assertOperationDoneSuccessfully(api.project().setCommonInstanceMetadata(metadata)); project = api.project().get(); assertNotNull(project); assertTrue(project.commonInstanceMetadata().containsKey(METADATA_ITEM_KEY), project.toString()); assertEquals(project.commonInstanceMetadata().get(METADATA_ITEM_KEY), METADATA_ITEM_VALUE); assertNotNull(project.commonInstanceMetadata().fingerprint()); }
public void insert_allOptions() throws Exception { server.enqueue(jsonResponse("/zone_operation.json")); NewInstance newInstance = NewInstance.create( "test-1", // name URI.create(url("/projects/party/zones/us-central1-a/machineTypes/n1-standard-1")), // machineType URI.create(url("/projects/party/global/networks/default")), // network null, // subnetwork Arrays.asList(AttachDisk.existingBootDisk(URI.create(url("/projects/party/zones/us-central1-a/disks/test")))), "desc", // description null // tags ); newInstance.metadata().put("aKey", "aValue"); assertEquals(instanceApi().create(newInstance), new ParseZoneOperationTest().expected(url("/projects"))); assertSent(server, "POST", "/projects/party/zones/us-central1-a/instances", stringFromResource("/instance_insert.json")); }
@Test(groups = "live", dependsOnMethods = "testListInstance") public void testSetMetadataForInstance() { Instance originalInstance = api().get(INSTANCE_NAME); Metadata update = Metadata.create(originalInstance.metadata().fingerprint()) .put(METADATA_ITEM_KEY, METADATA_ITEM_VALUE); assertOperationDoneSuccessfully(api().setMetadata(INSTANCE_NAME, update)); Instance modifiedInstance = api().get(INSTANCE_NAME); assertTrue(modifiedInstance.metadata().containsKey(METADATA_ITEM_KEY)); assertEquals(modifiedInstance.metadata().get(METADATA_ITEM_KEY), METADATA_ITEM_VALUE); assertNotNull(modifiedInstance.metadata().fingerprint()); }
@Consumes(APPLICATION_JSON) public Project expected(String baseUrl) { return Project.create( // "13024414184846275913", // id URI.create(baseUrl + "/761326798069"), // selfLink "party", // name "", // description Metadata.create("efgh").put("propA", "valueA").put("propB", "valueB"), // commonInstanceMetadata ImmutableList.of( // Quota.create("INSTANCES", 0, 8), // Quota.create("CPUS", 0, 8), // Quota.create("EPHEMERAL_ADDRESSES", 0, 8), // Quota.create("DISKS", 0, 8), // Quota.create("DISKS_TOTAL_GB", 0, 100), // Quota.create("SNAPSHOTS", 0, 1000), // Quota.create("NETWORKS", 1, 5), // Quota.create("FIREWALLS", 2, 100), // Quota.create("IMAGES", 0, 100)), // quotas null, // externalIpAddresses new SimpleDateFormatDateService().iso8601DateParse("2012-10-24T20:13:16.252"), // creationTimestamp UsageExportLocation.create("test-bucket", "report-prefix")// usageExportLocation ); } }
public void setMetadata() throws Exception { server.enqueue(jsonResponse("/zone_operation.json")); assertEquals(instanceApi().setMetadata("test-1", Metadata.create("efgh").put("foo", "bar")), new ParseZoneOperationTest().expected(url("/projects"))); assertSent(server, "POST", "/projects/party/zones/us-central1-a/instances/test-1/setMetadata", stringFromResource("/instance_set_metadata.json")); }
public void insert_builder_allOptions() throws Exception { server.enqueue(jsonResponse("/zone_operation.json")); NewInstance newInstance = new NewInstance.Builder( "test-1", // name URI.create(url("/projects/party/zones/us-central1-a/machineTypes/n1-standard-1")), // machineType URI.create(url("/projects/party/global/networks/default")), // network null, // subnetwork Arrays.asList(AttachDisk.existingBootDisk(URI.create(url("/projects/party/zones/us-central1-a/disks/test"))))) .canIpForward(true) .description("desc") .tags(null) .metadata(Metadata.create().put("aKey", "aValue")) .serviceAccounts(ImmutableList.of(ServiceAccount.create("default", ImmutableList.of("https://www.googleapis.com/auth/compute")))) .scheduling(Scheduling.create(OnHostMaintenance.MIGRATE, true, false)) .build(); assertEquals(instanceApi().create(newInstance), new ParseZoneOperationTest().expected(url("/projects"))); assertSent(server, "POST", "/projects/party/zones/us-central1-a/instances", stringFromResource("/instance_insert_full.json")); }
Tags.create(null, ImmutableList.of("foo", "bar")) // tags ); instance.metadata().put("mykey", "myvalue");