本文整理了Java中com.google.cloud.compute.deprecated.ZoneId.getZone()
方法的一些代码示例,展示了ZoneId.getZone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneId.getZone()
方法的具体详情如下:
包路径:com.google.cloud.compute.deprecated.ZoneId
类名称:ZoneId
方法名:getZone
[英]Returns the name of the zone.
[中]返回区域的名称。
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void run(Compute compute, ZoneId zone) {
System.out.printf("Zone info: %s%n", compute.getZone(zone.getZone()));
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void run(Compute compute, ZoneId zone) {
for (Operation operation : compute.listZoneOperations(zone.getZone()).iterateAll()) {
System.out.println(operation);
}
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Returns an instance identity given the zone identity and the instance name. The instance name
* must be 1-63 characters long and comply with RFC1035. Specifically, the name must match the
* regular expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a
* lowercase letter, and all following characters must be a dash, lowercase letter, or digit,
* except the last character, which cannot be a dash.
*
* @see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
*/
public static InstanceId of(ZoneId zoneId, String instance) {
return new InstanceId(zoneId.getProject(), zoneId.getZone(), instance);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Returns a disk identity given the zone identity and the disk name. The disk name must be 1-63
* characters long and comply with RFC1035. Specifically, the name must match the regular
* expression {@code [a-z]([-a-z0-9]*[a-z0-9])?} which means the first character must be a
* lowercase letter, and all following characters must be a dash, lowercase letter, or digit,
* except the last character, which cannot be a dash.
*
* @see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
*/
public static DiskId of(ZoneId zoneId, String disk) {
return new DiskId(zoneId.getProject(), zoneId.getZone(), disk);
}
代码示例来源:origin: googleapis/google-cloud-java
/** Returns a zone operation identity given the zone identity and the operation name. */
public static ZoneOperationId of(ZoneId zoneId, String operation) {
return new ZoneOperationId(zoneId.getProject(), zoneId.getZone(), operation);
}
代码示例来源:origin: googleapis/google-cloud-java
/** Returns a disk type identity given the zone identity and the disk type name. */
public static DiskTypeId of(ZoneId zoneId, String type) {
return new DiskTypeId(zoneId.getProject(), zoneId.getZone(), type);
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void run(Compute compute, ZoneId zone) {
Page<MachineType> machineTypePage;
if (zone != null) {
machineTypePage = compute.listMachineTypes(zone.getZone());
} else {
machineTypePage = compute.listMachineTypes();
}
for (MachineType diskType : machineTypePage.iterateAll()) {
System.out.println(diskType);
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void run(Compute compute, ZoneId zone) {
Page<DiskType> diskTypePage;
if (zone != null) {
diskTypePage = compute.listDiskTypes(zone.getZone());
} else {
diskTypePage = compute.listDiskTypes();
}
for (DiskType diskType : diskTypePage.iterateAll()) {
System.out.println(diskType);
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void run(Compute compute, ZoneId zone) {
Page<Instance> instancePage;
if (zone != null) {
instancePage = compute.listInstances(zone.getZone());
} else {
instancePage = compute.listInstances();
}
for (Instance instance : instancePage.iterateAll()) {
System.out.println(instance);
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZone_Null() {
EasyMock.expect(computeRpcMock.getZone(ZONE_ID.getZone(), EMPTY_RPC_OPTIONS)).andReturn(null);
EasyMock.replay(computeRpcMock);
compute = options.getService();
assertNull(compute.getZone(ZONE_ID.getZone()));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZone() {
EasyMock.expect(computeRpcMock.getZone(ZONE_ID.getZone(), EMPTY_RPC_OPTIONS))
.andReturn(ZONE.toPb());
EasyMock.replay(computeRpcMock);
compute = options.getService();
Zone zone = compute.getZone(ZONE_ID.getZone());
assertEquals(ZONE, zone);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZoneWithSelectedFields() {
Capture<Map<ComputeRpc.Option, Object>> capturedOptions = Capture.newInstance();
EasyMock.expect(computeRpcMock.getZone(eq(ZONE_ID.getZone()), capture(capturedOptions)))
.andReturn(ZONE.toPb());
EasyMock.replay(computeRpcMock);
compute = options.getService();
Zone zone = compute.getZone(ZONE_ID.getZone(), ZONE_OPTION_FIELDS);
String selector = (String) capturedOptions.getValue().get(ZONE_OPTION_FIELDS.getRpcOption());
assertTrue(selector.contains("selfLink"));
assertTrue(selector.contains("id"));
assertTrue(selector.contains("description"));
assertEquals(23, selector.length());
assertEquals(ZONE, zone);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testListZonesWithFilter() {
Page<Zone> zonePage =
compute.listZones(
Compute.ZoneListOption.filter(Compute.ZoneFilter.equals(Compute.ZoneField.NAME, ZONE)));
Iterator<Zone> zoneIterator = zonePage.iterateAll().iterator();
assertEquals(ZONE, zoneIterator.next().getZoneId().getZone());
assertFalse(zoneIterator.hasNext());
}
代码示例来源:origin: googleapis/google-cloud-java
com.google.api.services.compute.model.Zone toPb() {
com.google.api.services.compute.model.Zone zonePb =
new com.google.api.services.compute.model.Zone();
if (generatedId != null) {
zonePb.setId(new BigInteger(generatedId));
}
if (creationTimestamp != null) {
zonePb.setCreationTimestamp(TIMESTAMP_FORMATTER.print(creationTimestamp));
}
zonePb.setName(zoneId.getZone());
zonePb.setDescription(description);
zonePb.setSelfLink(zoneId.getSelfLink());
if (status != null) {
zonePb.setStatus(status.name());
}
if (region != null) {
zonePb.setRegion(region.getSelfLink());
}
if (deprecationStatus != null) {
zonePb.setDeprecated(deprecationStatus.toPb());
}
return zonePb;
}
代码示例来源:origin: googleapis/google-cloud-java
machineTypePb.setZone(machineTypeId.getZoneId().getZone());
if (deprecationStatus != null) {
machineTypePb.setDeprecated(deprecationStatus.toPb());
代码示例来源:origin: googleapis/google-cloud-java
private void compareZoneId(ZoneId expected, ZoneId value) {
assertEquals(expected, value);
assertEquals(expected.getProject(), expected.getProject());
assertEquals(expected.getZone(), expected.getZone());
assertEquals(expected.getSelfLink(), expected.getSelfLink());
assertEquals(expected.hashCode(), expected.hashCode());
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testOf() {
ZoneId zoneId = ZoneId.of(PROJECT, ZONE);
assertEquals(PROJECT, zoneId.getProject());
assertEquals(ZONE, zoneId.getZone());
assertEquals(URL, zoneId.getSelfLink());
zoneId = ZoneId.of(ZONE);
assertNull(zoneId.getProject());
assertEquals(ZONE, zoneId.getZone());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testToAndFromPb() {
com.google.api.services.compute.model.Zone zonePb = ZONE.toPb();
assertEquals(REGION_ID.getSelfLink(), zonePb.getRegion());
Zone zone = Zone.fromPb(zonePb);
compareZones(ZONE, zone);
assertEquals(ZONE_ID.getProject(), zone.getZoneId().getProject());
assertEquals(ZONE_ID.getZone(), zone.getZoneId().getZone());
zone = Zone.builder().setZoneId(ZONE_ID).build();
compareZones(zone, Zone.fromPb(zone.toPb()));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZone() {
Zone zone = compute.getZone(ZONE);
assertEquals(ZONE, zone.getZoneId().getZone());
assertNotNull(zone.getGeneratedId());
assertNotNull(zone.getCreationTimestamp());
assertNotNull(zone.getDescription());
assertNotNull(zone.getStatus());
assertNotNull(zone.getRegion());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGetZoneWithSelectedFields() {
Zone zone = compute.getZone(ZONE, Compute.ZoneOption.fields(Compute.ZoneField.ID));
assertEquals(ZONE, zone.getZoneId().getZone());
assertNotNull(zone.getGeneratedId());
assertNull(zone.getCreationTimestamp());
assertNull(zone.getDescription());
assertNull(zone.getStatus());
assertNull(zone.getRegion());
}
内容来源于网络,如有侵权,请联系作者删除!