- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.google.cloud.compute.v1.ZoneOperationClient
类的一些代码示例,展示了ZoneOperationClient
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOperationClient
类的具体详情如下:
包路径:com.google.cloud.compute.v1.ZoneOperationClient
类名称:ZoneOperationClient
[英]Service Description: Creates and runs virtual machines on Google Cloud Platform.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
zoneOperationClient.deleteZoneOperation(operation);
}
Note: close() needs to be called on the zoneOperationClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ZoneOperationSettings to create(). For example:
To customize credentials:
ZoneOperationSettings zoneOperationSettings =
ZoneOperationSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ZoneOperationClient zoneOperationClient =
ZoneOperationClient.create(zoneOperationSettings);
To customize the endpoint:
ZoneOperationSettings zoneOperationSettings =
ZoneOperationSettings.newBuilder().setEndpoint(myEndpoint).build();
ZoneOperationClient zoneOperationClient =
ZoneOperationClient.create(zoneOperationSettings);
[中]服务描述:在谷歌云平台上创建并运行虚拟机。
此类提供了通过映射到API方法的方法调用对支持服务进行远程调用的能力。开始的示例代码:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
zoneOperationClient.deleteZoneOperation(operation);
}
注意:需要对zoneOperationClient对象调用close(),以清理线程等资源。在上面的示例中,使用了try with resources,它会自动调用close()。
该类的表面包括针对每个API方法的几种类型的Java方法:
1.“扁平化”方法。使用这种类型的方法,请求类型的字段已转换为函数参数。可能不是所有字段都可以用作参数,也不是每个API方法都有平坦的方法入口点。
1.“请求对象”方法。这种类型的方法只接受一个参数,即请求对象,它必须在调用之前构造。并不是每个API方法都有一个请求对象方法。
1.“可调用”方法。这种类型的方法不接受任何参数,并返回一个不可变的API可调用对象,该对象可用于启动对服务的调用。
有关示例代码,请参见各个方法。
许多参数要求以特定的方式格式化资源名称。为了帮助处理这些名称,这个类为每种类型的名称包括一个格式化方法,另外还有一个解析方法,用于提取返回的名称中包含的各个标识符。
可以通过将ZoneOperationSettings的自定义实例传递给create()来自定义此类。例如:
要自定义凭据,请执行以下操作:
ZoneOperationSettings zoneOperationSettings =
ZoneOperationSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ZoneOperationClient zoneOperationClient =
ZoneOperationClient.create(zoneOperationSettings);
要自定义端点:
ZoneOperationSettings zoneOperationSettings =
ZoneOperationSettings.newBuilder().setEndpoint(myEndpoint).build();
ZoneOperationClient zoneOperationClient =
ZoneOperationClient.create(zoneOperationSettings);
代码示例来源:origin: googleapis/google-cloud-java
/** Constructs an instance of ZoneOperationClient with default settings. */
public static final ZoneOperationClient create() throws IOException {
return create(ZoneOperationSettings.newBuilder().build());
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Constructs an instance of ZoneOperationClient, using the given settings. The channels are
* created based on the settings passed in, or defaults for any settings that are not set.
*/
public static final ZoneOperationClient create(ZoneOperationSettings settings)
throws IOException {
return new ZoneOperationClient(settings);
}
代码示例来源:origin: googleapis/google-cloud-java
@AfterClass
public static void tearDown() throws Exception {
client.close();
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Deletes the specified zone-specific Operations resource.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
* zoneOperationClient.deleteZoneOperation(operation.toString());
* }
* </code></pre>
*
* @param operation Name of the Operations resource to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final void deleteZoneOperation(String operation) {
DeleteZoneOperationHttpRequest request =
DeleteZoneOperationHttpRequest.newBuilder().setOperation(operation).build();
deleteZoneOperation(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Retrieves the specified zone-specific Operations resource.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
* Operation response = zoneOperationClient.getZoneOperation(operation.toString());
* }
* </code></pre>
*
* @param operation Name of the Operations resource to return.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation getZoneOperation(String operation) {
GetZoneOperationHttpRequest request =
GetZoneOperationHttpRequest.newBuilder().setOperation(operation).build();
return getZoneOperation(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Retrieves a list of Operation resources contained within the specified zone.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
* for (Operation element : zoneOperationClient.listZoneOperations(zone.toString()).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param zone Name of the zone for request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final ListZoneOperationsPagedResponse listZoneOperations(String zone) {
ListZoneOperationsHttpRequest request =
ListZoneOperationsHttpRequest.newBuilder().setZone(zone).build();
return listZoneOperations(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Retrieves the specified zone-specific Operations resource.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
* GetZoneOperationHttpRequest request = GetZoneOperationHttpRequest.newBuilder()
* .setOperation(operation.toString())
* .build();
* Operation response = zoneOperationClient.getZoneOperation(request);
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation getZoneOperation(GetZoneOperationHttpRequest request) {
return getZoneOperationCallable().call(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Deletes the specified zone-specific Operations resource.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
* DeleteZoneOperationHttpRequest request = DeleteZoneOperationHttpRequest.newBuilder()
* .setOperation(operation.toString())
* .build();
* zoneOperationClient.deleteZoneOperation(request);
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final void deleteZoneOperation(DeleteZoneOperationHttpRequest request) {
deleteZoneOperationCallable().call(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Retrieves a list of Operation resources contained within the specified zone.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
* ListZoneOperationsHttpRequest request = ListZoneOperationsHttpRequest.newBuilder()
* .setZone(zone.toString())
* .build();
* for (Operation element : zoneOperationClient.listZoneOperations(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final ListZoneOperationsPagedResponse listZoneOperations(
ListZoneOperationsHttpRequest request) {
return listZoneOperationsPagedCallable().call(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Deletes the specified zone-specific Operations resource.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
* zoneOperationClient.deleteZoneOperation(operation);
* }
* </code></pre>
*
* @param operation Name of the Operations resource to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final void deleteZoneOperation(ProjectZoneOperationName operation) {
DeleteZoneOperationHttpRequest request =
DeleteZoneOperationHttpRequest.newBuilder()
.setOperation(operation == null ? null : operation.toString())
.build();
deleteZoneOperation(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Retrieves the specified zone-specific Operations resource.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
* Operation response = zoneOperationClient.getZoneOperation(operation);
* }
* </code></pre>
*
* @param operation Name of the Operations resource to return.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation getZoneOperation(ProjectZoneOperationName operation) {
GetZoneOperationHttpRequest request =
GetZoneOperationHttpRequest.newBuilder()
.setOperation(operation == null ? null : operation.toString())
.build();
return getZoneOperation(request);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Retrieves a list of Operation resources contained within the specified zone.
*
* <p>Sample code:
*
* <pre><code>
* try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
* ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
* for (Operation element : zoneOperationClient.listZoneOperations(zone).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param zone Name of the zone for request.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final ListZoneOperationsPagedResponse listZoneOperations(ProjectZoneName zone) {
ListZoneOperationsHttpRequest request =
ListZoneOperationsHttpRequest.newBuilder()
.setZone(zone == null ? null : zone.toString())
.build();
return listZoneOperations(request);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
@SuppressWarnings("all")
public void deleteZoneOperationTest() {
mockService.addNullResponse();
ProjectZoneOperationName operation =
ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
client.deleteZoneOperation(operation);
List<String> actualRequests = mockService.getRequestPaths();
Assert.assertEquals(1, actualRequests.size());
String apiClientHeaderKey =
mockService
.getRequestHeaders()
.get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
.iterator()
.next();
Assert.assertTrue(
GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
.matcher(apiClientHeaderKey)
.matches());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
@SuppressWarnings("all")
public void getZoneOperationExceptionTest() throws Exception {
ApiException exception =
ApiExceptionFactory.createException(
new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false);
mockService.addException(exception);
try {
ProjectZoneOperationName operation =
ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
client.getZoneOperation(operation);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
@SuppressWarnings("all")
public void listZoneOperationsExceptionTest() throws Exception {
ApiException exception =
ApiExceptionFactory.createException(
new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false);
mockService.addException(exception);
try {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
client.listZoneOperations(zone);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
@BeforeClass
public static void setUp() throws IOException {
clientSettings =
ZoneOperationSettings.newBuilder()
.setTransportChannelProvider(
ZoneOperationSettings.defaultHttpJsonTransportProviderBuilder()
.setHttpTransport(mockService)
.build())
.setCredentialsProvider(NoCredentialsProvider.create())
.build();
client = ZoneOperationClient.create(clientSettings);
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Constructs an instance of ZoneOperationClient, using the given stub for making calls. This is
* for advanced usage - prefer to use ZoneOperationSettings}.
*/
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final ZoneOperationClient create(ZoneOperationStub stub) {
return new ZoneOperationClient(stub);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
@SuppressWarnings("all")
public void deleteZoneOperationExceptionTest() throws Exception {
ApiException exception =
ApiExceptionFactory.createException(
new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false);
mockService.addException(exception);
try {
ProjectZoneOperationName operation =
ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
client.deleteZoneOperation(operation);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
代码示例来源:origin: googleapis/google-cloud-java
ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
Operation actualResponse = client.getZoneOperation(operation);
Assert.assertEquals(expectedResponse, actualResponse);
代码示例来源:origin: googleapis/google-cloud-java
ListZoneOperationsPagedResponse pagedListResponse = client.listZoneOperations(zone);
这里的这个问题对 updating Google Sheets charts linked to Google slides 有一个简洁的解决方案. function onOpen() { var
我正在尝试将 Google 表单添加到 Google 类作业中,但似乎不可能。 首先,它在这里 ( https://developers.google.com/classroom/reference/
出于某种原因,无论我做什么以及我如何尝试,这个日期格式化程序都不起作用。工具提示仍然显示错误的格式。你可以试试代码here . 在代码中我必须注释掉 formatter.format(dataTabl
我目前正在使用访问 token 和刷新 token 从 Google Analytics Reporting API (v4) 中提取数据。当我致力于自动从 Google Analytics 中提取数
我已在 Google 云端硬盘中创建了一个文件夹,例如测试一下,放入3个文件 a.jpg, b.jpg, c.jpg 我希望在同一帐户下的 Google 电子表格中访问文件,例如生成图像文件的链接,可
电子表格 A 是欢迎新移民来到我们小镇的团队的主数据源。它里面有大量非常敏感的数据,不能公开,哪怕是一点点。 (我们谈论的是 child 的姓名和出生日期以及他们在哪里上学……保证电子表格 A 的安全
有没有办法在 Google 文档中编写 Google Apps 脚本以从 Google 表格中检索仅限于非空白行的范围并将这些行显示为表格? 我正在寻找一个脚本,用于使用 Google Apps 脚本
有没有办法在 Google 文档中编写 Google Apps 脚本以从 Google 表格中检索仅限于非空白行的范围并将这些行显示为表格? 我正在寻找一个脚本,用于使用 Google Apps 脚本
尝试检索存储在 google firebase 中名为条目的节点下的表单条目,并使用谷歌工作表中的脚本编辑器附加到谷歌工作表。 我已将 FirebaseApp 库添加到谷歌表脚本编辑器。然后我的代码看
是否可以将我的 Web 应用程序的登录限制为仅限 google 组中的帐户? 我不希望每个人都可以使用他们的私有(private) gmail 登录,而只能使用我的 google 组中的用户。 最佳答
我们想使用 Google 自定义搜索实现 Google 附加链接搜索框。在谷歌 documentation , 我发现我们需要包含以下代码来启用附加链接搜索框 { "@context"
我想将特定搜索词的 Google 趋势图表添加到我的 Google Data Studio 报告中,但趋势不是数据源列表中的选项。我也找不到嵌入 JavaScript 的选项。是否可以将趋势图表添加到
是否可以将文件从 Google Drive 复制到 Google Cloud Storage?我想它会非常快,因为两者都在类似的存储系统上。 我还没有看到有关无缝执行此操作的任何方法的任何信息,而无需
之间有什么区别 ga('send', 'pageview', { 'dimension1': 'data goes here' }); 和 ga('set', 'dimension1', 'da
我正在尝试记录每个博客站点作者的点击率。 ga('send', 'pageview'); (in the header with the ga code to track each page) ga(
我设置了 Google Tag Manager 和 2 个数据层变量:一个用于跟踪用户 ID,传递给 Google Analytics 以同步用户 session ,另一个用于跟踪访问者类型。 在使用
我在我们的网站上遇到多个职位发布的问题。 我们在加拿大多个地点提供工作机会。所有职位页面都包含一个“LD+JSON ”职位发布的结构化数据,基于 Google 的职位发布文档: https://dev
公司未使用 Google 套件,使用个人(消费者)帐户(甚至是 Google 帐户)违反公司政策。 需要访问 Google Analytics - 没有 Google 帐户是否可能? 谢谢 最佳答案
我想分析人们使用哪些搜索关键字在 Play 商店中找到我的应用。 那可能吗?我怎么能这样做? 最佳答案 自 2013 年 10 月起,您可以关联您的 Google Analytics(分析)和 Goo
Google Now 和 Google Keep 中基于时间和位置的提醒与 Google Calendar 事件提醒不同。是否有公共(public) API 可以访问 Now 和 Keep 中的这些事
我是一名优秀的程序员,十分优秀!