本文整理匯總了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);