gpt4 book ai didi

com.google.cloud.compute.deprecated.ZoneId类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 13:59:31 26 4
gpt4 key购买 nike

本文整理了Java中com.google.cloud.compute.deprecated.ZoneId类的一些代码示例,展示了ZoneId类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneId类的具体详情如下:
包路径:com.google.cloud.compute.deprecated.ZoneId
类名称:ZoneId

ZoneId介绍

[英]A Google Compute Engine zone identity.
[中]谷歌计算引擎区域标识。

代码示例

代码示例来源: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 new zone identity given zone name. */
public static ZoneId of(String zone) {
 return ZoneId.of(null, zone);
}

代码示例来源:origin: googleapis/google-cloud-java

@Override
 public ZoneId apply(String pb) {
  return ZoneId.fromUrl(pb);
 }
};

代码示例来源:origin: googleapis/google-cloud-java

@Override
ZoneId setProjectId(String projectId) {
 if (getProject() != null) {
  return this;
 }
 return ZoneId.of(projectId, zone);
}

代码示例来源: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

@Override
public void run(Compute compute, ZoneId zone) {
 System.out.printf("Zone info: %s%n", compute.getZone(zone.getZone()));
}

代码示例来源: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 testToAndFromUrl() {
 ZoneId zoneId = ZoneId.of(PROJECT, ZONE);
 compareZoneId(zoneId, ZoneId.fromUrl(zoneId.getSelfLink()));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testMatchesUrl() {
 assertTrue(ZoneId.matchesUrl(ZoneId.of(PROJECT, ZONE).getSelfLink()));
 assertFalse(ZoneId.matchesUrl("notMatchingUrl"));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testSetProjectId() {
 ZoneId zoneId = ZoneId.of(PROJECT, ZONE);
 assertSame(zoneId, zoneId.setProjectId(PROJECT));
 compareZoneId(zoneId, ZoneId.of(ZONE).setProjectId(PROJECT));
 thrown.expect(IllegalArgumentException.class);
 thrown.expectMessage("notMatchingUrl is not a valid zone URL");
 ZoneId.fromUrl("notMatchingUrl");
}

代码示例来源: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

@Override
 public String apply(ZoneId zoneId) {
  return zoneId.getSelfLink();
 }
};

代码示例来源:origin: googleapis/google-cloud-java

/** Returns a new zone identity given project and zone names. */
public static ZoneId of(String project, String zone) {
 return new ZoneId(project, zone);
}

代码示例来源:origin: googleapis/google-cloud-java

@Override
public boolean equals(Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof ZoneId)) {
  return false;
 }
 ZoneId other = (ZoneId) obj;
 return baseEquals(other) && Objects.equals(zone, other.zone);
}

代码示例来源:origin: googleapis/google-cloud-java

@Override
public int hashCode() {
 return Objects.hash(baseHashCode(), zone);
}

代码示例来源: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

Disk toPb() {
 Disk diskPb = configuration.toPb();
 if (generatedId != null) {
  diskPb.setId(new BigInteger(generatedId));
 }
 if (creationTimestamp != null) {
  diskPb.setCreationTimestamp(TIMESTAMP_FORMATTER.print(creationTimestamp));
 }
 diskPb.setZone(diskId.getZoneId().getSelfLink());
 if (creationStatus != null) {
  diskPb.setStatus(creationStatus.toString());
 }
 diskPb.setName(diskId.getDisk());
 diskPb.setDescription(description);
 diskPb.setSelfLink(diskId.getSelfLink());
 if (licenses != null) {
  diskPb.setLicenses(Lists.transform(licenses, LicenseId.TO_URL_FUNCTION));
 }
 if (attachedInstances != null) {
  diskPb.setUsers(Lists.transform(attachedInstances, InstanceId.TO_URL_FUNCTION));
 }
 if (lastAttachTimestamp != null) {
  diskPb.setLastAttachTimestamp(TIMESTAMP_FORMATTER.print(lastAttachTimestamp));
 }
 if (lastDetachTimestamp != null) {
  diskPb.setLastDetachTimestamp(TIMESTAMP_FORMATTER.print(lastDetachTimestamp));
 }
 return diskPb;
}

代码示例来源:origin: googleapis/google-cloud-java

@Override
ZoneId parse(String... args) throws Exception {
 String message;
 if (args.length == 1) {
  return ZoneId.of(args[0]);
 } else if (args.length > 1) {
  message = "Too many arguments.";
 } else {
  message = "Missing required zone id.";
 }
 throw new IllegalArgumentException(message);
}

代码示例来源: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

@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);
  }
 }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com