예제 #1
0
        internal ApiResult AttachRiskAnalysisToChangeRequest(RiskAnalysis riskAnalysis)
        {
            ApiResult apiResult = new ApiResult();

            try
            {
                if (!riskAnalysis.IsValid())
                {
                    apiResult.SetFailuresAsStatusInResponseFields(riskAnalysis.StatusDesc);
                    return(apiResult);
                }

                riskAnalysis.Save();
                apiResult.SetSuccessAsStatusInResponseFields();
            }
            catch (Exception ex)
            {
                HandleError(nameof(AttachSystemAffectedToChangeRequest), "EXCEPTION", ex.Message);
                apiResult.SetFailuresAsStatusInResponseFields(ex.Message);
            }
            return(apiResult);
        }
예제 #2
0
    public static void Main(string[] args)
    {
        // Command line argument parser we use doesn't support more than 15 options, therefore
        // we split it
        if (args.Length == 0)
        {
            Console.WriteLine("Invalid number of arguments supplied");
            Environment.Exit(-1);
        }

        switch (args[0])
        {
        case "redactImage":
            Parser.Default.ParseArguments <RedactFromImageOptions>(args).MapResult(
                (RedactFromImageOptions options) => RedactSamples.RedactFromImage(
                    options.ProjectId,
                    options.ImageFromPath,
                    options.ImageToPath),
                errs => 1);
            break;

        case "kAnonymity":
        case "lDiversity":
        case "deidDateShift":
        case "kMap":
        case "listInfoTypes":
        case "inspectBigQuery":
        case "inspectDataStore":
        case "inspectGcs":
            Parser.Default.ParseArguments <
                KAnonymityOptions,
                LDiversityOptions,
                DeidDateShiftOptions,
                KMapOptions,
                ListInfoTypesOptions,
                InspectBigQueryOptions,
                InspectDatastoreOptions,
                InspectGcsOptions>(args).MapResult(
                (KAnonymityOptions opts) => RiskAnalysis.KAnonymity(
                    opts.CallingProjectId,
                    opts.TableProjectId,
                    opts.DatasetId,
                    opts.TableId,
                    opts.TopicId,
                    opts.SubscriptionId,
                    DlpSamplesUtils.ParseQuasiIds(opts.QuasiIdColumns)),
                (LDiversityOptions opts) => RiskAnalysis.LDiversity(
                    opts.CallingProjectId,
                    opts.TableProjectId,
                    opts.DatasetId,
                    opts.TableId,
                    opts.TopicId,
                    opts.SubscriptionId,
                    DlpSamplesUtils.ParseQuasiIds(opts.QuasiIdColumns),
                    opts.SensitiveAttribute),
                (KMapOptions opts) => RiskAnalysis.KMap(
                    opts.CallingProjectId,
                    opts.TableProjectId,
                    opts.DatasetId,
                    opts.TableId,
                    opts.TopicId,
                    opts.SubscriptionId,
                    DlpSamplesUtils.ParseQuasiIds(opts.QuasiIdColumns),
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    opts.RegionCode),
                (DeidDateShiftOptions opts) => DeIdentify.DeidDateShift(
                    opts.ProjectId,
                    opts.InputCsvFile,
                    opts.OutputCsvFile,
                    opts.LowerBoundDays,
                    opts.UpperBoundDays,
                    opts.DateFields,
                    opts.ContextFieldId,
                    opts.KeyName,
                    opts.WrappedKey),
                (ListInfoTypesOptions opts) => Metadata.ListInfoTypes(
                    opts.LanguageCode,
                    opts.Filter),
                (InspectBigQueryOptions opts) => InspectSamples.InspectBigQuery(
                    opts.ProjectId,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    !opts.NoIncludeQuote,
                    DlpSamplesUtils.ParseIdentifyingFields(opts.IdentifyingFields),
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    DlpSamplesUtils.ParseCustomInfoTypes(opts.CustomDictionary, opts.CustomRegexes),
                    opts.DatasetId,
                    opts.TableId),
                (InspectDatastoreOptions opts) => InspectSamples.InspectCloudDataStore(
                    opts.ProjectId,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    !opts.NoIncludeQuote,
                    opts.KindName,
                    opts.NamespaceId,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    DlpSamplesUtils.ParseCustomInfoTypes(opts.CustomDictionary, opts.CustomRegexes),
                    opts.DatasetId,
                    opts.TableId),
                (InspectGcsOptions opts) => InspectSamples.InspectGCS(
                    opts.ProjectId,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    !opts.NoIncludeQuote,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    DlpSamplesUtils.ParseCustomInfoTypes(opts.CustomDictionary, opts.CustomRegexes),
                    opts.BucketName,
                    opts.TopicId,
                    opts.SubscriptionId),
                errs => 1);
            break;

        default:
            Parser.Default.ParseArguments <
                InspectStringOptions,
                InspectFileOptions,
                CreateTemplateOptions,
                ListTemplatesOptions,
                DeleteTemplatesOptions,
                DeidMaskOptions,
                DeidFpeOptions,
                ReidFpeOptions,
                ListJobsOptions,
                DeleteJobOptions,
                CreateJobTriggerOptions,
                ListJobTriggersOptions,
                DeleteJobTriggerOptions,
                NumericalStatsOptions,
                CategoricalStatsOptions>(args)
            .MapResult(
                (InspectStringOptions opts) => InspectSamples.InspectString(
                    opts.ProjectId,
                    opts.Value,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    !opts.NoIncludeQuote,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    DlpSamplesUtils.ParseCustomInfoTypes(opts.CustomDictionary, opts.CustomRegexes)),
                (InspectFileOptions opts) => InspectSamples.InspectFile(
                    opts.ProjectId,
                    opts.File,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    !opts.NoIncludeQuote,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    DlpSamplesUtils.ParseCustomInfoTypes(opts.CustomDictionary, opts.CustomRegexes)),
                (CreateTemplateOptions opts) => InspectTemplates.CreateInspectTemplate(
                    opts.ProjectId,
                    opts.TemplateId,
                    opts.DisplayName,
                    opts.Description,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    !opts.NoIncludeQuote),
                (ListTemplatesOptions opts) => InspectTemplates.ListInspectTemplate(opts.ProjectId),
                (DeleteTemplatesOptions opts) => InspectTemplates.DeleteInspectTemplate(opts.ProjectId, opts.TemplateName),
                (DeidMaskOptions opts) => DeIdentify.DeidMask(
                    opts.ProjectId,
                    opts.Value,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    opts.Mask,
                    opts.Num,
                    opts.Reverse),
                (DeidFpeOptions opts) => DeIdentify.DeidFpe(
                    opts.ProjectId,
                    opts.Value,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    opts.KeyName,
                    opts.WrappedKeyFile,
                    opts.Alphabet),
                (ReidFpeOptions opts) => DeIdentify.ReidFpe(
                    opts.ProjectId,
                    opts.Value,
                    opts.KeyName,
                    opts.WrappedKeyFile,
                    opts.Alphabet),
                (ListJobsOptions opts) => Jobs.ListJobs(
                    opts.ProjectId,
                    opts.Filter,
                    opts.JobType),
                (DeleteJobOptions opts) => Jobs.DeleteJob(opts.JobName),
                (CreateJobTriggerOptions opts) => JobTriggers.CreateJobTrigger(
                    opts.ProjectId,
                    opts.BucketName,
                    opts.MinLikelihood,
                    opts.MaxFindings,
                    opts.AutoPopulateTimespan,
                    opts.ScanPeriod,
                    DlpSamplesUtils.ParseInfoTypes(opts.InfoTypes),
                    opts.TriggerId,
                    opts.DisplayName,
                    opts.Description
                    ),
                (ListJobTriggersOptions opts) => JobTriggers.ListJobTriggers(
                    opts.ProjectId
                    ),
                (DeleteJobTriggerOptions opts) => JobTriggers.DeleteJobTrigger(
                    opts.TriggerName
                    ),
                (NumericalStatsOptions opts) => RiskAnalysis.NumericalStats(
                    opts.CallingProjectId,
                    opts.TableProjectId,
                    opts.DatasetId,
                    opts.TableId,
                    opts.TopicId,
                    opts.SubscriptionId,
                    opts.ColumnName
                    ),
                (CategoricalStatsOptions opts) => RiskAnalysis.CategoricalStats(
                    opts.CallingProjectId,
                    opts.TableProjectId,
                    opts.DatasetId,
                    opts.TableId,
                    opts.TopicId,
                    opts.SubscriptionId,
                    opts.ColumnName
                    ),
                errs => 1);
            break;
        }
    }
예제 #3
0
 public ApiResult AttachRiskAnalysisToChangeRequest(RiskAnalysis riskAnalysis) => cRSubSystemAPI.AttachRiskAnalysisToChangeRequest(riskAnalysis);
 public ApiResult AttachRiskAnalysisToChangeRequest(RiskAnalysis riskAnalysis) => bll.AttachRiskAnalysisToChangeRequest(riskAnalysis);