Skip to content

Commit

Permalink
fix: Specify build as the body of a CreateBuild call. The Cloud B…
Browse files Browse the repository at this point in the history
…uild API has always assumed this, but now we are actually specifying it.

feat: Add `ReceiveTriggerWebhook` for webhooks activating specific triggers.

docs: Update field docs on required-ness behavior and fix typos.

docs: Add `$PROJECT_NUMBER` as a substitution variable.

feat: Add `SecretManager`-related resources and messages for corresponding integration.

docs: Clarify lifetime/expiration behavior around `ListBuilds` page tokens.

feat: Add `COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY` for corresponding comment control behavior with triggered builds.

feat: Add `E2_HIGHCPU_8` and `E2_HIGHCPU_32` machine types.

Committer: @LOZORD
PiperOrigin-RevId: 363244566

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Mar 16 12:32:12 2021 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 913f5553d5ff5940cddd8245313136449b2a3571
Source-Link: googleapis/googleapis@913f555
  • Loading branch information
yoshi-automation authored and jskeet committed Mar 17, 2021
1 parent 69c83e4 commit f3ab04e
Show file tree
Hide file tree
Showing 7 changed files with 4,935 additions and 2,781 deletions.
Expand Up @@ -16,6 +16,7 @@

namespace Google.Cloud.CloudBuild.V1.Snippets
{
using Google.Api;
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.LongRunning;
Expand Down Expand Up @@ -1182,6 +1183,45 @@ public async Task RunBuildTriggerAsync()
// End snippet
}

/// <summary>Snippet for ReceiveTriggerWebhook</summary>
public void ReceiveTriggerWebhookRequestObject()
{
// Snippet: ReceiveTriggerWebhook(ReceiveTriggerWebhookRequest, CallSettings)
// Create client
CloudBuildClient cloudBuildClient = CloudBuildClient.Create();
// Initialize request argument(s)
ReceiveTriggerWebhookRequest request = new ReceiveTriggerWebhookRequest
{
Body = new HttpBody(),
ProjectId = "",
Trigger = "",
Secret = "",
};
// Make the request
ReceiveTriggerWebhookResponse response = cloudBuildClient.ReceiveTriggerWebhook(request);
// End snippet
}

/// <summary>Snippet for ReceiveTriggerWebhookAsync</summary>
public async Task ReceiveTriggerWebhookRequestObjectAsync()
{
// Snippet: ReceiveTriggerWebhookAsync(ReceiveTriggerWebhookRequest, CallSettings)
// Additional: ReceiveTriggerWebhookAsync(ReceiveTriggerWebhookRequest, CancellationToken)
// Create client
CloudBuildClient cloudBuildClient = await CloudBuildClient.CreateAsync();
// Initialize request argument(s)
ReceiveTriggerWebhookRequest request = new ReceiveTriggerWebhookRequest
{
Body = new HttpBody(),
ProjectId = "",
Trigger = "",
Secret = "",
};
// Make the request
ReceiveTriggerWebhookResponse response = await cloudBuildClient.ReceiveTriggerWebhookAsync(request);
// End snippet
}

/// <summary>Snippet for CreateWorkerPool</summary>
public void CreateWorkerPoolRequestObject()
{
Expand Down
Expand Up @@ -14,6 +14,7 @@

// Generated code. DO NOT EDIT!

using ga = Google.Api;
using gaxgrpc = Google.Api.Gax.Grpc;
using lro = Google.LongRunning;
using wkt = Google.Protobuf.WellKnownTypes;
Expand Down Expand Up @@ -78,6 +79,7 @@ public void GetBuildRequestObject()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.GetBuild(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -136,6 +138,7 @@ public void GetBuildRequestObject()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.GetBuildAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<Build>(stt::Task.FromResult(expectedResponse), null, null, null, null));
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -195,6 +198,7 @@ public void GetBuild()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.GetBuild(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -252,6 +256,7 @@ public void GetBuild()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.GetBuildAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<Build>(stt::Task.FromResult(expectedResponse), null, null, null, null));
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -312,6 +317,7 @@ public void CancelBuildRequestObject()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.CancelBuild(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -370,6 +376,7 @@ public void CancelBuildRequestObject()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.CancelBuildAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<Build>(stt::Task.FromResult(expectedResponse), null, null, null, null));
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -429,6 +436,7 @@ public void CancelBuild()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.CancelBuild(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -486,6 +494,7 @@ public void CancelBuild()
QueueTtl = new wkt::Duration(),
ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
BuildName = BuildName.FromProjectBuild("[PROJECT]", "[BUILD]"),
AvailableSecrets = new Secrets(),
};
mockGrpcClient.Setup(x => x.CancelBuildAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<Build>(stt::Task.FromResult(expectedResponse), null, null, null, null));
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
Expand Down Expand Up @@ -1122,6 +1131,48 @@ public void UpdateBuildTrigger()
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void ReceiveTriggerWebhookRequestObject()
{
moq::Mock<CloudBuild.CloudBuildClient> mockGrpcClient = new moq::Mock<CloudBuild.CloudBuildClient>(moq::MockBehavior.Strict);
mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock<lro::Operations.OperationsClient>().Object);
ReceiveTriggerWebhookRequest request = new ReceiveTriggerWebhookRequest
{
Body = new ga::HttpBody(),
ProjectId = "project_id43ad98b0",
Trigger = "trigger098ed0c7",
Secret = "secret9422be5e",
};
ReceiveTriggerWebhookResponse expectedResponse = new ReceiveTriggerWebhookResponse { };
mockGrpcClient.Setup(x => x.ReceiveTriggerWebhook(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
ReceiveTriggerWebhookResponse response = client.ReceiveTriggerWebhook(request);
xunit::Assert.Same(expectedResponse, response);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public async stt::Task ReceiveTriggerWebhookRequestObjectAsync()
{
moq::Mock<CloudBuild.CloudBuildClient> mockGrpcClient = new moq::Mock<CloudBuild.CloudBuildClient>(moq::MockBehavior.Strict);
mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock<lro::Operations.OperationsClient>().Object);
ReceiveTriggerWebhookRequest request = new ReceiveTriggerWebhookRequest
{
Body = new ga::HttpBody(),
ProjectId = "project_id43ad98b0",
Trigger = "trigger098ed0c7",
Secret = "secret9422be5e",
};
ReceiveTriggerWebhookResponse expectedResponse = new ReceiveTriggerWebhookResponse { };
mockGrpcClient.Setup(x => x.ReceiveTriggerWebhookAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<ReceiveTriggerWebhookResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
CloudBuildClient client = new CloudBuildClientImpl(mockGrpcClient.Object, null);
ReceiveTriggerWebhookResponse responseCallSettings = await client.ReceiveTriggerWebhookAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
xunit::Assert.Same(expectedResponse, responseCallSettings);
ReceiveTriggerWebhookResponse responseCancellationToken = await client.ReceiveTriggerWebhookAsync(request, st::CancellationToken.None);
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void CreateWorkerPoolRequestObject()
{
Expand Down

0 comments on commit f3ab04e

Please sign in to comment.