Skip to content

Commit

Permalink
feat: add SubmitUri endpoint
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 533110799

Source-Link: googleapis/googleapis@3f5d0c9

Source-Link: https://github.com/googleapis/googleapis-gen/commit/530de5758e4e2cdb6af6d0cab7ad829171142a1f
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuV2ViUmlzay5WMS8uT3dsQm90LnlhbWwiLCJoIjoiNTMwZGU1NzU4ZTRlMmNkYjZhZjZkMGNhYjdhZDgyOTE3MTE0MmExZiJ9
  • Loading branch information
gcf-owl-bot[bot] authored and Rishabh-V committed May 18, 2023
1 parent fcf9391 commit bb16fb8
Show file tree
Hide file tree
Showing 13 changed files with 2,726 additions and 179 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2023 Google LLC
//
// 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
//
// https://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.

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START webrisk_v1_generated_WebRiskService_SubmitUri_async]
using Google.Api.Gax.ResourceNames;
using Google.Cloud.WebRisk.V1;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedWebRiskServiceClientSnippets
{
/// <summary>Snippet for SubmitUriAsync</summary>
/// <remarks>
/// 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/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task SubmitUriRequestObjectAsync()
{
// Create client
WebRiskServiceClient webRiskServiceClient = await WebRiskServiceClient.CreateAsync();
// Initialize request argument(s)
SubmitUriRequest request = new SubmitUriRequest
{
ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
Submission = new Submission(),
ThreatInfo = new ThreatInfo(),
ThreatDiscovery = new ThreatDiscovery(),
};
// Make the request
Operation<Submission, SubmitUriMetadata> response = await webRiskServiceClient.SubmitUriAsync(request);

// Poll until the returned long-running operation is complete
Operation<Submission, SubmitUriMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Submission result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Submission, SubmitUriMetadata> retrievedResponse = await webRiskServiceClient.PollOnceSubmitUriAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Submission retrievedResult = retrievedResponse.Result;
}
}
}
// [END webrisk_v1_generated_WebRiskService_SubmitUri_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2023 Google LLC
//
// 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
//
// https://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.

// Generated code. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START webrisk_v1_generated_WebRiskService_SubmitUri_sync]
using Google.Api.Gax.ResourceNames;
using Google.Cloud.WebRisk.V1;
using Google.LongRunning;

public sealed partial class GeneratedWebRiskServiceClientSnippets
{
/// <summary>Snippet for SubmitUri</summary>
/// <remarks>
/// 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/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void SubmitUriRequestObject()
{
// Create client
WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.Create();
// Initialize request argument(s)
SubmitUriRequest request = new SubmitUriRequest
{
ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
Submission = new Submission(),
ThreatInfo = new ThreatInfo(),
ThreatDiscovery = new ThreatDiscovery(),
};
// Make the request
Operation<Submission, SubmitUriMetadata> response = webRiskServiceClient.SubmitUri(request);

// Poll until the returned long-running operation is complete
Operation<Submission, SubmitUriMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Submission result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Submission, SubmitUriMetadata> retrievedResponse = webRiskServiceClient.PollOnceSubmitUri(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Submission retrievedResult = retrievedResponse.Result;
}
}
}
// [END webrisk_v1_generated_WebRiskService_SubmitUri_sync]
}
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,103 @@
"type": "SHORT"
}
]
},
{
"regionTag": "webrisk_v1_generated_WebRiskService_SubmitUri_sync",
"title": "SubmitUriRequestObject",
"description": "Snippet for SubmitUri",
"file": "WebRiskServiceClient.SubmitUriRequestObjectSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "SubmitUri",
"fullName": "Google.Cloud.WebRisk.V1.WebRiskServiceClient.SubmitUri",
"parameters": [
{
"type": "Google.Cloud.WebRisk.V1.SubmitUriRequest",
"name": "request"
},
{
"type": "Google.Api.Gax.Grpc.CallSettings",
"name": "callSettings"
}
],
"resultType": "Google.LongRunning.Operation<Google.Cloud.WebRisk.V1.Submission, Google.Cloud.WebRisk.V1.SubmitUriMetadata>",
"client": {
"shortName": "WebRiskServiceClient",
"fullName": "Google.Cloud.WebRisk.V1.WebRiskServiceClient"
},
"method": {
"shortName": "SubmitUri",
"fullName": "google.cloud.webrisk.v1.WebRiskService.SubmitUri",
"service": {
"shortName": "WebRiskService",
"fullName": "google.cloud.webrisk.v1.WebRiskService"
}
}
},
"canonical": true,
"origin": "API_DEFINITION",
"segments": [
{
"start": 20,
"end": 65,
"type": "FULL"
},
{
"start": 36,
"end": 63,
"type": "SHORT"
}
]
},
{
"regionTag": "webrisk_v1_generated_WebRiskService_SubmitUri_async",
"title": "SubmitUriRequestObjectAsync",
"description": "Snippet for SubmitUriAsync",
"file": "WebRiskServiceClient.SubmitUriRequestObjectAsyncSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "SubmitUriAsync",
"fullName": "Google.Cloud.WebRisk.V1.WebRiskServiceClient.SubmitUriAsync",
"async": true,
"parameters": [
{
"type": "Google.Cloud.WebRisk.V1.SubmitUriRequest",
"name": "request"
},
{
"type": "Google.Api.Gax.Grpc.CallSettings",
"name": "callSettings"
}
],
"resultType": "System.Threading.Tasks.Task<Google.LongRunning.Operation<Google.Cloud.WebRisk.V1.Submission, Google.Cloud.WebRisk.V1.SubmitUriMetadata>>",
"client": {
"shortName": "WebRiskServiceClient",
"fullName": "Google.Cloud.WebRisk.V1.WebRiskServiceClient"
},
"method": {
"shortName": "SubmitUri",
"fullName": "google.cloud.webrisk.v1.WebRiskService.SubmitUri",
"service": {
"shortName": "WebRiskService",
"fullName": "google.cloud.webrisk.v1.WebRiskService"
}
}
},
"canonical": true,
"origin": "API_DEFINITION",
"segments": [
{
"start": 20,
"end": 66,
"type": "FULL"
},
{
"start": 37,
"end": 64,
"type": "SHORT"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace GoogleCSharpSnippets
{
using Google.Api.Gax.ResourceNames;
using Google.Cloud.WebRisk.V1;
using Google.LongRunning;
using Google.Protobuf;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -337,5 +338,76 @@ public async Task CreateSubmissionResourceNamesAsync()
Submission response = await webRiskServiceClient.CreateSubmissionAsync(parent, submission);
// End snippet
}

/// <summary>Snippet for SubmitUri</summary>
public void SubmitUriRequestObject()
{
// Snippet: SubmitUri(SubmitUriRequest, CallSettings)
// Create client
WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.Create();
// Initialize request argument(s)
SubmitUriRequest request = new SubmitUriRequest
{
ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
Submission = new Submission(),
ThreatInfo = new ThreatInfo(),
ThreatDiscovery = new ThreatDiscovery(),
};
// Make the request
Operation<Submission, SubmitUriMetadata> response = webRiskServiceClient.SubmitUri(request);

// Poll until the returned long-running operation is complete
Operation<Submission, SubmitUriMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Submission result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Submission, SubmitUriMetadata> retrievedResponse = webRiskServiceClient.PollOnceSubmitUri(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Submission retrievedResult = retrievedResponse.Result;
}
// End snippet
}

/// <summary>Snippet for SubmitUriAsync</summary>
public async Task SubmitUriRequestObjectAsync()
{
// Snippet: SubmitUriAsync(SubmitUriRequest, CallSettings)
// Additional: SubmitUriAsync(SubmitUriRequest, CancellationToken)
// Create client
WebRiskServiceClient webRiskServiceClient = await WebRiskServiceClient.CreateAsync();
// Initialize request argument(s)
SubmitUriRequest request = new SubmitUriRequest
{
ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
Submission = new Submission(),
ThreatInfo = new ThreatInfo(),
ThreatDiscovery = new ThreatDiscovery(),
};
// Make the request
Operation<Submission, SubmitUriMetadata> response = await webRiskServiceClient.SubmitUriAsync(request);

// Poll until the returned long-running operation is complete
Operation<Submission, SubmitUriMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Submission result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Submission, SubmitUriMetadata> retrievedResponse = await webRiskServiceClient.PollOnceSubmitUriAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Submission retrievedResult = retrievedResponse.Result;
}
// End snippet
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Google.Api.Gax.Grpc" Version="[4.3.0, 5.0.0)" />
<PackageReference Include="Google.LongRunning" Version="[3.0.0, 4.0.0)" />
<PackageReference Include="Grpc.Core" Version="[2.46.5, 3.0.0)" PrivateAssets="None" Condition="'$(TargetFramework)'=='net462'" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#pragma warning disable CS8981
using gaxgrpc = Google.Api.Gax.Grpc;
using lro = Google.LongRunning;
using proto = Google.Protobuf;
using gpr = Google.Protobuf.Reflection;
using scg = System.Collections.Generic;

Expand All @@ -26,11 +28,35 @@ internal static class PackageApiMetadata
{
/// <summary>The <see cref="gaxgrpc::ApiMetadata"/> for services in this package.</summary>
internal static gaxgrpc::ApiMetadata ApiMetadata { get; } = new gaxgrpc::ApiMetadata("Google.Cloud.WebRisk.V1", GetFileDescriptors)
.WithRequestNumericEnumJsonEncoding(true);
.WithRequestNumericEnumJsonEncoding(true)
.WithHttpRuleOverrides(new scg::Dictionary<string, proto::ByteString>
{
{
"google.longrunning.Operations.CancelOperation",
// { "post": "/v1/{name=projects/*/operations/*}:cancel", "body": "*" }
proto::ByteString.FromBase64("IikvdjEve25hbWU9cHJvamVjdHMvKi9vcGVyYXRpb25zLyp9OmNhbmNlbDoBKg==")
},
{
"google.longrunning.Operations.DeleteOperation",
// { "delete": "/v1/{name=projects/*/operations/*}" }
proto::ByteString.FromBase64("KiIvdjEve25hbWU9cHJvamVjdHMvKi9vcGVyYXRpb25zLyp9")
},
{
"google.longrunning.Operations.GetOperation",
// { "get": "/v1/{name=projects/*/operations/*}" }
proto::ByteString.FromBase64("EiIvdjEve25hbWU9cHJvamVjdHMvKi9vcGVyYXRpb25zLyp9")
},
{
"google.longrunning.Operations.ListOperations",
// { "get": "/v1/{name=projects/*}/operations" }
proto::ByteString.FromBase64("EiAvdjEve25hbWU9cHJvamVjdHMvKn0vb3BlcmF0aW9ucw==")
},
});

private static scg::IEnumerable<gpr::FileDescriptor> GetFileDescriptors()
{
yield return WebriskReflection.Descriptor;
yield return lro::OperationsReflection.Descriptor;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#pragma warning disable CS8981
using gaxgrpc = Google.Api.Gax.Grpc;
using gcwv = Google.Cloud.WebRisk.V1;
using lro = Google.LongRunning;
using proto = Google.Protobuf;
using gpr = Google.Protobuf.Reflection;
using sys = System;
using scg = System.Collections.Generic;
Expand Down

0 comments on commit bb16fb8

Please sign in to comment.