Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [cloudbuild] Add GitLabConfig and fetchGitRefs for Cloud Build Repositories #9588

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions java-cloudbuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.16.0</version>
<version>26.18.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-build.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-build/3.21.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-build/3.22.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import com.google.cloudbuild.v2.CreateRepositoryRequest;
import com.google.cloudbuild.v2.DeleteConnectionRequest;
import com.google.cloudbuild.v2.DeleteRepositoryRequest;
import com.google.cloudbuild.v2.FetchGitRefsRequest;
import com.google.cloudbuild.v2.FetchGitRefsResponse;
import com.google.cloudbuild.v2.FetchLinkableRepositoriesRequest;
import com.google.cloudbuild.v2.FetchLinkableRepositoriesResponse;
import com.google.cloudbuild.v2.FetchReadTokenRequest;
Expand Down Expand Up @@ -71,7 +73,7 @@

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Manages connections to source code repostiories.
* Service Description: Manages connections to source code repositories.
*
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
Expand Down Expand Up @@ -2102,6 +2104,126 @@ public final FetchLinkableRepositoriesPagedResponse fetchLinkableRepositories(
return stub.fetchLinkableRepositoriesCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Fetch the list of branches or tags for a given repository.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (RepositoryManagerClient repositoryManagerClient = RepositoryManagerClient.create()) {
* RepositoryName repository =
* RepositoryName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]", "[REPOSITORY]");
* FetchGitRefsResponse response = repositoryManagerClient.fetchGitRefs(repository);
* }
* }</pre>
*
* @param repository Required. The resource name of the repository in the format
* `projects/&#42;/locations/&#42;/connections/&#42;/repositories/&#42;`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final FetchGitRefsResponse fetchGitRefs(RepositoryName repository) {
FetchGitRefsRequest request =
FetchGitRefsRequest.newBuilder()
.setRepository(repository == null ? null : repository.toString())
.build();
return fetchGitRefs(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Fetch the list of branches or tags for a given repository.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (RepositoryManagerClient repositoryManagerClient = RepositoryManagerClient.create()) {
* String repository =
* RepositoryName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]", "[REPOSITORY]").toString();
* FetchGitRefsResponse response = repositoryManagerClient.fetchGitRefs(repository);
* }
* }</pre>
*
* @param repository Required. The resource name of the repository in the format
* `projects/&#42;/locations/&#42;/connections/&#42;/repositories/&#42;`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final FetchGitRefsResponse fetchGitRefs(String repository) {
FetchGitRefsRequest request =
FetchGitRefsRequest.newBuilder().setRepository(repository).build();
return fetchGitRefs(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Fetch the list of branches or tags for a given repository.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (RepositoryManagerClient repositoryManagerClient = RepositoryManagerClient.create()) {
* FetchGitRefsRequest request =
* FetchGitRefsRequest.newBuilder()
* .setRepository(
* RepositoryName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]", "[REPOSITORY]")
* .toString())
* .build();
* FetchGitRefsResponse response = repositoryManagerClient.fetchGitRefs(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final FetchGitRefsResponse fetchGitRefs(FetchGitRefsRequest request) {
return fetchGitRefsCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Fetch the list of branches or tags for a given repository.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (RepositoryManagerClient repositoryManagerClient = RepositoryManagerClient.create()) {
* FetchGitRefsRequest request =
* FetchGitRefsRequest.newBuilder()
* .setRepository(
* RepositoryName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]", "[REPOSITORY]")
* .toString())
* .build();
* ApiFuture<FetchGitRefsResponse> future =
* repositoryManagerClient.fetchGitRefsCallable().futureCall(request);
* // Do something.
* FetchGitRefsResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<FetchGitRefsRequest, FetchGitRefsResponse> fetchGitRefsCallable() {
return stub.fetchGitRefsCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the access control policy on the specified resource. Replacesany existing policy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import com.google.cloudbuild.v2.CreateRepositoryRequest;
import com.google.cloudbuild.v2.DeleteConnectionRequest;
import com.google.cloudbuild.v2.DeleteRepositoryRequest;
import com.google.cloudbuild.v2.FetchGitRefsRequest;
import com.google.cloudbuild.v2.FetchGitRefsResponse;
import com.google.cloudbuild.v2.FetchLinkableRepositoriesRequest;
import com.google.cloudbuild.v2.FetchLinkableRepositoriesResponse;
import com.google.cloudbuild.v2.FetchReadTokenRequest;
Expand Down Expand Up @@ -220,6 +222,11 @@ public UnaryCallSettings<FetchReadTokenRequest, FetchReadTokenResponse> fetchRea
return ((RepositoryManagerStubSettings) getStubSettings()).fetchLinkableRepositoriesSettings();
}

/** Returns the object with the settings used for calls to fetchGitRefs. */
public UnaryCallSettings<FetchGitRefsRequest, FetchGitRefsResponse> fetchGitRefsSettings() {
return ((RepositoryManagerStubSettings) getStubSettings()).fetchGitRefsSettings();
}

/** Returns the object with the settings used for calls to setIamPolicy. */
public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() {
return ((RepositoryManagerStubSettings) getStubSettings()).setIamPolicySettings();
Expand Down Expand Up @@ -469,6 +476,12 @@ public UnaryCallSettings.Builder<GetRepositoryRequest, Repository> getRepository
return getStubSettingsBuilder().fetchLinkableRepositoriesSettings();
}

/** Returns the builder for the settings used for calls to fetchGitRefs. */
public UnaryCallSettings.Builder<FetchGitRefsRequest, FetchGitRefsResponse>
fetchGitRefsSettings() {
return getStubSettingsBuilder().fetchGitRefsSettings();
}

/** Returns the builder for the settings used for calls to setIamPolicy. */
public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() {
return getStubSettingsBuilder().setIamPolicySettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"DeleteRepository": {
"methods": ["deleteRepositoryAsync", "deleteRepositoryAsync", "deleteRepositoryAsync", "deleteRepositoryOperationCallable", "deleteRepositoryCallable"]
},
"FetchGitRefs": {
"methods": ["fetchGitRefs", "fetchGitRefs", "fetchGitRefs", "fetchGitRefsCallable"]
},
"FetchLinkableRepositories": {
"methods": ["fetchLinkableRepositories", "fetchLinkableRepositoriesPagedCallable", "fetchLinkableRepositoriesCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* <p>======================= RepositoryManagerClient =======================
*
* <p>Service Description: Manages connections to source code repostiories.
* <p>Service Description: Manages connections to source code repositories.
*
* <p>Sample for RepositoryManagerClient:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import com.google.cloudbuild.v2.CreateRepositoryRequest;
import com.google.cloudbuild.v2.DeleteConnectionRequest;
import com.google.cloudbuild.v2.DeleteRepositoryRequest;
import com.google.cloudbuild.v2.FetchGitRefsRequest;
import com.google.cloudbuild.v2.FetchGitRefsResponse;
import com.google.cloudbuild.v2.FetchLinkableRepositoriesRequest;
import com.google.cloudbuild.v2.FetchLinkableRepositoriesResponse;
import com.google.cloudbuild.v2.FetchReadTokenRequest;
Expand Down Expand Up @@ -212,6 +214,16 @@ public class GrpcRepositoryManagerStub extends RepositoryManagerStub {
ProtoUtils.marshaller(FetchLinkableRepositoriesResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<FetchGitRefsRequest, FetchGitRefsResponse>
fetchGitRefsMethodDescriptor =
MethodDescriptor.<FetchGitRefsRequest, FetchGitRefsResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.devtools.cloudbuild.v2.RepositoryManager/FetchGitRefs")
.setRequestMarshaller(ProtoUtils.marshaller(FetchGitRefsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(FetchGitRefsResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<SetIamPolicyRequest, Policy> setIamPolicyMethodDescriptor =
MethodDescriptor.<SetIamPolicyRequest, Policy>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
Expand Down Expand Up @@ -277,6 +289,7 @@ public class GrpcRepositoryManagerStub extends RepositoryManagerStub {
private final UnaryCallable<
FetchLinkableRepositoriesRequest, FetchLinkableRepositoriesPagedResponse>
fetchLinkableRepositoriesPagedCallable;
private final UnaryCallable<FetchGitRefsRequest, FetchGitRefsResponse> fetchGitRefsCallable;
private final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable;
private final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable;
private final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
Expand Down Expand Up @@ -463,6 +476,16 @@ protected GrpcRepositoryManagerStub(
return builder.build();
})
.build();
GrpcCallSettings<FetchGitRefsRequest, FetchGitRefsResponse> fetchGitRefsTransportSettings =
GrpcCallSettings.<FetchGitRefsRequest, FetchGitRefsResponse>newBuilder()
.setMethodDescriptor(fetchGitRefsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("repository", String.valueOf(request.getRepository()));
return builder.build();
})
.build();
GrpcCallSettings<SetIamPolicyRequest, Policy> setIamPolicyTransportSettings =
GrpcCallSettings.<SetIamPolicyRequest, Policy>newBuilder()
.setMethodDescriptor(setIamPolicyMethodDescriptor)
Expand Down Expand Up @@ -587,6 +610,9 @@ protected GrpcRepositoryManagerStub(
fetchLinkableRepositoriesTransportSettings,
settings.fetchLinkableRepositoriesSettings(),
clientContext);
this.fetchGitRefsCallable =
callableFactory.createUnaryCallable(
fetchGitRefsTransportSettings, settings.fetchGitRefsSettings(), clientContext);
this.setIamPolicyCallable =
callableFactory.createUnaryCallable(
setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext);
Expand Down Expand Up @@ -731,6 +757,11 @@ public UnaryCallable<FetchReadTokenRequest, FetchReadTokenResponse> fetchReadTok
return fetchLinkableRepositoriesPagedCallable;
}

@Override
public UnaryCallable<FetchGitRefsRequest, FetchGitRefsResponse> fetchGitRefsCallable() {
return fetchGitRefsCallable;
}

@Override
public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
return setIamPolicyCallable;
Expand Down
Loading
Loading