本文整理汇总了Java中com.google.api.services.servicemanagement.ServiceManagement类的典型用法代码示例。如果您正苦于以下问题:Java ServiceManagement类的具体用法?Java ServiceManagement怎么用?Java ServiceManagement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceManagement类属于com.google.api.services.servicemanagement包,在下文中一共展示了ServiceManagement类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ServiceConfigSupplier
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
@VisibleForTesting
ServiceConfigSupplier(
Environment environment,
HttpTransport httpTransport,
JsonFactory jsonFactory,
final GoogleCredential credential) {
this.environment = environment;
HttpRequestInitializer requestInitializer = new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
request.setThrowExceptionOnExecuteError(false);
credential.initialize(request);
}
};
this.serviceManagement =
new ServiceManagement.Builder(httpTransport, jsonFactory, requestInitializer)
.setApplicationName("Endpoints Frameworks Java")
.build();
}
示例2: mockServiceApi
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
private void mockServiceApi(Credential credential, String projectId, String... serviceIds)
throws IOException {
ServiceManagement servicesManagementApi = mock(ServiceManagement.class);
Services servicesApi = mock(Services.class);
Services.List request = mock(Services.List.class);
ListServicesResponse response = new ListServicesResponse();
doReturn(servicesManagementApi).when(apiFactory).newServiceManagementApi(credential);
doReturn(servicesApi).when(servicesManagementApi).services();
doReturn(request).when(servicesApi).list();
// List provides a fluent API
when(request.setFields(anyString())).thenReturn(request);
when(request.setConsumerId(anyString())).thenReturn(request);
when(request.setPageSize(anyInt())).thenReturn(request);
when(request.setPageToken(anyString())).thenReturn(request);
when(request.execute()).thenReturn(response);
List<ManagedService> managedServices = new ArrayList<>();
for (String serviceId : serviceIds) {
ManagedService managedService = new ManagedService();
managedService.setServiceName(serviceId);
managedService.setProducerProjectId(projectId);
managedServices.add(managedService);
}
response.setServices(managedServices);
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:28,代码来源:RunOptionsDefaultsComponentTest.java
示例3: compute
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
@Override
protected List<String> compute(IProgressMonitor monitor)
throws GoogleJsonResponseException, IOException {
String projectId = this.projectId;
ServiceManagement serviceManagement = apiFactory.newServiceManagementApi(credential);
ListServicesResponse response = null;
Collection<String> serviceIds = new ArrayList<>();
do {
checkCancelled(monitor);
// We request only the serviceNames as the rest does not appear to be helpful.
//@formatter:off
Services.List request = serviceManagement.services().list()
.setFields("services/serviceName")
.setConsumerId("project:" + projectId);
//@formatter:on
if (response != null && response.getNextPageToken() != null) {
request.setPageToken(response.getNextPageToken());
}
response = request.execute();
if (response.getServices() != null) {
for (ManagedService service : response.getServices()) {
serviceIds.add(service.getServiceName());
}
}
} while (response.getNextPageToken() != null);
return ImmutableList.copyOf(serviceIds);
}
示例4: newServiceManagementApi
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
@Override
public ServiceManagement newServiceManagementApi(Credential credential) {
Preconditions.checkNotNull(transportCache, "transportCache is null");
HttpTransport transport = transportCache.getUnchecked(GoogleApi.SERVICE_MANAGEMENT_API);
Preconditions.checkNotNull(transport, "transport is null");
Preconditions.checkNotNull(jsonFactory, "jsonFactory is null");
ServiceManagement serviceManagement =
new ServiceManagement.Builder(transport, jsonFactory, credential)
.setApplicationName(CloudToolsInfo.USER_AGENT).build();
return serviceManagement;
}
示例5: getServiceManagementClient
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
@Override
public ServiceManagement getServiceManagementClient(
@Nullable HttpRequestInitializer httpRequestInitializer) {
return new ServiceManagement.Builder(httpTransport, jsonFactory, httpRequestInitializer)
.setApplicationName(getApplicationName())
.build();
}
示例6: enableApi
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
private static void enableApi(
CloudLibrary library, CloudProject cloudProject, CredentialedUser user) throws IOException {
ServiceManagement serviceManagement =
GoogleApiClientFactory.getInstance().getServiceManagementClient(user.getCredential());
serviceManagement
.services()
.enable(
library.getServiceName(),
new EnableServiceRequest()
.setConsumerId(
String.format(SERVICE_REQUEST_PROJECT_PATTERN, cloudProject.projectId())))
.execute();
}
示例7: testNewServceManagementApi
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
@Test
public void testNewServceManagementApi() {
ServiceManagement serviceManagement =
googleApiFactory.newServiceManagementApi(mock(Credential.class));
assertEquals("https://servicemanagement.googleapis.com/", serviceManagement.getBaseUrl());
}
示例8: newServiceManagementApi
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
/**
* @return a ServiceManagement API client
*/
ServiceManagement newServiceManagementApi(Credential credential);
示例9: getServiceManagementClient
import com.google.api.services.servicemanagement.ServiceManagement; //导入依赖的package包/类
/**
* Creates a new instance of a {@link ServiceManagement} client.
*
* @param httpRequestInitializer optional HttpRequestInitializer
*/
public abstract ServiceManagement getServiceManagementClient(
@Nullable HttpRequestInitializer httpRequestInitializer);