com.google.api.services.servicecontrol.v1.ServiceControl Maven / Gradle / Ivy
Show all versions of endpoints-management-api-client Show documentation
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://github.com/google/apis-client-generator/
* Modify at your own risk.
*/
package com.google.api.services.servicecontrol.v1;
import com.google.api.client.http.protobuf.ProtoHttpContent;
import com.google.api.client.protobuf.ProtoObjectParser;
import com.google.api.client.util.ObjectParser;
/**
* Service definition for ServiceControl (v1).
*
*
* Google Service Control provides control plane functionality to managed services, such as logging, monitoring, and status checks.
*
*
*
* For more information about this service, see the
* API Documentation
*
*
*
* This service uses {@link ServiceControlRequestInitializer} to initialize global parameters via its
* {@link Builder}.
*
*
* @since 1.3
* @author Google, Inc.
*/
@SuppressWarnings("javadoc")
public class ServiceControl extends com.google.api.client.googleapis.services.AbstractGoogleClient {
private static final ObjectParser parser = new ProtoObjectParser();
// Note: Leave this static initializer at the top of the file.
static {
com.google.api.client.util.Preconditions.checkState(
com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1 &&
com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 15,
"You are currently running with version %s of google-api-client. " +
"You need at least version 1.15 of google-api-client to run version " +
"1.22.0-SNAPSHOT of the Google Service Control API library.", com.google.api.client.googleapis.GoogleUtils.VERSION);
}
/**
* The default encoded root URL of the service. This is determined when the library is generated
* and normally should not be changed.
*
* @since 1.7
*/
public static final String DEFAULT_ROOT_URL = "https://servicecontrol.googleapis.com/";
/**
* The default encoded service path of the service. This is determined when the library is
* generated and normally should not be changed.
*
* @since 1.7
*/
public static final String DEFAULT_SERVICE_PATH = "";
/**
* The default encoded base URL of the service. This is determined when the library is generated
* and normally should not be changed.
*/
public static final String DEFAULT_BASE_URL = DEFAULT_ROOT_URL + DEFAULT_SERVICE_PATH;
/**
* Constructor.
*
*
* Use {@link Builder} if you need to specify any of the optional parameters.
*
*
* @param transport HTTP transport, which should normally be:
*
* - Google App Engine:
* {@code com.google.api.client.extensions.appengine.http.UrlFetchTransport}
* - Android: {@code newCompatibleTransport} from
* {@code com.google.api.client.extensions.android.http.AndroidHttp}
* - Java: {@link com.google.api.client.googleapis.javanet.GoogleNetHttpTransport#newTrustedTransport()}
*
*
* @param httpRequestInitializer HTTP request initializer or {@code null} for none
* @since 1.7
*/
public ServiceControl(com.google.api.client.http.HttpTransport transport,
com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
this(new Builder(transport, httpRequestInitializer));
}
/**
* @param builder builder
*/
ServiceControl(Builder builder) {
super(builder);
}
@Override
protected void initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest> httpClientRequest) throws java.io.IOException {
super.initialize(httpClientRequest);
}
/**
* An accessor for creating requests from the Services collection.
*
* The typical use is:
*
* {@code ServiceControl servicecontrol = new ServiceControl(...);}
* {@code ServiceControl.Services.List request = servicecontrol.services().list(parameters ...)}
*
*
* @return the resource collection
*/
public Services services() {
return new Services();
}
/**
* The "services" collection of methods.
*/
public class Services {
/**
* Attempts to allocate quota for the specified consumer. It should be called before the
* operation is executed.
*
* This method requires the `servicemanagement.services.quota` permission on the specified
* service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
*
* **NOTE:** the client code **must** fail-open if the server returns one of the following quota
* errors: - `PROJECT_STATUS_UNAVAILABLE` - `SERVICE_STATUS_UNAVAILABLE` -
* `BILLING_STATUS_UNAVAILABLE` - `QUOTA_SYSTEM_UNAVAILABLE`
*
* The server may inject above errors to prohibit any hard dependency on the quota system.
*
* Create a request for the method "services.allocateQuota".
*
* This request holds the parameters needed by the servicecontrol server. After setting any
* optional parameters, call the {@link AllocateQuota#execute()} method to invoke the remote
* operation.
*
* @param serviceName Name of the service as specified in the service configuration. For
* example, `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service
* name.
* @param content the {@link com.google.api.servicecontrol.v1.AllocateQuotaRequest}
* @return the request
*/
public AllocateQuota allocateQuota(java.lang.String serviceName,
com.google.api.servicecontrol.v1.AllocateQuotaRequest content) throws java.io.IOException {
AllocateQuota result = new AllocateQuota(serviceName, content);
initialize(result);
return result;
}
public class AllocateQuota extends
ServiceControlRequest {
private static final String REST_PATH = "v1/services/{serviceName}:allocateQuota";
/**
* Attempts to allocate quota for the specified consumer. It should be called before the
* operation is executed.
*
* This method requires the `servicemanagement.services.quota` permission on the specified
* service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
*
* **NOTE:** the client code **must** fail-open if the server returns one of the following
* quota errors: - `PROJECT_STATUS_UNAVAILABLE` - `SERVICE_STATUS_UNAVAILABLE` -
* `BILLING_STATUS_UNAVAILABLE` - `QUOTA_SYSTEM_UNAVAILABLE`
*
* The server may inject above errors to prohibit any hard dependency on the quota system.
*
* Create a request for the method "services.allocateQuota".
*
* This request holds the parameters needed by the the servicecontrol server. After setting
* any optional parameters, call the {@link AllocateQuota#execute()} method to invoke the
* remote operation. {@link AllocateQuota#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
* must be called to initialize this instance immediately after invoking the constructor.
*
*
* @param serviceName Name of the service as specified in the service configuration. For
* example, `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service
* name.
* @param content the {@link com.google.api.servicecontrol.v1.AllocateQuotaRequest}
* @since 1.13
*/
protected AllocateQuota(java.lang.String serviceName,
com.google.api.servicecontrol.v1.AllocateQuotaRequest content) {
super(ServiceControl.this, "POST", REST_PATH, new ProtoHttpContent(content),
com.google.api.servicecontrol.v1.AllocateQuotaResponse.class);
this.serviceName = com.google.api.client.util.Preconditions
.checkNotNull(serviceName, "Required parameter serviceName must be specified.");
}
@Override
public AllocateQuota setAccessToken(java.lang.String accessToken) {
return (AllocateQuota) super.setAccessToken(accessToken);
}
@Override
public AllocateQuota setAlt(java.lang.String alt) {
return (AllocateQuota) super.setAlt(alt);
}
@Override
public AllocateQuota setBearerToken(java.lang.String bearerToken) {
return (AllocateQuota) super.setBearerToken(bearerToken);
}
@Override
public AllocateQuota setCallback(java.lang.String callback) {
return (AllocateQuota) super.setCallback(callback);
}
@Override
public AllocateQuota setFields(java.lang.String fields) {
return (AllocateQuota) super.setFields(fields);
}
@Override
public AllocateQuota setKey(java.lang.String key) {
return (AllocateQuota) super.setKey(key);
}
@Override
public AllocateQuota setOauthToken(java.lang.String oauthToken) {
return (AllocateQuota) super.setOauthToken(oauthToken);
}
@Override
public AllocateQuota setPp(java.lang.Boolean pp) {
return (AllocateQuota) super.setPp(pp);
}
@Override
public AllocateQuota setPrettyPrint(java.lang.Boolean prettyPrint) {
return (AllocateQuota) super.setPrettyPrint(prettyPrint);
}
@Override
public AllocateQuota setQuotaUser(java.lang.String quotaUser) {
return (AllocateQuota) super.setQuotaUser(quotaUser);
}
@Override
public AllocateQuota setUploadType(java.lang.String uploadType) {
return (AllocateQuota) super.setUploadType(uploadType);
}
@Override
public AllocateQuota setUploadProtocol(java.lang.String uploadProtocol) {
return (AllocateQuota) super.setUploadProtocol(uploadProtocol);
}
/**
* Name of the service as specified in the service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
@com.google.api.client.util.Key
private java.lang.String serviceName;
/**
* Name of the service as specified in the service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
public java.lang.String getServiceName() {
return serviceName;
}
/**
* Name of the service as specified in the service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
public AllocateQuota setServiceName(java.lang.String serviceName) {
this.serviceName = serviceName;
return this;
}
@Override
public AllocateQuota set(String parameterName, Object value) {
return (AllocateQuota) super.set(parameterName, value);
}
}
/**
* Checks an operation with Google Service Control to decide whether the given operation should
* proceed. It should be called before the operation is executed.
*
* If feasible, the client should cache the check results and reuse them for 60 seconds. In case
* of server errors, the client can rely on the cached results for longer time.
*
* NOTE: the `CheckRequest` has the size limit of 64KB.
*
* This method requires the `servicemanagement.services.check` permission on the specified
* service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
*
* Create a request for the method "services.check".
*
* This request holds the parameters needed by the servicecontrol server. After setting any
* optional parameters, call the {@link Check#execute()} method to invoke the remote operation.
*
* @param serviceName The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service name.
* @param content the {@link com.google.api.servicecontrol.v1.CheckRequest}
* @return the request
*/
public Check check(java.lang.String serviceName,
com.google.api.servicecontrol.v1.CheckRequest content) throws java.io.IOException {
Check result = new Check(serviceName, content);
initialize(result);
return result;
}
public class Check extends
ServiceControlRequest {
private static final String REST_PATH = "v1/services/{serviceName}:check";
/**
* Checks an operation with Google Service Control to decide whether the given operation
* should proceed. It should be called before the operation is executed.
*
* If feasible, the client should cache the check results and reuse them for 60 seconds. In
* case of server errors, the client can rely on the cached results for longer time.
*
* NOTE: the `CheckRequest` has the size limit of 64KB.
*
* This method requires the `servicemanagement.services.check` permission on the specified
* service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
*
* Create a request for the method "services.check".
*
* This request holds the parameters needed by the the servicecontrol server. After setting
* any optional parameters, call the {@link Check#execute()} method to invoke the remote
* operation. {@link Check#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
* must be called to initialize this instance immediately after invoking the constructor.
*
*
* @param serviceName The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service name.
* @param content the {@link com.google.api.servicecontrol.v1.CheckRequest}
* @since 1.13
*/
protected Check(java.lang.String serviceName,
com.google.api.servicecontrol.v1.CheckRequest content) {
super(ServiceControl.this, "POST", REST_PATH, new ProtoHttpContent(content),
com.google.api.servicecontrol.v1.CheckResponse.class);
this.serviceName = com.google.api.client.util.Preconditions
.checkNotNull(serviceName, "Required parameter serviceName must be specified.");
}
@Override
public Check setAccessToken(java.lang.String accessToken) {
return (Check) super.setAccessToken(accessToken);
}
@Override
public Check setAlt(java.lang.String alt) {
return (Check) super.setAlt(alt);
}
@Override
public Check setBearerToken(java.lang.String bearerToken) {
return (Check) super.setBearerToken(bearerToken);
}
@Override
public Check setCallback(java.lang.String callback) {
return (Check) super.setCallback(callback);
}
@Override
public Check setFields(java.lang.String fields) {
return (Check) super.setFields(fields);
}
@Override
public Check setKey(java.lang.String key) {
return (Check) super.setKey(key);
}
@Override
public Check setOauthToken(java.lang.String oauthToken) {
return (Check) super.setOauthToken(oauthToken);
}
@Override
public Check setPp(java.lang.Boolean pp) {
return (Check) super.setPp(pp);
}
@Override
public Check setPrettyPrint(java.lang.Boolean prettyPrint) {
return (Check) super.setPrettyPrint(prettyPrint);
}
@Override
public Check setQuotaUser(java.lang.String quotaUser) {
return (Check) super.setQuotaUser(quotaUser);
}
@Override
public Check setUploadType(java.lang.String uploadType) {
return (Check) super.setUploadType(uploadType);
}
@Override
public Check setUploadProtocol(java.lang.String uploadProtocol) {
return (Check) super.setUploadProtocol(uploadProtocol);
}
/**
* The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
@com.google.api.client.util.Key
private java.lang.String serviceName;
/**
* The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
public java.lang.String getServiceName() {
return serviceName;
}
/**
* The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
public Check setServiceName(java.lang.String serviceName) {
this.serviceName = serviceName;
return this;
}
@Override
public Check set(String parameterName, Object value) {
return (Check) super.set(parameterName, value);
}
}
/**
* Reports operation results to Google Service Control, such as logs and metrics. It should be
* called after an operation is completed.
*
* If feasible, the client should aggregate reporting data for up to 5 seconds to reduce API
* traffic. Limiting aggregation to 5 seconds is to reduce data loss during client crashes.
* Clients should carefully choose the aggregation time window to avoid data loss risk more than
* 0.01% for business and compliance reasons.
*
* NOTE: the `ReportRequest` has the size limit of 1MB.
*
* This method requires the `servicemanagement.services.report` permission on the specified
* service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
*
* Create a request for the method "services.report".
*
* This request holds the parameters needed by the servicecontrol server. After setting any
* optional parameters, call the {@link Report#execute()} method to invoke the remote
* operation.
*
* @param serviceName The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service name.
* @param content the {@link com.google.api.servicecontrol.v1.ReportRequest}
* @return the request
*/
public Report report(java.lang.String serviceName,
com.google.api.servicecontrol.v1.ReportRequest content) throws java.io.IOException {
Report result = new Report(serviceName, content);
initialize(result);
return result;
}
public class Report extends
ServiceControlRequest {
private static final String REST_PATH = "v1/services/{serviceName}:report";
/**
* Reports operation results to Google Service Control, such as logs and metrics. It should be
* called after an operation is completed.
*
* If feasible, the client should aggregate reporting data for up to 5 seconds to reduce API
* traffic. Limiting aggregation to 5 seconds is to reduce data loss during client crashes.
* Clients should carefully choose the aggregation time window to avoid data loss risk more
* than 0.01% for business and compliance reasons.
*
* NOTE: the `ReportRequest` has the size limit of 1MB.
*
* This method requires the `servicemanagement.services.report` permission on the specified
* service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
*
* Create a request for the method "services.report".
*
* This request holds the parameters needed by the the servicecontrol server. After setting
* any optional parameters, call the {@link Report#execute()} method to invoke the remote
* operation. {@link Report#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
* must be called to initialize this instance immediately after invoking the constructor.
*
*
* @param serviceName The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service name.
* @param content the {@link com.google.api.servicecontrol.v1.ReportRequest}
* @since 1.13
*/
protected Report(java.lang.String serviceName,
com.google.api.servicecontrol.v1.ReportRequest content) {
super(ServiceControl.this, "POST", REST_PATH, new ProtoHttpContent(content),
com.google.api.servicecontrol.v1.ReportResponse.class);
this.serviceName = com.google.api.client.util.Preconditions
.checkNotNull(serviceName, "Required parameter serviceName must be specified.");
}
@Override
public Report setAccessToken(java.lang.String accessToken) {
return (Report) super.setAccessToken(accessToken);
}
@Override
public Report setAlt(java.lang.String alt) {
return (Report) super.setAlt(alt);
}
@Override
public Report setBearerToken(java.lang.String bearerToken) {
return (Report) super.setBearerToken(bearerToken);
}
@Override
public Report setCallback(java.lang.String callback) {
return (Report) super.setCallback(callback);
}
@Override
public Report setFields(java.lang.String fields) {
return (Report) super.setFields(fields);
}
@Override
public Report setKey(java.lang.String key) {
return (Report) super.setKey(key);
}
@Override
public Report setOauthToken(java.lang.String oauthToken) {
return (Report) super.setOauthToken(oauthToken);
}
@Override
public Report setPp(java.lang.Boolean pp) {
return (Report) super.setPp(pp);
}
@Override
public Report setPrettyPrint(java.lang.Boolean prettyPrint) {
return (Report) super.setPrettyPrint(prettyPrint);
}
@Override
public Report setQuotaUser(java.lang.String quotaUser) {
return (Report) super.setQuotaUser(quotaUser);
}
@Override
public Report setUploadType(java.lang.String uploadType) {
return (Report) super.setUploadType(uploadType);
}
@Override
public Report setUploadProtocol(java.lang.String uploadProtocol) {
return (Report) super.setUploadProtocol(uploadProtocol);
}
/**
* The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
@com.google.api.client.util.Key
private java.lang.String serviceName;
/**
* The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
public java.lang.String getServiceName() {
return serviceName;
}
/**
* The service name as specified in its service configuration. For example,
* `"pubsub.googleapis.com"`.
*
* See google.api.Service for the definition of a service name.
*/
public Report setServiceName(java.lang.String serviceName) {
this.serviceName = serviceName;
return this;
}
@Override
public Report set(String parameterName, Object value) {
return (Report) super.set(parameterName, value);
}
}
}
/**
* Builder for {@link ServiceControl}.
*
*
* Implementation is not thread-safe.
*
*
* @since 1.3.0
*/
public static final class Builder extends com.google.api.client.googleapis.services.AbstractGoogleClient.Builder {
/**
* Returns an instance of a new builder.
*
* @param transport HTTP transport, which should normally be:
*
* - Google App Engine:
* {@code com.google.api.client.extensions.appengine.http.UrlFetchTransport}
* - Android: {@code newCompatibleTransport} from
* {@code com.google.api.client.extensions.android.http.AndroidHttp}
* - Java: {@link com.google.api.client.googleapis.javanet.GoogleNetHttpTransport#newTrustedTransport()}
*
*
* @param httpRequestInitializer HTTP request initializer or {@code null} for none
* @since 1.7
*/
public Builder(com.google.api.client.http.HttpTransport transport,
com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
super(
transport,
DEFAULT_ROOT_URL,
DEFAULT_SERVICE_PATH,
parser,
httpRequestInitializer);
}
/** Builds a new instance of {@link ServiceControl}. */
@Override
public ServiceControl build() {
return new ServiceControl(this);
}
@Override
public Builder setRootUrl(String rootUrl) {
return (Builder) super.setRootUrl(rootUrl);
}
@Override
public Builder setServicePath(String servicePath) {
return (Builder) super.setServicePath(servicePath);
}
@Override
public Builder setHttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
return (Builder) super.setHttpRequestInitializer(httpRequestInitializer);
}
@Override
public Builder setApplicationName(String applicationName) {
return (Builder) super.setApplicationName(applicationName);
}
@Override
public Builder setSuppressPatternChecks(boolean suppressPatternChecks) {
return (Builder) super.setSuppressPatternChecks(suppressPatternChecks);
}
@Override
public Builder setSuppressRequiredParameterChecks(boolean suppressRequiredParameterChecks) {
return (Builder) super.setSuppressRequiredParameterChecks(suppressRequiredParameterChecks);
}
@Override
public Builder setSuppressAllChecks(boolean suppressAllChecks) {
return (Builder) super.setSuppressAllChecks(suppressAllChecks);
}
/**
* Set the {@link ServiceControlRequestInitializer}.
*
* @since 1.12
*/
public Builder setServiceControlRequestInitializer(
ServiceControlRequestInitializer servicecontrolRequestInitializer) {
return (Builder) super.setGoogleClientRequestInitializer(servicecontrolRequestInitializer);
}
@Override
public Builder setGoogleClientRequestInitializer(
com.google.api.client.googleapis.services.GoogleClientRequestInitializer googleClientRequestInitializer) {
return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
}
}