diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index dc05a7276..5db36a5f7 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:a6aa751984f1e905c3ae5a3aac78fc7b68210626ce91487dc7ff4f0a06f010cc -# created: 2024-01-22T14:14:20.913785597Z + digest: sha256:68ba5f5164a4b55529d358bb262feaa000536a0c62980727dd05a91bbb47ea5e +# created: 2024-05-09T16:31:37.168667071Z diff --git a/.github/workflows/approve-readme.yaml b/.github/workflows/approve-readme.yaml index f5fc7d516..59f00b8eb 100644 --- a/.github/workflows/approve-readme.yaml +++ b/.github/workflows/approve-readme.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} script: | diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml index 7a106d007..18d92e5a2 100644 --- a/.github/workflows/auto-release.yaml +++ b/.github/workflows/auto-release.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest if: contains(github.head_ref, 'release-please') steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} debug: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 37fc04345..8ac2a5b4f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: matrix: java: [8, 11] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: actions/setup-java@v1 with: java-version: ${{matrix.java}} @@ -34,7 +34,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: actions/setup-java@v1 with: java-version: 8 @@ -62,7 +62,7 @@ jobs: matrix: java: [8, 11] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: actions/setup-java@v1 with: java-version: ${{matrix.java}} @@ -72,7 +72,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: actions/setup-java@v1 with: java-version: 11 @@ -84,7 +84,7 @@ jobs: clirr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: actions/setup-java@v1 with: java-version: 8 diff --git a/.github/workflows/downstream.yaml b/.github/workflows/downstream.yaml index c756c63e2..edc40acd8 100644 --- a/.github/workflows/downstream.yaml +++ b/.github/workflows/downstream.yaml @@ -132,7 +132,7 @@ jobs: - workflow-executions - workflows steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: actions/setup-java@v3 with: distribution: zulu diff --git a/.github/workflows/renovate_config_check.yaml b/.github/workflows/renovate_config_check.yaml index 87d8eb2be..7c5ec7865 100644 --- a/.github/workflows/renovate_config_check.yaml +++ b/.github/workflows/renovate_config_check.yaml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '20' diff --git a/CHANGELOG.md b/CHANGELOG.md index c46e5adeb..7dc89f797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [2.5.0](https://github.com/googleapis/google-api-java-client/compare/v2.4.1...v2.5.0) (2024-05-10) + + +### Features + +* Add ApiVersion Support ([#2462](https://github.com/googleapis/google-api-java-client/issues/2462)) ([9f3f64c](https://github.com/googleapis/google-api-java-client/commit/9f3f64c42e6e9ecd3715d18582569efa3622a0ea)) + + +### Bug Fixes + +* **deps:** Update dependency com.google.api-client:google-api-client to v2.4.1 ([#2448](https://github.com/googleapis/google-api-java-client/issues/2448)) ([0ea6c2b](https://github.com/googleapis/google-api-java-client/commit/0ea6c2b0db7a9bc624c442cb7ea9a15f8ec6b21c)) +* **deps:** Update dependency com.google.appengine:appengine-api-1.0-sdk to v2.0.27 ([#2468](https://github.com/googleapis/google-api-java-client/issues/2468)) ([ffc0e6d](https://github.com/googleapis/google-api-java-client/commit/ffc0e6d2121a48b603374a43830570b8d8a282bc)) +* **deps:** Update dependency com.google.cloud:libraries-bom to v26.39.0 ([#2471](https://github.com/googleapis/google-api-java-client/issues/2471)) ([69e6724](https://github.com/googleapis/google-api-java-client/commit/69e6724e51f73cb46524b3a61989639341b10151)) +* **deps:** Update dependency com.google.guava:guava to v33.2.0-jre ([#2449](https://github.com/googleapis/google-api-java-client/issues/2449)) ([252c494](https://github.com/googleapis/google-api-java-client/commit/252c49406108bb402c9f4d8f6cb9116af2b96697)) +* **deps:** Update dependency commons-codec:commons-codec to v1.17.0 ([#2472](https://github.com/googleapis/google-api-java-client/issues/2472)) ([8440f32](https://github.com/googleapis/google-api-java-client/commit/8440f326dd6b5718c433de90707ef599532b58d2)) +* Fix ApiVersion header typo ([#2467](https://github.com/googleapis/google-api-java-client/issues/2467)) ([bd396ca](https://github.com/googleapis/google-api-java-client/commit/bd396ca929c31c54da1d6969ae5917ffaa32a02a)) + ## [2.4.1](https://github.com/googleapis/google-api-java-client/compare/v2.4.0...v2.4.1) (2024-03-26) diff --git a/google-api-client-android/pom.xml b/google-api-client-android/pom.xml index 4c3f59f7e..a90477081 100644 --- a/google-api-client-android/pom.xml +++ b/google-api-client-android/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-android diff --git a/google-api-client-appengine/pom.xml b/google-api-client-appengine/pom.xml index e993e70fc..0878911f2 100644 --- a/google-api-client-appengine/pom.xml +++ b/google-api-client-appengine/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-appengine diff --git a/google-api-client-assembly/pom.xml b/google-api-client-assembly/pom.xml index cb2ffecb7..1aed8b365 100644 --- a/google-api-client-assembly/pom.xml +++ b/google-api-client-assembly/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml com.google.api-client diff --git a/google-api-client-bom/pom.xml b/google-api-client-bom/pom.xml index 1becce5fb..3b6aa52b1 100644 --- a/google-api-client-bom/pom.xml +++ b/google-api-client-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.api-client google-api-client-bom - 2.4.1 + 2.5.0 pom Google API Client Library for Java BOM @@ -63,48 +63,48 @@ com.google.api-client google-api-client - 2.4.1 + 2.5.0 com.google.api-client google-api-client-android - 2.4.1 + 2.5.0 com.google.api-client google-api-client-appengine - 2.4.1 + 2.5.0 com.google.api-client google-api-client-assembly - 2.4.1 + 2.5.0 pom com.google.api-client google-api-client-gson - 2.4.1 + 2.5.0 com.google.api-client google-api-client-jackson2 - 2.4.1 + 2.5.0 com.google.api-client google-api-client-protobuf - 2.4.1 + 2.5.0 com.google.api-client google-api-client-servlet - 2.4.1 + 2.5.0 com.google.api-client google-api-client-xml - 2.4.1 + 2.5.0 @@ -170,7 +170,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.0 + 3.2.4 sign-artifacts diff --git a/google-api-client-gson/pom.xml b/google-api-client-gson/pom.xml index 0ef7eaeb8..958f20b3f 100644 --- a/google-api-client-gson/pom.xml +++ b/google-api-client-gson/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-gson diff --git a/google-api-client-jackson2/pom.xml b/google-api-client-jackson2/pom.xml index 9c7dadaac..bcab9959e 100644 --- a/google-api-client-jackson2/pom.xml +++ b/google-api-client-jackson2/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-jackson2 diff --git a/google-api-client-protobuf/pom.xml b/google-api-client-protobuf/pom.xml index 0559f6f2e..a0a0fad42 100644 --- a/google-api-client-protobuf/pom.xml +++ b/google-api-client-protobuf/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-protobuf diff --git a/google-api-client-servlet/pom.xml b/google-api-client-servlet/pom.xml index fd4b3f98d..dff52b4be 100644 --- a/google-api-client-servlet/pom.xml +++ b/google-api-client-servlet/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-servlet diff --git a/google-api-client-xml/pom.xml b/google-api-client-xml/pom.xml index fd4be01da..27aaca78c 100644 --- a/google-api-client-xml/pom.xml +++ b/google-api-client-xml/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client-xml diff --git a/google-api-client/pom.xml b/google-api-client/pom.xml index 6e8ad9ee0..2a602d27f 100644 --- a/google-api-client/pom.xml +++ b/google-api-client/pom.xml @@ -4,7 +4,7 @@ com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 ../pom.xml google-api-client diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java index cd6d12b65..c9a7b5967 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java @@ -37,6 +37,7 @@ import com.google.api.client.http.UriTemplate; import com.google.api.client.util.GenericData; import com.google.api.client.util.Preconditions; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import java.io.IOException; import java.io.InputStream; @@ -62,7 +63,13 @@ public abstract class AbstractGoogleClientRequest extends GenericData { */ public static final String USER_AGENT_SUFFIX = "Google-API-Java-Client"; - private static final String API_VERSION_HEADER = "X-Goog-Api-Client"; + private static final String API_CLIENT_HEADER = "X-Goog-Api-Client"; + + /** + * The generated request class will pass this constant as part of the header if the RPC supports + * ApiVersion. + */ + protected static final String API_VERSION_HEADER = "X-Goog-Api-Version"; /** Google client. */ private final AbstractGoogleClient abstractGoogleClient; @@ -133,7 +140,7 @@ protected AbstractGoogleClientRequest( requestHeaders.setUserAgent(USER_AGENT_SUFFIX + "/" + GoogleUtils.VERSION); } // Set the header for the Api Client version (Java and OS version) - requestHeaders.set(API_VERSION_HEADER, ApiClientVersion.DEFAULT_VERSION); + requestHeaders.set(API_CLIENT_HEADER, ApiClientVersion.DEFAULT_VERSION); } /** @@ -312,6 +319,12 @@ public AbstractGoogleClientRequest setRequestHeaders(HttpHeaders headers) { return this; } + /** Returns the ApiVersion set in the headers. If ApiVersion is not set, null is returned. */ + @VisibleForTesting + String getApiVersionHeader() { + return (String) requestHeaders.get(API_VERSION_HEADER); + } + /** * Returns the HTTP headers of the last response or {@code null} before request has been executed. */ diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/testing/services/MockGoogleClientRequest.java b/google-api-client/src/main/java/com/google/api/client/googleapis/testing/services/MockGoogleClientRequest.java index c1cf32cc2..b3b0ad4de 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/testing/services/MockGoogleClientRequest.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/testing/services/MockGoogleClientRequest.java @@ -18,6 +18,7 @@ import com.google.api.client.http.HttpHeaders; import com.google.api.client.http.UriTemplate; import com.google.api.client.util.Beta; +import com.google.common.base.Strings; /** * {@link Beta}
@@ -46,7 +47,32 @@ public MockGoogleClientRequest( String uriTemplate, HttpContent content, Class responseClass) { + this(client, method, uriTemplate, content, responseClass, null); + } + + /** + * @param client Google client + * @param method HTTP Method + * @param uriTemplate URI template for the path relative to the base URL. If it starts with a "/" + * the base path from the base URL will be stripped out. The URI template can also be a full + * URL. URI template expansion is done using {@link UriTemplate#expand(String, String, Object, + * boolean)} + * @param content HTTP content or {@code null} for none + * @param responseClass response class to parse into + * @param apiVersion ApiVersion to be passed to the header + */ + public MockGoogleClientRequest( + AbstractGoogleClient client, + String method, + String uriTemplate, + HttpContent content, + Class responseClass, + String apiVersion) { super(client, method, uriTemplate, content, responseClass); + // Matches generator code: Null or Empty String is not set to the header + if (!Strings.isNullOrEmpty(apiVersion)) { + getRequestHeaders().set(API_VERSION_HEADER, apiVersion); + } } @Override diff --git a/google-api-client/src/test/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequestTest.java b/google-api-client/src/test/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequestTest.java index 1eefdb139..79e156b34 100644 --- a/google-api-client/src/test/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequestTest.java +++ b/google-api-client/src/test/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequestTest.java @@ -242,6 +242,49 @@ public void testUserAgent() throws IOException { request.executeUnparsed(); } + public void testSetsApiVersionHeader_apiVersionSet() { + String apiVersion = "testVersion"; + HttpTransport transport = new MockHttpTransport(); + MockGoogleClient client = + new MockGoogleClient.Builder(transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null) + .build(); + AbstractGoogleClientRequest request = + new MockGoogleClientRequest<>( + client, HttpMethods.GET, URI_TEMPLATE, null, Void.class, apiVersion); + assertEquals(apiVersion, request.getApiVersionHeader()); + } + + public void testDoesNotSetsApiVersionHeader_noApiVersionSet() { + HttpTransport transport = new MockHttpTransport(); + MockGoogleClient client = + new MockGoogleClient.Builder(transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null) + .build(); + AbstractGoogleClientRequest request = + new MockGoogleClientRequest<>(client, HttpMethods.GET, URI_TEMPLATE, null, Void.class); + assertNull(request.getApiVersionHeader()); + } + + public void testNullApiVersionHeader_noApiVersionSet() { + HttpTransport transport = new MockHttpTransport(); + MockGoogleClient client = + new MockGoogleClient.Builder(transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null) + .build(); + final AbstractGoogleClientRequest request = + new MockGoogleClientRequest<>( + client, HttpMethods.GET, URI_TEMPLATE, null, Void.class, null); + assertNull(request.getApiVersionHeader()); + } + + public void testEmptyStringApiVersionHeader_noApiVersionSet() { + HttpTransport transport = new MockHttpTransport(); + MockGoogleClient client = + new MockGoogleClient.Builder(transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null) + .build(); + final AbstractGoogleClientRequest request = + new MockGoogleClientRequest<>(client, HttpMethods.GET, URI_TEMPLATE, null, Void.class, ""); + assertNull(request.getApiVersionHeader()); + } + public void testSetsApiClientHeader() throws IOException { HttpTransport transport = new AssertHeaderTransport("X-Goog-Api-Client", "gl-java/\\d+\\.\\d+\\.\\d+.*"); diff --git a/pom.xml b/pom.xml index 31e811ae0..8520fce06 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.google.api-client google-api-client-parent - 2.4.1 + 2.5.0 pom Parent for the Google API Client Library for Java The Google APIs Client Library for Java is a Java client library @@ -256,11 +256,11 @@
maven-assembly-plugin - 3.7.0 + 3.7.1 maven-compiler-plugin - 3.12.1 + 3.13.0 1.7 1.7 @@ -296,7 +296,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.1 @@ -511,14 +511,14 @@ 1.44.1 4.4.16 4.5.14 - 1.16.1 + 1.17.0 1.35.0 1.23.0 3.0.2 2.8.6 3.25.3 - 33.0.0-jre - 2.0.25 + 33.2.0-jre + 2.0.27 1.1.4c 2.3-20090302111651 3.2.2 @@ -543,7 +543,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.0 + 3.2.4 sign-artifacts diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 69008cc8b..d1a3df82a 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.api-client google-api-client - 2.3.0 + 2.4.1 diff --git a/samples/pom.xml b/samples/pom.xml index 91b1098a5..a2fd7d435 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -38,7 +38,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.2 true diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index ba42d268f..388775f5b 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.api-client google-api-client - 2.3.0 + 2.4.1 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index a006534e0..d2979cdc1 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 26.34.0 + 26.39.0 pom import diff --git a/versions.txt b/versions.txt index 04bd1786f..7c7ebfa0d 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-api-client:2.4.1:2.4.1 +google-api-client:2.5.0:2.5.0