From 206caf16ec6efea09966e214fe9547639687ffae Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 18:50:11 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#703) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- google-cloud-websecurityscanner/pom.xml | 16 + .../v1/WebSecurityScannerClient.java | 15 + .../v1/WebSecurityScannerSettings.java | 23 +- ...JsonWebSecurityScannerCallableFactory.java | 105 ++ .../stub/HttpJsonWebSecurityScannerStub.java | 880 +++++++++++ .../stub/WebSecurityScannerStubSettings.java | 53 +- .../v1alpha/WebSecurityScannerClient.java | 15 + .../v1alpha/WebSecurityScannerSettings.java | 23 +- ...JsonWebSecurityScannerCallableFactory.java | 105 ++ .../stub/HttpJsonWebSecurityScannerStub.java | 882 +++++++++++ .../stub/WebSecurityScannerStubSettings.java | 53 +- .../v1beta/WebSecurityScannerClient.java | 15 + .../v1beta/WebSecurityScannerSettings.java | 23 +- ...JsonWebSecurityScannerCallableFactory.java | 105 ++ .../stub/HttpJsonWebSecurityScannerStub.java | 880 +++++++++++ .../stub/WebSecurityScannerStubSettings.java | 53 +- .../WebSecurityScannerClientHttpJsonTest.java | 863 +++++++++++ .../WebSecurityScannerClientHttpJsonTest.java | 1362 ++++++++++++++++ .../WebSecurityScannerClientHttpJsonTest.java | 1378 +++++++++++++++++ .../SyncCreateScanConfig.java | 47 + .../SyncCreateSetCredentialsProvider.java | 43 + .../SyncCreateSetCredentialsProvider1.java | 43 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateScanConfig.java | 47 + .../SyncCreateScanConfig.java | 43 + .../AsyncDeleteScanConfig.java | 44 + .../SyncDeleteScanConfig.java | 39 + .../getfinding/AsyncGetFinding.java | 42 + .../getfinding/SyncGetFinding.java | 39 + .../getscanconfig/AsyncGetScanConfig.java | 44 + .../getscanconfig/SyncGetScanConfig.java | 40 + .../getscanrun/AsyncGetScanRun.java | 42 + .../getscanrun/SyncGetScanRun.java | 39 + .../listcrawledurls/AsyncListCrawledUrls.java | 50 + .../AsyncListCrawledUrlsPaged.java | 58 + .../listcrawledurls/SyncListCrawledUrls.java | 46 + .../listfindings/AsyncListFindings.java | 51 + .../listfindings/AsyncListFindingsPaged.java | 59 + .../listfindings/SyncListFindings.java | 47 + .../AsyncListFindingTypeStats.java | 44 + .../SyncListFindingTypeStats.java | 41 + .../listscanconfigs/AsyncListScanConfigs.java | 50 + .../AsyncListScanConfigsPaged.java | 58 + .../listscanconfigs/SyncListScanConfigs.java | 46 + .../listscanruns/AsyncListScanRuns.java | 50 + .../listscanruns/AsyncListScanRunsPaged.java | 58 + .../listscanruns/SyncListScanRuns.java | 46 + .../startscanrun/AsyncStartScanRun.java | 43 + .../startscanrun/SyncStartScanRun.java | 39 + .../stopscanrun/AsyncStopScanRun.java | 43 + .../stopscanrun/SyncStopScanRun.java | 39 + .../AsyncUpdateScanConfig.java | 48 + .../SyncUpdateScanConfig.java | 44 + .../SyncCreateScanConfig.java | 47 + .../SyncCreateScanConfig.java | 47 + .../SyncCreateSetCredentialsProvider.java | 44 + .../SyncCreateSetCredentialsProvider1.java | 43 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateScanConfig.java | 48 + .../SyncCreateScanConfig.java | 44 + ...CreateScanConfigProjectnameScanconfig.java | 42 + .../SyncCreateScanConfigStringScanconfig.java | 42 + .../AsyncDeleteScanConfig.java | 47 + .../SyncDeleteScanConfig.java | 42 + .../SyncDeleteScanConfigScanconfigname.java | 40 + .../SyncDeleteScanConfigString.java | 39 + .../getfinding/AsyncGetFinding.java | 48 + .../getfinding/SyncGetFinding.java | 45 + .../getfinding/SyncGetFindingFindingname.java | 39 + .../getfinding/SyncGetFindingString.java | 40 + .../getscanconfig/AsyncGetScanConfig.java | 47 + .../getscanconfig/SyncGetScanConfig.java | 43 + .../SyncGetScanConfigScanconfigname.java | 41 + .../SyncGetScanConfigString.java | 39 + .../getscanrun/AsyncGetScanRun.java | 46 + .../getscanrun/SyncGetScanRun.java | 43 + .../getscanrun/SyncGetScanRunScanrunname.java | 39 + .../getscanrun/SyncGetScanRunString.java | 39 + .../listcrawledurls/AsyncListCrawledUrls.java | 51 + .../AsyncListCrawledUrlsPaged.java | 59 + .../listcrawledurls/SyncListCrawledUrls.java | 47 + .../SyncListCrawledUrlsScanrunname.java | 43 + .../SyncListCrawledUrlsString.java | 41 + .../listfindings/AsyncListFindings.java | 52 + .../listfindings/AsyncListFindingsPaged.java | 60 + .../listfindings/SyncListFindings.java | 48 + .../SyncListFindingsScanrunnameString.java | 44 + .../SyncListFindingsStringString.java | 44 + .../AsyncListFindingTypeStats.java | 47 + .../SyncListFindingTypeStats.java | 44 + .../SyncListFindingTypeStatsScanrunname.java | 41 + .../SyncListFindingTypeStatsString.java | 41 + .../listscanconfigs/AsyncListScanConfigs.java | 51 + .../AsyncListScanConfigsPaged.java | 59 + .../listscanconfigs/SyncListScanConfigs.java | 47 + .../SyncListScanConfigsProjectname.java | 43 + .../SyncListScanConfigsString.java | 41 + .../listscanruns/AsyncListScanRuns.java | 51 + .../listscanruns/AsyncListScanRunsPaged.java | 59 + .../listscanruns/SyncListScanRuns.java | 47 + .../SyncListScanRunsScanconfigname.java | 43 + .../listscanruns/SyncListScanRunsString.java | 41 + .../startscanrun/AsyncStartScanRun.java | 47 + .../startscanrun/SyncStartScanRun.java | 43 + .../SyncStartScanRunScanconfigname.java | 41 + .../startscanrun/SyncStartScanRunString.java | 39 + .../stopscanrun/AsyncStopScanRun.java | 47 + .../stopscanrun/SyncStopScanRun.java | 43 + .../SyncStopScanRunScanrunname.java | 40 + .../stopscanrun/SyncStopScanRunString.java | 39 + .../AsyncUpdateScanConfig.java | 48 + .../SyncUpdateScanConfig.java | 44 + ...ncUpdateScanConfigScanconfigFieldmask.java | 42 + .../SyncCreateScanConfig.java | 47 + .../SyncCreateScanConfig.java | 47 + .../SyncCreateSetCredentialsProvider.java | 44 + .../SyncCreateSetCredentialsProvider1.java | 43 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateScanConfig.java | 48 + .../SyncCreateScanConfig.java | 44 + ...CreateScanConfigProjectnameScanconfig.java | 42 + .../SyncCreateScanConfigStringScanconfig.java | 42 + .../AsyncDeleteScanConfig.java | 47 + .../SyncDeleteScanConfig.java | 42 + .../SyncDeleteScanConfigScanconfigname.java | 40 + .../SyncDeleteScanConfigString.java | 38 + .../getfinding/AsyncGetFinding.java | 48 + .../getfinding/SyncGetFinding.java | 45 + .../getfinding/SyncGetFindingFindingname.java | 39 + .../getfinding/SyncGetFindingString.java | 40 + .../getscanconfig/AsyncGetScanConfig.java | 47 + .../getscanconfig/SyncGetScanConfig.java | 43 + .../SyncGetScanConfigScanconfigname.java | 41 + .../SyncGetScanConfigString.java | 39 + .../getscanrun/AsyncGetScanRun.java | 46 + .../getscanrun/SyncGetScanRun.java | 43 + .../getscanrun/SyncGetScanRunScanrunname.java | 39 + .../getscanrun/SyncGetScanRunString.java | 39 + .../listcrawledurls/AsyncListCrawledUrls.java | 51 + .../AsyncListCrawledUrlsPaged.java | 59 + .../listcrawledurls/SyncListCrawledUrls.java | 47 + .../SyncListCrawledUrlsScanrunname.java | 43 + .../SyncListCrawledUrlsString.java | 41 + .../listfindings/AsyncListFindings.java | 52 + .../listfindings/AsyncListFindingsPaged.java | 60 + .../listfindings/SyncListFindings.java | 48 + .../SyncListFindingsScanrunnameString.java | 44 + .../SyncListFindingsStringString.java | 43 + .../AsyncListFindingTypeStats.java | 47 + .../SyncListFindingTypeStats.java | 44 + .../SyncListFindingTypeStatsScanrunname.java | 41 + .../SyncListFindingTypeStatsString.java | 41 + .../listscanconfigs/AsyncListScanConfigs.java | 51 + .../AsyncListScanConfigsPaged.java | 59 + .../listscanconfigs/SyncListScanConfigs.java | 47 + .../SyncListScanConfigsProjectname.java | 43 + .../SyncListScanConfigsString.java | 41 + .../listscanruns/AsyncListScanRuns.java | 51 + .../listscanruns/AsyncListScanRunsPaged.java | 59 + .../listscanruns/SyncListScanRuns.java | 47 + .../SyncListScanRunsScanconfigname.java | 43 + .../listscanruns/SyncListScanRunsString.java | 41 + .../startscanrun/AsyncStartScanRun.java | 47 + .../startscanrun/SyncStartScanRun.java | 43 + .../SyncStartScanRunScanconfigname.java | 41 + .../startscanrun/SyncStartScanRunString.java | 39 + .../stopscanrun/AsyncStopScanRun.java | 47 + .../stopscanrun/SyncStopScanRun.java | 43 + .../SyncStopScanRunScanrunname.java | 39 + .../stopscanrun/SyncStopScanRunString.java | 39 + .../AsyncUpdateScanConfig.java | 48 + .../SyncUpdateScanConfig.java | 44 + ...ncUpdateScanConfigScanconfigFieldmask.java | 42 + .../SyncCreateScanConfig.java | 47 + 174 files changed, 13809 insertions(+), 15 deletions(-) create mode 100644 google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerCallableFactory.java create mode 100644 google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerStub.java create mode 100644 google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerCallableFactory.java create mode 100644 google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerStub.java create mode 100644 google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerCallableFactory.java create mode 100644 google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerStub.java create mode 100644 google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClientHttpJsonTest.java create mode 100644 google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClientHttpJsonTest.java create mode 100644 google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClientHttpJsonTest.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/AsyncGetFinding.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/SyncGetFinding.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/AsyncGetScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/SyncGetScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindings.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/SyncListFindings.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRuns.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/SyncListScanRuns.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/AsyncStartScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/SyncStartScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/SyncStopScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/AsyncGetFinding.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFinding.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/AsyncGetScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindings.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindings.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRuns.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRuns.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/AsyncStartScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/AsyncGetFinding.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFinding.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/AsyncGetScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindings.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindings.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRuns.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRuns.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/AsyncStartScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRun.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java diff --git a/google-cloud-websecurityscanner/pom.xml b/google-cloud-websecurityscanner/pom.xml index 9112248f..98bfd2af 100644 --- a/google-cloud-websecurityscanner/pom.xml +++ b/google-cloud-websecurityscanner/pom.xml @@ -66,6 +66,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -103,12 +107,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClient.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClient.java index 6315711b..d05e5287 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClient.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClient.java @@ -106,6 +106,21 @@ * WebSecurityScannerClient.create(webSecurityScannerSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * WebSecurityScannerSettings webSecurityScannerSettings =
+ *     WebSecurityScannerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * WebSecurityScannerClient webSecurityScannerClient =
+ *     WebSecurityScannerClient.create(webSecurityScannerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerSettings.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerSettings.java index bf6583ac..838d6101 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerSettings.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -174,11 +175,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return WebSecurityScannerStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return WebSecurityScannerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return WebSecurityScannerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return WebSecurityScannerStubSettings.defaultTransportChannelProvider(); } @@ -188,11 +196,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return WebSecurityScannerStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -230,6 +244,11 @@ private static Builder createDefault() { return new Builder(WebSecurityScannerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(WebSecurityScannerStubSettings.newHttpJsonBuilder()); + } + public WebSecurityScannerStubSettings.Builder getStubSettingsBuilder() { return ((WebSecurityScannerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerCallableFactory.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerCallableFactory.java new file mode 100644 index 00000000..79930c68 --- /dev/null +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the WebSecurityScanner service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonWebSecurityScannerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerStub.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerStub.java new file mode 100644 index 00000000..448c4ade --- /dev/null +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/HttpJsonWebSecurityScannerStub.java @@ -0,0 +1,880 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.stub; + +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListCrawledUrlsPagedResponse; +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListFindingsPagedResponse; +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListScanConfigsPagedResponse; +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListScanRunsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.websecurityscanner.v1.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.Finding; +import com.google.cloud.websecurityscanner.v1.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1.ListCrawledUrlsResponse; +import com.google.cloud.websecurityscanner.v1.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1.ListFindingsResponse; +import com.google.cloud.websecurityscanner.v1.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1.ListScanConfigsResponse; +import com.google.cloud.websecurityscanner.v1.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1.ListScanRunsResponse; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1.UpdateScanConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the WebSecurityScanner service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonWebSecurityScannerStub extends WebSecurityScannerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/CreateScanConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/scanConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("scanConfig", request.getScanConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/DeleteScanConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listScanConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/scanConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListScanConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/UpdateScanConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{scanConfig.name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "scanConfig.name", request.getScanConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("scanConfig", request.getScanConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + startScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/StartScanRun") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/scanConfigs/*}:start", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.websecurityscanner.v1.WebSecurityScanner/GetScanRun") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/scanConfigs/*/scanRuns/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listScanRunsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/ListScanRuns") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/scanConfigs/*}/scanRuns", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListScanRunsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + stopScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/StopScanRun") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/scanConfigs/*/scanRuns/*}:stop", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listCrawledUrlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/ListCrawledUrls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCrawledUrlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.websecurityscanner.v1.WebSecurityScanner/GetFinding") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListFindingTypeStatsRequest, ListFindingTypeStatsResponse> + listFindingTypeStatsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1.WebSecurityScanner/ListFindingTypeStats") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingTypeStatsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createScanConfigCallable; + private final UnaryCallable deleteScanConfigCallable; + private final UnaryCallable getScanConfigCallable; + private final UnaryCallable + listScanConfigsCallable; + private final UnaryCallable + listScanConfigsPagedCallable; + private final UnaryCallable updateScanConfigCallable; + private final UnaryCallable startScanRunCallable; + private final UnaryCallable getScanRunCallable; + private final UnaryCallable listScanRunsCallable; + private final UnaryCallable + listScanRunsPagedCallable; + private final UnaryCallable stopScanRunCallable; + private final UnaryCallable + listCrawledUrlsCallable; + private final UnaryCallable + listCrawledUrlsPagedCallable; + private final UnaryCallable getFindingCallable; + private final UnaryCallable listFindingsCallable; + private final UnaryCallable + listFindingsPagedCallable; + private final UnaryCallable + listFindingTypeStatsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonWebSecurityScannerStub create(WebSecurityScannerStubSettings settings) + throws IOException { + return new HttpJsonWebSecurityScannerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonWebSecurityScannerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonWebSecurityScannerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonWebSecurityScannerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonWebSecurityScannerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonWebSecurityScannerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listScanConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listScanConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings startScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(startScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listScanRunsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listScanRunsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings stopScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(stopScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listCrawledUrlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCrawledUrlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listFindingTypeStatsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listFindingTypeStatsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createScanConfigCallable = + callableFactory.createUnaryCallable( + createScanConfigTransportSettings, settings.createScanConfigSettings(), clientContext); + this.deleteScanConfigCallable = + callableFactory.createUnaryCallable( + deleteScanConfigTransportSettings, settings.deleteScanConfigSettings(), clientContext); + this.getScanConfigCallable = + callableFactory.createUnaryCallable( + getScanConfigTransportSettings, settings.getScanConfigSettings(), clientContext); + this.listScanConfigsCallable = + callableFactory.createUnaryCallable( + listScanConfigsTransportSettings, settings.listScanConfigsSettings(), clientContext); + this.listScanConfigsPagedCallable = + callableFactory.createPagedCallable( + listScanConfigsTransportSettings, settings.listScanConfigsSettings(), clientContext); + this.updateScanConfigCallable = + callableFactory.createUnaryCallable( + updateScanConfigTransportSettings, settings.updateScanConfigSettings(), clientContext); + this.startScanRunCallable = + callableFactory.createUnaryCallable( + startScanRunTransportSettings, settings.startScanRunSettings(), clientContext); + this.getScanRunCallable = + callableFactory.createUnaryCallable( + getScanRunTransportSettings, settings.getScanRunSettings(), clientContext); + this.listScanRunsCallable = + callableFactory.createUnaryCallable( + listScanRunsTransportSettings, settings.listScanRunsSettings(), clientContext); + this.listScanRunsPagedCallable = + callableFactory.createPagedCallable( + listScanRunsTransportSettings, settings.listScanRunsSettings(), clientContext); + this.stopScanRunCallable = + callableFactory.createUnaryCallable( + stopScanRunTransportSettings, settings.stopScanRunSettings(), clientContext); + this.listCrawledUrlsCallable = + callableFactory.createUnaryCallable( + listCrawledUrlsTransportSettings, settings.listCrawledUrlsSettings(), clientContext); + this.listCrawledUrlsPagedCallable = + callableFactory.createPagedCallable( + listCrawledUrlsTransportSettings, settings.listCrawledUrlsSettings(), clientContext); + this.getFindingCallable = + callableFactory.createUnaryCallable( + getFindingTransportSettings, settings.getFindingSettings(), clientContext); + this.listFindingsCallable = + callableFactory.createUnaryCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingsPagedCallable = + callableFactory.createPagedCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingTypeStatsCallable = + callableFactory.createUnaryCallable( + listFindingTypeStatsTransportSettings, + settings.listFindingTypeStatsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createScanConfigMethodDescriptor); + methodDescriptors.add(deleteScanConfigMethodDescriptor); + methodDescriptors.add(getScanConfigMethodDescriptor); + methodDescriptors.add(listScanConfigsMethodDescriptor); + methodDescriptors.add(updateScanConfigMethodDescriptor); + methodDescriptors.add(startScanRunMethodDescriptor); + methodDescriptors.add(getScanRunMethodDescriptor); + methodDescriptors.add(listScanRunsMethodDescriptor); + methodDescriptors.add(stopScanRunMethodDescriptor); + methodDescriptors.add(listCrawledUrlsMethodDescriptor); + methodDescriptors.add(getFindingMethodDescriptor); + methodDescriptors.add(listFindingsMethodDescriptor); + methodDescriptors.add(listFindingTypeStatsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createScanConfigCallable() { + return createScanConfigCallable; + } + + @Override + public UnaryCallable deleteScanConfigCallable() { + return deleteScanConfigCallable; + } + + @Override + public UnaryCallable getScanConfigCallable() { + return getScanConfigCallable; + } + + @Override + public UnaryCallable listScanConfigsCallable() { + return listScanConfigsCallable; + } + + @Override + public UnaryCallable + listScanConfigsPagedCallable() { + return listScanConfigsPagedCallable; + } + + @Override + public UnaryCallable updateScanConfigCallable() { + return updateScanConfigCallable; + } + + @Override + public UnaryCallable startScanRunCallable() { + return startScanRunCallable; + } + + @Override + public UnaryCallable getScanRunCallable() { + return getScanRunCallable; + } + + @Override + public UnaryCallable listScanRunsCallable() { + return listScanRunsCallable; + } + + @Override + public UnaryCallable listScanRunsPagedCallable() { + return listScanRunsPagedCallable; + } + + @Override + public UnaryCallable stopScanRunCallable() { + return stopScanRunCallable; + } + + @Override + public UnaryCallable listCrawledUrlsCallable() { + return listCrawledUrlsCallable; + } + + @Override + public UnaryCallable + listCrawledUrlsPagedCallable() { + return listCrawledUrlsPagedCallable; + } + + @Override + public UnaryCallable getFindingCallable() { + return getFindingCallable; + } + + @Override + public UnaryCallable listFindingsCallable() { + return listFindingsCallable; + } + + @Override + public UnaryCallable listFindingsPagedCallable() { + return listFindingsPagedCallable; + } + + @Override + public UnaryCallable + listFindingTypeStatsCallable() { + return listFindingTypeStatsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/WebSecurityScannerStubSettings.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/WebSecurityScannerStubSettings.java index a06ccab6..863dfae8 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/WebSecurityScannerStubSettings.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1/stub/WebSecurityScannerStubSettings.java @@ -30,6 +30,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -436,6 +439,11 @@ public WebSecurityScannerStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcWebSecurityScannerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonWebSecurityScannerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -468,18 +476,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(WebSecurityScannerStubSettings.class)) @@ -487,11 +502,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(WebSecurityScannerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return WebSecurityScannerStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -679,6 +713,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createScanConfigSettings() diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClient.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClient.java index 9f86b271..6b4db15e 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClient.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClient.java @@ -105,6 +105,21 @@ * WebSecurityScannerClient.create(webSecurityScannerSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * WebSecurityScannerSettings webSecurityScannerSettings =
+ *     WebSecurityScannerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * WebSecurityScannerClient webSecurityScannerClient =
+ *     WebSecurityScannerClient.create(webSecurityScannerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerSettings.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerSettings.java index 630a3916..430ab763 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerSettings.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -175,11 +176,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return WebSecurityScannerStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return WebSecurityScannerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return WebSecurityScannerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return WebSecurityScannerStubSettings.defaultTransportChannelProvider(); } @@ -189,11 +197,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return WebSecurityScannerStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -231,6 +245,11 @@ private static Builder createDefault() { return new Builder(WebSecurityScannerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(WebSecurityScannerStubSettings.newHttpJsonBuilder()); + } + public WebSecurityScannerStubSettings.Builder getStubSettingsBuilder() { return ((WebSecurityScannerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerCallableFactory.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerCallableFactory.java new file mode 100644 index 00000000..e43f8164 --- /dev/null +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the WebSecurityScanner service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonWebSecurityScannerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerStub.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerStub.java new file mode 100644 index 00000000..12f0943e --- /dev/null +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/HttpJsonWebSecurityScannerStub.java @@ -0,0 +1,882 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.stub; + +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListCrawledUrlsPagedResponse; +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListFindingsPagedResponse; +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListScanConfigsPagedResponse; +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListScanRunsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListScanConfigsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListScanRunsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the WebSecurityScanner service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonWebSecurityScannerStub extends WebSecurityScannerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/CreateScanConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*}/scanConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("scanConfig", request.getScanConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/DeleteScanConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listScanConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*}/scanConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListScanConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/UpdateScanConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{scanConfig.name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "scanConfig.name", request.getScanConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("scanConfig", request.getScanConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + startScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StartScanRun") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/scanConfigs/*}:start", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetScanRun") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listScanRunsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListScanRuns") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/scanConfigs/*}/scanRuns", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListScanRunsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + stopScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/StopScanRun") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*}:stop", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listCrawledUrlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListCrawledUrls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCrawledUrlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/GetFinding") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListFindingTypeStatsRequest, ListFindingTypeStatsResponse> + listFindingTypeStatsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner/ListFindingTypeStats") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingTypeStatsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createScanConfigCallable; + private final UnaryCallable deleteScanConfigCallable; + private final UnaryCallable getScanConfigCallable; + private final UnaryCallable + listScanConfigsCallable; + private final UnaryCallable + listScanConfigsPagedCallable; + private final UnaryCallable updateScanConfigCallable; + private final UnaryCallable startScanRunCallable; + private final UnaryCallable getScanRunCallable; + private final UnaryCallable listScanRunsCallable; + private final UnaryCallable + listScanRunsPagedCallable; + private final UnaryCallable stopScanRunCallable; + private final UnaryCallable + listCrawledUrlsCallable; + private final UnaryCallable + listCrawledUrlsPagedCallable; + private final UnaryCallable getFindingCallable; + private final UnaryCallable listFindingsCallable; + private final UnaryCallable + listFindingsPagedCallable; + private final UnaryCallable + listFindingTypeStatsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonWebSecurityScannerStub create(WebSecurityScannerStubSettings settings) + throws IOException { + return new HttpJsonWebSecurityScannerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonWebSecurityScannerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonWebSecurityScannerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonWebSecurityScannerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonWebSecurityScannerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonWebSecurityScannerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listScanConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listScanConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings startScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(startScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listScanRunsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listScanRunsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings stopScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(stopScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listCrawledUrlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCrawledUrlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listFindingTypeStatsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listFindingTypeStatsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createScanConfigCallable = + callableFactory.createUnaryCallable( + createScanConfigTransportSettings, settings.createScanConfigSettings(), clientContext); + this.deleteScanConfigCallable = + callableFactory.createUnaryCallable( + deleteScanConfigTransportSettings, settings.deleteScanConfigSettings(), clientContext); + this.getScanConfigCallable = + callableFactory.createUnaryCallable( + getScanConfigTransportSettings, settings.getScanConfigSettings(), clientContext); + this.listScanConfigsCallable = + callableFactory.createUnaryCallable( + listScanConfigsTransportSettings, settings.listScanConfigsSettings(), clientContext); + this.listScanConfigsPagedCallable = + callableFactory.createPagedCallable( + listScanConfigsTransportSettings, settings.listScanConfigsSettings(), clientContext); + this.updateScanConfigCallable = + callableFactory.createUnaryCallable( + updateScanConfigTransportSettings, settings.updateScanConfigSettings(), clientContext); + this.startScanRunCallable = + callableFactory.createUnaryCallable( + startScanRunTransportSettings, settings.startScanRunSettings(), clientContext); + this.getScanRunCallable = + callableFactory.createUnaryCallable( + getScanRunTransportSettings, settings.getScanRunSettings(), clientContext); + this.listScanRunsCallable = + callableFactory.createUnaryCallable( + listScanRunsTransportSettings, settings.listScanRunsSettings(), clientContext); + this.listScanRunsPagedCallable = + callableFactory.createPagedCallable( + listScanRunsTransportSettings, settings.listScanRunsSettings(), clientContext); + this.stopScanRunCallable = + callableFactory.createUnaryCallable( + stopScanRunTransportSettings, settings.stopScanRunSettings(), clientContext); + this.listCrawledUrlsCallable = + callableFactory.createUnaryCallable( + listCrawledUrlsTransportSettings, settings.listCrawledUrlsSettings(), clientContext); + this.listCrawledUrlsPagedCallable = + callableFactory.createPagedCallable( + listCrawledUrlsTransportSettings, settings.listCrawledUrlsSettings(), clientContext); + this.getFindingCallable = + callableFactory.createUnaryCallable( + getFindingTransportSettings, settings.getFindingSettings(), clientContext); + this.listFindingsCallable = + callableFactory.createUnaryCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingsPagedCallable = + callableFactory.createPagedCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingTypeStatsCallable = + callableFactory.createUnaryCallable( + listFindingTypeStatsTransportSettings, + settings.listFindingTypeStatsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createScanConfigMethodDescriptor); + methodDescriptors.add(deleteScanConfigMethodDescriptor); + methodDescriptors.add(getScanConfigMethodDescriptor); + methodDescriptors.add(listScanConfigsMethodDescriptor); + methodDescriptors.add(updateScanConfigMethodDescriptor); + methodDescriptors.add(startScanRunMethodDescriptor); + methodDescriptors.add(getScanRunMethodDescriptor); + methodDescriptors.add(listScanRunsMethodDescriptor); + methodDescriptors.add(stopScanRunMethodDescriptor); + methodDescriptors.add(listCrawledUrlsMethodDescriptor); + methodDescriptors.add(getFindingMethodDescriptor); + methodDescriptors.add(listFindingsMethodDescriptor); + methodDescriptors.add(listFindingTypeStatsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createScanConfigCallable() { + return createScanConfigCallable; + } + + @Override + public UnaryCallable deleteScanConfigCallable() { + return deleteScanConfigCallable; + } + + @Override + public UnaryCallable getScanConfigCallable() { + return getScanConfigCallable; + } + + @Override + public UnaryCallable listScanConfigsCallable() { + return listScanConfigsCallable; + } + + @Override + public UnaryCallable + listScanConfigsPagedCallable() { + return listScanConfigsPagedCallable; + } + + @Override + public UnaryCallable updateScanConfigCallable() { + return updateScanConfigCallable; + } + + @Override + public UnaryCallable startScanRunCallable() { + return startScanRunCallable; + } + + @Override + public UnaryCallable getScanRunCallable() { + return getScanRunCallable; + } + + @Override + public UnaryCallable listScanRunsCallable() { + return listScanRunsCallable; + } + + @Override + public UnaryCallable listScanRunsPagedCallable() { + return listScanRunsPagedCallable; + } + + @Override + public UnaryCallable stopScanRunCallable() { + return stopScanRunCallable; + } + + @Override + public UnaryCallable listCrawledUrlsCallable() { + return listCrawledUrlsCallable; + } + + @Override + public UnaryCallable + listCrawledUrlsPagedCallable() { + return listCrawledUrlsPagedCallable; + } + + @Override + public UnaryCallable getFindingCallable() { + return getFindingCallable; + } + + @Override + public UnaryCallable listFindingsCallable() { + return listFindingsCallable; + } + + @Override + public UnaryCallable listFindingsPagedCallable() { + return listFindingsPagedCallable; + } + + @Override + public UnaryCallable + listFindingTypeStatsCallable() { + return listFindingTypeStatsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/WebSecurityScannerStubSettings.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/WebSecurityScannerStubSettings.java index cdd5c548..518a4b1c 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/WebSecurityScannerStubSettings.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1alpha/stub/WebSecurityScannerStubSettings.java @@ -30,6 +30,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -437,6 +440,11 @@ public WebSecurityScannerStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcWebSecurityScannerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonWebSecurityScannerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -469,18 +477,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(WebSecurityScannerStubSettings.class)) @@ -488,11 +503,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(WebSecurityScannerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return WebSecurityScannerStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -680,6 +714,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createScanConfigSettings() diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClient.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClient.java index 0e141c99..1cb0a29d 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClient.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClient.java @@ -105,6 +105,21 @@ * WebSecurityScannerClient.create(webSecurityScannerSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * WebSecurityScannerSettings webSecurityScannerSettings =
+ *     WebSecurityScannerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * WebSecurityScannerClient webSecurityScannerClient =
+ *     WebSecurityScannerClient.create(webSecurityScannerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerSettings.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerSettings.java index 76bc7244..b218cd5b 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerSettings.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -175,11 +176,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return WebSecurityScannerStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return WebSecurityScannerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return WebSecurityScannerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return WebSecurityScannerStubSettings.defaultTransportChannelProvider(); } @@ -189,11 +197,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return WebSecurityScannerStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -231,6 +245,11 @@ private static Builder createDefault() { return new Builder(WebSecurityScannerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(WebSecurityScannerStubSettings.newHttpJsonBuilder()); + } + public WebSecurityScannerStubSettings.Builder getStubSettingsBuilder() { return ((WebSecurityScannerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerCallableFactory.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerCallableFactory.java new file mode 100644 index 00000000..b06b3ce4 --- /dev/null +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the WebSecurityScanner service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonWebSecurityScannerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerStub.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerStub.java new file mode 100644 index 00000000..b0ce37aa --- /dev/null +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/HttpJsonWebSecurityScannerStub.java @@ -0,0 +1,880 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.stub; + +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListCrawledUrlsPagedResponse; +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListFindingsPagedResponse; +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse; +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanRunsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse; +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1beta.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListFindingsResponse; +import com.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse; +import com.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListScanRunsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the WebSecurityScanner service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonWebSecurityScannerStub extends WebSecurityScannerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/CreateScanConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/scanConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("scanConfig", request.getScanConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/DeleteScanConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listScanConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/scanConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListScanConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateScanConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/UpdateScanConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{scanConfig.name=projects/*/scanConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "scanConfig.name", request.getScanConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("scanConfig", request.getScanConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + startScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StartScanRun") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/scanConfigs/*}:start", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetScanRun") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listScanRunsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListScanRuns") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*/scanConfigs/*}/scanRuns", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListScanRunsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + stopScanRunMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/StopScanRun") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}:stop", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ScanRun.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listCrawledUrlsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListCrawledUrls") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCrawledUrlsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.websecurityscanner.v1beta.WebSecurityScanner/GetFinding") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListFindingTypeStatsRequest, ListFindingTypeStatsResponse> + listFindingTypeStatsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner/ListFindingTypeStats") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingTypeStatsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createScanConfigCallable; + private final UnaryCallable deleteScanConfigCallable; + private final UnaryCallable getScanConfigCallable; + private final UnaryCallable + listScanConfigsCallable; + private final UnaryCallable + listScanConfigsPagedCallable; + private final UnaryCallable updateScanConfigCallable; + private final UnaryCallable startScanRunCallable; + private final UnaryCallable getScanRunCallable; + private final UnaryCallable listScanRunsCallable; + private final UnaryCallable + listScanRunsPagedCallable; + private final UnaryCallable stopScanRunCallable; + private final UnaryCallable + listCrawledUrlsCallable; + private final UnaryCallable + listCrawledUrlsPagedCallable; + private final UnaryCallable getFindingCallable; + private final UnaryCallable listFindingsCallable; + private final UnaryCallable + listFindingsPagedCallable; + private final UnaryCallable + listFindingTypeStatsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonWebSecurityScannerStub create(WebSecurityScannerStubSettings settings) + throws IOException { + return new HttpJsonWebSecurityScannerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonWebSecurityScannerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonWebSecurityScannerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonWebSecurityScannerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonWebSecurityScannerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonWebSecurityScannerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonWebSecurityScannerStub( + WebSecurityScannerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listScanConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listScanConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateScanConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateScanConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings startScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(startScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listScanRunsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listScanRunsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings stopScanRunTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(stopScanRunMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listCrawledUrlsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCrawledUrlsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listFindingTypeStatsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listFindingTypeStatsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createScanConfigCallable = + callableFactory.createUnaryCallable( + createScanConfigTransportSettings, settings.createScanConfigSettings(), clientContext); + this.deleteScanConfigCallable = + callableFactory.createUnaryCallable( + deleteScanConfigTransportSettings, settings.deleteScanConfigSettings(), clientContext); + this.getScanConfigCallable = + callableFactory.createUnaryCallable( + getScanConfigTransportSettings, settings.getScanConfigSettings(), clientContext); + this.listScanConfigsCallable = + callableFactory.createUnaryCallable( + listScanConfigsTransportSettings, settings.listScanConfigsSettings(), clientContext); + this.listScanConfigsPagedCallable = + callableFactory.createPagedCallable( + listScanConfigsTransportSettings, settings.listScanConfigsSettings(), clientContext); + this.updateScanConfigCallable = + callableFactory.createUnaryCallable( + updateScanConfigTransportSettings, settings.updateScanConfigSettings(), clientContext); + this.startScanRunCallable = + callableFactory.createUnaryCallable( + startScanRunTransportSettings, settings.startScanRunSettings(), clientContext); + this.getScanRunCallable = + callableFactory.createUnaryCallable( + getScanRunTransportSettings, settings.getScanRunSettings(), clientContext); + this.listScanRunsCallable = + callableFactory.createUnaryCallable( + listScanRunsTransportSettings, settings.listScanRunsSettings(), clientContext); + this.listScanRunsPagedCallable = + callableFactory.createPagedCallable( + listScanRunsTransportSettings, settings.listScanRunsSettings(), clientContext); + this.stopScanRunCallable = + callableFactory.createUnaryCallable( + stopScanRunTransportSettings, settings.stopScanRunSettings(), clientContext); + this.listCrawledUrlsCallable = + callableFactory.createUnaryCallable( + listCrawledUrlsTransportSettings, settings.listCrawledUrlsSettings(), clientContext); + this.listCrawledUrlsPagedCallable = + callableFactory.createPagedCallable( + listCrawledUrlsTransportSettings, settings.listCrawledUrlsSettings(), clientContext); + this.getFindingCallable = + callableFactory.createUnaryCallable( + getFindingTransportSettings, settings.getFindingSettings(), clientContext); + this.listFindingsCallable = + callableFactory.createUnaryCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingsPagedCallable = + callableFactory.createPagedCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingTypeStatsCallable = + callableFactory.createUnaryCallable( + listFindingTypeStatsTransportSettings, + settings.listFindingTypeStatsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createScanConfigMethodDescriptor); + methodDescriptors.add(deleteScanConfigMethodDescriptor); + methodDescriptors.add(getScanConfigMethodDescriptor); + methodDescriptors.add(listScanConfigsMethodDescriptor); + methodDescriptors.add(updateScanConfigMethodDescriptor); + methodDescriptors.add(startScanRunMethodDescriptor); + methodDescriptors.add(getScanRunMethodDescriptor); + methodDescriptors.add(listScanRunsMethodDescriptor); + methodDescriptors.add(stopScanRunMethodDescriptor); + methodDescriptors.add(listCrawledUrlsMethodDescriptor); + methodDescriptors.add(getFindingMethodDescriptor); + methodDescriptors.add(listFindingsMethodDescriptor); + methodDescriptors.add(listFindingTypeStatsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createScanConfigCallable() { + return createScanConfigCallable; + } + + @Override + public UnaryCallable deleteScanConfigCallable() { + return deleteScanConfigCallable; + } + + @Override + public UnaryCallable getScanConfigCallable() { + return getScanConfigCallable; + } + + @Override + public UnaryCallable listScanConfigsCallable() { + return listScanConfigsCallable; + } + + @Override + public UnaryCallable + listScanConfigsPagedCallable() { + return listScanConfigsPagedCallable; + } + + @Override + public UnaryCallable updateScanConfigCallable() { + return updateScanConfigCallable; + } + + @Override + public UnaryCallable startScanRunCallable() { + return startScanRunCallable; + } + + @Override + public UnaryCallable getScanRunCallable() { + return getScanRunCallable; + } + + @Override + public UnaryCallable listScanRunsCallable() { + return listScanRunsCallable; + } + + @Override + public UnaryCallable listScanRunsPagedCallable() { + return listScanRunsPagedCallable; + } + + @Override + public UnaryCallable stopScanRunCallable() { + return stopScanRunCallable; + } + + @Override + public UnaryCallable listCrawledUrlsCallable() { + return listCrawledUrlsCallable; + } + + @Override + public UnaryCallable + listCrawledUrlsPagedCallable() { + return listCrawledUrlsPagedCallable; + } + + @Override + public UnaryCallable getFindingCallable() { + return getFindingCallable; + } + + @Override + public UnaryCallable listFindingsCallable() { + return listFindingsCallable; + } + + @Override + public UnaryCallable listFindingsPagedCallable() { + return listFindingsPagedCallable; + } + + @Override + public UnaryCallable + listFindingTypeStatsCallable() { + return listFindingTypeStatsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/WebSecurityScannerStubSettings.java b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/WebSecurityScannerStubSettings.java index 89c6308d..52c5e9b6 100644 --- a/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/WebSecurityScannerStubSettings.java +++ b/google-cloud-websecurityscanner/src/main/java/com/google/cloud/websecurityscanner/v1beta/stub/WebSecurityScannerStubSettings.java @@ -30,6 +30,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -437,6 +440,11 @@ public WebSecurityScannerStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcWebSecurityScannerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonWebSecurityScannerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -469,18 +477,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(WebSecurityScannerStubSettings.class)) @@ -488,11 +503,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(WebSecurityScannerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return WebSecurityScannerStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -680,6 +714,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createScanConfigSettings() diff --git a/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClientHttpJsonTest.java b/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClientHttpJsonTest.java new file mode 100644 index 00000000..88fea022 --- /dev/null +++ b/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1/WebSecurityScannerClientHttpJsonTest.java @@ -0,0 +1,863 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1; + +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListCrawledUrlsPagedResponse; +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListFindingsPagedResponse; +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListScanConfigsPagedResponse; +import static com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient.ListScanRunsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.websecurityscanner.v1.stub.HttpJsonWebSecurityScannerStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class WebSecurityScannerClientHttpJsonTest { + private static MockHttpService mockService; + private static WebSecurityScannerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonWebSecurityScannerStub.getMethodDescriptors(), + WebSecurityScannerSettings.getDefaultEndpoint()); + WebSecurityScannerSettings settings = + WebSecurityScannerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = WebSecurityScannerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .setManagedScan(true) + .setStaticIpScan(true) + .build(); + mockService.addResponse(expectedResponse); + + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent("projects/project-2353") + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + + ScanConfig actualResponse = client.createScanConfig(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent("projects/project-2353") + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + client.createScanConfig(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteScanConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .build(); + + client.deleteScanConfig(request); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .build(); + client.deleteScanConfig(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .setManagedScan(true) + .setStaticIpScan(true) + .build(); + mockService.addResponse(expectedResponse); + + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .build(); + + ScanConfig actualResponse = client.getScanConfig(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .build(); + client.getScanConfig(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanConfigsTest() throws Exception { + ScanConfig responsesElement = ScanConfig.newBuilder().build(); + ListScanConfigsResponse expectedResponse = + ListScanConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllScanConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listScanConfigs(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .setManagedScan(true) + .setStaticIpScan(true) + .build(); + mockService.addResponse(expectedResponse); + + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig( + ScanConfig.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .setManagedScan(true) + .setStaticIpScan(true) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + ScanConfig actualResponse = client.updateScanConfig(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig( + ScanConfig.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .setManagedScan(true) + .setStaticIpScan(true) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateScanConfig(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName("name3373707") + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + StartScanRunRequest request = + StartScanRunRequest.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .build(); + + ScanRun actualResponse = client.startScanRun(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StartScanRunRequest request = + StartScanRunRequest.newBuilder() + .setName("projects/project-7376/scanConfigs/scanConfig-7376") + .build(); + client.startScanRun(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName("name3373707") + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetScanRunRequest request = + GetScanRunRequest.newBuilder() + .setName("projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135") + .build(); + + ScanRun actualResponse = client.getScanRun(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetScanRunRequest request = + GetScanRunRequest.newBuilder() + .setName("projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135") + .build(); + client.getScanRun(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanRunsTest() throws Exception { + ScanRun responsesElement = ScanRun.newBuilder().build(); + ListScanRunsResponse expectedResponse = + ListScanRunsResponse.newBuilder() + .setNextPageToken("") + .addAllScanRuns(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent("projects/project-2657/scanConfigs/scanConfig-2657") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListScanRunsPagedResponse pagedListResponse = client.listScanRuns(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanRunsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanRunsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent("projects/project-2657/scanConfigs/scanConfig-2657") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listScanRuns(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName("name3373707") + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + StopScanRunRequest request = + StopScanRunRequest.newBuilder() + .setName("projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135") + .build(); + + ScanRun actualResponse = client.stopScanRun(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StopScanRunRequest request = + StopScanRunRequest.newBuilder() + .setName("projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135") + .build(); + client.stopScanRun(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCrawledUrlsTest() throws Exception { + CrawledUrl responsesElement = CrawledUrl.newBuilder().build(); + ListCrawledUrlsResponse expectedResponse = + ListCrawledUrlsResponse.newBuilder() + .setNextPageToken("") + .addAllCrawledUrls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent("projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListCrawledUrlsPagedResponse pagedListResponse = client.listCrawledUrls(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCrawledUrlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCrawledUrlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent("projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listCrawledUrls(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName("name3373707") + .setFindingType("findingType1116910179") + .setHttpMethod("httpMethod751124361") + .setFuzzedUrl("fuzzedUrl-1730986655") + .setBody("body3029410") + .setDescription("description-1724546052") + .setReproductionUrl("reproductionUrl-2086120797") + .setFrameUrl("frameUrl-1644982078") + .setFinalUrl("finalUrl-681275367") + .setTrackingId("trackingId1168987698") + .setForm(Form.newBuilder().build()) + .setOutdatedLibrary(OutdatedLibrary.newBuilder().build()) + .setViolatingResource(ViolatingResource.newBuilder().build()) + .setVulnerableHeaders(VulnerableHeaders.newBuilder().build()) + .setVulnerableParameters(VulnerableParameters.newBuilder().build()) + .setXss(Xss.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetFindingRequest request = + GetFindingRequest.newBuilder() + .setName( + "projects/project-9877/scanConfigs/scanConfig-9877/scanRuns/scanRun-9877/findings/finding-9877") + .build(); + + Finding actualResponse = client.getFinding(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetFindingRequest request = + GetFindingRequest.newBuilder() + .setName( + "projects/project-9877/scanConfigs/scanConfig-9877/scanRuns/scanRun-9877/findings/finding-9877") + .build(); + client.getFinding(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest() throws Exception { + Finding responsesElement = Finding.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllFindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent("projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104") + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListFindingsPagedResponse pagedListResponse = client.listFindings(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFindingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent("projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104") + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listFindings(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingTypeStatsTest() throws Exception { + ListFindingTypeStatsResponse expectedResponse = + ListFindingTypeStatsResponse.newBuilder() + .addAllFindingTypeStats(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder() + .setParent("projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104") + .build(); + + ListFindingTypeStatsResponse actualResponse = client.listFindingTypeStats(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingTypeStatsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder() + .setParent("projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104") + .build(); + client.listFindingTypeStats(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClientHttpJsonTest.java b/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClientHttpJsonTest.java new file mode 100644 index 00000000..405a1ed0 --- /dev/null +++ b/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1alpha/WebSecurityScannerClientHttpJsonTest.java @@ -0,0 +1,1362 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha; + +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListCrawledUrlsPagedResponse; +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListFindingsPagedResponse; +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListScanConfigsPagedResponse; +import static com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient.ListScanRunsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.websecurityscanner.v1alpha.stub.HttpJsonWebSecurityScannerStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class WebSecurityScannerClientHttpJsonTest { + private static MockHttpService mockService; + private static WebSecurityScannerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonWebSecurityScannerStub.getMethodDescriptors(), + WebSecurityScannerSettings.getDefaultEndpoint()); + WebSecurityScannerSettings settings = + WebSecurityScannerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = WebSecurityScannerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + + ScanConfig actualResponse = client.createScanConfig(parent, scanConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + client.createScanConfig(parent, scanConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createScanConfigTest2() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + + ScanConfig actualResponse = client.createScanConfig(parent, scanConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createScanConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + client.createScanConfig(parent, scanConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteScanConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + client.deleteScanConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.deleteScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteScanConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + + client.deleteScanConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteScanConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + client.deleteScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + ScanConfig actualResponse = client.getScanConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.getScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanConfigTest2() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + + ScanConfig actualResponse = client.getScanConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + client.getScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanConfigsTest() throws Exception { + ScanConfig responsesElement = ScanConfig.newBuilder().build(); + ListScanConfigsResponse expectedResponse = + ListScanConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllScanConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listScanConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanConfigsTest2() throws Exception { + ScanConfig responsesElement = ScanConfig.newBuilder().build(); + ListScanConfigsResponse expectedResponse = + ListScanConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllScanConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listScanConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfig scanConfig = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ScanConfig actualResponse = client.updateScanConfig(scanConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfig scanConfig = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateScanConfig(scanConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + ScanRun actualResponse = client.startScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.startScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startScanRunTest2() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + + ScanRun actualResponse = client.startScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startScanRunExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + client.startScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ScanRun actualResponse = client.getScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.getScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanRunTest2() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + + ScanRun actualResponse = client.getScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanRunExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + client.getScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanRunsTest() throws Exception { + ScanRun responsesElement = ScanRun.newBuilder().build(); + ListScanRunsResponse expectedResponse = + ListScanRunsResponse.newBuilder() + .setNextPageToken("") + .addAllScanRuns(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfigName parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + ListScanRunsPagedResponse pagedListResponse = client.listScanRuns(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanRunsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanRunsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.listScanRuns(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanRunsTest2() throws Exception { + ScanRun responsesElement = ScanRun.newBuilder().build(); + ListScanRunsResponse expectedResponse = + ListScanRunsResponse.newBuilder() + .setNextPageToken("") + .addAllScanRuns(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2657/scanConfigs/scanConfig-2657"; + + ListScanRunsPagedResponse pagedListResponse = client.listScanRuns(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanRunsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanRunsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2657/scanConfigs/scanConfig-2657"; + client.listScanRuns(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ScanRun actualResponse = client.stopScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.stopScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopScanRunTest2() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + + ScanRun actualResponse = client.stopScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopScanRunExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + client.stopScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCrawledUrlsTest() throws Exception { + CrawledUrl responsesElement = CrawledUrl.newBuilder().build(); + ListCrawledUrlsResponse expectedResponse = + ListCrawledUrlsResponse.newBuilder() + .setNextPageToken("") + .addAllCrawledUrls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ListCrawledUrlsPagedResponse pagedListResponse = client.listCrawledUrls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCrawledUrlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCrawledUrlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.listCrawledUrls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCrawledUrlsTest2() throws Exception { + CrawledUrl responsesElement = CrawledUrl.newBuilder().build(); + ListCrawledUrlsResponse expectedResponse = + ListCrawledUrlsResponse.newBuilder() + .setNextPageToken("") + .addAllCrawledUrls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + + ListCrawledUrlsPagedResponse pagedListResponse = client.listCrawledUrls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCrawledUrlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCrawledUrlsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + client.listCrawledUrls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]").toString()) + .setHttpMethod("httpMethod751124361") + .setFuzzedUrl("fuzzedUrl-1730986655") + .setBody("body3029410") + .setDescription("description-1724546052") + .setReproductionUrl("reproductionUrl-2086120797") + .setFrameUrl("frameUrl-1644982078") + .setFinalUrl("finalUrl-681275367") + .setTrackingId("trackingId1168987698") + .setOutdatedLibrary(OutdatedLibrary.newBuilder().build()) + .setViolatingResource(ViolatingResource.newBuilder().build()) + .setVulnerableHeaders(VulnerableHeaders.newBuilder().build()) + .setVulnerableParameters(VulnerableParameters.newBuilder().build()) + .setXss(Xss.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + FindingName name = FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]"); + + Finding actualResponse = client.getFinding(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FindingName name = FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]"); + client.getFinding(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFindingTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]").toString()) + .setHttpMethod("httpMethod751124361") + .setFuzzedUrl("fuzzedUrl-1730986655") + .setBody("body3029410") + .setDescription("description-1724546052") + .setReproductionUrl("reproductionUrl-2086120797") + .setFrameUrl("frameUrl-1644982078") + .setFinalUrl("finalUrl-681275367") + .setTrackingId("trackingId1168987698") + .setOutdatedLibrary(OutdatedLibrary.newBuilder().build()) + .setViolatingResource(ViolatingResource.newBuilder().build()) + .setVulnerableHeaders(VulnerableHeaders.newBuilder().build()) + .setVulnerableParameters(VulnerableParameters.newBuilder().build()) + .setXss(Xss.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9877/scanConfigs/scanConfig-9877/scanRuns/scanRun-9877/findings/finding-9877"; + + Finding actualResponse = client.getFinding(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9877/scanConfigs/scanConfig-9877/scanRuns/scanRun-9877/findings/finding-9877"; + client.getFinding(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest() throws Exception { + Finding responsesElement = Finding.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllFindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + String filter = "filter-1274492040"; + + ListFindingsPagedResponse pagedListResponse = client.listFindings(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFindingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + String filter = "filter-1274492040"; + client.listFindings(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest2() throws Exception { + Finding responsesElement = Finding.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllFindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + String filter = "filter-1274492040"; + + ListFindingsPagedResponse pagedListResponse = client.listFindings(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFindingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + String filter = "filter-1274492040"; + client.listFindings(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingTypeStatsTest() throws Exception { + ListFindingTypeStatsResponse expectedResponse = + ListFindingTypeStatsResponse.newBuilder() + .addAllFindingTypeStats(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ListFindingTypeStatsResponse actualResponse = client.listFindingTypeStats(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingTypeStatsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.listFindingTypeStats(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingTypeStatsTest2() throws Exception { + ListFindingTypeStatsResponse expectedResponse = + ListFindingTypeStatsResponse.newBuilder() + .addAllFindingTypeStats(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + + ListFindingTypeStatsResponse actualResponse = client.listFindingTypeStats(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingTypeStatsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + client.listFindingTypeStats(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClientHttpJsonTest.java b/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClientHttpJsonTest.java new file mode 100644 index 00000000..2ab561f9 --- /dev/null +++ b/google-cloud-websecurityscanner/src/test/java/com/google/cloud/websecurityscanner/v1beta/WebSecurityScannerClientHttpJsonTest.java @@ -0,0 +1,1378 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta; + +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListCrawledUrlsPagedResponse; +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListFindingsPagedResponse; +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanConfigsPagedResponse; +import static com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient.ListScanRunsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.websecurityscanner.v1beta.stub.HttpJsonWebSecurityScannerStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class WebSecurityScannerClientHttpJsonTest { + private static MockHttpService mockService; + private static WebSecurityScannerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonWebSecurityScannerStub.getMethodDescriptors(), + WebSecurityScannerSettings.getDefaultEndpoint()); + WebSecurityScannerSettings settings = + WebSecurityScannerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = WebSecurityScannerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + + ScanConfig actualResponse = client.createScanConfig(parent, scanConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + client.createScanConfig(parent, scanConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createScanConfigTest2() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + + ScanConfig actualResponse = client.createScanConfig(parent, scanConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createScanConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + client.createScanConfig(parent, scanConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteScanConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + client.deleteScanConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.deleteScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteScanConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + + client.deleteScanConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteScanConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + client.deleteScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + ScanConfig actualResponse = client.getScanConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.getScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanConfigTest2() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + + ScanConfig actualResponse = client.getScanConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + client.getScanConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanConfigsTest() throws Exception { + ScanConfig responsesElement = ScanConfig.newBuilder().build(); + ListScanConfigsResponse expectedResponse = + ListScanConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllScanConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listScanConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanConfigsTest2() throws Exception { + ScanConfig responsesElement = ScanConfig.newBuilder().build(); + ListScanConfigsResponse expectedResponse = + ListScanConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllScanConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListScanConfigsPagedResponse pagedListResponse = client.listScanConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listScanConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateScanConfigTest() throws Exception { + ScanConfig expectedResponse = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfig scanConfig = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ScanConfig actualResponse = client.updateScanConfig(scanConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateScanConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfig scanConfig = + ScanConfig.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setDisplayName("displayName1714148973") + .setMaxQps(844445913) + .addAllStartingUrls(new ArrayList()) + .setAuthentication(ScanConfig.Authentication.newBuilder().build()) + .addAllBlacklistPatterns(new ArrayList()) + .setSchedule(ScanConfig.Schedule.newBuilder().build()) + .addAllTargetPlatforms(new ArrayList()) + .setLatestRun(ScanRun.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateScanConfig(scanConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + ScanRun actualResponse = client.startScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.startScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startScanRunTest2() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + + ScanRun actualResponse = client.startScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startScanRunExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7376/scanConfigs/scanConfig-7376"; + client.startScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ScanRun actualResponse = client.getScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.getScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getScanRunTest2() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + + ScanRun actualResponse = client.getScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getScanRunExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + client.getScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanRunsTest() throws Exception { + ScanRun responsesElement = ScanRun.newBuilder().build(); + ListScanRunsResponse expectedResponse = + ListScanRunsResponse.newBuilder() + .setNextPageToken("") + .addAllScanRuns(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ScanConfigName parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + + ListScanRunsPagedResponse pagedListResponse = client.listScanRuns(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanRunsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanRunsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanConfigName parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + client.listScanRuns(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listScanRunsTest2() throws Exception { + ScanRun responsesElement = ScanRun.newBuilder().build(); + ListScanRunsResponse expectedResponse = + ListScanRunsResponse.newBuilder() + .setNextPageToken("") + .addAllScanRuns(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2657/scanConfigs/scanConfig-2657"; + + ListScanRunsPagedResponse pagedListResponse = client.listScanRuns(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getScanRunsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listScanRunsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2657/scanConfigs/scanConfig-2657"; + client.listScanRuns(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopScanRunTest() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ScanRun actualResponse = client.stopScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopScanRunExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.stopScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopScanRunTest2() throws Exception { + ScanRun expectedResponse = + ScanRun.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setUrlsCrawledCount(-1749797253) + .setUrlsTestedCount(-1498664068) + .setHasVulnerabilities(true) + .setProgressPercent(-2137894861) + .setErrorTrace(ScanRunErrorTrace.newBuilder().build()) + .addAllWarningTraces(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + + ScanRun actualResponse = client.stopScanRun(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopScanRunExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1135/scanConfigs/scanConfig-1135/scanRuns/scanRun-1135"; + client.stopScanRun(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCrawledUrlsTest() throws Exception { + CrawledUrl responsesElement = CrawledUrl.newBuilder().build(); + ListCrawledUrlsResponse expectedResponse = + ListCrawledUrlsResponse.newBuilder() + .setNextPageToken("") + .addAllCrawledUrls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ListCrawledUrlsPagedResponse pagedListResponse = client.listCrawledUrls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCrawledUrlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCrawledUrlsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.listCrawledUrls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listCrawledUrlsTest2() throws Exception { + CrawledUrl responsesElement = CrawledUrl.newBuilder().build(); + ListCrawledUrlsResponse expectedResponse = + ListCrawledUrlsResponse.newBuilder() + .setNextPageToken("") + .addAllCrawledUrls(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + + ListCrawledUrlsPagedResponse pagedListResponse = client.listCrawledUrls(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCrawledUrlsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCrawledUrlsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + client.listCrawledUrls(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]").toString()) + .setFindingType("findingType1116910179") + .setHttpMethod("httpMethod751124361") + .setFuzzedUrl("fuzzedUrl-1730986655") + .setBody("body3029410") + .setDescription("description-1724546052") + .setReproductionUrl("reproductionUrl-2086120797") + .setFrameUrl("frameUrl-1644982078") + .setFinalUrl("finalUrl-681275367") + .setTrackingId("trackingId1168987698") + .setForm(Form.newBuilder().build()) + .setOutdatedLibrary(OutdatedLibrary.newBuilder().build()) + .setViolatingResource(ViolatingResource.newBuilder().build()) + .setVulnerableHeaders(VulnerableHeaders.newBuilder().build()) + .setVulnerableParameters(VulnerableParameters.newBuilder().build()) + .setXss(Xss.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + FindingName name = FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]"); + + Finding actualResponse = client.getFinding(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FindingName name = FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]"); + client.getFinding(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFindingTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]").toString()) + .setFindingType("findingType1116910179") + .setHttpMethod("httpMethod751124361") + .setFuzzedUrl("fuzzedUrl-1730986655") + .setBody("body3029410") + .setDescription("description-1724546052") + .setReproductionUrl("reproductionUrl-2086120797") + .setFrameUrl("frameUrl-1644982078") + .setFinalUrl("finalUrl-681275367") + .setTrackingId("trackingId1168987698") + .setForm(Form.newBuilder().build()) + .setOutdatedLibrary(OutdatedLibrary.newBuilder().build()) + .setViolatingResource(ViolatingResource.newBuilder().build()) + .setVulnerableHeaders(VulnerableHeaders.newBuilder().build()) + .setVulnerableParameters(VulnerableParameters.newBuilder().build()) + .setXss(Xss.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9877/scanConfigs/scanConfig-9877/scanRuns/scanRun-9877/findings/finding-9877"; + + Finding actualResponse = client.getFinding(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9877/scanConfigs/scanConfig-9877/scanRuns/scanRun-9877/findings/finding-9877"; + client.getFinding(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest() throws Exception { + Finding responsesElement = Finding.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllFindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + String filter = "filter-1274492040"; + + ListFindingsPagedResponse pagedListResponse = client.listFindings(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFindingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + String filter = "filter-1274492040"; + client.listFindings(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest2() throws Exception { + Finding responsesElement = Finding.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllFindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + String filter = "filter-1274492040"; + + ListFindingsPagedResponse pagedListResponse = client.listFindings(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFindingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + String filter = "filter-1274492040"; + client.listFindings(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingTypeStatsTest() throws Exception { + ListFindingTypeStatsResponse expectedResponse = + ListFindingTypeStatsResponse.newBuilder() + .addAllFindingTypeStats(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + + ListFindingTypeStatsResponse actualResponse = client.listFindingTypeStats(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingTypeStatsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + client.listFindingTypeStats(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingTypeStatsTest2() throws Exception { + ListFindingTypeStatsResponse expectedResponse = + ListFindingTypeStatsResponse.newBuilder() + .addAllFindingTypeStats(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + + ListFindingTypeStatsResponse actualResponse = client.listFindingTypeStats(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingTypeStatsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-3104/scanConfigs/scanConfig-3104/scanRuns/scanRun-3104"; + client.listFindingTypeStats(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..0165340a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.stub.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerstubsettings_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1.stub.WebSecurityScannerStubSettings; +import java.time.Duration; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerStubSettings.Builder webSecurityScannerSettingsBuilder = + WebSecurityScannerStubSettings.newBuilder(); + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .setRetrySettings( + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + WebSecurityScannerStubSettings webSecurityScannerSettings = + webSecurityScannerSettingsBuilder.build(); + } +} +// [END websecurityscanner_v1_generated_websecurityscannerstubsettings_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..42404661 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START +// websecurityscanner_v1_generated_websecurityscannerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerSettings; +import com.google.cloud.websecurityscanner.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..41e63185 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START +// websecurityscanner_v1_generated_websecurityscannerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder() + .setTransportChannelProvider( + WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END +// websecurityscanner_v1_generated_websecurityscannerclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..4b0f7a86 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_create_setendpoint_sync] +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerSettings; +import com.google.cloud.websecurityscanner.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder().setEndpoint(myEndpoint).build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java new file mode 100644 index 00000000..d5be65fc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_createscanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + asyncCreateScanConfig(); + } + + public static void asyncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent("parent-995424086") + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + ApiFuture future = + webSecurityScannerClient.createScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_createscanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..74ffd593 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent("parent-995424086") + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java new file mode 100644 index 00000000..365e7e26 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_deletescanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteScanConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteScanConfig(); + } + + public static void asyncDeleteScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + webSecurityScannerClient.deleteScanConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_deletescanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java new file mode 100644 index 00000000..f51c84a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_deletescanconfig_sync] +import com.google.cloud.websecurityscanner.v1.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncDeleteScanConfig { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfig(); + } + + public static void syncDeleteScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder().setName("name3373707").build(); + webSecurityScannerClient.deleteScanConfig(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_deletescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/AsyncGetFinding.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/AsyncGetFinding.java new file mode 100644 index 00000000..aca1c9d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/AsyncGetFinding.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_getfinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.Finding; +import com.google.cloud.websecurityscanner.v1.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncGetFinding { + + public static void main(String[] args) throws Exception { + asyncGetFinding(); + } + + public static void asyncGetFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetFindingRequest request = GetFindingRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = webSecurityScannerClient.getFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_getfinding_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/SyncGetFinding.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/SyncGetFinding.java new file mode 100644 index 00000000..a022e022 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getfinding/SyncGetFinding.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_getfinding_sync] +import com.google.cloud.websecurityscanner.v1.Finding; +import com.google.cloud.websecurityscanner.v1.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncGetFinding { + + public static void main(String[] args) throws Exception { + syncGetFinding(); + } + + public static void syncGetFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetFindingRequest request = GetFindingRequest.newBuilder().setName("name3373707").build(); + Finding response = webSecurityScannerClient.getFinding(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_getfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java new file mode 100644 index 00000000..40a2e73d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_getscanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncGetScanConfig { + + public static void main(String[] args) throws Exception { + asyncGetScanConfig(); + } + + public static void asyncGetScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + webSecurityScannerClient.getScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_getscanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java new file mode 100644 index 00000000..7d05af13 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_getscanconfig_sync] +import com.google.cloud.websecurityscanner.v1.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncGetScanConfig { + + public static void main(String[] args) throws Exception { + syncGetScanConfig(); + } + + public static void syncGetScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder().setName("name3373707").build(); + ScanConfig response = webSecurityScannerClient.getScanConfig(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_getscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/AsyncGetScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/AsyncGetScanRun.java new file mode 100644 index 00000000..35f5963c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/AsyncGetScanRun.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_getscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncGetScanRun { + + public static void main(String[] args) throws Exception { + asyncGetScanRun(); + } + + public static void asyncGetScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanRunRequest request = GetScanRunRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = webSecurityScannerClient.getScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_getscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/SyncGetScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/SyncGetScanRun.java new file mode 100644 index 00000000..4182b871 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/getscanrun/SyncGetScanRun.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_getscanrun_sync] +import com.google.cloud.websecurityscanner.v1.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncGetScanRun { + + public static void main(String[] args) throws Exception { + syncGetScanRun(); + } + + public static void syncGetScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanRunRequest request = GetScanRunRequest.newBuilder().setName("name3373707").build(); + ScanRun response = webSecurityScannerClient.getScanRun(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_getscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java new file mode 100644 index 00000000..8128b5be --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listcrawledurls_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.CrawledUrl; +import com.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncListCrawledUrls { + + public static void main(String[] args) throws Exception { + asyncListCrawledUrls(); + } + + public static void asyncListCrawledUrls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listCrawledUrlsPagedCallable().futureCall(request); + // Do something. + for (CrawledUrl element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listcrawledurls_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java new file mode 100644 index 00000000..85d06350 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listcrawledurls_paged_async] +import com.google.cloud.websecurityscanner.v1.CrawledUrl; +import com.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1.ListCrawledUrlsResponse; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListCrawledUrlsPaged { + + public static void main(String[] args) throws Exception { + asyncListCrawledUrlsPaged(); + } + + public static void asyncListCrawledUrlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListCrawledUrlsResponse response = + webSecurityScannerClient.listCrawledUrlsCallable().call(request); + for (CrawledUrl element : response.getCrawledUrlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listcrawledurls_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java new file mode 100644 index 00000000..ad9bf66c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listcrawledurls_sync] +import com.google.cloud.websecurityscanner.v1.CrawledUrl; +import com.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncListCrawledUrls { + + public static void main(String[] args) throws Exception { + syncListCrawledUrls(); + } + + public static void syncListCrawledUrls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listcrawledurls_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindings.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindings.java new file mode 100644 index 00000000..0549b8d2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindings.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.Finding; +import com.google.cloud.websecurityscanner.v1.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncListFindings { + + public static void main(String[] args) throws Exception { + asyncListFindings(); + } + + public static void asyncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listFindingsPagedCallable().futureCall(request); + // Do something. + for (Finding element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 00000000..308c9c27 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listfindings_paged_async] +import com.google.cloud.websecurityscanner.v1.Finding; +import com.google.cloud.websecurityscanner.v1.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1.ListFindingsResponse; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListFindingsPaged(); + } + + public static void asyncListFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListFindingsResponse response = + webSecurityScannerClient.listFindingsCallable().call(request); + for (Finding element : response.getFindingsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/SyncListFindings.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/SyncListFindings.java new file mode 100644 index 00000000..8d3b4586 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindings/SyncListFindings.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listfindings_sync] +import com.google.cloud.websecurityscanner.v1.Finding; +import com.google.cloud.websecurityscanner.v1.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncListFindings { + + public static void main(String[] args) throws Exception { + syncListFindings(); + } + + public static void syncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent("parent-995424086") + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Finding element : webSecurityScannerClient.listFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java new file mode 100644 index 00000000..bf9db34a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listfindingtypestats_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncListFindingTypeStats { + + public static void main(String[] args) throws Exception { + asyncListFindingTypeStats(); + } + + public static void asyncListFindingTypeStats() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder().setParent("parent-995424086").build(); + ApiFuture future = + webSecurityScannerClient.listFindingTypeStatsCallable().futureCall(request); + // Do something. + ListFindingTypeStatsResponse response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listfindingtypestats_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java new file mode 100644 index 00000000..17da1008 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listfindingtypestats_sync] +import com.google.cloud.websecurityscanner.v1.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncListFindingTypeStats { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStats(); + } + + public static void syncListFindingTypeStats() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder().setParent("parent-995424086").build(); + ListFindingTypeStatsResponse response = + webSecurityScannerClient.listFindingTypeStats(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listfindingtypestats_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java new file mode 100644 index 00000000..75109e33 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listscanconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncListScanConfigs { + + public static void main(String[] args) throws Exception { + asyncListScanConfigs(); + } + + public static void asyncListScanConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listScanConfigsPagedCallable().futureCall(request); + // Do something. + for (ScanConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listscanconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java new file mode 100644 index 00000000..94ee8483 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listscanconfigs_paged_async] +import com.google.cloud.websecurityscanner.v1.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1.ListScanConfigsResponse; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListScanConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListScanConfigsPaged(); + } + + public static void asyncListScanConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListScanConfigsResponse response = + webSecurityScannerClient.listScanConfigsCallable().call(request); + for (ScanConfig element : response.getScanConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listscanconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java new file mode 100644 index 00000000..8a97137b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listscanconfigs_sync] +import com.google.cloud.websecurityscanner.v1.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncListScanConfigs { + + public static void main(String[] args) throws Exception { + syncListScanConfigs(); + } + + public static void syncListScanConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listscanconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRuns.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRuns.java new file mode 100644 index 00000000..ea35bc6c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRuns.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listscanruns_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncListScanRuns { + + public static void main(String[] args) throws Exception { + asyncListScanRuns(); + } + + public static void asyncListScanRuns() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listScanRunsPagedCallable().futureCall(request); + // Do something. + for (ScanRun element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listscanruns_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java new file mode 100644 index 00000000..525941ed --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listscanruns_paged_async] +import com.google.cloud.websecurityscanner.v1.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1.ListScanRunsResponse; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListScanRunsPaged { + + public static void main(String[] args) throws Exception { + asyncListScanRunsPaged(); + } + + public static void asyncListScanRunsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListScanRunsResponse response = + webSecurityScannerClient.listScanRunsCallable().call(request); + for (ScanRun element : response.getScanRunsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listscanruns_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/SyncListScanRuns.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/SyncListScanRuns.java new file mode 100644 index 00000000..b63bddb3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/listscanruns/SyncListScanRuns.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_listscanruns_sync] +import com.google.cloud.websecurityscanner.v1.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncListScanRuns { + + public static void main(String[] args) throws Exception { + syncListScanRuns(); + } + + public static void syncListScanRuns() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent("parent-995424086") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ScanRun element : webSecurityScannerClient.listScanRuns(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_listscanruns_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/AsyncStartScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/AsyncStartScanRun.java new file mode 100644 index 00000000..b41ee017 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/AsyncStartScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_startscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncStartScanRun { + + public static void main(String[] args) throws Exception { + asyncStartScanRun(); + } + + public static void asyncStartScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StartScanRunRequest request = StartScanRunRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + webSecurityScannerClient.startScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_startscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/SyncStartScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/SyncStartScanRun.java new file mode 100644 index 00000000..68025cf8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/startscanrun/SyncStartScanRun.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_startscanrun_sync] +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncStartScanRun { + + public static void main(String[] args) throws Exception { + syncStartScanRun(); + } + + public static void syncStartScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StartScanRunRequest request = StartScanRunRequest.newBuilder().setName("name3373707").build(); + ScanRun response = webSecurityScannerClient.startScanRun(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_startscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java new file mode 100644 index 00000000..94e0f8bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_stopscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class AsyncStopScanRun { + + public static void main(String[] args) throws Exception { + asyncStopScanRun(); + } + + public static void asyncStopScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StopScanRunRequest request = StopScanRunRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + webSecurityScannerClient.stopScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_stopscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/SyncStopScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/SyncStopScanRun.java new file mode 100644 index 00000000..7af2e73a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/stopscanrun/SyncStopScanRun.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_stopscanrun_sync] +import com.google.cloud.websecurityscanner.v1.ScanRun; +import com.google.cloud.websecurityscanner.v1.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; + +public class SyncStopScanRun { + + public static void main(String[] args) throws Exception { + syncStopScanRun(); + } + + public static void syncStopScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StopScanRunRequest request = StopScanRunRequest.newBuilder().setName("name3373707").build(); + ScanRun response = webSecurityScannerClient.stopScanRun(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_stopscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java new file mode 100644 index 00000000..cea409c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_updatescanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.UpdateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateScanConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateScanConfig(); + } + + public static void asyncUpdateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig(ScanConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + webSecurityScannerClient.updateScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_updatescanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java new file mode 100644 index 00000000..a29bbab6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannerclient_updatescanconfig_sync] +import com.google.cloud.websecurityscanner.v1.ScanConfig; +import com.google.cloud.websecurityscanner.v1.UpdateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateScanConfig { + + public static void main(String[] args) throws Exception { + syncUpdateScanConfig(); + } + + public static void syncUpdateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig(ScanConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ScanConfig response = webSecurityScannerClient.updateScanConfig(request); + } + } +} +// [END websecurityscanner_v1_generated_websecurityscannerclient_updatescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..10363a8c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1.samples; + +// [START websecurityscanner_v1_generated_websecurityscannersettings_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1.WebSecurityScannerSettings; +import java.time.Duration; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings.Builder webSecurityScannerSettingsBuilder = + WebSecurityScannerSettings.newBuilder(); + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .setRetrySettings( + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + WebSecurityScannerSettings webSecurityScannerSettings = + webSecurityScannerSettingsBuilder.build(); + } +} +// [END websecurityscanner_v1_generated_websecurityscannersettings_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..0054c532 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.stub.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerstubsettings_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.stub.WebSecurityScannerStubSettings; +import java.time.Duration; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerStubSettings.Builder webSecurityScannerSettingsBuilder = + WebSecurityScannerStubSettings.newBuilder(); + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .setRetrySettings( + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + WebSecurityScannerStubSettings webSecurityScannerSettings = + webSecurityScannerSettingsBuilder.build(); + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerstubsettings_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..490039b7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerSettings; +import com.google.cloud.websecurityscanner.v1alpha.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..4ff9af91 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder() + .setTransportChannelProvider( + WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..5e6cc175 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_create_setendpoint_sync] +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerSettings; +import com.google.cloud.websecurityscanner.v1alpha.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder().setEndpoint(myEndpoint).build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java new file mode 100644 index 00000000..575bd274 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + asyncCreateScanConfig(); + } + + public static void asyncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + ApiFuture future = + webSecurityScannerClient.createScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..ea53bdff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java new file mode 100644 index 00000000..351ab09c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_projectnamescanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncCreateScanConfigProjectnameScanconfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfigProjectnameScanconfig(); + } + + public static void syncCreateScanConfigProjectnameScanconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(parent, scanConfig); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_projectnamescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java new file mode 100644 index 00000000..ac3edc09 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_stringscanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncCreateScanConfigStringScanconfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfigStringScanconfig(); + } + + public static void syncCreateScanConfigStringScanconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(parent, scanConfig); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_createscanconfig_stringscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java new file mode 100644 index 00000000..318e0813 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteScanConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteScanConfig(); + } + + public static void asyncDeleteScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.deleteScanConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java new file mode 100644 index 00000000..faff8db8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncDeleteScanConfig { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfig(); + } + + public static void syncDeleteScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + webSecurityScannerClient.deleteScanConfig(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java new file mode 100644 index 00000000..520e3729 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncDeleteScanConfigScanconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfigScanconfigname(); + } + + public static void syncDeleteScanConfigScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + webSecurityScannerClient.deleteScanConfig(name); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java new file mode 100644 index 00000000..78d96ba3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncDeleteScanConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfigString(); + } + + public static void syncDeleteScanConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + webSecurityScannerClient.deleteScanConfig(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_deletescanconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/AsyncGetFinding.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/AsyncGetFinding.java new file mode 100644 index 00000000..abf0ec3e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/AsyncGetFinding.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.FindingName; +import com.google.cloud.websecurityscanner.v1alpha.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncGetFinding { + + public static void main(String[] args) throws Exception { + asyncGetFinding(); + } + + public static void asyncGetFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetFindingRequest request = + GetFindingRequest.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]") + .toString()) + .build(); + ApiFuture future = webSecurityScannerClient.getFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFinding.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFinding.java new file mode 100644 index 00000000..e3e6ac24 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFinding.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_sync] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.FindingName; +import com.google.cloud.websecurityscanner.v1alpha.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetFinding { + + public static void main(String[] args) throws Exception { + syncGetFinding(); + } + + public static void syncGetFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetFindingRequest request = + GetFindingRequest.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]") + .toString()) + .build(); + Finding response = webSecurityScannerClient.getFinding(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java new file mode 100644 index 00000000..cf08995d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_findingname_sync] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.FindingName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetFindingFindingname { + + public static void main(String[] args) throws Exception { + syncGetFindingFindingname(); + } + + public static void syncGetFindingFindingname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + FindingName name = FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]"); + Finding response = webSecurityScannerClient.getFinding(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_findingname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingString.java new file mode 100644 index 00000000..82caa2ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getfinding/SyncGetFindingString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.FindingName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetFindingString { + + public static void main(String[] args) throws Exception { + syncGetFindingString(); + } + + public static void syncGetFindingString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]").toString(); + Finding response = webSecurityScannerClient.getFinding(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getfinding_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java new file mode 100644 index 00000000..b1bfa157 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncGetScanConfig { + + public static void main(String[] args) throws Exception { + asyncGetScanConfig(); + } + + public static void asyncGetScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.getScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java new file mode 100644 index 00000000..1a49e57f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetScanConfig { + + public static void main(String[] args) throws Exception { + syncGetScanConfig(); + } + + public static void syncGetScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ScanConfig response = webSecurityScannerClient.getScanConfig(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java new file mode 100644 index 00000000..387e2638 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetScanConfigScanconfigname { + + public static void main(String[] args) throws Exception { + syncGetScanConfigScanconfigname(); + } + + public static void syncGetScanConfigScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + ScanConfig response = webSecurityScannerClient.getScanConfig(name); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java new file mode 100644 index 00000000..47c5cbd3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetScanConfigString { + + public static void main(String[] args) throws Exception { + syncGetScanConfigString(); + } + + public static void syncGetScanConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + ScanConfig response = webSecurityScannerClient.getScanConfig(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/AsyncGetScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/AsyncGetScanRun.java new file mode 100644 index 00000000..9d46af37 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/AsyncGetScanRun.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncGetScanRun { + + public static void main(String[] args) throws Exception { + asyncGetScanRun(); + } + + public static void asyncGetScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanRunRequest request = + GetScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ApiFuture future = webSecurityScannerClient.getScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRun.java new file mode 100644 index 00000000..24aa7b9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_sync] +import com.google.cloud.websecurityscanner.v1alpha.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetScanRun { + + public static void main(String[] args) throws Exception { + syncGetScanRun(); + } + + public static void syncGetScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanRunRequest request = + GetScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ScanRun response = webSecurityScannerClient.getScanRun(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java new file mode 100644 index 00000000..3473b887 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetScanRunScanrunname { + + public static void main(String[] args) throws Exception { + syncGetScanRunScanrunname(); + } + + public static void syncGetScanRunScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + ScanRun response = webSecurityScannerClient.getScanRun(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunString.java new file mode 100644 index 00000000..326bcb94 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/getscanrun/SyncGetScanRunString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncGetScanRunString { + + public static void main(String[] args) throws Exception { + syncGetScanRunString(); + } + + public static void syncGetScanRunString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + ScanRun response = webSecurityScannerClient.getScanRun(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_getscanrun_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java new file mode 100644 index 00000000..4c85e3ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.CrawledUrl; +import com.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncListCrawledUrls { + + public static void main(String[] args) throws Exception { + asyncListCrawledUrls(); + } + + public static void asyncListCrawledUrls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listCrawledUrlsPagedCallable().futureCall(request); + // Do something. + for (CrawledUrl element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java new file mode 100644 index 00000000..9b80874c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_paged_async] +import com.google.cloud.websecurityscanner.v1alpha.CrawledUrl; +import com.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListCrawledUrlsPaged { + + public static void main(String[] args) throws Exception { + asyncListCrawledUrlsPaged(); + } + + public static void asyncListCrawledUrlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListCrawledUrlsResponse response = + webSecurityScannerClient.listCrawledUrlsCallable().call(request); + for (CrawledUrl element : response.getCrawledUrlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java new file mode 100644 index 00000000..c7a68c46 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_sync] +import com.google.cloud.websecurityscanner.v1alpha.CrawledUrl; +import com.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListCrawledUrls { + + public static void main(String[] args) throws Exception { + syncListCrawledUrls(); + } + + public static void syncListCrawledUrls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java new file mode 100644 index 00000000..35f223a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1alpha.CrawledUrl; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListCrawledUrlsScanrunname { + + public static void main(String[] args) throws Exception { + syncListCrawledUrlsScanrunname(); + } + + public static void syncListCrawledUrlsScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java new file mode 100644 index 00000000..a02c74ea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.CrawledUrl; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListCrawledUrlsString { + + public static void main(String[] args) throws Exception { + syncListCrawledUrlsString(); + } + + public static void syncListCrawledUrlsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listcrawledurls_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindings.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindings.java new file mode 100644 index 00000000..110132b9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindings.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncListFindings { + + public static void main(String[] args) throws Exception { + asyncListFindings(); + } + + public static void asyncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listFindingsPagedCallable().futureCall(request); + // Do something. + for (Finding element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 00000000..ebeba969 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_paged_async] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListFindingsPaged(); + } + + public static void asyncListFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListFindingsResponse response = + webSecurityScannerClient.listFindingsCallable().call(request); + for (Finding element : response.getFindingsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindings.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindings.java new file mode 100644 index 00000000..3c9686e3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindings.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_sync] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListFindings { + + public static void main(String[] args) throws Exception { + syncListFindings(); + } + + public static void syncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Finding element : webSecurityScannerClient.listFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java new file mode 100644 index 00000000..fd301351 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_scanrunnamestring_sync] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListFindingsScanrunnameString { + + public static void main(String[] args) throws Exception { + syncListFindingsScanrunnameString(); + } + + public static void syncListFindingsScanrunnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + String filter = "filter-1274492040"; + for (Finding element : webSecurityScannerClient.listFindings(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_scanrunnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsStringString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsStringString.java new file mode 100644 index 00000000..9ec4085b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindings/SyncListFindingsStringString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_stringstring_sync] +import com.google.cloud.websecurityscanner.v1alpha.Finding; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListFindingsStringString { + + public static void main(String[] args) throws Exception { + syncListFindingsStringString(); + } + + public static void syncListFindingsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + String filter = "filter-1274492040"; + for (Finding element : webSecurityScannerClient.listFindings(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindings_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java new file mode 100644 index 00000000..d4b4f87a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncListFindingTypeStats { + + public static void main(String[] args) throws Exception { + asyncListFindingTypeStats(); + } + + public static void asyncListFindingTypeStats() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.listFindingTypeStatsCallable().futureCall(request); + // Do something. + ListFindingTypeStatsResponse response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java new file mode 100644 index 00000000..5b3cc258 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_sync] +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListFindingTypeStats { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStats(); + } + + public static void syncListFindingTypeStats() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ListFindingTypeStatsResponse response = + webSecurityScannerClient.listFindingTypeStats(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java new file mode 100644 index 00000000..3a57fe76 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListFindingTypeStatsScanrunname { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStatsScanrunname(); + } + + public static void syncListFindingTypeStatsScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + ListFindingTypeStatsResponse response = webSecurityScannerClient.listFindingTypeStats(parent); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java new file mode 100644 index 00000000..6837a2e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListFindingTypeStatsString { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStatsString(); + } + + public static void syncListFindingTypeStatsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + ListFindingTypeStatsResponse response = webSecurityScannerClient.listFindingTypeStats(parent); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listfindingtypestats_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java new file mode 100644 index 00000000..9414028e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncListScanConfigs { + + public static void main(String[] args) throws Exception { + asyncListScanConfigs(); + } + + public static void asyncListScanConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listScanConfigsPagedCallable().futureCall(request); + // Do something. + for (ScanConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java new file mode 100644 index 00000000..8ff38689 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_paged_async] +import com.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListScanConfigsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListScanConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListScanConfigsPaged(); + } + + public static void asyncListScanConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListScanConfigsResponse response = + webSecurityScannerClient.listScanConfigsCallable().call(request); + for (ScanConfig element : response.getScanConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java new file mode 100644 index 00000000..e21641f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_sync] +import com.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListScanConfigs { + + public static void main(String[] args) throws Exception { + syncListScanConfigs(); + } + + public static void syncListScanConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java new file mode 100644 index 00000000..ad4993b6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_projectname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListScanConfigsProjectname { + + public static void main(String[] args) throws Exception { + syncListScanConfigsProjectname(); + } + + public static void syncListScanConfigsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java new file mode 100644 index 00000000..3fe88a3e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ProjectName; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListScanConfigsString { + + public static void main(String[] args) throws Exception { + syncListScanConfigsString(); + } + + public static void syncListScanConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRuns.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRuns.java new file mode 100644 index 00000000..d221b828 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRuns.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncListScanRuns { + + public static void main(String[] args) throws Exception { + asyncListScanRuns(); + } + + public static void asyncListScanRuns() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listScanRunsPagedCallable().futureCall(request); + // Do something. + for (ScanRun element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java new file mode 100644 index 00000000..833ec846 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_paged_async] +import com.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ListScanRunsResponse; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListScanRunsPaged { + + public static void main(String[] args) throws Exception { + asyncListScanRunsPaged(); + } + + public static void asyncListScanRunsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListScanRunsResponse response = + webSecurityScannerClient.listScanRunsCallable().call(request); + for (ScanRun element : response.getScanRunsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRuns.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRuns.java new file mode 100644 index 00000000..854e4de0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRuns.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_sync] +import com.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListScanRuns { + + public static void main(String[] args) throws Exception { + syncListScanRuns(); + } + + public static void syncListScanRuns() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ScanRun element : webSecurityScannerClient.listScanRuns(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java new file mode 100644 index 00000000..a848cb98 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListScanRunsScanconfigname { + + public static void main(String[] args) throws Exception { + syncListScanRunsScanconfigname(); + } + + public static void syncListScanRunsScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + for (ScanRun element : webSecurityScannerClient.listScanRuns(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsString.java new file mode 100644 index 00000000..2c166a33 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/listscanruns/SyncListScanRunsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncListScanRunsString { + + public static void main(String[] args) throws Exception { + syncListScanRunsString(); + } + + public static void syncListScanRunsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + for (ScanRun element : webSecurityScannerClient.listScanRuns(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_listscanruns_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/AsyncStartScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/AsyncStartScanRun.java new file mode 100644 index 00000000..a8b37337 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/AsyncStartScanRun.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncStartScanRun { + + public static void main(String[] args) throws Exception { + asyncStartScanRun(); + } + + public static void asyncStartScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StartScanRunRequest request = + StartScanRunRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.startScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRun.java new file mode 100644 index 00000000..5df8e708 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncStartScanRun { + + public static void main(String[] args) throws Exception { + syncStartScanRun(); + } + + public static void syncStartScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StartScanRunRequest request = + StartScanRunRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ScanRun response = webSecurityScannerClient.startScanRun(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java new file mode 100644 index 00000000..f1a07e29 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncStartScanRunScanconfigname { + + public static void main(String[] args) throws Exception { + syncStartScanRunScanconfigname(); + } + + public static void syncStartScanRunScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + ScanRun response = webSecurityScannerClient.startScanRun(name); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunString.java new file mode 100644 index 00000000..fc363f92 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/startscanrun/SyncStartScanRunString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfigName; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncStartScanRunString { + + public static void main(String[] args) throws Exception { + syncStartScanRunString(); + } + + public static void syncStartScanRunString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + ScanRun response = webSecurityScannerClient.startScanRun(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_startscanrun_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java new file mode 100644 index 00000000..00de868d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class AsyncStopScanRun { + + public static void main(String[] args) throws Exception { + asyncStopScanRun(); + } + + public static void asyncStopScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StopScanRunRequest request = + StopScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.stopScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRun.java new file mode 100644 index 00000000..47577125 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncStopScanRun { + + public static void main(String[] args) throws Exception { + syncStopScanRun(); + } + + public static void syncStopScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StopScanRunRequest request = + StopScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ScanRun response = webSecurityScannerClient.stopScanRun(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java new file mode 100644 index 00000000..e6d78b9f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncStopScanRunScanrunname { + + public static void main(String[] args) throws Exception { + syncStopScanRunScanrunname(); + } + + public static void syncStopScanRunScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + ScanRun response = webSecurityScannerClient.stopScanRun(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java new file mode 100644 index 00000000..9086eebb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_string_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanRun; +import com.google.cloud.websecurityscanner.v1alpha.ScanRunName; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; + +public class SyncStopScanRunString { + + public static void main(String[] args) throws Exception { + syncStopScanRunString(); + } + + public static void syncStopScanRunString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + ScanRun response = webSecurityScannerClient.stopScanRun(name); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_stopscanrun_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java new file mode 100644 index 00000000..a2c5687c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_updatescanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateScanConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateScanConfig(); + } + + public static void asyncUpdateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig(ScanConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + webSecurityScannerClient.updateScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_updatescanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java new file mode 100644 index 00000000..fa428674 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannerclient_updatescanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateScanConfig { + + public static void main(String[] args) throws Exception { + syncUpdateScanConfig(); + } + + public static void syncUpdateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig(ScanConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ScanConfig response = webSecurityScannerClient.updateScanConfig(request); + } + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannerclient_updatescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java new file mode 100644 index 00000000..8d99d4ea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START +// websecurityscanner_v1alpha_generated_websecurityscannerclient_updatescanconfig_scanconfigfieldmask_sync] +import com.google.cloud.websecurityscanner.v1alpha.ScanConfig; +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateScanConfigScanconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateScanConfigScanconfigFieldmask(); + } + + public static void syncUpdateScanConfigScanconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ScanConfig response = webSecurityScannerClient.updateScanConfig(scanConfig, updateMask); + } + } +} +// [END +// websecurityscanner_v1alpha_generated_websecurityscannerclient_updatescanconfig_scanconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..27874bcb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1alpha/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1alpha.samples; + +// [START websecurityscanner_v1alpha_generated_websecurityscannersettings_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1alpha.WebSecurityScannerSettings; +import java.time.Duration; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings.Builder webSecurityScannerSettingsBuilder = + WebSecurityScannerSettings.newBuilder(); + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .setRetrySettings( + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + WebSecurityScannerSettings webSecurityScannerSettings = + webSecurityScannerSettingsBuilder.build(); + } +} +// [END websecurityscanner_v1alpha_generated_websecurityscannersettings_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..535fb251 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/stub/websecurityscannerstubsettings/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.stub.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerstubsettings_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.stub.WebSecurityScannerStubSettings; +import java.time.Duration; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerStubSettings.Builder webSecurityScannerSettingsBuilder = + WebSecurityScannerStubSettings.newBuilder(); + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .setRetrySettings( + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + WebSecurityScannerStubSettings webSecurityScannerSettings = + webSecurityScannerSettingsBuilder.build(); + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerstubsettings_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..8a3915a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings; +import com.google.cloud.websecurityscanner.v1beta.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..d8d6baa9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder() + .setTransportChannelProvider( + WebSecurityScannerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..a0197f2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_create_setendpoint_sync] +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings; +import com.google.cloud.websecurityscanner.v1beta.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings webSecurityScannerSettings = + WebSecurityScannerSettings.newBuilder().setEndpoint(myEndpoint).build(); + WebSecurityScannerClient webSecurityScannerClient = + WebSecurityScannerClient.create(webSecurityScannerSettings); + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java new file mode 100644 index 00000000..fa9af7ec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/AsyncCreateScanConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + asyncCreateScanConfig(); + } + + public static void asyncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + ApiFuture future = + webSecurityScannerClient.createScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..288c7943 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + CreateScanConfigRequest request = + CreateScanConfigRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setScanConfig(ScanConfig.newBuilder().build()) + .build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java new file mode 100644 index 00000000..ae6a6916 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigProjectnameScanconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_projectnamescanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncCreateScanConfigProjectnameScanconfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfigProjectnameScanconfig(); + } + + public static void syncCreateScanConfigProjectnameScanconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(parent, scanConfig); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_projectnamescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java new file mode 100644 index 00000000..769b0370 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/createscanconfig/SyncCreateScanConfigStringScanconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_stringscanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncCreateScanConfigStringScanconfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfigStringScanconfig(); + } + + public static void syncCreateScanConfigStringScanconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + ScanConfig response = webSecurityScannerClient.createScanConfig(parent, scanConfig); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_createscanconfig_stringscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java new file mode 100644 index 00000000..28063182 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/AsyncDeleteScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteScanConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteScanConfig(); + } + + public static void asyncDeleteScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.deleteScanConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java new file mode 100644 index 00000000..72e16e1f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncDeleteScanConfig { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfig(); + } + + public static void syncDeleteScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + DeleteScanConfigRequest request = + DeleteScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + webSecurityScannerClient.deleteScanConfig(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java new file mode 100644 index 00000000..3eefe091 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigScanconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncDeleteScanConfigScanconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfigScanconfigname(); + } + + public static void syncDeleteScanConfigScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + webSecurityScannerClient.deleteScanConfig(name); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java new file mode 100644 index 00000000..4e9f157b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/deletescanconfig/SyncDeleteScanConfigString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncDeleteScanConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteScanConfigString(); + } + + public static void syncDeleteScanConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + webSecurityScannerClient.deleteScanConfig(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_deletescanconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/AsyncGetFinding.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/AsyncGetFinding.java new file mode 100644 index 00000000..5f43cc0d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/AsyncGetFinding.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.FindingName; +import com.google.cloud.websecurityscanner.v1beta.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncGetFinding { + + public static void main(String[] args) throws Exception { + asyncGetFinding(); + } + + public static void asyncGetFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetFindingRequest request = + GetFindingRequest.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]") + .toString()) + .build(); + ApiFuture future = webSecurityScannerClient.getFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFinding.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFinding.java new file mode 100644 index 00000000..7e171b7f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFinding.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_sync] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.FindingName; +import com.google.cloud.websecurityscanner.v1beta.GetFindingRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetFinding { + + public static void main(String[] args) throws Exception { + syncGetFinding(); + } + + public static void syncGetFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetFindingRequest request = + GetFindingRequest.newBuilder() + .setName( + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]") + .toString()) + .build(); + Finding response = webSecurityScannerClient.getFinding(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java new file mode 100644 index 00000000..7852f9be --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingFindingname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_findingname_sync] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.FindingName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetFindingFindingname { + + public static void main(String[] args) throws Exception { + syncGetFindingFindingname(); + } + + public static void syncGetFindingFindingname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + FindingName name = FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]"); + Finding response = webSecurityScannerClient.getFinding(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_findingname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingString.java new file mode 100644 index 00000000..6e267654 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getfinding/SyncGetFindingString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_string_sync] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.FindingName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetFindingString { + + public static void main(String[] args) throws Exception { + syncGetFindingString(); + } + + public static void syncGetFindingString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = + FindingName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]", "[FINDING]").toString(); + Finding response = webSecurityScannerClient.getFinding(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getfinding_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java new file mode 100644 index 00000000..5f28cfdb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/AsyncGetScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncGetScanConfig { + + public static void main(String[] args) throws Exception { + asyncGetScanConfig(); + } + + public static void asyncGetScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.getScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java new file mode 100644 index 00000000..ef7d3e7a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetScanConfig { + + public static void main(String[] args) throws Exception { + syncGetScanConfig(); + } + + public static void syncGetScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanConfigRequest request = + GetScanConfigRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ScanConfig response = webSecurityScannerClient.getScanConfig(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java new file mode 100644 index 00000000..e289caa8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigScanconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetScanConfigScanconfigname { + + public static void main(String[] args) throws Exception { + syncGetScanConfigScanconfigname(); + } + + public static void syncGetScanConfigScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + ScanConfig response = webSecurityScannerClient.getScanConfig(name); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java new file mode 100644 index 00000000..53fac7e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanconfig/SyncGetScanConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetScanConfigString { + + public static void main(String[] args) throws Exception { + syncGetScanConfigString(); + } + + public static void syncGetScanConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + ScanConfig response = webSecurityScannerClient.getScanConfig(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/AsyncGetScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/AsyncGetScanRun.java new file mode 100644 index 00000000..7ad7a7dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/AsyncGetScanRun.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncGetScanRun { + + public static void main(String[] args) throws Exception { + asyncGetScanRun(); + } + + public static void asyncGetScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanRunRequest request = + GetScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ApiFuture future = webSecurityScannerClient.getScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRun.java new file mode 100644 index 00000000..9b82a1d1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_sync] +import com.google.cloud.websecurityscanner.v1beta.GetScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetScanRun { + + public static void main(String[] args) throws Exception { + syncGetScanRun(); + } + + public static void syncGetScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + GetScanRunRequest request = + GetScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ScanRun response = webSecurityScannerClient.getScanRun(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java new file mode 100644 index 00000000..e26bb669 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunScanrunname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetScanRunScanrunname { + + public static void main(String[] args) throws Exception { + syncGetScanRunScanrunname(); + } + + public static void syncGetScanRunScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + ScanRun response = webSecurityScannerClient.getScanRun(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunString.java new file mode 100644 index 00000000..cf78eea9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/getscanrun/SyncGetScanRunString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncGetScanRunString { + + public static void main(String[] args) throws Exception { + syncGetScanRunString(); + } + + public static void syncGetScanRunString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + ScanRun response = webSecurityScannerClient.getScanRun(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_getscanrun_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java new file mode 100644 index 00000000..d81560dc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrls.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.CrawledUrl; +import com.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncListCrawledUrls { + + public static void main(String[] args) throws Exception { + asyncListCrawledUrls(); + } + + public static void asyncListCrawledUrls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listCrawledUrlsPagedCallable().futureCall(request); + // Do something. + for (CrawledUrl element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java new file mode 100644 index 00000000..2f99a3ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/AsyncListCrawledUrlsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_paged_async] +import com.google.cloud.websecurityscanner.v1beta.CrawledUrl; +import com.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListCrawledUrlsPaged { + + public static void main(String[] args) throws Exception { + asyncListCrawledUrlsPaged(); + } + + public static void asyncListCrawledUrlsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListCrawledUrlsResponse response = + webSecurityScannerClient.listCrawledUrlsCallable().call(request); + for (CrawledUrl element : response.getCrawledUrlsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java new file mode 100644 index 00000000..6a1ff75c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrls.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_sync] +import com.google.cloud.websecurityscanner.v1beta.CrawledUrl; +import com.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListCrawledUrls { + + public static void main(String[] args) throws Exception { + syncListCrawledUrls(); + } + + public static void syncListCrawledUrls() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListCrawledUrlsRequest request = + ListCrawledUrlsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java new file mode 100644 index 00000000..3402011f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsScanrunname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1beta.CrawledUrl; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListCrawledUrlsScanrunname { + + public static void main(String[] args) throws Exception { + syncListCrawledUrlsScanrunname(); + } + + public static void syncListCrawledUrlsScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java new file mode 100644 index 00000000..76821182 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listcrawledurls/SyncListCrawledUrlsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_string_sync] +import com.google.cloud.websecurityscanner.v1beta.CrawledUrl; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListCrawledUrlsString { + + public static void main(String[] args) throws Exception { + syncListCrawledUrlsString(); + } + + public static void syncListCrawledUrlsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + for (CrawledUrl element : webSecurityScannerClient.listCrawledUrls(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listcrawledurls_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindings.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindings.java new file mode 100644 index 00000000..6a66c784 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindings.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncListFindings { + + public static void main(String[] args) throws Exception { + asyncListFindings(); + } + + public static void asyncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listFindingsPagedCallable().futureCall(request); + // Do something. + for (Finding element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 00000000..cfb8d63a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/AsyncListFindingsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_paged_async] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListFindingsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListFindingsPaged(); + } + + public static void asyncListFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListFindingsResponse response = + webSecurityScannerClient.listFindingsCallable().call(request); + for (Finding element : response.getFindingsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindings.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindings.java new file mode 100644 index 00000000..72dfbbef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindings.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_sync] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.ListFindingsRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListFindings { + + public static void main(String[] args) throws Exception { + syncListFindings(); + } + + public static void syncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Finding element : webSecurityScannerClient.listFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java new file mode 100644 index 00000000..31f3dd56 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsScanrunnameString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_scanrunnamestring_sync] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListFindingsScanrunnameString { + + public static void main(String[] args) throws Exception { + syncListFindingsScanrunnameString(); + } + + public static void syncListFindingsScanrunnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + String filter = "filter-1274492040"; + for (Finding element : webSecurityScannerClient.listFindings(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_scanrunnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsStringString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsStringString.java new file mode 100644 index 00000000..9c39e8ec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindings/SyncListFindingsStringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_stringstring_sync] +import com.google.cloud.websecurityscanner.v1beta.Finding; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListFindingsStringString { + + public static void main(String[] args) throws Exception { + syncListFindingsStringString(); + } + + public static void syncListFindingsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + String filter = "filter-1274492040"; + for (Finding element : webSecurityScannerClient.listFindings(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listfindings_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java new file mode 100644 index 00000000..88d7e3e6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/AsyncListFindingTypeStats.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncListFindingTypeStats { + + public static void main(String[] args) throws Exception { + asyncListFindingTypeStats(); + } + + public static void asyncListFindingTypeStats() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.listFindingTypeStatsCallable().futureCall(request); + // Do something. + ListFindingTypeStatsResponse response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java new file mode 100644 index 00000000..df8125f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStats.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_sync] +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListFindingTypeStats { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStats(); + } + + public static void syncListFindingTypeStats() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListFindingTypeStatsRequest request = + ListFindingTypeStatsRequest.newBuilder() + .setParent(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ListFindingTypeStatsResponse response = + webSecurityScannerClient.listFindingTypeStats(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java new file mode 100644 index 00000000..c2c3c000 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsScanrunname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListFindingTypeStatsScanrunname { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStatsScanrunname(); + } + + public static void syncListFindingTypeStatsScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + ListFindingTypeStatsResponse response = webSecurityScannerClient.listFindingTypeStats(parent); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java new file mode 100644 index 00000000..fe863a03 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listfindingtypestats/SyncListFindingTypeStatsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListFindingTypeStatsString { + + public static void main(String[] args) throws Exception { + syncListFindingTypeStatsString(); + } + + public static void syncListFindingTypeStatsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + ListFindingTypeStatsResponse response = webSecurityScannerClient.listFindingTypeStats(parent); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_listfindingtypestats_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java new file mode 100644 index 00000000..30b52423 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncListScanConfigs { + + public static void main(String[] args) throws Exception { + asyncListScanConfigs(); + } + + public static void asyncListScanConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listScanConfigsPagedCallable().futureCall(request); + // Do something. + for (ScanConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java new file mode 100644 index 00000000..37a8b60a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/AsyncListScanConfigsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_paged_async] +import com.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListScanConfigsResponse; +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListScanConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListScanConfigsPaged(); + } + + public static void asyncListScanConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListScanConfigsResponse response = + webSecurityScannerClient.listScanConfigsCallable().call(request); + for (ScanConfig element : response.getScanConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java new file mode 100644 index 00000000..bf643261 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_sync] +import com.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest; +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListScanConfigs { + + public static void main(String[] args) throws Exception { + syncListScanConfigs(); + } + + public static void syncListScanConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanConfigsRequest request = + ListScanConfigsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java new file mode 100644 index 00000000..4f8256e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsProjectname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_projectname_sync] +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListScanConfigsProjectname { + + public static void main(String[] args) throws Exception { + syncListScanConfigsProjectname(); + } + + public static void syncListScanConfigsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java new file mode 100644 index 00000000..980006c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanconfigs/SyncListScanConfigsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ProjectName; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListScanConfigsString { + + public static void main(String[] args) throws Exception { + syncListScanConfigsString(); + } + + public static void syncListScanConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (ScanConfig element : webSecurityScannerClient.listScanConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRuns.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRuns.java new file mode 100644 index 00000000..e5a440d7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRuns.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncListScanRuns { + + public static void main(String[] args) throws Exception { + asyncListScanRuns(); + } + + public static void asyncListScanRuns() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + webSecurityScannerClient.listScanRunsPagedCallable().futureCall(request); + // Do something. + for (ScanRun element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java new file mode 100644 index 00000000..fc1b1534 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/AsyncListScanRunsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_paged_async] +import com.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1beta.ListScanRunsResponse; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.common.base.Strings; + +public class AsyncListScanRunsPaged { + + public static void main(String[] args) throws Exception { + asyncListScanRunsPaged(); + } + + public static void asyncListScanRunsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListScanRunsResponse response = + webSecurityScannerClient.listScanRunsCallable().call(request); + for (ScanRun element : response.getScanRunsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRuns.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRuns.java new file mode 100644 index 00000000..aace25f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRuns.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_sync] +import com.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListScanRuns { + + public static void main(String[] args) throws Exception { + syncListScanRuns(); + } + + public static void syncListScanRuns() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ListScanRunsRequest request = + ListScanRunsRequest.newBuilder() + .setParent(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ScanRun element : webSecurityScannerClient.listScanRuns(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java new file mode 100644 index 00000000..428586cc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsScanconfigname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListScanRunsScanconfigname { + + public static void main(String[] args) throws Exception { + syncListScanRunsScanconfigname(); + } + + public static void syncListScanRunsScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + for (ScanRun element : webSecurityScannerClient.listScanRuns(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsString.java new file mode 100644 index 00000000..94b19f26 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/listscanruns/SyncListScanRunsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncListScanRunsString { + + public static void main(String[] args) throws Exception { + syncListScanRunsString(); + } + + public static void syncListScanRunsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String parent = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + for (ScanRun element : webSecurityScannerClient.listScanRuns(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_listscanruns_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/AsyncStartScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/AsyncStartScanRun.java new file mode 100644 index 00000000..e9975035 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/AsyncStartScanRun.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncStartScanRun { + + public static void main(String[] args) throws Exception { + asyncStartScanRun(); + } + + public static void asyncStartScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StartScanRunRequest request = + StartScanRunRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.startScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRun.java new file mode 100644 index 00000000..a8d52ca7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.StartScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncStartScanRun { + + public static void main(String[] args) throws Exception { + syncStartScanRun(); + } + + public static void syncStartScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StartScanRunRequest request = + StartScanRunRequest.newBuilder() + .setName(ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString()) + .build(); + ScanRun response = webSecurityScannerClient.startScanRun(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java new file mode 100644 index 00000000..1c00ee9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunScanconfigname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_scanconfigname_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncStartScanRunScanconfigname { + + public static void main(String[] args) throws Exception { + syncStartScanRunScanconfigname(); + } + + public static void syncStartScanRunScanconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfigName name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]"); + ScanRun response = webSecurityScannerClient.startScanRun(name); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_scanconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunString.java new file mode 100644 index 00000000..c5c411f1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/startscanrun/SyncStartScanRunString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfigName; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncStartScanRunString { + + public static void main(String[] args) throws Exception { + syncStartScanRunString(); + } + + public static void syncStartScanRunString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanConfigName.of("[PROJECT]", "[SCAN_CONFIG]").toString(); + ScanRun response = webSecurityScannerClient.startScanRun(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_startscanrun_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java new file mode 100644 index 00000000..4dc71043 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/AsyncStopScanRun.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class AsyncStopScanRun { + + public static void main(String[] args) throws Exception { + asyncStopScanRun(); + } + + public static void asyncStopScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StopScanRunRequest request = + StopScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ApiFuture future = + webSecurityScannerClient.stopScanRunCallable().futureCall(request); + // Do something. + ScanRun response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRun.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRun.java new file mode 100644 index 00000000..b13712b0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRun.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.StopScanRunRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncStopScanRun { + + public static void main(String[] args) throws Exception { + syncStopScanRun(); + } + + public static void syncStopScanRun() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + StopScanRunRequest request = + StopScanRunRequest.newBuilder() + .setName(ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString()) + .build(); + ScanRun response = webSecurityScannerClient.stopScanRun(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java new file mode 100644 index 00000000..c881236a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunScanrunname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_scanrunname_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncStopScanRunScanrunname { + + public static void main(String[] args) throws Exception { + syncStopScanRunScanrunname(); + } + + public static void syncStopScanRunScanrunname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanRunName name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]"); + ScanRun response = webSecurityScannerClient.stopScanRun(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_scanrunname_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java new file mode 100644 index 00000000..d2053496 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/stopscanrun/SyncStopScanRunString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_string_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanRun; +import com.google.cloud.websecurityscanner.v1beta.ScanRunName; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; + +public class SyncStopScanRunString { + + public static void main(String[] args) throws Exception { + syncStopScanRunString(); + } + + public static void syncStopScanRunString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + String name = ScanRunName.of("[PROJECT]", "[SCAN_CONFIG]", "[SCAN_RUN]").toString(); + ScanRun response = webSecurityScannerClient.stopScanRun(name); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_stopscanrun_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java new file mode 100644 index 00000000..b2ac2033 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/AsyncUpdateScanConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_updatescanconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateScanConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateScanConfig(); + } + + public static void asyncUpdateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig(ScanConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + webSecurityScannerClient.updateScanConfigCallable().futureCall(request); + // Do something. + ScanConfig response = future.get(); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_updatescanconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java new file mode 100644 index 00000000..c9526de7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannerclient_updatescanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateScanConfig { + + public static void main(String[] args) throws Exception { + syncUpdateScanConfig(); + } + + public static void syncUpdateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + UpdateScanConfigRequest request = + UpdateScanConfigRequest.newBuilder() + .setScanConfig(ScanConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ScanConfig response = webSecurityScannerClient.updateScanConfig(request); + } + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannerclient_updatescanconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java new file mode 100644 index 00000000..d4265b1b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannerclient/updatescanconfig/SyncUpdateScanConfigScanconfigFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START +// websecurityscanner_v1beta_generated_websecurityscannerclient_updatescanconfig_scanconfigfieldmask_sync] +import com.google.cloud.websecurityscanner.v1beta.ScanConfig; +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateScanConfigScanconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateScanConfigScanconfigFieldmask(); + } + + public static void syncUpdateScanConfigScanconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (WebSecurityScannerClient webSecurityScannerClient = WebSecurityScannerClient.create()) { + ScanConfig scanConfig = ScanConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ScanConfig response = webSecurityScannerClient.updateScanConfig(scanConfig, updateMask); + } + } +} +// [END +// websecurityscanner_v1beta_generated_websecurityscannerclient_updatescanconfig_scanconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java new file mode 100644 index 00000000..9b6007a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/websecurityscanner/v1beta/websecurityscannersettings/createscanconfig/SyncCreateScanConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.websecurityscanner.v1beta.samples; + +// [START websecurityscanner_v1beta_generated_websecurityscannersettings_createscanconfig_sync] +import com.google.cloud.websecurityscanner.v1beta.WebSecurityScannerSettings; +import java.time.Duration; + +public class SyncCreateScanConfig { + + public static void main(String[] args) throws Exception { + syncCreateScanConfig(); + } + + public static void syncCreateScanConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + WebSecurityScannerSettings.Builder webSecurityScannerSettingsBuilder = + WebSecurityScannerSettings.newBuilder(); + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .setRetrySettings( + webSecurityScannerSettingsBuilder + .createScanConfigSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + WebSecurityScannerSettings webSecurityScannerSettings = + webSecurityScannerSettingsBuilder.build(); + } +} +// [END websecurityscanner_v1beta_generated_websecurityscannersettings_createscanconfig_sync]