/// <summary>Snippet for CreateInspectTemplate</summary> public void CreateInspectTemplate_RequestObject() { // Snippet: CreateInspectTemplate(CreateInspectTemplateRequest,CallSettings) // Create client DlpServiceClient dlpServiceClient = DlpServiceClient.Create(); // Initialize request argument(s) CreateInspectTemplateRequest request = new CreateInspectTemplateRequest { ParentAsOrganizationName = new OrganizationName("[ORGANIZATION]"), }; // Make the request InspectTemplate response = dlpServiceClient.CreateInspectTemplate(request); // End snippet }
/// <summary>Snippet for CreateInspectTemplateAsync</summary> public async Task CreateInspectTemplateAsync_RequestObject() { // Snippet: CreateInspectTemplateAsync(CreateInspectTemplateRequest,CallSettings) // Additional: CreateInspectTemplateAsync(CreateInspectTemplateRequest,CancellationToken) // Create client DlpServiceClient dlpServiceClient = await DlpServiceClient.CreateAsync(); // Initialize request argument(s) CreateInspectTemplateRequest request = new CreateInspectTemplateRequest { ParentAsOrganizationName = new OrganizationName("[ORGANIZATION]"), }; // Make the request InspectTemplate response = await dlpServiceClient.CreateInspectTemplateAsync(request); // End snippet }
public async Task CreateInspectTemplateAsync() { Mock <DlpService.DlpServiceClient> mockGrpcClient = new Mock <DlpService.DlpServiceClient>(MockBehavior.Strict); CreateInspectTemplateRequest request = new CreateInspectTemplateRequest { ParentAsOrganizationName = new OrganizationName("[ORGANIZATION]"), }; InspectTemplate expectedResponse = new InspectTemplate { Name = "name3373707", DisplayName = "displayName1615086568", Description = "description-1724546052", }; mockGrpcClient.Setup(x => x.CreateInspectTemplateAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <InspectTemplate>(Task.FromResult(expectedResponse), null, null, null, null)); DlpServiceClient client = new DlpServiceClientImpl(mockGrpcClient.Object, null); InspectTemplate response = await client.CreateInspectTemplateAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
// [START dlp_create_inspect_template] public static string CreateInspectTemplate( string projectId, string templateId, string displayName, string description, string likelihood, int maxFindings, bool includeQuote) { DlpServiceClient client = DlpServiceClient.Create(); var request = new CreateInspectTemplateRequest { Parent = $"projects/{projectId}", InspectTemplate = new InspectTemplate { DisplayName = displayName, Description = description, InspectConfig = new InspectConfig { MinLikelihood = (Likelihood)Enum.Parse(typeof(Likelihood), likelihood), Limits = new InspectConfig.Types.FindingLimits { MaxFindingsPerRequest = maxFindings }, IncludeQuote = includeQuote }, }, TemplateId = templateId }; var response = client.CreateInspectTemplate(request); Console.WriteLine($"Successfully created template {response.Name}."); return(response.Name); }
public static InspectTemplate Create( string projectId, string templateId, string displayName, string description, Likelihood likelihood, int maxFindings, bool includeQuote) { var client = DlpServiceClient.Create(); var request = new CreateInspectTemplateRequest { Parent = new LocationName(projectId, "global").ToString(), InspectTemplate = new InspectTemplate { DisplayName = displayName, Description = description, InspectConfig = new InspectConfig { MinLikelihood = likelihood, Limits = new InspectConfig.Types.FindingLimits { MaxFindingsPerRequest = maxFindings }, IncludeQuote = includeQuote }, }, TemplateId = templateId }; var response = client.CreateInspectTemplate(request); Console.WriteLine($"Successfully created template {response.Name}."); return(response); }