Skip to content

Commit

Permalink
Regenerating spi layer - GAX 0.0.22 (#1379)
Browse files Browse the repository at this point in the history
* Regenerating spi layer - GAX 0.0.22

* Update options and spi classes to catch GAX changes
  • Loading branch information
mziccard authored Nov 10, 2016
1 parent 81278dc commit 6383cc1
Show file tree
Hide file tree
Showing 93 changed files with 1,873 additions and 1,765 deletions.
2 changes: 1 addition & 1 deletion google-cloud-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>0.0.21</version>
<version>0.0.22</version>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import static com.google.common.base.MoreObjects.firstNonNull;

import com.google.api.gax.core.ConnectionSettings;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.core.RetrySettings;
import com.google.api.gax.grpc.ChannelProvider;
import com.google.api.gax.grpc.InstantiatingChannelProvider;
import com.google.api.gax.grpc.UnaryCallSettings;
import com.google.auth.Credentials;
import com.google.cloud.spi.ServiceRpcFactory;
Expand Down Expand Up @@ -304,26 +306,19 @@ protected UnaryCallSettings.Builder getApiCallSettings() {
}

/**
* Returns a builder for connection-related settings.
* Returns a channel provider.
*/
@Deprecated
protected ConnectionSettings.Builder connectionSettings() {
return getConnectionSettings();
}

/**
* Returns a builder for connection-related settings.
*/
protected ConnectionSettings.Builder getConnectionSettings() {
protected ChannelProvider getChannelProvider() {
HostAndPort hostAndPort = HostAndPort.fromString(getHost());
ConnectionSettings.Builder builder = ConnectionSettings.newBuilder()
InstantiatingChannelProvider.Builder builder = InstantiatingChannelProvider.newBuilder()
.setServiceAddress(hostAndPort.getHostText())
.setPort(hostAndPort.getPort());
.setPort(hostAndPort.getPort())
.setClientLibHeader(getLibraryName(), firstNonNull(getLibraryVersion(), ""));
Credentials scopedCredentials = getScopedCredentials();
if (scopedCredentials != null && scopedCredentials != NoCredentials.getInstance()) {
builder.provideCredentialsWith(scopedCredentials);
builder.setCredentialsProvider(FixedCredentialsProvider.create(scopedCredentials));
}
return builder;
return builder.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2016, Google Inc. All rights reserved.
*
* 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
* 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
* 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.
* 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.
*/
package com.google.cloud.errorreporting.spi.v1beta1;

import com.google.api.gax.grpc.ChannelAndExecutor;
import com.google.api.gax.grpc.UnaryCallable;
import com.google.api.gax.protobuf.PathTemplate;
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup;
Expand Down Expand Up @@ -69,18 +72,22 @@
*
* <pre>
* <code>
* ErrorGroupServiceSettings errorGroupServiceSettings = ErrorGroupServiceSettings.defaultBuilder()
* .provideChannelWith(myCredentials)
* .build();
* ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create(errorGroupServiceSettings);
* InstantiatingChannelProvider channelProvider =
* ErrorGroupServiceSettings.defaultChannelProviderBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* ErrorGroupServiceSettings errorGroupServiceSettings =
* ErrorGroupServiceSettings.defaultBuilder().setChannelProvider(channelProvider).build();
* ErrorGroupServiceApi errorGroupServiceApi =
* ErrorGroupServiceApi.create(errorGroupServiceSettings);
* </code>
* </pre>
*/
@javax.annotation.Generated("by GAPIC")
public class ErrorGroupServiceApi implements AutoCloseable {
private final ErrorGroupServiceSettings settings;
private final ManagedChannel channel;
private final ScheduledExecutorService executor;
private final ManagedChannel channel;
private final List<AutoCloseable> closeables = new ArrayList<>();

private final UnaryCallable<GetGroupRequest, ErrorGroup> getGroupCallable;
Expand All @@ -89,13 +96,21 @@ public class ErrorGroupServiceApi implements AutoCloseable {
private static final PathTemplate GROUP_PATH_TEMPLATE =
PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}");

private static final PathTemplate PROJECT_PATH_TEMPLATE =
PathTemplate.createWithoutUrlEncoding("projects/{project}");

/** 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);
}

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

/** 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");
Expand All @@ -106,6 +121,11 @@ public static final String parseGroupFromGroupName(String groupName) {
return GROUP_PATH_TEMPLATE.parse(groupName).get("group");
}

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

/** Constructs an instance of ErrorGroupServiceApi with default settings. */
public static final ErrorGroupServiceApi create() throws IOException {
return create(ErrorGroupServiceSettings.defaultBuilder().build());
Expand All @@ -126,8 +146,9 @@ public static final ErrorGroupServiceApi create(ErrorGroupServiceSettings settin
*/
protected ErrorGroupServiceApi(ErrorGroupServiceSettings settings) throws IOException {
this.settings = settings;
this.executor = settings.getExecutorProvider().getOrBuildExecutor();
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
ChannelAndExecutor channelAndExecutor = settings.getChannelAndExecutor();
this.executor = channelAndExecutor.getExecutor();
this.channel = channelAndExecutor.getChannel();

this.getGroupCallable =
UnaryCallable.create(settings.getGroupSettings(), this.channel, this.executor);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2016, Google Inc. All rights reserved.
*
* 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
* 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
* 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.
* 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.
*/
package com.google.cloud.errorreporting.spi.v1beta1;

import com.google.api.gax.core.ConnectionSettings;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.RetrySettings;
import com.google.api.gax.grpc.ChannelProvider;
import com.google.api.gax.grpc.ExecutorProvider;
import com.google.api.gax.grpc.InstantiatingChannelProvider;
import com.google.api.gax.grpc.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.ServiceApiSettings;
import com.google.api.gax.grpc.SimpleCallSettings;
import com.google.api.gax.grpc.UnaryCallSettings;
import com.google.auth.Credentials;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand All @@ -28,11 +33,8 @@
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupServiceGrpc;
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
import com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest;
import io.grpc.ManagedChannel;
import io.grpc.Status;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import org.joda.time.Duration;

// AUTO-GENERATED DOCUMENTATION AND CLASS
Expand Down Expand Up @@ -87,6 +89,11 @@ public SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings()
return updateGroupSettings;
}

/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return InstantiatingExecutorProvider.newBuilder();
}

/** Returns the default service address. */
public static String getDefaultServiceAddress() {
return DEFAULT_SERVICE_ADDRESS;
Expand All @@ -102,6 +109,19 @@ public static ImmutableList<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
}

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
}

/** Returns a builder for the default ChannelProvider for this service. */
public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder() {
return InstantiatingChannelProvider.newBuilder()
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
.setPort(DEFAULT_SERVICE_PORT)
.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
}

/** Returns a builder for this class with recommended defaults. */
public static Builder defaultBuilder() {
return Builder.createDefault();
Expand All @@ -118,13 +138,7 @@ public Builder toBuilder() {
}

private ErrorGroupServiceSettings(Builder settingsBuilder) throws IOException {
super(
settingsBuilder.getChannelProvider(),
settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
settingsBuilder.getClientLibVersion());
super(settingsBuilder.getExecutorProvider(), settingsBuilder.getChannelProvider());

getGroupSettings = settingsBuilder.getGroupSettings().build();
updateGroupSettings = settingsBuilder.updateGroupSettings().build();
Expand Down Expand Up @@ -169,7 +183,7 @@ public static class Builder extends ServiceApiSettings.Builder {
}

private Builder() {
super(s_getDefaultConnectionSettingsBuilder().build());
super(defaultChannelProviderBuilder().build());

getGroupSettings = SimpleCallSettings.newBuilder(ErrorGroupServiceGrpc.METHOD_GET_GROUP);

Expand Down Expand Up @@ -206,57 +220,15 @@ private Builder(ErrorGroupServiceSettings settings) {
ImmutableList.<UnaryCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
}

private static ConnectionSettings.Builder s_getDefaultConnectionSettingsBuilder() {
return ConnectionSettings.newBuilder()
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
.setPort(DEFAULT_SERVICE_PORT)
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES);
}

@Override
protected ConnectionSettings.Builder getDefaultConnectionSettingsBuilder() {
return s_getDefaultConnectionSettingsBuilder();
}

@Override
public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
super.provideExecutorWith(executor, shouldAutoClose);
return this;
}

@Override
public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
super.provideChannelWith(channel, shouldAutoClose);
return this;
}

@Override
public Builder provideChannelWith(ConnectionSettings settings) {
super.provideChannelWith(settings);
return this;
}

@Override
public Builder provideChannelWith(Credentials credentials) {
super.provideChannelWith(credentials);
return this;
}

@Override
public Builder provideChannelWith(List<String> scopes) {
super.provideChannelWith(scopes);
return this;
}

@Override
public Builder setGeneratorHeader(String name, String version) {
super.setGeneratorHeader(name, version);
public Builder setExecutorProvider(ExecutorProvider executorProvider) {
super.setExecutorProvider(executorProvider);
return this;
}

@Override
public Builder setClientLibHeader(String name, String version) {
super.setClientLibHeader(name, version);
public Builder setChannelProvider(ChannelProvider channelProvider) {
super.setChannelProvider(channelProvider);
return this;
}

Expand Down
Loading

0 comments on commit 6383cc1

Please sign in to comment.