Skip to content

Commit

Permalink
Regenerating spi layer - format cleanup (#1306)
Browse files Browse the repository at this point in the history
* Formatting using latest google-java-format (1.1)
* Removing unused imports
  • Loading branch information
garrettjonesgoogle authored and mziccard committed Oct 4, 2016
1 parent b61af33 commit 88344a2
Show file tree
Hide file tree
Showing 44 changed files with 1,726 additions and 2,506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,27 @@
* </pre>
*
* <p>Note: close() needs to be called on the errorGroupServiceApi object to clean up resources such
* as threads. In the example above, try-with-resources is used, which automatically calls
* close().
* as threads. In the example above, try-with-resources is used, which automatically calls close().
*
* <p>The surface of this class includes several types of Java methods for each of the API's methods:
* <p>The surface of this class includes several types of Java methods for each of the API's
* methods:
*
* <ol>
* <li> A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available
* as parameters, and not every API method will have a flattened method entry point.
* <li> A "request object" method. This type of method only takes one parameter, a request
* object, which must be constructed before the call. Not every API method will have a request
* object method.
* <li> A "callable" method. This type of method takes no parameters and returns an immutable
* ApiCallable object, which can be used to initiate calls to the service.
* <li> A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
* <li> A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
* <li> A "callable" method. This type of method takes no parameters and returns an immutable
* ApiCallable object, which can be used to initiate calls to the service.
* </ol>
*
* <p>See the individual methods for example code.
*
* <p>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.
* <p>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.
*
* <p>This class can be customized by passing in a custom instance of ErrorGroupServiceSettings to
* create(). For example:
Expand All @@ -90,53 +89,40 @@ public class ErrorGroupServiceApi implements AutoCloseable {
private static final PathTemplate GROUP_PATH_TEMPLATE =
PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}");

/**
* Formats a string containing the fully-qualified path to represent
* a group resource.
*/
/** Formats a string containing the fully-qualified path to represent a group resource. */
public static final String formatGroupName(String project, String group) {
return GROUP_PATH_TEMPLATE.instantiate(
"project", project,
"group", group);
}

/**
* Parses the project from the given fully-qualified path which
* represents a group resource.
*/
/** Parses the project from the given fully-qualified path which represents a group resource. */
public static final String parseProjectFromGroupName(String groupName) {
return GROUP_PATH_TEMPLATE.parse(groupName).get("project");
}

/**
* Parses the group from the given fully-qualified path which
* represents a group resource.
*/
/** Parses the group from the given fully-qualified path which represents a group resource. */
public static final String parseGroupFromGroupName(String groupName) {
return GROUP_PATH_TEMPLATE.parse(groupName).get("group");
}

/**
* Constructs an instance of ErrorGroupServiceApi with default settings.
*/
/** Constructs an instance of ErrorGroupServiceApi with default settings. */
public static final ErrorGroupServiceApi create() throws IOException {
return create(ErrorGroupServiceSettings.defaultBuilder().build());
}

/**
* Constructs an instance of ErrorGroupServiceApi, using the given settings.
* The channels are created based on the settings passed in, or defaults for any
* settings that are not set.
* Constructs an instance of ErrorGroupServiceApi, 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 ErrorGroupServiceApi create(ErrorGroupServiceSettings settings)
throws IOException {
return new ErrorGroupServiceApi(settings);
}

/**
* Constructs an instance of ErrorGroupServiceApi, using the given settings.
* This is protected so that it easy to make a subclass, but otherwise, the static
* factory methods should be preferred.
* Constructs an instance of ErrorGroupServiceApi, using the given settings. This is protected so
* that it easy to make a subclass, but otherwise, the static factory methods should be preferred.
*/
protected ErrorGroupServiceApi(ErrorGroupServiceSettings settings) throws IOException {
this.settings = settings;
Expand Down Expand Up @@ -176,7 +162,8 @@ public final ErrorGroupServiceSettings getSettings() {
/**
* Get the specified group.
*
* Sample code:
* <p>Sample code:
*
* <pre><code>
* try (ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create()) {
* String formattedGroupName = ErrorGroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
Expand All @@ -185,13 +172,11 @@ public final ErrorGroupServiceSettings getSettings() {
* </code></pre>
*
* @param groupName [Required] The group resource name. Written as
* &lt;code&gt;projects/&lt;var&gt;projectID&lt;/var&gt;/groups/&lt;var&gt;group_name&lt;/var&gt;&lt;/code&gt;.
* Call
* &lt;a href="/error-reporting/reference/rest/v1beta1/projects.groupStats/list"&gt;
* &lt;code&gt;groupStats.list&lt;/code&gt;&lt;/a&gt; to return a list of groups belonging to
* this project.
*
* Example: &lt;code&gt;projects/my-project-123/groups/my-group&lt;/code&gt;
* &lt;code&gt;projects/&lt;var&gt;projectID&lt;/var&gt;/groups/&lt;var&gt;group_name&lt;/var&gt;&lt;/code&gt;.
* Call &lt;a href="/error-reporting/reference/rest/v1beta1/projects.groupStats/list"&gt;
* &lt;code&gt;groupStats.list&lt;/code&gt;&lt;/a&gt; to return a list of groups belonging to
* this project.
* <p>Example: &lt;code&gt;projects/my-project-123/groups/my-group&lt;/code&gt;
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ErrorGroup getGroup(String groupName) {
Expand All @@ -204,7 +189,8 @@ public final ErrorGroup getGroup(String groupName) {
/**
* Get the specified group.
*
* Sample code:
* <p>Sample code:
*
* <pre><code>
* try (ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create()) {
* String formattedGroupName = ErrorGroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
Expand All @@ -226,7 +212,8 @@ private final ErrorGroup getGroup(GetGroupRequest request) {
/**
* Get the specified group.
*
* Sample code:
* <p>Sample code:
*
* <pre><code>
* try (ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create()) {
* String formattedGroupName = ErrorGroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
Expand All @@ -245,10 +232,10 @@ public final ApiCallable<GetGroupRequest, ErrorGroup> getGroupCallable() {

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Replace the data for the specified group.
* Fails if the group does not exist.
* Replace the data for the specified group. Fails if the group does not exist.
*
* <p>Sample code:
*
* Sample code:
* <pre><code>
* try (ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create()) {
* ErrorGroup group = ErrorGroup.newBuilder().build();
Expand All @@ -266,10 +253,10 @@ public final ErrorGroup updateGroup(ErrorGroup group) {

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Replace the data for the specified group.
* Fails if the group does not exist.
* Replace the data for the specified group. Fails if the group does not exist.
*
* <p>Sample code:
*
* Sample code:
* <pre><code>
* try (ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create()) {
* ErrorGroup group = ErrorGroup.newBuilder().build();
Expand All @@ -289,10 +276,10 @@ private final ErrorGroup updateGroup(UpdateGroupRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Replace the data for the specified group.
* Fails if the group does not exist.
* Replace the data for the specified group. Fails if the group does not exist.
*
* <p>Sample code:
*
* Sample code:
* <pre><code>
* try (ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create()) {
* ErrorGroup group = ErrorGroup.newBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.api.gax.core.ConnectionSettings;
import com.google.api.gax.core.RetrySettings;
import com.google.api.gax.grpc.ApiCallSettings;
import com.google.api.gax.grpc.PageStreamingDescriptor;
import com.google.api.gax.grpc.ServiceApiSettings;
import com.google.api.gax.grpc.SimpleCallSettings;
import com.google.auth.Credentials;
Expand All @@ -43,15 +42,15 @@
* <p>The default instance has everything set to sensible defaults:
*
* <ul>
* <li>The default service address (clouderrorreporting.googleapis.com) and default port (443)
* are used.
* <li>Credentials are acquired automatically through Application Default Credentials.
* <li>Retries are configured for idempotent methods but not for non-idempotent methods.
* <li>The default service address (clouderrorreporting.googleapis.com) and default port (443) are
* used.
* <li>Credentials are acquired automatically through Application Default Credentials.
* <li>Retries are configured for idempotent methods but not for non-idempotent methods.
* </ul>
*
* <p>The builder of this class is recursive, so contained classes are themselves builders.
* When build() is called, the tree of builders is called to create the complete settings
* object. For example, to set the total timeout of getGroup to 30 seconds:
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object. For
* example, to set the total timeout of getGroup to 30 seconds:
*
* <pre>
* <code>
Expand All @@ -65,25 +64,17 @@
*/
@javax.annotation.Generated("by GAPIC")
public class ErrorGroupServiceSettings extends ServiceApiSettings {
/**
* The default address of the service.
*/
/** The default address of the service. */
private static final String DEFAULT_SERVICE_ADDRESS = "clouderrorreporting.googleapis.com";

/**
* The default port of the service.
*/
/** The default port of the service. */
private static final int DEFAULT_SERVICE_PORT = 443;

/**
* The default scopes of the service.
*/
/** The default scopes of the service. */
private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
ImmutableList.<String>builder().add("https://www.googleapis.com/auth/cloud-platform").build();

/**
* The default connection settings of the service.
*/
/** The default connection settings of the service. */
public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
ConnectionSettings.newBuilder()
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
Expand All @@ -94,58 +85,42 @@ public class ErrorGroupServiceSettings extends ServiceApiSettings {
private final SimpleCallSettings<GetGroupRequest, ErrorGroup> getGroupSettings;
private final SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings;

/**
* Returns the object with the settings used for calls to getGroup.
*/
/** Returns the object with the settings used for calls to getGroup. */
public SimpleCallSettings<GetGroupRequest, ErrorGroup> getGroupSettings() {
return getGroupSettings;
}

/**
* Returns the object with the settings used for calls to updateGroup.
*/
/** Returns the object with the settings used for calls to updateGroup. */
public SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings() {
return updateGroupSettings;
}

/**
* Returns the default service address.
*/
/** Returns the default service address. */
public static String getDefaultServiceAddress() {
return DEFAULT_SERVICE_ADDRESS;
}

/**
* Returns the default service port.
*/
/** Returns the default service port. */
public static int getDefaultServicePort() {
return DEFAULT_SERVICE_PORT;
}

/**
* Returns the default service scopes.
*/
/** Returns the default service scopes. */
public static ImmutableList<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
}

/**
* Returns a builder for this class with recommended defaults.
*/
/** Returns a builder for this class with recommended defaults. */
public static Builder defaultBuilder() {
return Builder.createDefault();
}

/**
* Returns a new builder for this class.
*/
/** Returns a new builder for this class. */
public static Builder newBuilder() {
return new Builder();
}

/**
* Returns a builder containing all the values of this settings class.
*/
/** Returns a builder containing all the values of this settings class. */
public Builder toBuilder() {
return new Builder(this);
}
Expand All @@ -163,9 +138,7 @@ private ErrorGroupServiceSettings(Builder settingsBuilder) throws IOException {
updateGroupSettings = settingsBuilder.updateGroupSettings().build();
}

/**
* Builder for ErrorGroupServiceSettings.
*/
/** Builder for ErrorGroupServiceSettings. */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList<ApiCallSettings.Builder> methodSettingsBuilders;

Expand Down Expand Up @@ -289,25 +262,20 @@ public Builder setClientLibHeader(String name, String version) {
}

/**
* Applies the given settings to all of the API methods in this service. Only
* values that are non-null will be applied, so this method is not capable
* of un-setting any values.
* Applies the given settings to all of the API methods in this service. Only values that are
* non-null will be applied, so this method is not capable of un-setting any values.
*/
public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
return this;
}

/**
* Returns the builder for the settings used for calls to getGroup.
*/
/** Returns the builder for the settings used for calls to getGroup. */
public SimpleCallSettings.Builder<GetGroupRequest, ErrorGroup> getGroupSettings() {
return getGroupSettings;
}

/**
* Returns the builder for the settings used for calls to updateGroup.
*/
/** Returns the builder for the settings used for calls to updateGroup. */
public SimpleCallSettings.Builder<UpdateGroupRequest, ErrorGroup> updateGroupSettings() {
return updateGroupSettings;
}
Expand Down
Loading

0 comments on commit 88344a2

Please sign in to comment.